git log [diff-tree options]...
And this makes "git log" to take common diff-tree options, so that it can be used as "git whatchanged". The recent revision walker updates by Linus to make path limiting low-latency helps this quite a bit. Signed-off-by: Junio C Hamano <junkio@cox.net>
Junio C Hamano committed
Apr 9, 2006 at 01:59 UTC
52b70d56bd23811003a72866cc23a0a44b9da1b7
1 file changed
+31
-1
git.c
+31
-1
@@ -16,6 +16,8 @@
16
#include "cache.h"
17
#include "commit.h"
18
#include "revision.h"
19
+#include "diff.h"
20
+#include "log-tree.h"
21
22
#ifndef PATH_MAX
23
# define PATH_MAX 4096
@@ -285,7 +287,10 @@ static int cmd_log(int argc, const char **argv, char **envp)
287
int abbrev = DEFAULT_ABBREV;
288
int abbrev_commit = 0;
289
const char *commit_prefix = "commit ";
290
+ struct log_tree_opt opt;
291
+ int do_diff = 0;
292
293
+ init_log_tree_opt(&opt);
294
argc = setup_revisions(argc, argv, &rev, "HEAD");
295
while (1 < argc) {
296
const char *arg = argv[1];
@@ -310,10 +315,32 @@ static int cmd_log(int argc, const char **argv, char **envp)
315
else if (40 < abbrev)
316
abbrev = 40;
317
}
313
- else
318
+ else {
319
+ int cnt = log_tree_opt_parse(&opt, argv+1, argc-1);
320
+ if (0 < cnt) {
321
+ do_diff = 1;
322
+ argv += cnt;
323
+ argc -= cnt;
324
+ continue;
325
+ }
326
die("unrecognized argument: %s", arg);
327
+ }
328
+
329
argc--; argv++;
330
}
331
+ if (do_diff) {
332
+ opt.diffopt.abbrev = abbrev;
333
+ opt.verbose_header = 0;
334
+ opt.always_show_header = 0;
335
+ opt.no_commit_id = 1;
336
+ if (opt.combine_merges)
337
+ opt.ignore_merges = 0;
338
+ if (opt.dense_combined_merges)
339
+ opt.diffopt.output_format = DIFF_FORMAT_PATCH;
340
+ if (opt.diffopt.output_format == DIFF_FORMAT_PATCH)
341
+ opt.diffopt.recursive = 1;
342
+ diff_setup_done(&opt.diffopt);
343
+ }
344
345
prepare_revision_walk(&rev);
346
setup_pager();
@@ -350,6 +377,9 @@ static int cmd_log(int argc, const char **argv, char **envp)
377
pretty_print_commit(commit_format, commit, ~0, buf,
378
LOGSIZE, abbrev);
379
printf("%s\n", buf);
380
+
381
+ if (do_diff)
382
+ log_tree_commit(&opt, commit);
383
}
384
free(buf);
385
return 0;