tj / tj/git-extras

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

Open
#1,154 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

pull request is welcome
Dominant language
Shell
Stars
18.1k
Forks
1.2k
Avg merge
5d 17h
Merged PRs (30d)
1

Description

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.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by comparing usage handling in the affected git-* scripts, especially git-archimport, git-filter-branch, git-mergetool, git-submodule, and git-web--browse, and read git-sh-setup's usage() behavior. Choose and apply a consistent approach for commands invoked as git foo so their usage output uses that invocation; direct script execution should remain understandable.

Written by the indexing model from the issue text.

Assessment

Tech stack
git, shell
Domain
cli
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.