git-extras icon indicating copy to clipboard operation
git-extras copied to clipboard

Usage output should use `git foo` when invoked via git

Open sparr opened this issue 1 year ago • 5 comments

If I run the git-cp script directly with no parameters, the output says USAGE: /foo/bar/bin/git-cp [...] which is on point. I might want it to just say git-cp there, but that's a minor quibble.

More importantly, and the subject of this issue, is that if I run git cp and git searches my path to find the git-cp script, then the output STILL says USAGE: /foo/bar/bin/git-cp [...] when I think it should say USAGE: git cp [...] in keeping with the behavior of most other git commands.

Some git command scripts included with git use different approaches for this:

  • git-archimport, git-cvsexportcommit, git-cvsimport, git-cvsserver, and git-merge-one-file all hard code the usage text of git whatever without regard for the actual filename
  • git-filter-branch, git-merge-one-file, git-mergetool, git-submodule, and git-web--browse all use git-sh-setup's usage() to parse the script filename and blindly removes the first dash
  • git-p4 does what git-extras does now, outputting the full path to the script

I propose one of the following solutions:

  1. Hard code git foo as the usage invocation for git-foo across all the scripts
  2. Use git-sh-setup's usage()
  3. Implement a custom detection of git invocation, perhaps by checking for GIT_EXEC_PATH

I volunteer to implement any of these if you pick one.

sparr avatar Aug 08 '24 13:08 sparr

PR is welcome!

spacewander avatar Aug 09 '24 03:08 spacewander

@spacewander Any suggestion on whether I pursue option 1, 2, or 3?

Also, how complete would such a change need to be to get accepted? I notice a lot of the git-extras scripts were written with different usage string paradigms already, probably copied from different upstream behaviors. Some of them will be easy to convert to use something more flexible. Others are already very complex and may be difficult to convert.

sparr avatar Aug 10 '24 16:08 sparr

I don't have a strong opinion, but I would vote for option 1. It's the easiest way to implement.

spacewander avatar Aug 12 '24 02:08 spacewander

I have underestimated how many different usage output paradigms there would be in the different scripts here. This will be a bigger undertaking than I originally thought. I still want to do it, just not today.

sparr avatar Sep 15 '24 04:09 sparr

@sparr Thanks for your investigation! We can wait for it.

spacewander avatar Sep 17 '24 03:09 spacewander