Re: [PATCH v2] git-jump: pick a mode automatically when invoked without arguments
- From
Junio C Hamano <gitster@pobox.com>
- Date
- May 21, 2026, 01:22 UTC
- Message-ID
- <xmqqik8h36al.fsf@gitster.g>
- In-Reply-To
- <pull.2108.v2.git.1779280307112.gitgitgadget@gmail.com>
"Greg Hurrell via GitGitGadget" <gitgitgadget@gmail.com> writes:
> If none of the interesting cases listed above applies, then auto mode > falls back to the existing usage-and-exit behavior.
If more than one interesting cases apply, what happens, and what should happen?
Show 10 quoted lines
> diff --git a/contrib/git-jump/README b/contrib/git-jump/README > index 3211841305..ac35792e55 100644 > --- a/contrib/git-jump/README > +++ b/contrib/git-jump/README > @@ -75,8 +75,20 @@ git jump grep foo_bar > # arbitrary grep options > git jump grep -i foo_bar > > +# jump to places with conflict markers or whitespace errors > +# (as reported by # `git diff --check`)
Is "#" after "reported by" intended?
Show 10 quoted lines
> diff --git a/contrib/git-jump/git-jump b/contrib/git-jump/git-jump
> index 8d1d5d79a6..43d3b42a41 100755
> --- a/contrib/git-jump/git-jump
> +++ b/contrib/git-jump/git-jump
> @@ -2,10 +2,11 @@
>
> usage() {
> cat <<\EOF
> -usage: git jump [--stdout] <mode> [<args>]
> +usage: git jump [--stdout] [<mode>] [<args>]So "git jump --stdout foo.c" should mean "git jump --stdout auto foo.c", OK.
Show 20 quoted lines
> @@ -16,6 +17,10 @@ grep: elements are grep hits. Arguments are given to git grep or, if
>
> ws: elements are whitespace errors. Arguments are given to diff --check.
>
> +auto: select one of the other modes based on worktree state;
> + "merge" if there are unmerged paths, "diff" if there are
> + unstaged changes, "ws" if there are whitespace errors.
> +
> If the optional argument `--stdout` is given, print the quickfix
> lines to standard output instead of feeding it to the editor.
> EOF
> @@ -82,6 +87,23 @@ mode_ws() {
> git diff --check "$@"
> }
>
> +mode_auto() {
> + if test "$(git rev-parse --is-inside-work-tree 2>/dev/null)" != "true"; then
> + usage >&2
> + exit 1
> + fiThat looks like a basic safety measure, which is good.
Show 5 quoted lines
> + if test -n "$(git ls-files -u "$@")"; then > + mode_merge "$@" > + elif ! git diff --quiet "$@"; then > + mode_diff "$@" > + elif ! git diff --check >/dev/null 2>&1; then
Shouldn't this "diff --check" be restricted by "$@" if given?
Show 6 quoted lines
> + mode_ws "$@" > + else > + usage >&2 > + exit 1 > + fi > +}