Git development
 help / color / mirror / Atom feed
From: Jeff King <peff@peff.net>
To: Junio C Hamano <gitster@pobox.com>
Cc: nanako3@bluebottle.com, git@vger.kernel.org
Subject: [PATCH] git-stash: don't complain when listing in a repo with no stash
Date: Mon, 2 Jul 2007 00:21:24 -0400	[thread overview]
Message-ID: <20070702042124.GA29479@coredump.intra.peff.net> (raw)

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>
---
 git-stash.sh |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/git-stash.sh b/git-stash.sh
index 7644bd5..18d3322 100755
--- a/git-stash.sh
+++ b/git-stash.sh
@@ -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'
 }
-- 
1.5.2.2.1452.g896f6

             reply	other threads:[~2007-07-02  4:21 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-07-02  4:21 Jeff King [this message]
2007-07-02  5:02 ` [PATCH] git-stash: don't complain when listing in a repo with no stash しらいしななこ

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20070702042124.GA29479@coredump.intra.peff.net \
    --to=peff@peff.net \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=nanako3@bluebottle.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox