summaryrefslogtreecommitdiff
path: root/contrib/completion
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2019-07-19 18:30:22 (GMT)
committerJunio C Hamano <gitster@pobox.com>2019-07-19 18:30:22 (GMT)
commit8a4acc5f4cdd811476ffa0b5c63ae4cc35ef288f (patch)
tree2b74cebb26cc6fdeff4c5a7a029fe9b6dcda7f9c /contrib/completion
parentd60dc1a0b3829f3c4d69696f43f1c178c0701cdb (diff)
parente981bf75251ecab712fa70ea2fe995a973ed5dba (diff)
downloadgit-8a4acc5f4cdd811476ffa0b5c63ae4cc35ef288f.zip
git-8a4acc5f4cdd811476ffa0b5c63ae4cc35ef288f.tar.gz
git-8a4acc5f4cdd811476ffa0b5c63ae4cc35ef288f.tar.bz2
Merge branch 'pw/prompt-cherry-pick-revert-fix'
When one step in multi step cherry-pick or revert is reset or committed, the command line prompt script failed to notice the current status, which has been improved. * pw/prompt-cherry-pick-revert-fix: git-prompt: improve cherry-pick/revert detection
Diffstat (limited to 'contrib/completion')
-rw-r--r--contrib/completion/git-prompt.sh37
1 files changed, 33 insertions, 4 deletions
diff --git a/contrib/completion/git-prompt.sh b/contrib/completion/git-prompt.sh
index 983e419..1d510cd 100644
--- a/contrib/completion/git-prompt.sh
+++ b/contrib/completion/git-prompt.sh
@@ -286,6 +286,37 @@ __git_eread ()
test -r "$1" && IFS=$'\r\n' read "$2" <"$1"
}
+# see if a cherry-pick or revert is in progress, if the user has committed a
+# conflict resolution with 'git commit' in the middle of a sequence of picks or
+# reverts then CHERRY_PICK_HEAD/REVERT_HEAD will not exist so we have to read
+# the todo file.
+__git_sequencer_status ()
+{
+ local todo
+ if test -f "$g/CHERRY_PICK_HEAD"
+ then
+ r="|CHERRY-PICKING"
+ return 0;
+ elif test -f "$g/REVERT_HEAD"
+ then
+ r="|REVERTING"
+ return 0;
+ elif __git_eread "$g/sequencer/todo" todo
+ then
+ case "$todo" in
+ p[\ \ ]|pick[\ \ ]*)
+ r="|CHERRY-PICKING"
+ return 0
+ ;;
+ revert[\ \ ]*)
+ r="|REVERTING"
+ return 0
+ ;;
+ esac
+ fi
+ return 1
+}
+
# __git_ps1 accepts 0 or 1 arguments (i.e., format string)
# when called from PS1 using command substitution
# in this mode it prints text to add to bash PS1 prompt (includes branch name)
@@ -417,10 +448,8 @@ __git_ps1 ()
fi
elif [ -f "$g/MERGE_HEAD" ]; then
r="|MERGING"
- elif [ -f "$g/CHERRY_PICK_HEAD" ]; then
- r="|CHERRY-PICKING"
- elif [ -f "$g/REVERT_HEAD" ]; then
- r="|REVERTING"
+ elif __git_sequencer_status; then
+ :
elif [ -f "$g/BISECT_LOG" ]; then
r="|BISECTING"
fi