From: Erik Cervin Edin <erik@cervined.in>
To: git@vger.kernel.org
Subject: Re: [PATCH] git-jump: pick a mode automatically when invoked without arguments
Date: Thu, 14 May 2026 17:40:34 +0200 [thread overview]
Message-ID: <agXb1SXKnA69L9ak@mbp> (raw)
In-Reply-To: <20260508175240.GA737125@coredump.intra.peff.net>
On 26/05/08 04:30PM, Greg Hurrell wrote:
> Hopefully, they at least read the README before installing it from contrib/
> (although Homebrew recently starting installing it for folks automatically,
> so may not remain true for much longer on macOS...)
Oh! I didn't know that but looking closer on my homebrew installed Git,
looks like you're right.
I would've assumed that if users had jumped through the hoops of
installing git-jump from contrib/ it stands to reason they would have
some sense of what it does. But if this is landing as a part of regular
brew install git, I'd wager there's a few unsuspecting people running
git-jump that don't know what it does.
> Would having "git jump auto" work for you?
Imo, this sounds ideal -- there's something odd about `git jump` picking
the subcommand heuristically. At least when I invoke git-jump I always
do so with a specific intent of _where_ I want to jump. Then again, I
never do a jump merge or a jump ws.
> Homebrew installing `git-jump` by default a few months ago[^2] broke
> this, because aliases can't shadow builtin commands.
But it looks like this doesn't work in this case. Even if you have
git-jump installed stand-alone (mine is in ~/bin/git-jump, in PATH,
before /opt/homebrew/bin.)
FWIW I alias jump to j, jump diff to jd and jump grep to jg. E.g.
git jd # git jump diff
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.
> But there are two situations where we can usefully infer the most
> valuable and likely mode that a user would want to use, and select it
> automatically when they run `git jump` without arguments:
>
> 1. When there are unmerged paths in the index, the user likely
> wants `git jump merge`.
>
> 2. When the working tree has unstaged changes, the user likely
> wants `git jump diff`.
I can think of a third situation -- when there are staged changes flagged by
git diff --cached --check.
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 in all, I think an auto jumping mode could be genuinely useful.
prev parent reply other threads:[~2026-05-14 15:40 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-08 9:07 [PATCH] git-jump: pick a mode automatically when invoked without arguments Greg Hurrell via GitGitGadget
2026-05-08 14:13 ` Jeff King
2026-05-08 14:30 ` Greg Hurrell
2026-05-08 17:52 ` Jeff King
2026-05-14 15:40 ` Erik Cervin Edin [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=agXb1SXKnA69L9ak@mbp \
--to=erik@cervined.in \
--cc=git@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox