aboutsummaryrefslogtreecommitdiff
path: root/refs.c
diff options
context:
space:
mode:
authorJunio C Hamano <junkio@cox.net>2006-10-05 23:16:15 -0700
committerJunio C Hamano <junkio@cox.net>2006-10-05 23:17:11 -0700
commitab2a1a32ffa5a39aaf4204bd717562bce49e0a36 (patch)
tree21b6b7f63d6e74f023df5d338282b0a75df55c35 /refs.c
parent422b4a0e03658d0933a7abc149f175735ea9c4b5 (diff)
downloadgit-ab2a1a32ffa5a39aaf4204bd717562bce49e0a36.tar.gz
git-ab2a1a32ffa5a39aaf4204bd717562bce49e0a36.tar.xz
ref-log: allow ref@{count} syntax.
Often I find myself wanting to say 'tip of "next" before I merged the last three topics'. Now I can say that with: git log next@{3}..next Since small integers alone are invalid input strings to approxidate, there is no fear of confusion. Signed-off-by: Junio C Hamano <junkio@cox.net>
Diffstat (limited to 'refs.c')
-rw-r--r--refs.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/refs.c b/refs.c
index 305c1a92c..d7f4aa5d8 100644
--- a/refs.c
+++ b/refs.c
@@ -795,7 +795,7 @@ int write_ref_sha1(struct ref_lock *lock,
return 0;
}
-int read_ref_at(const char *ref, unsigned long at_time, unsigned char *sha1)
+int read_ref_at(const char *ref, unsigned long at_time, int cnt, unsigned char *sha1)
{
const char *logfile, *logdata, *logend, *rec, *lastgt, *lastrec;
char *tz_c;
@@ -828,7 +828,7 @@ int read_ref_at(const char *ref, unsigned long at_time, unsigned char *sha1)
if (!lastgt)
die("Log %s is corrupt.", logfile);
date = strtoul(lastgt + 1, &tz_c, 10);
- if (date <= at_time) {
+ if (date <= at_time || cnt == 0) {
if (lastrec) {
if (get_sha1_hex(lastrec, logged_sha1))
die("Log %s is corrupt.", logfile);
@@ -859,6 +859,8 @@ int read_ref_at(const char *ref, unsigned long at_time, unsigned char *sha1)
return 0;
}
lastrec = rec;
+ if (cnt > 0)
+ cnt--;
}
rec = logdata;