]> asedeno.scripts.mit.edu Git - git.git/commitdiff
git-stash: don't complain when listing in a repo with no stash
authorJeff King <peff@peff.net>
Mon, 2 Jul 2007 04:21:24 +0000 (00:21 -0400)
committerJunio C Hamano <gitster@pobox.com>
Mon, 2 Jul 2007 04:45:13 +0000 (21:45 -0700)
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 <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
git-stash.sh

index 7644bd5a23d46bdcb5f8da00e2e21bce184a1669..18d3322ab5d57c8dc8e1333fc007861ef89e2d6d 100755 (executable)
@@ -76,7 +76,12 @@ save_stash () {
        printf >&2 'Saved WIP on %s\n' "$msg"
 }
 
+have_stash () {
+       git-rev-parse --verify $ref_stash >/dev/null 2>&1
+}
+
 list_stash () {
+       have_stash || return 0
        git-log --pretty=oneline -g "$@" $ref_stash |
        sed -n -e 's/^[.0-9a-f]* refs\///p'
 }