Commit Diff


commit - 69d57f3de25cfb3fd0cbfef22bd20090b36cee5e
commit + f2b0a8b0a1881cbc7388392deaa518caf38be151
blob - d3a3569afd8e1161702e6fba6e579b31db71ff2a
blob + 68b5face374018032f08f3badf8b7728e33e799d
--- lib/worktree.c
+++ lib/worktree.c
@@ -5004,12 +5004,12 @@ write_tree(struct got_object_id **new_tree_id, int *ne
 		    (ct->flags & GOT_COMMITABLE_ADDED))
 			continue;
 
-		 if (!got_path_is_child(pe->path, path_base_tree,
+		 if (!got_path_is_child(ct->in_repo_path, path_base_tree,
 		     strlen(path_base_tree)))
 			continue;
 
 		err = got_path_skip_common_ancestor(&child_path, path_base_tree,
-		    pe->path);
+		    ct->in_repo_path);
 		if (err)
 			goto done;
 
blob - b877e38e53b5003239de90bd1bd31223db2fd177
blob + 5e1cf69b0f453b136cd17913c1199ce2641b47d8
--- regress/cmdline/commit.sh
+++ regress/cmdline/commit.sh
@@ -440,12 +440,62 @@ function test_commit_path_prefix {
 	echo '+modified delta' >> $testroot/stdout.expected
 
 	got diff -r $testroot/repo $commit1 $commit2 > $testroot/stdout
+	cmp -s $testroot/stdout.expected $testroot/stdout
+	ret="$?"
+	if [ "$ret" != "0" ]; then
+		diff -u $testroot/stdout.expected $testroot/stdout
+		test_done "$testroot" "$ret"
+		return 1
+	fi
+
+	(cd $testroot/wt && got rm delta > /dev/null)
+	echo new > $testroot/wt/new
+	(cd $testroot/wt && got add new > /dev/null)
+
+	(cd $testroot/wt && got commit -m 'remove gamma/delta; add gamma/new' \
+		> $testroot/stdout)
+
+	local commit3=`git_show_head $testroot/repo`
+	echo "A  new" > $testroot/stdout.expected
+	echo "D  delta" >> $testroot/stdout.expected
+	echo "Created commit $commit3" >> $testroot/stdout.expected
+
+	cmp -s $testroot/stdout.expected $testroot/stdout
+	ret="$?"
+	if [ "$ret" != "0" ]; then
+		diff -u $testroot/stdout.expected $testroot/stdout
+		test_done "$testroot" "$ret"
+		return 1
+	fi
+
+	echo "diff $commit2 $commit3" > $testroot/stdout.expected
+	echo -n 'blob - ' >> $testroot/stdout.expected
+	got tree -r $testroot/repo -c $commit2 -i gamma | grep 'delta$' \
+		| cut -d' ' -f 1 | sed -e 's/$/ (mode 644)/' \
+		>> $testroot/stdout.expected
+	echo 'blob + /dev/null' >> $testroot/stdout.expected
+	echo '--- gamma/delta' >> $testroot/stdout.expected
+	echo '+++ /dev/null' >> $testroot/stdout.expected
+	echo '@@ -1 +0,0 @@' >> $testroot/stdout.expected
+	echo '-modified delta' >> $testroot/stdout.expected
+	echo 'blob - /dev/null' >> $testroot/stdout.expected
+	echo -n 'blob + ' >> $testroot/stdout.expected
+	got tree -r $testroot/repo -c $commit3 -i gamma | grep 'new$' | \
+		cut -d' ' -f 1 | sed -e 's/$/ (mode 644)/' \
+		>> $testroot/stdout.expected
+	echo '--- /dev/null' >> $testroot/stdout.expected
+	echo '+++ gamma/new' >> $testroot/stdout.expected
+	echo '@@ -0,0 +1 @@' >> $testroot/stdout.expected
+	echo '+new' >> $testroot/stdout.expected
+
+	got diff -r $testroot/repo $commit2 $commit3 > $testroot/stdout
 	cmp -s $testroot/stdout.expected $testroot/stdout
 	ret="$?"
 	if [ "$ret" != "0" ]; then
 		diff -u $testroot/stdout.expected $testroot/stdout
 	fi
 	test_done "$testroot" "$ret"
+	return "$ret"
 }
 
 function test_commit_dir_path {