Skip to content

Commit 477f2b4

Browse files
author
Junio C Hamano
committed
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>
1 parent a8baa7b commit 477f2b4

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

git.c

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,9 @@ static int cmd_log(int argc, const char **argv, char **envp)
288288
int abbrev_commit = 0;
289289
const char *commit_prefix = "commit ";
290290
struct log_tree_opt opt;
291+
int shown = 0;
291292
int do_diff = 0;
293+
int full_diff = 0;
292294

293295
init_log_tree_opt(&opt);
294296
argc = setup_revisions(argc, argv, &rev, "HEAD");
@@ -315,6 +317,10 @@ static int cmd_log(int argc, const char **argv, char **envp)
315317
else if (40 < abbrev)
316318
abbrev = 40;
317319
}
320+
else if (!strcmp(arg, "--full-diff")) {
321+
do_diff = 1;
322+
full_diff = 1;
323+
}
318324
else {
319325
int cnt = log_tree_opt_parse(&opt, argv+1, argc-1);
320326
if (0 < cnt) {
@@ -328,6 +334,7 @@ static int cmd_log(int argc, const char **argv, char **envp)
328334

329335
argc--; argv++;
330336
}
337+
331338
if (do_diff) {
332339
opt.diffopt.abbrev = abbrev;
333340
opt.verbose_header = 0;
@@ -339,12 +346,16 @@ static int cmd_log(int argc, const char **argv, char **envp)
339346
opt.diffopt.output_format = DIFF_FORMAT_PATCH;
340347
if (opt.diffopt.output_format == DIFF_FORMAT_PATCH)
341348
opt.diffopt.recursive = 1;
349+
if (!full_diff && rev.prune_data)
350+
diff_tree_setup_paths(rev.prune_data, &opt.diffopt);
342351
diff_setup_done(&opt.diffopt);
343352
}
344353

345354
prepare_revision_walk(&rev);
346355
setup_pager();
347356
while ((commit = get_revision(&rev)) != NULL) {
357+
if (commit_format != CMIT_FMT_ONELINE && shown)
358+
putchar('\n');
348359
fputs(commit_prefix, stdout);
349360
if (abbrev_commit && abbrev)
350361
fputs(find_unique_abbrev(commit->object.sha1, abbrev),
@@ -377,9 +388,9 @@ static int cmd_log(int argc, const char **argv, char **envp)
377388
pretty_print_commit(commit_format, commit, ~0, buf,
378389
LOGSIZE, abbrev);
379390
printf("%s\n", buf);
380-
381391
if (do_diff)
382392
log_tree_commit(&opt, commit);
393+
shown = 1;
383394
}
384395
free(buf);
385396
return 0;

0 commit comments

Comments
 (0)