]> git.ipfire.org Git - thirdparty/git.git/commit
git-jump: pick a mode automatically when invoked without arguments
authorGreg Hurrell <greg.hurrell@datadoghq.com>
Thu, 21 May 2026 13:45:09 +0000 (13:45 +0000)
committerJunio C Hamano <gitster@pobox.com>
Thu, 21 May 2026 14:01:04 +0000 (23:01 +0900)
commit74216ffe0aa02309e1fc510c0056ec6fd523898c
treec59bbf0a7614f67311243881de1ca6adaa8e5d39
parent1c00d2d8392f603a6263f11f1a50fde96ae5475e
git-jump: pick a mode automatically when invoked without arguments

When `git jump` is invoked with no positional arguments (and no
arguments after `--stdout`) it currently prints usage and exits with
status 1.

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:

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`.

In this commit we teach `git jump` a new "auto" mode which detects these
cases and dispatches to the corresponding mode automatically. The user
can either explicitly spell out `git jump auto`, or just leave it at
`git jump` (because "auto" is the default).

If none of the interesting cases listed above applies, then auto mode
falls back to the existing usage-and-exit behavior.

Signed-off-by: Greg Hurrell <greg.hurrell@datadoghq.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
contrib/git-jump/README
contrib/git-jump/git-jump