aboutsummaryrefslogtreecommitdiff
path: root/contrib/completion
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2009-05-16 19:49:42 -0700
committerJunio C Hamano <gitster@pobox.com>2009-05-16 19:49:42 -0700
commit671d1bc6a098d1015fbdd6e085d6daf12c1dce15 (patch)
tree20fa2bf3411f0ac3b3185a2f354b03341b92aa14 /contrib/completion
parent8a94bc7bdc54db0d77058e63baf173ff932cba7c (diff)
parente4b09dad9f65395fd4bb8ab165012a3a6698a75b (diff)
downloadgit-671d1bc6a098d1015fbdd6e085d6daf12c1dce15.tar.gz
git-671d1bc6a098d1015fbdd6e085d6daf12c1dce15.tar.xz
Merge branch 'maint'
* maint: test: checkout shouldn't say that HEAD has moved if it didn't completion: enhance "current branch" display completion: simplify "current branch" in __git_ps1() completion: fix PS1 display during a merge on detached HEAD builtin-checkout: Don't tell user that HEAD has moved before it has pre-commit.sample: don't print incidental SHA1 tests: Add tests for missing format-patch long options api-parse-options.txt: use 'func' instead of 'funct' Turn on USE_ST_TIMESPEC for OpenBSD ls-tree manpage: output of ls-tree is compatible with update-index ls-tree manpage: use "unless" instead of "when ... is not"
Diffstat (limited to 'contrib/completion')
-rwxr-xr-xcontrib/completion/git-completion.bash32
1 files changed, 22 insertions, 10 deletions
diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
index ad26b7c5a..b6bcd5cc2 100755
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -99,20 +99,32 @@ __git_ps1 ()
elif [ -d "$g/rebase-merge" ]; then
r="|REBASE-m"
b="$(cat "$g/rebase-merge/head-name")"
- elif [ -f "$g/MERGE_HEAD" ]; then
- r="|MERGING"
- b="$(git symbolic-ref HEAD 2>/dev/null)"
else
+ if [ -f "$g/MERGE_HEAD" ]; then
+ r="|MERGING"
+ fi
if [ -f "$g/BISECT_LOG" ]; then
r="|BISECTING"
fi
- if ! b="$(git symbolic-ref HEAD 2>/dev/null)"; then
- if ! b="$(git describe --exact-match HEAD 2>/dev/null)"; then
- if [ -r "$g/HEAD" ]; then
- b="$(cut -c1-7 "$g/HEAD")..."
- fi
- fi
- fi
+
+ b="$(git symbolic-ref HEAD 2>/dev/null)" || {
+
+ b="$(
+ case "${GIT_PS1_DESCRIBE_STYLE-}" in
+ (contains)
+ git describe --contains HEAD ;;
+ (branch)
+ git describe --contains --all HEAD ;;
+ (describe)
+ git describe HEAD ;;
+ (* | default)
+ git describe --exact-match HEAD ;;
+ esac 2>/dev/null)" ||
+
+ b="$(cut -c1-7 "$g/HEAD" 2>/dev/null)..." ||
+ b="unknown"
+ b="($b)"
+ }
fi
local w