Skip to content

Commit

Permalink
reflog: fix warning message.
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Junio C Hamano committed Dec 21, 2006
1 parent 6304929 commit e29cb53
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions refs.c
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand All @@ -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;
Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -1116,3 +1121,4 @@ void for_each_reflog_ent(const char *ref, each_reflog_ent_fn fn, void *cb_data)
}
fclose(logfp);
}

0 comments on commit e29cb53

Please sign in to comment.