summaryrefslogtreecommitdiff
path: root/sha1_name.c
diff options
context:
space:
mode:
authorJunio C Hamano <junkio@cox.net>2007-01-19 01:19:05 -0800
committerJunio C Hamano <junkio@cox.net>2007-01-19 17:57:53 -0800
commit16d7cc90dd6e68a170362ae6f0fbfbc504fd246b (patch)
tree6675317cbe5a1d8017d1c7856fd3ac430debd247 /sha1_name.c
parente86eb6668ee0c574ba0b6c2c94564d4159a6fcc7 (diff)
downloadgit-16d7cc90dd6e68a170362ae6f0fbfbc504fd246b.tar.gz
Extend read_ref_at() to be usable from places other than sha1_name.
You can pass an extra argument to the function to receive the reflog message information. Also when the log does not go back beyond the point the user asked, the cut-off time and count are given back to the caller for emitting the error messages as appropriately. We could later add configuration for get_sha1_basic() to make it an error instead of it being just a warning. Signed-off-by: Junio C Hamano <junkio@cox.net>
Diffstat (limited to 'sha1_name.c')
-rw-r--r--sha1_name.c16
1 files changed, 15 insertions, 1 deletions
diff --git a/sha1_name.c b/sha1_name.c
index ae31851900..9dfb3ac574 100644
--- a/sha1_name.c
+++ b/sha1_name.c
@@ -304,6 +304,9 @@ static int get_sha1_basic(const char *str, int len, unsigned char *sha1)
/* Is it asking for N-th entry, or approxidate? */
int nth, i;
unsigned long at_time;
+ unsigned long co_time;
+ int co_tz, co_cnt;
+
for (i = nth = 0; 0 <= nth && i < reflog_len; i++) {
char ch = str[at+2+i];
if ('0' <= ch && ch <= '9')
@@ -315,7 +318,18 @@ static int get_sha1_basic(const char *str, int len, unsigned char *sha1)
at_time = 0;
else
at_time = approxidate(str + at + 2);
- read_ref_at(real_ref, at_time, nth, sha1);
+ if (read_ref_at(real_ref, at_time, nth, sha1, NULL,
+ &co_time, &co_tz, &co_cnt)) {
+ if (at_time)
+ fprintf(stderr,
+ "warning: Log for '%.*s' only goes "
+ "back to %s.\n", len, str,
+ show_rfc2822_date(co_time, co_tz));
+ else
+ fprintf(stderr,
+ "warning: Log for '%.*s' only has "
+ "%d entries.\n", len, str, co_cnt);
+ }
}
free(real_ref);