Skip to content

Commit acf23a1

Browse files
committed
Merge branch 'jc/diff-tree-stdin-fix' into next
"diff-tree --stdin" has been broken for about a year, but 2.36 release broke it even worse by breaking running the command with <pathspec>, which in turn broke "gitk" and got noticed. This has been corrected by aligning its behaviour to that of "log". * jc/diff-tree-stdin-fix: 2.36 gitk/diff-tree --stdin regression fix
2 parents 673a597 + f8781bf commit acf23a1

File tree

3 files changed

+18
-0
lines changed

3 files changed

+18
-0
lines changed

builtin/diff-tree.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,7 @@ int cmd_diff_tree(int argc, const char **argv, const char *prefix)
195195
int saved_dcctc = 0;
196196

197197
opt->diffopt.rotate_to_strict = 0;
198+
opt->diffopt.no_free = 1;
198199
if (opt->diffopt.detect_rename) {
199200
if (!the_index.cache)
200201
repo_read_index(the_repository);
@@ -217,6 +218,8 @@ int cmd_diff_tree(int argc, const char **argv, const char *prefix)
217218
}
218219
opt->diffopt.degraded_cc_to_c = saved_dcctc;
219220
opt->diffopt.needed_rename_limit = saved_nrl;
221+
opt->diffopt.no_free = 0;
222+
diff_free(&opt->diffopt);
220223
}
221224

222225
return diff_result_code(&opt->diffopt, 0);

log-tree.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1098,6 +1098,7 @@ int log_tree_commit(struct rev_info *opt, struct commit *commit)
10981098
opt->loginfo = &log;
10991099
opt->diffopt.no_free = 1;
11001100

1101+
/* NEEDSWORK: no restoring of no_free? Why? */
11011102
if (opt->line_level_traverse)
11021103
return line_log_print(opt, commit);
11031104

t/t4013-diff-various.sh

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -542,6 +542,20 @@ test_expect_success 'diff-tree --stdin with log formatting' '
542542
test_cmp expect actual
543543
'
544544

545+
test_expect_success 'diff-tree --stdin with pathspec' '
546+
cat >expect <<-EOF &&
547+
Third
548+
549+
dir/sub
550+
Second
551+
552+
dir/sub
553+
EOF
554+
git rev-list master^ |
555+
git diff-tree -r --stdin --name-only --format=%s dir >actual &&
556+
test_cmp expect actual
557+
'
558+
545559
test_expect_success 'diff -I<regex>: setup' '
546560
git checkout master &&
547561
test_seq 50 >file0 &&

0 commit comments

Comments
 (0)