git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: bug in bash completion for git-branch --set-upstream-to on OSX

From
SZEDER Gábor <szeder@ira.uka.de>
Date
Mar 22, 2015, 11:06 UTC
Message-ID
<20150322120612.Horde.LAxCkP-VMKE3Ur7ZXII3Hg1@webmail.informatik.kit.edu>
Hi,
Quoting Jason Karns <karns.17@gmail.com>:
Show 16 quoted lines
> There appears to be a bug in the bash completion for git-branch when
> attempting to complete the remote ref argument for --set-upstream-to=
>
> When:
>
> $ git branch --set-upstream-to=origin/mast<TAB>
>
> I would expect it to complete to:
>
> $ git branch --set-upstream-to=origin/master
>
> However, the completion for --set-upstream-to= completes the ref
> correctly, but completely wipes the --set-upstream option; resulting
> in:
>
> $ git branch origin/master
Strange.
The code in question
    case "$cur" in
    --set-upstream-to=*)
            __gitcomp "$(__git_refs)" "" "${cur##--set-upstream-to=}"
            ;;

looks unsuspicious, this is the "standard" way to complete '--option=<TAB>' (except that we should use __gitcomp_nl() for completing refs, but that should have no effect on this issue). Does the same issue affect other 'git cmd --option=<TAB>' completions as well, e.g. 'git log --date=<TAB>' or 'git commit --reuse-message=<TAB>'?

We had a similar issue with ':' on the command line a looong while ago, see v1.5.6.4~9^2 (bash completion: Resolve git show ref:path<tab> losing ref: portion, 2008-07-15). Maybe we are dealing with the same issue here, just a different character?

What does
    printf "$COMP_WORDBREAKS" |tr ' \t\n' STN

print out? Is the '=' missing, perhaps? If that's indeed the case, does adding it back (COMP_WORDBREAKS="$COMP_WORDBREAKS"=) fix the issue?

Gábor
Next: Jason Karns
Message 1 of 3 in “Re: bug in bash completion for git-branch --set-upstream-to on OSX”
  1. SZEDER GáborMar 22, 2015
  2. Jason KarnsMar 23, 2015
  3. Jason KarnsMar 23, 2015

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.