diff options
author | David Aguilar <davvid@gmail.com> | 2014-09-18 20:45:37 -0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2014-09-19 10:46:15 -0700 |
commit | c41a87dd80cd32cfd6e2d670153a9b69dc627f71 (patch) | |
tree | 2e46f6355196a3b2c84ef52f32f35c45c5e585e1 /sha1_name.c | |
parent | 2892dfeec3f98f7e65a2746d271471d2c3c4af57 (diff) | |
download | git-c41a87dd80cd32cfd6e2d670153a9b69dc627f71.tar.gz |
refs: make rev-parse --quiet actually quiet
When a reflog is deleted, e.g. when "git stash" clears its stashes,
"git rev-parse --verify --quiet" dies:
fatal: Log for refs/stash is empty.
The reason is that the get_sha1() code path does not allow us
to suppress this message.
Pass the flags bitfield through get_sha1_with_context() so that
read_ref_at() can suppress the message.
Use get_sha1_with_context1() instead of get_sha1() in rev-parse
so that the --quiet flag is honored.
Signed-off-by: David Aguilar <davvid@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'sha1_name.c')
-rw-r--r-- | sha1_name.c | 24 |
1 files changed, 15 insertions, 9 deletions
diff --git a/sha1_name.c b/sha1_name.c index 7098b10e3d..5b004f513b 100644 --- a/sha1_name.c +++ b/sha1_name.c @@ -432,7 +432,8 @@ static inline int upstream_mark(const char *string, int len) static int get_sha1_1(const char *name, int len, unsigned char *sha1, unsigned lookup_flags); static int interpret_nth_prior_checkout(const char *name, int namelen, struct strbuf *buf); -static int get_sha1_basic(const char *str, int len, unsigned char *sha1) +static int get_sha1_basic(const char *str, int len, unsigned char *sha1, + unsigned int flags) { static const char *warn_msg = "refname '%.*s' is ambiguous."; static const char *object_name_msg = N_( @@ -511,7 +512,7 @@ static int get_sha1_basic(const char *str, int len, unsigned char *sha1) if (!refs_found) return -1; - if (warn_ambiguous_refs && + if (warn_ambiguous_refs && !(flags & GET_SHA1_QUIETLY) && (refs_found > 1 || !get_short_sha1(str, len, tmp_sha1, GET_SHA1_QUIETLY))) warning(warn_msg, len, str); @@ -545,7 +546,7 @@ static int get_sha1_basic(const char *str, int len, unsigned char *sha1) return -1; } } - if (read_ref_at(real_ref, at_time, nth, sha1, NULL, + if (read_ref_at(real_ref, flags, at_time, nth, sha1, NULL, &co_time, &co_tz, &co_cnt)) { if (!len) { if (starts_with(real_ref, "refs/heads/")) { @@ -557,11 +558,16 @@ static int get_sha1_basic(const char *str, int len, unsigned char *sha1) len = 4; } } - if (at_time) - warning("Log for '%.*s' only goes " - "back to %s.", len, str, - show_date(co_time, co_tz, DATE_RFC2822)); - else { + if (at_time) { + if (!(flags & GET_SHA1_QUIETLY)) { + warning("Log for '%.*s' only goes " + "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); } @@ -801,7 +807,7 @@ static int get_sha1_1(const char *name, int len, unsigned char *sha1, unsigned l if (!ret) return 0; - ret = get_sha1_basic(name, len, sha1); + ret = get_sha1_basic(name, len, sha1, lookup_flags); if (!ret) return 0; |