Skip to content

Commit e832f5c

Browse files
felipecgitster
authored andcommitted
completion: avoid ls-remote in certain scenarios
It's _very_ slow in many cases, and there's really no point in fetching *everything* from the remote just for completion. In many cases it might be faster for the user to type the whole thing. If the user manually specifies 'refs/*', then the full ls-remote completion is triggered. Signed-off-by: Felipe Contreras <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent edca415 commit e832f5c

File tree

1 file changed

+2
-8
lines changed

1 file changed

+2
-8
lines changed

contrib/completion/git-completion.bash

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -427,14 +427,8 @@ __git_refs ()
427427
done
428428
;;
429429
*)
430-
git ls-remote "$dir" HEAD ORIG_HEAD 'refs/tags/*' 'refs/heads/*' 'refs/remotes/*' 2>/dev/null | \
431-
while read -r hash i; do
432-
case "$i" in
433-
*^{}) ;;
434-
refs/*) echo "${i#refs/*/}" ;;
435-
*) echo "$i" ;;
436-
esac
437-
done
430+
echo "HEAD"
431+
git for-each-ref --format="%(refname:short)" -- "refs/remotes/$dir/" | sed -e "s#^$dir/##"
438432
;;
439433
esac
440434
}

0 commit comments

Comments
 (0)