From: Junio C Hamano <gitster@pobox.com>
To: "Yury Norov (NVIDIA)" <yury.norov@gmail.com>
Cc: git@vger.kernel.org, "Thiago Perrotta" <tbperrotta@gmail.com>,
"Philippe Blain" <levraiphilippeblain@gmail.com>,
"Rubén Justo" <rjusto@gmail.com>,
"Yury Norov" <ynorov@nvidia.com>,
linux-kernel@vger.kernel.org, Codex <codex@openai.com>
Subject: Re: [PATCH] completion: complete paths for git send-email
Date: Sun, 19 Jul 2026 10:04:41 -0700 [thread overview]
Message-ID: <xmqqwluqnc5y.fsf@gitster.g> (raw)
In-Reply-To: <20260719134447.381835-1-yury.norov@gmail.com> (Yury Norov's message of "Sun, 19 Jul 2026 09:44:47 -0400")
"Yury Norov (NVIDIA)" <yury.norov@gmail.com> writes:
> From: Yury Norov <ynorov@nvidia.com>
>
> git send-email accepts either revisions or paths to patch files, but its
> Bash completion only offers revisions. This prevents patch files from
> being completed. It can also make a prefix such as "0" expand to an
> unrelated hexadecimal ref even when matching 0001-*.patch files exist.
>
> In my Linux tree, an attempt to autocomplete the standard-named patch
> brings a random hashtag:
>
> $ ls 0*
> 0001-bitmap-drop-bitmap_next_set_region.patch
> $ git send-email 0<Tab>
> $ git send-email 05c69d298c96703741cac9a5cbbf6c53bd55a6e2
Wow. Even though I use nothing but 'git send-email' when sending my
own patches, I have never noticed this behavior. I guess that is
primarily because I only use the command via my own wrapper script,
so the usual bash completion kicks in only for filenames in my
workflow. Since I store my patches two levels deep in my working
tree (for example, '+outgo/topic/0000-cover-letter.txt'), I suspect
that even if I got rid of my wrapper, I would not suffer from this
issue. An attempt to run 'git send-email +outgo/contrib-doc/0<TAB>'
expanding the trailing '0' into a hexadecimal object name would
indeed be quite annoying.
Good find.
> Introduce an append variant of __gitcomp_file() and use it to add
> filesystem candidates after the existing revision candidates. Keep the
> latter because revisions remain valid send-email arguments.
OK. I will need help from those who are more familiar with our
completion code than I am to properly assess this change. Any
assistance in reviewing this would be appreciated.
> diff --git a/t/t9902-completion.sh b/t/t9902-completion.sh
> index 55dc9eabf..e87827f21 100755
> --- a/t/t9902-completion.sh
> +++ b/t/t9902-completion.sh
> @@ -2777,7 +2777,17 @@ test_expect_success PERL 'send-email' '
> test_completion "git send-email --val" <<-\EOF &&
> --validate Z
> EOF
> - test_completion "git send-email ma" "main "
> + test_completion "git send-email ma" "main " &&
> +
> + git tag 05c69d298c96703741cac9a5cbbf6c53bd55a6e2 &&
> + test_when_finished "git tag -d 05c69d298c96703741cac9a5cbbf6c53bd55a6e2 &&
> + rm -f 0001-example.patch 0002-example.patch" &&
If the initial 'git tag' fails, 'test_when_finished' is never
registered, and we end up failing to remove the '000?-example.patch'
files. The usual way to write this is:
- set up 'test_when_finished' with a body that is written to
succeed even if the clean-up target is not present (your '-f' in
'rm -f' is good, as it prevents 'rm' from failing even if
'0001-example.patch' does not get created); then
- write the test code that dirties the state (requiring clean-up)
after registering the 'test_when_finished' handler.
That is, "Prepare the clean-up first, and then you do not have to
worry about making a mess."
By the way, the use of a purely hexadecimal string as a tag or
branch name is highly misleading. What happens if an object exists
whose name is identical to that tag? Git offers ways to
disambiguate if you really want to, but I do not see any reason for
a sensible person or workflow to deliberately place oneself in a
situation where such disambiguation becomes necessary.
Of course, that is no excuse for the bug. Our completion script
should not misbehave, even when confronted with a workflow that uses
funny-looking tags.
prev parent reply other threads:[~2026-07-19 17:04 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-19 13:44 [PATCH] completion: complete paths for git send-email Yury Norov (NVIDIA)
2026-07-19 17:04 ` 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=xmqqwluqnc5y.fsf@gitster.g \
--to=gitster@pobox.com \
--cc=codex@openai.com \
--cc=git@vger.kernel.org \
--cc=levraiphilippeblain@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=rjusto@gmail.com \
--cc=tbperrotta@gmail.com \
--cc=ynorov@nvidia.com \
--cc=yury.norov@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