summaryrefslogtreecommitdiff
path: root/plugins/mercurial
diff options
context:
space:
mode:
authorDavid Sutherland <djsutho@gmail.com>2013-10-17 16:48:58 +1000
committerMarc Cornellà <hello@mcornella.com>2021-12-13 10:50:56 +0100
commit1c07001896de18cd0a742d7892b948ba7bab10c7 (patch)
treed8439c2f2011a952242230ebf2f94c1180ef7dde /plugins/mercurial
parent4119f53004de987215e4ae2ce49d0f818ad58c63 (diff)
downloadzsh-1c07001896de18cd0a742d7892b948ba7bab10c7.tar.gz
zsh-1c07001896de18cd0a742d7892b948ba7bab10c7.tar.bz2
zsh-1c07001896de18cd0a742d7892b948ba7bab10c7.zip
fix(mercurial): correctly check for untracked files in `hg_dirty` (#2177)
Closes #2177 Closes #6197 Co-authored-by: Henrik Ravn <hravnx@gmail.com>
Diffstat (limited to 'plugins/mercurial')
-rw-r--r--plugins/mercurial/mercurial.plugin.zsh18
1 files changed, 15 insertions, 3 deletions
diff --git a/plugins/mercurial/mercurial.plugin.zsh b/plugins/mercurial/mercurial.plugin.zsh
index 6e72f0b1e..9b85d02f6 100644
--- a/plugins/mercurial/mercurial.plugin.zsh
+++ b/plugins/mercurial/mercurial.plugin.zsh
@@ -91,13 +91,25 @@ function hg_prompt_info {
}
function hg_dirty {
- local hg_status
- if ! hg_status="$(hg status -mar 2>/dev/null)"; then
+ # Do nothing if clean / dirty settings aren't defined
+ if [[ -z "$ZSH_THEME_HG_PROMPT_DIRTY" && -z "$ZSH_THEME_HG_PROMPT_CLEAN" ]]; then
return
fi
+ # Check if there are modifications
+ local hg_status
+ if [[ "$DISABLE_UNTRACKED_FILES_DIRTY" = true ]]; then
+ if ! hg_status="$(hg status -q 2>/dev/null)"; then
+ return
+ fi
+ else
+ if ! hg_status="$(hg status 2>/dev/null)"; then
+ return
+ fi
+ fi
+
# grep exits with 0 when dirty
- if command grep -Eq '^\s*[ACDIM!?L]' <<< "$hg_status"; then
+ if command grep -Eq '^\s*[ACDIMR!?L].*$' <<< "$hg_status"; then
echo $ZSH_THEME_HG_PROMPT_DIRTY
return
fi