summaryrefslogtreecommitdiff
path: root/contrib
diff options
context:
space:
mode:
authorLibravatar Junio C Hamano <gitster@pobox.com>2020-07-06 22:09:13 -0700
committerLibravatar Junio C Hamano <gitster@pobox.com>2020-07-06 22:09:13 -0700
commit0cc4dcacb323cfd1cfe6e6a750ecc86eb215180d (patch)
treeb9a8298b085c8805cf944924b4373ae9a654b48e /contrib
parentMerge branch 'ps/ref-transaction-hook' (diff)
parentgit-prompt: include sparsity state as well (diff)
downloadtgif-0cc4dcacb323cfd1cfe6e6a750ecc86eb215180d.tar.xz
Merge branch 'en/sparse-status'
"git status" learned to report the status of sparse checkout. * en/sparse-status: git-prompt: include sparsity state as well git-prompt: document how in-progress operations affect the prompt wt-status: show sparse checkout status as well
Diffstat (limited to 'contrib')
-rw-r--r--contrib/completion/git-prompt.sh26
1 files changed, 24 insertions, 2 deletions
diff --git a/contrib/completion/git-prompt.sh b/contrib/completion/git-prompt.sh
index 014cd7c3cf..e6cd5464e5 100644
--- a/contrib/completion/git-prompt.sh
+++ b/contrib/completion/git-prompt.sh
@@ -70,6 +70,15 @@
# state symbols by setting GIT_PS1_STATESEPARATOR. The default separator
# is SP.
#
+# When there is an in-progress operation such as a merge, rebase,
+# revert, cherry-pick, or bisect, the prompt will include information
+# related to the operation, often in the form "|<OPERATION-NAME>".
+#
+# When the repository has a sparse-checkout, a notification of the form
+# "|SPARSE" will be included in the prompt. This can be shortened to a
+# single '?' character by setting GIT_PS1_COMPRESSSPARSESTATE, or omitted
+# by setting GIT_PS1_OMITSPARSESTATE.
+#
# By default, __git_ps1 will compare HEAD to your SVN upstream if it can
# find one, or @{upstream} otherwise. Once you have set
# GIT_PS1_SHOWUPSTREAM, you can override it on a per-repository basis by
@@ -421,6 +430,13 @@ __git_ps1 ()
return $exit
fi
+ local sparse=""
+ if [ -z "${GIT_PS1_COMPRESSSPARSESTATE}" ] &&
+ [ -z "${GIT_PS1_OMITSPARSESTATE}" ] &&
+ [ "$(git config --bool core.sparseCheckout)" == "true" ]; then
+ sparse="|SPARSE"
+ fi
+
local r=""
local b=""
local step=""
@@ -492,6 +508,7 @@ __git_ps1 ()
local i=""
local s=""
local u=""
+ local h=""
local c=""
local p=""
@@ -524,6 +541,11 @@ __git_ps1 ()
u="%${ZSH_VERSION+%}"
fi
+ if [ -n "${GIT_PS1_COMPRESSSPARSESTATE}" ] &&
+ [ "$(git config --bool core.sparseCheckout)" == "true" ]; then
+ h="?"
+ fi
+
if [ -n "${GIT_PS1_SHOWUPSTREAM-}" ]; then
__git_ps1_show_upstream
fi
@@ -542,8 +564,8 @@ __git_ps1 ()
b="\${__git_ps1_branch_name}"
fi
- local f="$w$i$s$u"
- local gitstring="$c$b${f:+$z$f}$r$p"
+ local f="$h$w$i$s$u"
+ local gitstring="$c$b${f:+$z$f}${sparse}$r$p"
if [ $pcmode = yes ]; then
if [ "${__git_printf_supports_v-}" != yes ]; then