Commit Diff


commit - 5c5396e5c1ee0b8ede1cce4c7262a946ab1b3970
commit + 9334723a60466be8c0bff5875128e9f02c32e5b1
blob - 68fc40572b1afa42c02409a2836ca23e2d7df464
blob + 84681e2a5ec0f41b9ea674365f6fb81fb230a356
--- regress/cmdline/diff.sh
+++ regress/cmdline/diff.sh
@@ -1783,6 +1783,37 @@ EOF
 	ret=$?
 	if [ $ret -ne 0 ]; then
 		diff -u $testroot/stdout.expected $testroot/stdout
+	fi
+	test_done "$testroot" "$ret"
+}
+
+test_diff_file_to_dir() {
+	local testroot=`test_init diff_file_to_dir`
+	local commit_id0=`git_show_head $testroot/repo`
+
+	got checkout $testroot/repo $testroot/wt > /dev/null
+	ret=$?
+	if [ $ret -ne 0 ]; then
+		test_done "$testroot" "$ret"
+		return 1
+	fi
+
+	git_rm $testroot/repo alpha
+	mkdir $testroot/repo/alpha
+	echo eta > $testroot/repo/alpha/eta
+	(cd $testroot/repo && git add alpha/eta)
+	git_commit $testroot/repo -m "changed alpha into directory"
+	local commit_id1=`git_show_head $testroot/repo`
+
+	echo "diff $commit_id0 $commit_id1" > $testroot/stdout.expected
+	echo "commit - $commit_id0" >> $testroot/stdout.expected
+	echo "commit + $commit_id1" >> $testroot/stdout.expected
+	got diff -r $testroot/repo $commit_id0 $commit_id1 > $testroot/stdout
+	# Diff should not be empty
+	cmp -s $testroot/stdout.expected $testroot/stdout
+	ret=$?
+	if [ $ret -eq 0 ]; then
+		ret="xfail file to directory"
 	fi
 	test_done "$testroot" "$ret"
 }
@@ -1803,3 +1834,4 @@ run_test test_diff_crlf
 run_test test_diff_worktree_newfile_xbit
 run_test test_diff_commit_diffstat
 run_test test_diff_worktree_diffstat
+run_test test_diff_file_to_dir