Skip to content

Commit c9a0c59

Browse files
committed
Refactor style
1 parent 849c85e commit c9a0c59

File tree

1 file changed

+12
-13
lines changed

1 file changed

+12
-13
lines changed

prompt.sh

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -239,19 +239,18 @@ find_git_stash_status() {
239239
if [[ -z "$git_branch" ]]; then
240240
return
241241
fi
242-
if echo "$PWD" | grep "/\.git\(/\|$\)" >/dev/null
243-
then :
244-
else
245-
local stashed_commit=$(git stash list -n 1 | cut -d ':' -f 3 | cut -d ' ' -f 2)
246-
local current_commit=$(git rev-parse --short HEAD 2> /dev/null)
247-
local stashed_branch=$(git stash list -n 1 | cut -d ':' -f 2 | sed 's+.* ++')
248-
#local stashed_branch=$(git stash list -n 1 | grep -o "^[^:]*: On [^:]*" | cut -d ' ' -f 3)
249-
local current_branch=$(git rev-parse --abbrev-ref HEAD 2> /dev/null)
250-
# This sets the stash marker if either the current commit or the current branch name is mentioned in the top stack entry.
251-
# CONSIDER: Alternatively we could have just grepped `git stash list` for either the commit_id or the branch_name. This would also indicate older matching stashes.
252-
if [[ "$stashed_commit" = "$current_commit" ]] || [[ -n "$current_branch" ]] && [[ "$stashed_branch" = "$current_branch" ]]; then
253-
git_stash_mark=''
254-
fi
242+
if echo "$PWD" | grep "/\.git\(/\|$\)" >/dev/null; then
243+
return
244+
fi
245+
local stashed_commit=$(git stash list -n 1 | cut -d ':' -f 3 | cut -d ' ' -f 2)
246+
local current_commit=$(git rev-parse --short HEAD 2> /dev/null)
247+
local stashed_branch=$(git stash list -n 1 | cut -d ':' -f 2 | sed 's+.* ++')
248+
#local stashed_branch=$(git stash list -n 1 | grep -o "^[^:]*: On [^:]*" | cut -d ' ' -f 3)
249+
local current_branch=$(git rev-parse --abbrev-ref HEAD 2> /dev/null)
250+
# This sets the stash marker if either the current commit or the current branch name is mentioned in the top stack entry.
251+
# CONSIDER: Alternatively we could have just grepped `git stash list` for either the commit_id or the branch_name. This would also indicate older matching stashes.
252+
if [[ "$stashed_commit" = "$current_commit" ]] || [[ -n "$current_branch" ]] && [[ "$stashed_branch" = "$current_branch" ]]; then
253+
git_stash_mark=''
255254
fi
256255
}
257256

0 commit comments

Comments
 (0)