From: Junio C Hamano <gitster@pobox.com>
To: "Greg Hurrell via GitGitGadget" <gitgitgadget@gmail.com>
Cc: git@vger.kernel.org, Jeff King <peff@peff.net>,
Greg Hurrell <greg@hurrell.net>,
Erik Cervin Edin <erik@cervined.in>,
Greg Hurrell <greg.hurrell@datadoghq.com>
Subject: Re: [PATCH v2] git-jump: pick a mode automatically when invoked without arguments
Date: Thu, 21 May 2026 10:30:54 +0900 [thread overview]
Message-ID: <xmqqecj535wx.fsf@gitster.g> (raw)
In-Reply-To: <xmqqik8h36al.fsf@gitster.g> (Junio C. Hamano's message of "Thu, 21 May 2026 10:22:42 +0900")
Junio C Hamano <gitster@pobox.com> writes:
>> +mode_auto() {
>> + if test "$(git rev-parse --is-inside-work-tree 2>/dev/null)" != "true"; then
>> + usage >&2
>> + exit 1
>> + fi
>
> That looks like a basic safety measure, which is good.
>
>> + 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?
>> + mode_ws "$@"
If there are any unstaged changes (possibly with whitespace errors),
'git diff --quiet' would exit with non-zero, so "elif ! git diff
--quiet" would be taken and we do mode_diff. The user cannot rely
on "auto" to trigger mode_ws to check whitespace errors in the
working tree files because of this. If there is no unstaged
changes, 'git diff --quiet' woudl exit with zero, so the control
comes to "git diff --check", but then there is nothing mode_ws to
work on in that case, right? So it is not clear to me in what
situation this auto selection of mode_ws would help us.
>> + else
>> + usage >&2
>> + exit 1
>> + fi
>> +}
prev parent reply other threads:[~2026-05-21 1:30 UTC|newest]
Thread overview: 10+ 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
2026-05-19 9:03 ` Greg Hurrell
2026-05-19 21:22 ` Jeff King
2026-05-20 12:31 ` [PATCH v2] " Greg Hurrell via GitGitGadget
2026-05-21 1:22 ` Junio C Hamano
2026-05-21 1:30 ` Junio C Hamano [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=xmqqecj535wx.fsf@gitster.g \
--to=gitster@pobox.com \
--cc=erik@cervined.in \
--cc=git@vger.kernel.org \
--cc=gitgitgadget@gmail.com \
--cc=greg.hurrell@datadoghq.com \
--cc=greg@hurrell.net \
--cc=peff@peff.net \
/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