]> git.ipfire.org Git - thirdparty/git.git/commit - contrib/completion/git-completion.bash
bash completion: fix completion issues with fetch, pull, and push
authorJay Soffian <jaysoffian@gmail.com>
Fri, 6 Mar 2009 04:39:31 +0000 (23:39 -0500)
committerJunio C Hamano <gitster@pobox.com>
Sun, 8 Mar 2009 04:19:45 +0000 (20:19 -0800)
commit52d5c3b5b22b6a672ace19f631768a63bb6a2250
tree20f7a3fdde7cdd0cffe7a85f7c1bb0c6cd0cd5ac
parentd5e31235f2df3d54930c79f46fb7a7e2394899d0
bash completion: fix completion issues with fetch, pull, and push

Sverre Rabbelier noticed a completion issue with push:

 $ git push ori<tab>
 git push origin

 $ git push -f ori<tab>
 git push -f origin/

Markus Heidelberg pointed out that the issue extends to fetch and pull.

The reason is that the current code naively assumes that if
COMP_CWORD=2, it should complete a remote name, otherwise it should
complete a refspec. This assumption fails if there are any --options.

This patch fixes that issue by instead scanning COMP_CWORDS to see if
the remote has been completed yet (we now assume the first non-dashed
argument is the remote). The new logic is factored into a function,
shared by fetch, pull, and push.

The new function also properly handles '.' as the remote.

Signed-off-by: Jay Soffian <jaysoffian@gmail.com>
Acked-by: Shawn O. Pearce <spearce@spearce.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
contrib/completion/git-completion.bash