aboutsummaryrefslogtreecommitdiffstats
path: root/t/t8020-last-modified.sh
diff options
context:
space:
mode:
authorToon Claes <toon@iotcl.com>2025-09-18 10:00:08 +0200
committerJunio C Hamano <gitster@pobox.com>2025-09-18 08:00:41 -0700
commite6c06e87a255995d2e7ead2b8e49e46e29a724fb (patch)
treed98350747cdc7bb2a1beab7c2f73909215cd8250 /t/t8020-last-modified.sh
parent215033b3ac599432a17d58f18a92b356d98354a9 (diff)
downloadgit-e6c06e87a255995d2e7ead2b8e49e46e29a724fb.tar.gz
last-modified: fix bug when some paths remain unhandled
The recently introduced new subcommand git-last-modified(1) runs into an error in some scenarios. It then would exit with the message: BUG: paths remaining beyond boundary in last-modified This seems to happens for example when criss-cross merges are involved. In that scenario, the function diff_tree_combined() gets called. The function diff_tree_combined() copies the `struct diff_options` from the input `struct rev_info` to override some flags. One flag is `recursive`, which is always set to 1. This has been the case since the inception of this function in af3feefa1d (diff-tree -c: show a merge commit a bit more sensibly., 2006-01-24). This behavior is incompatible with git-last-modified(1), when called non-recursive (which is the default). The last-modified machinery uses a hashmap for all the paths it wants to get the last-modified commit for. Through log_tree_commit() the callback mark_path() is called. The diff machinery uses diff_tree_combined() internally, and due to it's recursive behavior the callback receives entries inside subtrees, but not the subtree entries themselves. So a directory is never expelled from the hashmap, and the BUG() statement gets hit. Because there are many callers calling into diff_tree_combined(), both directly and indirectly, we cannot simply change it's behavior. Instead, add a flag `no_recursive_diff_tree_combined` which supresses the behavior of diff_tree_combined() to override `recursive` and set this flag in builtin/last-modified.c. Signed-off-by: Toon Claes <toon@iotcl.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/t8020-last-modified.sh')
-rwxr-xr-xt/t8020-last-modified.sh16
1 files changed, 16 insertions, 0 deletions
diff --git a/t/t8020-last-modified.sh b/t/t8020-last-modified.sh
index 5eb4cef035..e13aad1439 100755
--- a/t/t8020-last-modified.sh
+++ b/t/t8020-last-modified.sh
@@ -128,6 +128,22 @@ test_expect_success 'only last-modified files in the current tree' '
EOF
'
+test_expect_success 'last-modified with subdir and criss-cross merge' '
+ git checkout -b branch-k1 1 &&
+ mkdir -p a k &&
+ test_commit k1 a/file2 &&
+ git checkout -b branch-k2 &&
+ test_commit k2 k/file2 &&
+ git checkout branch-k1 &&
+ test_merge km2 branch-k2 &&
+ test_merge km3 3 &&
+ check_last_modified <<-\EOF
+ km3 a
+ k2 k
+ 1 file
+ EOF
+'
+
test_expect_success 'cross merge boundaries in blaming' '
git checkout HEAD^0 &&
git rm -rf . &&