Skip to content

Commit d5518d5

Browse files
committed
Merge branch 'tc/last-modified-recursive-fix'
"git last-modified" operating in non-recursive mode used to trigger a BUG(), which has been corrected. * tc/last-modified-recursive-fix: last-modified: fix bug when some paths remain unhandled
2 parents 96ed0a8 + e6c06e8 commit d5518d5

File tree

4 files changed

+26
-1
lines changed

4 files changed

+26
-1
lines changed

builtin/last-modified.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,7 @@ static int last_modified_init(struct last_modified *lm, struct repository *r,
265265
lm->rev.boundary = 1;
266266
lm->rev.no_commit_id = 1;
267267
lm->rev.diff = 1;
268+
lm->rev.diffopt.flags.no_recursive_diff_tree_combined = 1;
268269
lm->rev.diffopt.flags.recursive = lm->recursive;
269270
lm->rev.diffopt.flags.tree_in_recursive = lm->show_trees;
270271

combine-diff.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1515,8 +1515,9 @@ void diff_tree_combined(const struct object_id *oid,
15151515

15161516
diffopts = *opt;
15171517
copy_pathspec(&diffopts.pathspec, &opt->pathspec);
1518-
diffopts.flags.recursive = 1;
15191518
diffopts.flags.allow_external = 0;
1519+
if (!opt->flags.no_recursive_diff_tree_combined)
1520+
diffopts.flags.recursive = 1;
15201521

15211522
/* find set of paths that everybody touches
15221523
*

diff.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,13 @@ struct diff_flags {
127127
unsigned recursive;
128128
unsigned tree_in_recursive;
129129

130+
/*
131+
* Historically diff_tree_combined() overrides recursive to 1. To
132+
* suppress this behavior, set the flag below.
133+
* It has no effect if recursive is already set to 1.
134+
*/
135+
unsigned no_recursive_diff_tree_combined;
136+
130137
/* Affects the way how a file that is seemingly binary is treated. */
131138
unsigned binary;
132139
unsigned text;

t/t8020-last-modified.sh

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,22 @@ test_expect_success 'only last-modified files in the current tree' '
128128
EOF
129129
'
130130

131+
test_expect_success 'last-modified with subdir and criss-cross merge' '
132+
git checkout -b branch-k1 1 &&
133+
mkdir -p a k &&
134+
test_commit k1 a/file2 &&
135+
git checkout -b branch-k2 &&
136+
test_commit k2 k/file2 &&
137+
git checkout branch-k1 &&
138+
test_merge km2 branch-k2 &&
139+
test_merge km3 3 &&
140+
check_last_modified <<-\EOF
141+
km3 a
142+
k2 k
143+
1 file
144+
EOF
145+
'
146+
131147
test_expect_success 'cross merge boundaries in blaming' '
132148
git checkout HEAD^0 &&
133149
git rm -rf . &&

0 commit comments

Comments
 (0)