mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Yury Norov <ynorov@nvidia.com>
To: Junio C Hamano <gitster@pobox.com>
Cc: "D. Ben Knoble" <ben.knoble@gmail.com>,
	"Yury Norov (NVIDIA)" <yury.norov@gmail.com>,
	git@vger.kernel.org, "Thiago Perrotta" <tbperrotta@gmail.com>,
	"Philippe Blain" <levraiphilippeblain@gmail.com>,
	"Rubén Justo" <rjusto@gmail.com>,
	linux-kernel@vger.kernel.org, Codex <codex@openai.com>
Subject: Re: [PATCH] completion: complete paths for git send-email
Date: Tue, 21 Jul 2026 14:03:30 -0400	[thread overview]
Message-ID: <al-0ckPhoa-ZPhSi@yury> (raw)
In-Reply-To: <xmqqcxwgz2u3.fsf@gitster.g>

On Tue, Jul 21, 2026 at 10:09:56AM -0700, Junio C Hamano wrote:
> "D. Ben Knoble" <ben.knoble@gmail.com> writes:
> 
> > On Sun, Jul 19, 2026 at 9:45 AM Yury Norov (NVIDIA)
> > <yury.norov@gmail.com> wrote:
> >>
> >> 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:
> >
> > It is unusual to call this a "hashtag." Perhaps "hash" or "object
> 
> Very good point, but I am not sure if the author truly meant object
> names here.   > name" (or id) based on the glossary and datamodel docs?

I said hashtag because for me it's a hash of the tag:

git send-email 0<TAB>
git send-email 05c69d298c96703741cac9a5cbbf6c53bd55a6e2

But also it's a name of the tag, and git warns about it:

  $ git show 05c69d298c96703741cac9a5cbbf6c53bd55a6e2
  warning: refname '05c69d298c96703741cac9a5cbbf6c53bd55a6e2' is ambiguous.
  Git normally never creates a ref that ends with 40 hex characters
  because it will be ignored when you just specify 40-hex. These refs
  may be created by mistake. For example,
  
    git switch -c $br $(git rev-parse ...)
  
  where "$br" is somehow empty and a 40-hex ref is created. Please
  examine these refs and maybe delete them. Turn this message off by
  running "git config set advice.objectNameWarning false"
  commit 05c69d298c96703741cac9a5cbbf6c53bd55a6e2 (tag: 05c69d298c96703741cac9a5cbbf6c53bd55a6e2)
  Author: Tejun Heo <tj@kernel.org>
  Date:   Tue May 15 08:22:04 2012 +0200
  ...

I have no local branch or local file with that name, but the tag exists
for 14 years, and will not go away. And yes, it breaks autocompletion.

So, after rethinking, the problem looks like this: if autocompletion
logic finds a tag beginning with that pattern, it doesn't attempt to
search for the matching files, which is wrong

> The reproduction test uses a long hexadecimal string,
> but that is not an object name; it is an unusual-looking tag name.
> It is like naming a topic branch '012345' and complaining that:
> 
>     $ git send-email 0<TAB>
> 
> completes the input to the branch name while ignoring the
> 0001-changes.patch file.
> 
> When you have a branch named '0-tolerance-policy' and:
> 
>     $ git send-email 0<TAB>
> 
> completes to that branch name, you would not dream of complaining
> about the completion.  IOW, I think the complaint is somewhat unfair
> to begin with.
> 
> Actually, I do not know if the completion script really expands an
> abbreviated object name to a full one.  I tried:
> 
>     $ git rev-parse seen^2
>     179eccf0d01729c19a3238905b951b1880aa4ba1
>     $ git checkout master
>     $ . contrib/completion/git-completion.bash
>     $ git send-email 17<TAB>
> 
> and waited for some time, but it did not complete to anything.
> 
> In any case, when both a '0001-my-changes.patch' file and a
> '0-tolerance-policy' branch exist in your repository and current
> working directory, running:
> 
>     $ git send-email 0<TAB>
> 
> should offer both as candidates, I thihk.  Since I only ever pass
> filenames to the command, I personally do not think it is a huge
> loss if the completion script stops looking at refs and sticks to
> filenames only, but others may have a use for that feature.

Agree. The test should create a file 0001.patch, then a tag
0-tag, then a branch 0-branch, maybe something else that is
relevant; and then make sure every option is correctly offered
by autocompletion.

Guys please let me know if everything else is needed before I send v2.

Thanks,
Yury

  reply	other threads:[~2026-07-21 18:03 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-19 13:44 Yury Norov (NVIDIA)
2026-07-19 17:04 ` Junio C Hamano
2026-07-21 12:49 ` D. Ben Knoble
2026-07-21 17:09   ` Junio C Hamano
2026-07-21 18:03     ` Yury Norov [this message]
2026-07-21 19:22       ` Junio C Hamano
2026-07-22 10:29         ` Ben Knoble
2026-07-22 15:32           ` Junio C Hamano
2026-07-21 22:21     ` SZEDER Gábor

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=al-0ckPhoa-ZPhSi@yury \
    --to=ynorov@nvidia.com \
    --cc=ben.knoble@gmail.com \
    --cc=codex@openai.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=levraiphilippeblain@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rjusto@gmail.com \
    --cc=tbperrotta@gmail.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

all inboxes | Powered by JetHome®