summaryrefslogtreecommitdiff
path: root/refs.c
diff options
context:
space:
mode:
authorJunio C Hamano <junkio@cox.net>2007-01-19 01:20:23 -0800
committerJunio C Hamano <junkio@cox.net>2007-01-19 17:57:53 -0800
commit76a44c5c0b25b1dbde56d17353d5b0821b7c6981 (patch)
tree80c2458f63293c767a1a830cf9a77f55336b899b /refs.c
parent16d7cc90dd6e68a170362ae6f0fbfbc504fd246b (diff)
downloadgit-76a44c5c0b25b1dbde56d17353d5b0821b7c6981.tar.gz
show-branch --reflog: show the reflog message at the top.
This changes the output so the list at the top shows the reflog message, along with their relative timestamps. You can use --reflog=<n> to show <n> most recent log entries, or use --reflog=<n>,<b> to show <n> entries going back from the entry <b>. <b> can be either a number (so --reflog=4,20 shows 4 records starting from @{20}) or a timestamp (e.g. --reflog='4,1 day'). Here is a sample output (with --list option): $ git show-branch --reflog=10 --list jc/show-reflog [jc/show-reflog@{0}] (3 minutes ago) commit (amend): show-branch --ref [jc/show-reflog@{1}] (5 minutes ago) reset HEAD^ [jc/show-reflog@{2}] (14 minutes ago) commit: show-branch --reflog: sho [jc/show-reflog@{3}] (14 minutes ago) commit: show-branch --reflog: sho [jc/show-reflog@{4}] (18 minutes ago) commit (amend): Extend read_ref_a [jc/show-reflog@{5}] (18 minutes ago) commit (amend): Extend read_ref_a [jc/show-reflog@{6}] (18 minutes ago) commit (amend): Extend read_ref_a [jc/show-reflog@{7}] (18 minutes ago) am: read_ref_at(): allow retrievi [jc/show-reflog@{8}] (18 minutes ago) reset --hard HEAD~4 [jc/show-reflog@{9}] (61 minutes ago) commit: show-branch --reflog: use This shows what I did more cleanly: $ git show-branch --reflog=10 jc/show-reflog ! [jc/show-reflog@{0}] (3 minutes ago) commit (amend): show-branch --ref ! [jc/show-reflog@{1}] (5 minutes ago) reset HEAD^ ! [jc/show-reflog@{2}] (14 minutes ago) commit: show-branch --reflog: ! [jc/show-reflog@{3}] (14 minutes ago) commit: show-branch --reflog: ! [jc/show-reflog@{4}] (18 minutes ago) commit (amend): Extend read_ ! [jc/show-reflog@{5}] (18 minutes ago) commit (amend): Extend read ! [jc/show-reflog@{6}] (18 minutes ago) commit (amend): Extend rea ! [jc/show-reflog@{7}] (18 minutes ago) am: read_ref_at(): allow ! [jc/show-reflog@{8}] (18 minutes ago) reset --hard HEAD~4 ! [jc/show-reflog@{9}] (61 minutes ago) commit: show-branch --r ---------- + [jc/show-reflog@{0}] show-branch --reflog: show the reflog + [jc/show-reflog@{2}] show-branch --reflog: show the reflog +++ [jc/show-reflog@{1}] show-branch --reflog: show the reflog +++++ [jc/show-reflog@{4}] Extend read_ref_at() to be usable fro + [jc/show-reflog@{5}] Extend read_ref_at() to be usable fro + [jc/show-reflog@{6}] Extend read_ref_at() to be usable fro + [jc/show-reflog@{7}] read_ref_at(): allow retrieving the r + [jc/show-reflog@{9}] show-branch --reflog: use updated rea + [jc/show-reflog@{9}^] read_ref_at(): allow reporting the c + [jc/show-reflog@{9}~2] show-branch --reflog: show the refl + [jc/show-reflog@{9}~3] read_ref_at(): allow retrieving the ++++++++++ [jc/show-reflog@{8}] dwim_ref(): Separate name-to-ref DWIM At @{9}, I had a commit to complete 5 patch series, but I wanted to consolidate two commits that enhances read_ref_at() into one (they were @{9}^ and @{9}~3), and another two that touch show-branch into one (@{9} and @{9}~2). I first saved them with "format-patch -4", and then did a reset at @{8}. At @{7}, I applied one of them with "am", and then used "git-apply" on the other one, and amended the commit at @{6} (so @{6} and @{7} has the same parent). I did not like the log message, so I amended again at @{5}. Then I cherry-picked @{9}~2 to create @{3} (the log message shows that it needs to learn to set GIT_REFLOG_ACTION -- it uses "git-commit" and the log entry is attributed for it). Another cherry-pick built @{2} out of @{9}, but what I wanted to do was to squash these two into one, so I did a "reset HEAD^" at @{1} and then made the final commit by amending what was at the top. Signed-off-by: Junio C Hamano <junkio@cox.net>
Diffstat (limited to 'refs.c')
-rw-r--r--refs.c5
1 files changed, 2 insertions, 3 deletions
diff --git a/refs.c b/refs.c
index 60375a786f..81173282fc 100644
--- a/refs.c
+++ b/refs.c
@@ -1068,6 +1068,7 @@ int read_ref_at(const char *ref, unsigned long at_time, int cnt, unsigned char *
die("Log %s is corrupt.", logfile);
date = strtoul(lastgt + 1, &tz_c, 10);
if (date <= at_time || cnt == 0) {
+ tz = strtoul(tz_c, NULL, 10);
if (msg)
*msg = ref_msg(rec, logend);
if (cutoff_time)
@@ -1075,14 +1076,13 @@ int read_ref_at(const char *ref, unsigned long at_time, int cnt, unsigned char *
if (cutoff_tz)
*cutoff_tz = tz;
if (cutoff_cnt)
- *cutoff_cnt = reccnt;
+ *cutoff_cnt = reccnt - 1;
if (lastrec) {
if (get_sha1_hex(lastrec, logged_sha1))
die("Log %s is corrupt.", logfile);
if (get_sha1_hex(rec + 41, sha1))
die("Log %s is corrupt.", logfile);
if (hashcmp(logged_sha1, sha1)) {
- tz = strtoul(tz_c, NULL, 10);
fprintf(stderr,
"warning: Log %s has gap after %s.\n",
logfile, show_rfc2822_date(date, tz));
@@ -1096,7 +1096,6 @@ int read_ref_at(const char *ref, unsigned long at_time, int cnt, unsigned char *
if (get_sha1_hex(rec + 41, logged_sha1))
die("Log %s is corrupt.", logfile);
if (hashcmp(logged_sha1, sha1)) {
- tz = strtoul(tz_c, NULL, 10);
fprintf(stderr,
"warning: Log %s unexpectedly ended on %s.\n",
logfile, show_rfc2822_date(date, tz));