From: Christian Couder <chriscool@tuxfamily.org>
To: Junio C Hamano <gitster@pobox.com>
Cc: git@vger.kernel.org
Subject: [PATCH 2/3] rev-parse: fix using "--default" with "--verify"
Date: Sun, 11 May 2008 18:27:36 +0200 [thread overview]
Message-ID: <20080511182736.b279b655.chriscool@tuxfamily.org> (raw)
Before this patch, something like:
$ git rev-parse --verify HEAD --default master
did not work, while:
$ git rev-parse --default master --verify HEAD
worked.
This patch fixes that, so that they both work (assuming
HEAD and master can be parsed).
Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
---
builtin-rev-parse.c | 2 ++
t/t1503-rev-parse-verify.sh | 11 +++++------
2 files changed, 7 insertions(+), 6 deletions(-)
diff --git a/builtin-rev-parse.c b/builtin-rev-parse.c
index 0e59707..7dbf282 100644
--- a/builtin-rev-parse.c
+++ b/builtin-rev-parse.c
@@ -583,6 +583,8 @@ int cmd_rev_parse(int argc, const char **argv, const char *prefix)
continue;
verify_filename(prefix, arg);
}
+ if (verify && revs_count == 1)
+ return 0;
show_default();
if (verify && revs_count != 1)
die_no_single_rev(quiet);
diff --git a/t/t1503-rev-parse-verify.sh b/t/t1503-rev-parse-verify.sh
index a0d14cb..e93f1b3 100755
--- a/t/t1503-rev-parse-verify.sh
+++ b/t/t1503-rev-parse-verify.sh
@@ -97,18 +97,17 @@ test_expect_failure '3 no stdout output on error' '
test -z "$(git rev-parse --verify $HASH2 HEAD)"
'
-test_expect_success '1 with --default' '
+test_expect_success 'use --default' '
git rev-parse --verify --default master &&
git rev-parse --verify --default master HEAD &&
git rev-parse --default master --verify &&
git rev-parse --default master --verify HEAD &&
+ git rev-parse --verify HEAD --default master &&
test_must_fail git rev-parse --verify foo --default master &&
test_must_fail git rev-parse --default HEAD --verify bar &&
- test_must_fail git rev-parse --verify --default HEAD baz
-'
-
-test_expect_failure '2 with --default' '
- git rev-parse --verify HEAD --default master
+ test_must_fail git rev-parse --verify --default HEAD baz &&
+ test_must_fail git rev-parse --default foo --verify &&
+ test_must_fail git rev-parse --verify --default bar
'
test_done
--
1.5.5.1.347.g86562
reply other threads:[~2008-05-11 16:23 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20080511182736.b279b655.chriscool@tuxfamily.org \
--to=chriscool@tuxfamily.org \
--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).