From: Junio C Hamano <gitster@pobox.com>
To: "SZEDER Gábor" <szeder.dev@gmail.com>
Cc: git@vger.kernel.org,
"Philippe Blain" <levraiphilippeblain@gmail.com>,
"Britton Leo Kerin" <britton.kerin@gmail.com>,
"Elijah Newren" <newren@gmail.com>,
"Rubén Justo" <rjusto@gmail.com>,
"Patrick Steinhardt" <ps@pks.im>
Subject: Re: [PATCH] completion: complete tracked paths for 'git diff'
Date: Mon, 03 Aug 2026 08:45:39 -0700 [thread overview]
Message-ID: <xmqqpkzzyzq4.fsf@gitster.g> (raw)
In-Reply-To: <xmqq33wv1fts.fsf@gitster.g> (Junio C. Hamano's message of "Mon, 03 Aug 2026 06:41:51 -0700")
Junio C Hamano <gitster@pobox.com> writes:
> SZEDER Gábor <szeder.dev@gmail.com> writes:
>
>> I think we should check whether the '--no-index' option is present on
>> the command line, and simply not call __git_complete_index_file() if
>> it is, to let Bash list all paths; i.e. each of those calls should be
>> protected by an additional 'if test -z "$(__git_find_on_cmdline
>> "--no-index")' condition, perhaps.
>
>
> Ah, I did not think of the "we made 'git diff' work without Git"
> mode at all.
>
> But I would avoid scanning the command line for '--no-index' for two
> reasons:
>
> (1) "git diff -S --no-index maint master" would not give you the
> '--no-index' mode.
>
> (2) When run outside the working tree of a repository, you do not
> have to say '--no-index'.
>
> These make detecting the "'git diff' but not Git" mode tedious and
> error-prone.
>
> I have not tried this, but if we arranged the code to fall back
> further to Bash-native "paths in $PWD" after the completion code in
> the posted patch found nothing, would it be sufficient?
Eh, isn't the code already arranged to do so? With the posted
completion script loaded, I do
$ cd $HOME
$ git diff [--no-index] w/git.git/C<TAB>
where (1) my $HOME is not under version control (dotfiles are
installed after getting built from their sources that are version
controlled elsewhere), and (2) ~/w/git.git/ is the primary working
tree I work in. I see
Cargo.toml CODE_OF_CONDUCT.md COPYING
offered as choices. As there is no index or rev when I am in my
$HOME directory, naturally the only completion that kicks in is the
bash native "paths we see".
So I think I do not need anything special to "arrange" the fallback.
Thanks.
next prev parent reply other threads:[~2026-08-03 15:45 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-03 0:58 [PATCH] completion: complete tracked paths for 'git diff' Junio C Hamano
2026-08-03 1:07 ` Junio C Hamano
2026-08-03 5:44 ` SZEDER Gábor
2026-08-03 13:41 ` Junio C Hamano
2026-08-03 15:45 ` Junio C Hamano [this message]
2026-08-04 16:22 ` [PATCH v2] " Junio C Hamano
2026-08-05 19:42 ` [PATCH v3 0/3] completion of 'git [-C <dir>] diff' Junio C Hamano
2026-08-05 19:42 ` [PATCH v3 1/3] completion: no-op refactoring of diff completion Junio C Hamano
2026-08-05 19:42 ` [PATCH v3 2/3] completion: complete tracked paths for 'git diff' Junio C Hamano
2026-08-05 19:42 ` [PATCH v3 3/3] completion: 'git diff' completes untracked paths as a last resort Junio C Hamano
2026-08-06 11:30 ` D. Ben Knoble
2026-08-06 15:06 ` Junio C Hamano
2026-08-06 11:30 ` [PATCH v3 0/3] completion of 'git [-C <dir>] diff' D. Ben Knoble
2026-08-07 1:38 ` [PATCH v4 " Junio C Hamano
2026-08-07 1:38 ` [PATCH v4 1/3] completion: no-op refactoring of diff completion Junio C Hamano
2026-08-07 6:15 ` Elijah Newren
2026-08-07 15:09 ` Junio C Hamano
2026-08-07 1:38 ` [PATCH v4 2/3] completion: complete tracked paths for 'git diff' Junio C Hamano
2026-08-07 6:18 ` Elijah Newren
2026-08-07 11:02 ` D. Ben Knoble
2026-08-07 15:13 ` Junio C Hamano
2026-08-07 15:22 ` Elijah Newren
2026-08-07 1:38 ` [PATCH v4 3/3] completion: 'git diff' completes untracked paths as a last resort Junio C Hamano
2026-08-07 6:31 ` [PATCH v4 0/3] completion of 'git [-C <dir>] diff' Elijah Newren
2026-08-07 11:05 ` D. Ben Knoble
2026-08-07 16:19 ` [PATCH v5 " Junio C Hamano
2026-08-07 16:19 ` [PATCH v5 1/3] completion: no-op refactoring of diff completion Junio C Hamano
2026-08-07 16:19 ` [PATCH v5 2/3] completion: complete tracked paths for 'git diff' Junio C Hamano
2026-08-07 16:19 ` [PATCH v5 3/3] completion: 'git diff' completes untracked paths as a last resort Junio C Hamano
2026-08-07 16:53 ` [PATCH v5 0/3] completion of 'git [-C <dir>] diff' Elijah Newren
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=xmqqpkzzyzq4.fsf@gitster.g \
--to=gitster@pobox.com \
--cc=britton.kerin@gmail.com \
--cc=git@vger.kernel.org \
--cc=levraiphilippeblain@gmail.com \
--cc=newren@gmail.com \
--cc=ps@pks.im \
--cc=rjusto@gmail.com \
--cc=szeder.dev@gmail.com \
/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