summaryrefslogtreecommitdiff
path: root/refs.c
diff options
context:
space:
mode:
authorJunio C Hamano <junkio@cox.net>2006-12-19 06:07:45 (GMT)
committerJunio C Hamano <junkio@cox.net>2006-12-21 01:22:10 (GMT)
commite29cb53a8b6aa1256221207b14a1c8ef72f69d9f (patch)
tree35f785303cdc19faa8d5f65cd4a8de99c4421830 /refs.c
parent63049292e083faf80e033eba4fa43efdbac3acad (diff)
downloadgit-e29cb53a8b6aa1256221207b14a1c8ef72f69d9f.zip
git-e29cb53a8b6aa1256221207b14a1c8ef72f69d9f.tar.gz
git-e29cb53a8b6aa1256221207b14a1c8ef72f69d9f.tar.bz2
reflog: fix warning message.
When ref@{N} is specified on a ref that has only M entries (M < N), instead of saying the initial timestamp the reflog has, warn that there is only M entries. Signed-off-by: Junio C Hamano <junkio@cox.net>
Diffstat (limited to 'refs.c')
-rw-r--r--refs.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/refs.c b/refs.c
index b67b1f0..8b2a3c1 100644
--- a/refs.c
+++ b/refs.c
@@ -1013,7 +1013,7 @@ int read_ref_at(const char *ref, unsigned long at_time, int cnt, unsigned char *
{
const char *logfile, *logdata, *logend, *rec, *lastgt, *lastrec;
char *tz_c;
- int logfd, tz;
+ int logfd, tz, reccnt = 0;
struct stat st;
unsigned long date;
unsigned char logged_sha1[20];
@@ -1031,6 +1031,7 @@ int read_ref_at(const char *ref, unsigned long at_time, int cnt, unsigned char *
lastrec = NULL;
rec = logend = logdata + st.st_size;
while (logdata < rec) {
+ reccnt++;
if (logdata < rec && *(rec-1) == '\n')
rec--;
lastgt = NULL;
@@ -1087,8 +1088,12 @@ int read_ref_at(const char *ref, unsigned long at_time, int cnt, unsigned char *
if (get_sha1_hex(logdata, sha1))
die("Log %s is corrupt.", logfile);
munmap((void*)logdata, st.st_size);
- fprintf(stderr, "warning: Log %s only goes back to %s.\n",
- logfile, show_rfc2822_date(date, tz));
+ if (at_time)
+ fprintf(stderr, "warning: Log %s only goes back to %s.\n",
+ logfile, show_rfc2822_date(date, tz));
+ else
+ fprintf(stderr, "warning: Log %s only has %d entries.\n",
+ logfile, reccnt);
return 0;
}
@@ -1116,3 +1121,4 @@ void for_each_reflog_ent(const char *ref, each_reflog_ent_fn fn, void *cb_data)
}
fclose(logfp);
}
+