{"thread":{"id":"8801","subject":"[PATCH] git-stash: don't complain when listing in a repo with no stash","startedAt":"2007-07-02T04:21:24Z","lastAt":"2007-07-02T05:02:48Z","messageCount":2,"participants":["Jeff King","しらいしななこ"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"46214","messageId":"20070702042124.GA29479@coredump.intra.peff.net","threadId":"8801","inReplyTo":null,"subject":"[PATCH] git-stash: don't complain when listing in a repo with no stash","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2007-07-02T04:21:24Z","receivedAt":"2007-07-02T04:21:24Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"Previously, the git-log invocation would complain if a repo\nhad not had any stashes created in it yet:\n\n$ git-init\n$ git-stash\nfatal: ambiguous argument 'refs/stash': unknown revision or\n  path not in the working tree.\nUse '--' to separate paths from revisions\n\nInstead, we only call git-log if we actually have a\nrefs/stash. We could alternatively create the ref when any\nstash command is called, but it's better for the 'list'\ncommand to not require write access to the repo.\n\nSigned-off-by: Jeff King <peff@peff.net>\n---\n git-stash.sh |    5 +++++\n 1 files changed, 5 insertions(+), 0 deletions(-)\n\ndiff --git a/git-stash.sh b/git-stash.sh\nindex 7644bd5..18d3322 100755\n--- a/git-stash.sh\n+++ b/git-stash.sh\n@@ -76,7 +76,12 @@ save_stash () {\n \tprintf >&2 'Saved WIP on %s\\n' \"$msg\"\n }\n \n+have_stash () {\n+\tgit-rev-parse --verify $ref_stash >/dev/null 2>&1\n+}\n+\n list_stash () {\n+\thave_stash || return 0\n \tgit-log --pretty=oneline -g \"$@\" $ref_stash |\n \tsed -n -e 's/^[.0-9a-f]* refs\\///p'\n }\n-- \n1.5.2.2.1452.g896f6\n"},{"id":"46216","messageId":"200707020503.l6253NPQ020362@mi0.bluebottle.com","threadId":"8801","inReplyTo":"20070702042124.GA29479@coredump.intra.peff.net","subject":"Re: [PATCH] git-stash: don't complain when listing in a repo with no stash","fromName":"しらいしななこ","fromEmail":"nanako3@bluebottle.com","sentAt":"2007-07-02T05:02:48Z","receivedAt":"2007-07-02T05:02:48Z","isPatch":true,"sender":{"key":"nanako3@lavabit.com","avatar":"https://gravatar.com/avatar/3777b9e201c5883a62b1a6fdf7c53f2d712d1d80989146063ea861e33aad72a8?d=mp&s=160"},"body":"Quoting Jeff King <peff@peff.net>:\n\n> Previously, the git-log invocation would complain if a repo\n> had not had any stashes created in it yet:\n>\n> $ git-init\n> $ git-stash\n> fatal: ambiguous argument 'refs/stash': unknown revision or\n>   path not in the working tree.\n> Use '--' to separate paths from revisions\n>\n> Instead, we only call git-log if we actually have a\n> refs/stash. We could alternatively create the ref when any\n> stash command is called, but it's better for the 'list'\n> command to not require write access to the repo.\n>\n> Signed-off-by: Jeff King <peff@peff.net>\n\nThank you for correcting the bugs I introduced.\n\n-- \nNanako Shiraishi\nhttp://ivory.ap.teacup.com/nanako3/\n\n----------------------------------------------------------------------\nFinally - A spam blocker that actually works.\nhttp://www.bluebottle.com\n"}]}