Commit Diff


commit - c8255edc87c31f45f65dcab98db4acfb9a7218dc
commit + f9a64b14696fdd28e727956bd9c47f595f32f265
blob - 4721d314c761fef6ff7f1dfe3ff55d52e6d39216
blob + 4a83ec7819b07c9e4a689fc50177a7b979abbbf9
--- regress/cmdline/log.sh
+++ regress/cmdline/log.sh
@@ -768,7 +768,61 @@ test_log_changed_paths() {
 	fi
 	test_done "$testroot" "$ret"
 }
+
+test_log_merge_commit_nonexistent_path() {
+	local testroot=`test_init log_merge_commit_corner_case 1`
 
+        # Create the following commit graph (most recent commit shown first):
+        #
+        #   o  create dir/beta
+        #   |
+        #   o  merge (does not touch dir)
+        #  / \
+        # o   o  changes which don't touch the directory "dir"
+        #  \ /
+        #   o  initial commit, which includes directory "dir" but not dir/beta
+
+
+	mkdir $testroot/repo/dir
+	touch $testroot/repo/dir/alpha
+	git -C $testroot/repo add dir/alpha
+	git_commit $testroot/repo -m "initial commit"
+
+	git -C $testroot/repo checkout -q -b aux
+	touch $testroot/repo/gamma
+	git -C $testroot/repo add gamma
+	git_commit $testroot/repo -m "change on aux"
+
+	git -C $testroot/repo checkout -q master
+	touch $testroot/repo/delta
+	git -C $testroot/repo add delta
+	git_commit $testroot/repo -m "change on master"
+
+	git -C $testroot/repo merge -q -m "merge" aux
+
+	touch $testroot/repo/dir/beta
+	git -C $testroot/repo add dir/beta
+	git_commit $testroot/repo -m "add beta"
+
+	head_commit=`git_show_head $testroot/repo`
+
+	got log -r $testroot/repo -b dir/beta | grep ^commit > $testroot/stdout
+	ret=$?
+	if [ $ret -ne 0 ]; then
+		echo "log command failed unexpectedly" >&2
+		test_done "$testroot" "1"
+		return 1
+	fi
+
+	echo "commit $head_commit (master)" > $testroot/stdout.expected
+	cmp -s $testroot/stdout.expected $testroot/stdout
+	ret=$?
+	if [ $ret -ne 0 ]; then
+		diff -u $testroot/stdout.expected $testroot/stdout
+	fi
+	test_done "$testroot" "$ret"
+}
+
 test_log_submodule() {
 	local testroot=`test_init log_submodule`
 
@@ -1201,6 +1255,7 @@ run_test test_log_end_at_commit
 run_test test_log_reverse_display
 run_test test_log_in_worktree_different_repo
 run_test test_log_changed_paths
+run_test test_log_merge_commit_nonexistent_path
 run_test test_log_submodule
 run_test test_log_diffstat
 run_test test_log_commit_keywords