Fix --walk-reflog with --pretty=oneline
Now, "git log --abbrev-commit --pretty=o --walk-reflogs HEAD" is reasonably pleasant to use. Signed-off-by: Junio C Hamano <junkio@cox.net>
Junio C Hamano committed
Jan 20, 2007 at 00:51 UTC
4d12a471230625da73be464f5a20b7480a6b8ecb
4 files changed
+28
-14
Documentation/git-rev-list.txt
+3
-1
@@ -27,6 +27,7 @@ SYNOPSIS
27
[ \--pretty | \--header ]
28
[ \--bisect ]
29
[ \--merge ]
30
+ [ \--walk-reflogs ]
31
<commit>... [ \-- <paths>... ]
32
33
DESCRIPTION
@@ -203,7 +204,8 @@ this causes the output to have two extra lines of information
204
taken from the reflog. By default, 'commit@{Nth}' notation is
205
used in the output. When the starting commit is specified as
206
'commit@{now}', output also uses 'commit@{timestamp}' notation
206
-instead.
207
+instead. Under '\--pretty=oneline', the commit message is
208
+prefixed with this information on the same line.
209
210
--merge::
211
log-tree.c
+2
-1
@@ -225,7 +225,8 @@ void show_log(struct rev_info *opt, const char *sep)
225
diff_get_color(opt->diffopt.color_diff, DIFF_RESET));
226
putchar(opt->commit_format == CMIT_FMT_ONELINE ? ' ' : '\n');
227
if (opt->reflog_info)
228
- show_reflog_message(opt->reflog_info);
228
+ show_reflog_message(opt->reflog_info,
229
+ opt->commit_format == CMIT_FMT_ONELINE);;
230
}
231
232
/*
reflog-walk.c
+22
-11
@@ -219,21 +219,32 @@ void fake_reflog_parent(struct reflog_walk_info *info, struct commit *commit)
219
commit->object.flags &= ~(ADDED | SEEN | SHOWN);
220
}
221
222
-void show_reflog_message(struct reflog_walk_info* info)
222
+void show_reflog_message(struct reflog_walk_info* info, int oneline)
223
{
224
if (info && info->last_commit_reflog) {
225
struct commit_reflog *commit_reflog = info->last_commit_reflog;
226
struct reflog_info *info;
227
228
- printf("Reflog: %s@{", commit_reflog->reflogs->ref);
229
- info = &commit_reflog->reflogs->items[commit_reflog->recno + 1];
230
- if (commit_reflog->flag)
231
- printf("%s", show_rfc2822_date(info->timestamp,
232
- info->tz));
233
- else
234
- printf("%d", commit_reflog->reflogs->nr
235
- - 2 - commit_reflog->recno);
236
- printf("} (%s)\nReflog message: %s",
237
- info->email, info->message);
228
+ info = &commit_reflog->reflogs->items[commit_reflog->recno+1];
229
+ if (oneline) {
230
+ printf("%s@{", commit_reflog->reflogs->ref);
231
+ if (commit_reflog->flag)
232
+ printf("%s", show_date(info->timestamp, 0, 1));
233
+ else
234
+ printf("%d", commit_reflog->reflogs->nr
235
+ - 2 - commit_reflog->recno);
236
+ printf("}: ");
237
+ }
238
+ else {
239
+ printf("Reflog: %s@{", commit_reflog->reflogs->ref);
240
+ if (commit_reflog->flag)
241
+ printf("%s", show_rfc2822_date(info->timestamp,
242
+ info->tz));
243
+ else
244
+ printf("%d", commit_reflog->reflogs->nr
245
+ - 2 - commit_reflog->recno);
246
+ printf("} (%s)\nReflog message: %s",
247
+ info->email, info->message);
248
+ }
249
}
250
}
reflog-walk.h
+1
-1
@@ -6,6 +6,6 @@ extern void add_reflog_for_walk(struct reflog_walk_info *info,
6
struct commit *commit, const char *name);
7
extern void fake_reflog_parent(struct reflog_walk_info *info,
8
struct commit *commit);
9
-extern void show_reflog_message(struct reflog_walk_info* info);
9
+extern void show_reflog_message(struct reflog_walk_info *info, int);
10
11
#endif