Subject: Re: [PATCH] git-jump: pick a mode automatically when invoked without arguments

From: Jeff King <[email-masked]>
Date: Tue, 19 May 2026 17:22:34 -0400

On Tue, May 19, 2026 at 11:03:44AM +0200, Greg Hurrell wrote:

> On Thu, May 14, 2026, at 5:40 PM, Erik Cervin Edin wrote:
> > On 26/05/08 09:07AM, Greg Hurrell via GitGitGadget wrote:
> > > -usage: git jump [--stdout] <mode> [<args>]
> > > +usage: git jump [--stdout] [<mode>] [<args>]
> > 
> > The usage message makes <mode> optional but doesn't explain what
> > happens when you omit it. Seems worth documenting the auto-detect behavior
> > there too.
> > 
> > If we're going to teach git-jump how to be more clever about where to jump,
> > does it also make sense to bake `git jump ws` into this?
> > 
> > Also, if this is going to grow into a proper auto-detect heuristic, it
> > might be cleaner as a first-class mode rather than logic spliced into the
> > argument parser. Something like:
> > 
> >     mode_auto() {
> >         if test -n "$(git ls-files -u)"; then
> >             mode_merge "$@"
> >         elif ! git diff --quiet; then
> >             mode_diff "$@"
> >         elif ! git diff --cached --check >/dev/null 2>&1; then
> >             mode_ws --cached "$@"
> >         else
> >             return 0
> >         fi
> >     }
> > 
> > That way `git jump auto` works explicitly, bare `git jump` defaults
> > to it (just `set -- auto` when $# -lt 1), and the usage text can
> > document the heuristic. It also keeps the detection and dispatch in
> > one place in case someone wants to tweak the priority later.
> 
> All of those suggestions sound reasonable to me. Jeff, do you agree?
> If so, I can update the patch.

Yeah, I agree that having an explicit "auto" mode (and then just
defaulting to it) makes perfect sense.

I don't really have an opinion on adding "ws" in here. Despite being the
person who added the whitespace mode in the first place, I can't
remember ever using it in the last 10 years. ;) But the cost is fairly
low to support it, so we might as well.

-Peff