git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] fixup! refs: make rev-parse --quiet actually quiet
@ 2014-09-17  4:35 David Aguilar
  2014-09-17  4:35 ` [PATCH 2/2] rev-parse: honor --quiet when asking for reflog dates that do not exist David Aguilar
  0 siblings, 1 reply; 5+ messages in thread
From: David Aguilar @ 2014-09-17  4:35 UTC (permalink / raw)
  To: Junio C Hamano
  Cc: git, Christian Couder, Ævar Arnfjörð Bjarmason,
	Jon Seymour, Ronnie Sahlberg, Michael Haggerty, Fabian Ruch,
	Johannes Sixt

---
This is a fixup for da/rev-parse-verify-quiet in pu
We now exit(128) and handle the "Log for XXX only has DDD entries" case.

 refs.c                      |  2 +-
 sha1_name.c                 |  3 +++
 t/t1503-rev-parse-verify.sh | 10 +++++++++-
 3 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/refs.c b/refs.c
index 447e339..9e405f9 100644
--- a/refs.c
+++ b/refs.c
@@ -3128,7 +3128,7 @@ int read_ref_at(const char *refname, unsigned int flags, unsigned long at_time,
 
 	if (!cb.reccnt) {
 		if (flags & GET_SHA1_QUIETLY)
-			exit(1);
+			exit(128);
 		else
 			die("Log for %s is empty.", refname);
 	}
diff --git a/sha1_name.c b/sha1_name.c
index d292e31..be9a9de 100644
--- a/sha1_name.c
+++ b/sha1_name.c
@@ -563,6 +563,9 @@ static int get_sha1_basic(const char *str, int len, unsigned char *sha1,
 					"back to %s.", len, str,
 					show_date(co_time, co_tz, DATE_RFC2822));
 			else {
+				if (flags & GET_SHA1_QUIETLY) {
+					exit(128);
+				}
 				die("Log for '%.*s' only has %d entries.",
 				    len, str, co_cnt);
 			}
diff --git a/t/t1503-rev-parse-verify.sh b/t/t1503-rev-parse-verify.sh
index 4fe9f0e..7c3d830 100755
--- a/t/t1503-rev-parse-verify.sh
+++ b/t/t1503-rev-parse-verify.sh
@@ -86,12 +86,20 @@ test_expect_success 'fails silently when using -q' '
 test_expect_success 'fails silently when using -q with deleted reflogs' '
 	ref=$(git rev-parse HEAD) &&
 	: >.git/logs/refs/test &&
-	git update-ref -m "reflog message for refs/test" refs/test "$ref" &&
+	git update-ref -m "message for refs/test" refs/test "$ref" &&
 	git reflog delete --updateref --rewrite refs/test@{0} &&
 	test_must_fail git rev-parse -q --verify refs/test@{0} >error 2>&1 &&
 	test_must_be_empty error
 '
 
+test_expect_success 'fails silently when using -q with not enough reflogs' '
+	ref=$(git rev-parse HEAD) &&
+	: >.git/logs/refs/test2 &&
+	git update-ref -m "message for refs/test2" refs/test2 "$ref" &&
+	test_must_fail git rev-parse -q --verify refs/test2@{999} >error 2>&1 &&
+	test_must_be_empty error
+'
+
 test_expect_success 'no stdout output on error' '
 	test -z "$(git rev-parse --verify)" &&
 	test -z "$(git rev-parse --verify foo)" &&
-- 
2.1.0.248.g6401287.dirty

^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2014-09-19  3:47 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-09-17  4:35 [PATCH 1/2] fixup! refs: make rev-parse --quiet actually quiet David Aguilar
2014-09-17  4:35 ` [PATCH 2/2] rev-parse: honor --quiet when asking for reflog dates that do not exist David Aguilar
2014-09-18 16:07   ` Junio C Hamano
2014-09-18 16:12   ` Junio C Hamano
2014-09-19  3:47     ` David Aguilar

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).