@matheusbsbs / matheus-bagliano / commits / 477f2b4131
Fork 0

git log --full-diff

Without this flag, "git log -p paths..." shows commits that touch the specified paths, and diffs about the same specified paths. With this, the full diff is shown for commits that touch the specified paths. Signed-off-by: Junio C Hamano <junkio@cox.net>

Junio C Hamano committed Apr 10, 2006 at 16:40 UTC 477f2b41310c4b1040a9e7f72720b9c39d82caf9
1 file changed +12 -1
git.c
+12 -1
@@ -288,7 +288,9 @@ static int cmd_log(int argc, const char **argv, char **envp)
288 int abbrev_commit = 0;
289 const char *commit_prefix = "commit ";
290 struct log_tree_opt opt;
291 + int shown = 0;
292 int do_diff = 0;
293 + int full_diff = 0;
294
295 init_log_tree_opt(&opt);
296 argc = setup_revisions(argc, argv, &rev, "HEAD");
@@ -315,6 +317,10 @@ static int cmd_log(int argc, const char **argv, char **envp)
317 else if (40 < abbrev)
318 abbrev = 40;
319 }
320 + else if (!strcmp(arg, "--full-diff")) {
321 + do_diff = 1;
322 + full_diff = 1;
323 + }
324 else {
325 int cnt = log_tree_opt_parse(&opt, argv+1, argc-1);
326 if (0 < cnt) {
@@ -328,6 +334,7 @@ static int cmd_log(int argc, const char **argv, char **envp)
334
335 argc--; argv++;
336 }
337 +
338 if (do_diff) {
339 opt.diffopt.abbrev = abbrev;
340 opt.verbose_header = 0;
@@ -339,12 +346,16 @@ static int cmd_log(int argc, const char **argv, char **envp)
346 opt.diffopt.output_format = DIFF_FORMAT_PATCH;
347 if (opt.diffopt.output_format == DIFF_FORMAT_PATCH)
348 opt.diffopt.recursive = 1;
349 + if (!full_diff && rev.prune_data)
350 + diff_tree_setup_paths(rev.prune_data, &opt.diffopt);
351 diff_setup_done(&opt.diffopt);
352 }
353
354 prepare_revision_walk(&rev);
355 setup_pager();
356 while ((commit = get_revision(&rev)) != NULL) {
357 + if (commit_format != CMIT_FMT_ONELINE && shown)
358 + putchar('\n');
359 fputs(commit_prefix, stdout);
360 if (abbrev_commit && abbrev)
361 fputs(find_unique_abbrev(commit->object.sha1, abbrev),
@@ -377,9 +388,9 @@ static int cmd_log(int argc, const char **argv, char **envp)
388 pretty_print_commit(commit_format, commit, ~0, buf,
389 LOGSIZE, abbrev);
390 printf("%s\n", buf);
380 -
391 if (do_diff)
392 log_tree_commit(&opt, commit);
393 + shown = 1;
394 }
395 free(buf);
396 return 0;