Skip to content

Commit 401de40

Browse files
peffgitster
authored andcommitted
git-stash: don't complain when listing in a repo with no stash
Previously, the git-log invocation would complain if a repo had not had any stashes created in it yet: $ git-init $ git-stash fatal: ambiguous argument 'refs/stash': unknown revision or path not in the working tree. Use '--' to separate paths from revisions Instead, we only call git-log if we actually have a refs/stash. We could alternatively create the ref when any stash command is called, but it's better for the 'list' command to not require write access to the repo. Signed-off-by: Jeff King <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 006a866 commit 401de40

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

git-stash.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,12 @@ save_stash () {
7676
printf >&2 'Saved WIP on %s\n' "$msg"
7777
}
7878

79+
have_stash () {
80+
git-rev-parse --verify $ref_stash >/dev/null 2>&1
81+
}
82+
7983
list_stash () {
84+
have_stash || return 0
8085
git-log --pretty=oneline -g "$@" $ref_stash |
8186
sed -n -e 's/^[.0-9a-f]* refs\///p'
8287
}

0 commit comments

Comments
 (0)