From d25b251ef7fca67320e2a65f05b4a912c133a19e Mon Sep 17 00:00:00 2001 From: Zhiming Wang Date: Sun, 17 Jan 2016 13:22:54 -0800 Subject: [PATCH] git: Add revert to special action contexts revert is very similar to cherry-pick and has a sequence variant. --- modules/git/README.md | 2 ++ modules/git/functions/git-info | 16 +++++++++++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/modules/git/README.md b/modules/git/README.md index 4d37cbc4..0a31e002 100644 --- a/modules/git/README.md +++ b/modules/git/README.md @@ -389,6 +389,8 @@ The following contexts must be enabled with the following zstyle: | rebase | value | Rebasing | rebase-interactive | value | Rebasing interactively | rebase-merge | value | Rebasing merge +| revert | value | Reverting +| revert-sequence | value | Reverting sequence First, format the repository state attributes. For example, to format the branch and remote names, define the following styles. diff --git a/modules/git/functions/git-info b/modules/git/functions/git-info index 8aaa4c32..d27365c2 100644 --- a/modules/git/functions/git-info +++ b/modules/git/functions/git-info @@ -5,7 +5,7 @@ # Sorin Ionescu # -# Gets the Git special action (am, bisect, cherry, merge, rebase). +# Gets the Git special action (am, bisect, cherry, merge, rebase, revert). # Borrowed from vcs_info and edited. function _git-action { local action_dir @@ -18,6 +18,8 @@ function _git-action { local rebase_formatted local rebase_interactive_formatted local rebase_merge_formatted + local revert_formatted + local revert_sequence_formatted for action_dir in \ "${git_dir}/rebase-apply" \ @@ -80,6 +82,18 @@ function _git-action { return 0 fi + if [[ -f "${git_dir}/REVERT_HEAD" ]]; then + if [[ -d "${git_dir}/sequencer" ]] ; then + zstyle -s ':prezto:module:git:info:action:revert-sequence' format 'revert_sequence_formatted' || revert_sequence_formatted='revert-sequence' + print "$revert_sequence_formatted" + else + zstyle -s ':prezto:module:git:info:action:revert' format 'revert_formatted' || revert_formatted='revert' + print "$revert_formatted" + fi + + return 0 + fi + if [[ -f "${git_dir}/BISECT_LOG" ]]; then zstyle -s ':prezto:module:git:info:action:bisect' format 'bisect_formatted' || bisect_formatted='bisect' print "$bisect_formatted"