From: Jing Xue <jingxue@digizenstudio.com>
To: Junio C Hamano <gitster@pobox.com>
Cc: git <git@vger.kernel.org>
Subject: [PATCH] Replace the cryptic messages from "git stash show".
Date: Sat, 15 Dec 2007 00:14:25 -0500 [thread overview]
Message-ID: <20071215051425.GA9118@fawkes> (raw)
In-Reply-To: <7vir32xdn3.fsf@gitster.siamese.dyndns.org>
On Thu, Dec 13, 2007 at 05:34:40PM -0800, Junio C Hamano wrote:
>
> I agree "git stash show" should not give cryptic error message, but I
> think you should do this only when the user did not explicitly say which
> stash to show (that is, we should still give error message if the user
> said "git stash show garbage").
Good point. Actually I found out that if there _are_ some stashes and an
invalid name is given, the current behavior is still printing
refs/stash, which I think is not quite right. So I also try to fix that
while I'm at it.
Now "git stash show" will keep quiet and just exit if there are no
stashes at all. "git stash show some-non-existent-stash" will always
print a clear message indicating the case.
---
git-stash.sh | 23 ++++++++++++++++++++---
1 files changed, 20 insertions(+), 3 deletions(-)
diff --git a/git-stash.sh b/git-stash.sh
index f16fd9c..40e93dd 100755
--- a/git-stash.sh
+++ b/git-stash.sh
@@ -116,13 +116,30 @@ show_stash () {
flags=$(git rev-parse --no-revs --flags "$@")
if test -z "$flags"
then
- flags=--stat
+ diff_flags=--stat
+ else
+ diff_flags=$flags
+ fi
+ s=$(git rev-parse --revs-only --no-flags "$@")
+ if test -z "$s"
+ then
+ arguments=$@
+ if test "${flags}" = "${arguments}"
+ then
+ s=$(git rev-parse --revs-only --no-flags $ref_stash)
+ if test -z "$s"
+ then
+ return 0
+ fi
+ else
+ eval stash_name=\$$#
+ die "Can't find any stash with name $stash_name"
+ fi
fi
- s=$(git rev-parse --revs-only --no-flags --default $ref_stash "$@")
w_commit=$(git rev-parse --verify "$s") &&
b_commit=$(git rev-parse --verify "$s^") &&
- git diff $flags $b_commit $w_commit
+ git diff $diff_flags $b_commit $w_commit
}
apply_stash () {
--
1.5.4.rc0.8.gd381b
next prev parent reply other threads:[~2007-12-15 5:15 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-12-14 1:28 [PATCH] Makes 'git-stash show' stay quiet when there are no stashes Jing Xue
2007-12-14 1:34 ` Junio C Hamano
2007-12-15 5:14 ` Jing Xue [this message]
2007-12-15 6:12 ` [PATCH] Replace the cryptic messages from "git stash show" Junio C Hamano
2007-12-15 17:08 ` Jing Xue
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=20071215051425.GA9118@fawkes \
--to=jingxue@digizenstudio.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.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;
as well as URLs for NNTP newsgroup(s).