Andrew's git
/
gitweb.git
/ diff
summary
|
log
|
commit
| diff |
tree
commit
grep
author
committer
pickaxe
?
re
reflog: fix warning message.
author
Junio C Hamano
<junkio@cox.net>
Tue, 19 Dec 2006 06:07:45 +0000
(22:07 -0800)
committer
Junio C Hamano
<junkio@cox.net>
Thu, 21 Dec 2006 01:22:10 +0000
(17:22 -0800)
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>
refs.c
patch
|
blob
|
history
raw
|
patch
|
inline
| side by side (parent:
6304929
)
diff --git
a/refs.c
b/refs.c
index b67b1f011f448dcc1b604312c8e678821f9701f1..8b2a3c13784166e93e15be6f9222d26272a3b78b 100644
(file)
--- 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;
{
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];
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) {
lastrec = NULL;
rec = logend = logdata + st.st_size;
while (logdata < rec) {
+ reccnt++;
if (logdata < rec && *(rec-1) == '\n')
rec--;
lastgt = NULL;
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);
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;
}
return 0;
}
@@
-1116,3
+1121,4
@@
void for_each_reflog_ent(const char *ref, each_reflog_ent_fn fn, void *cb_data)
}
fclose(logfp);
}
}
fclose(logfp);
}
+