commit - 8f8646e5e92d5fc7ecc97732100e239380ac5de9
commit + e0233ceaa769843b74b877040ce8d8446283a403
blob - b41a123079e68a9fd5ae7da2768b794c15d69403
blob + e97e4a41f6e33058d7fa59cafff72d23268115a3
--- lib/worktree.c
+++ lib/worktree.c
*match = 0;
- if (strchr(ct->path, '/') == NULL) {
+ if (strchr(ct->in_repo_path, '/') == NULL) {
*match = got_path_is_root_dir(path);
return NULL;
}
- err = got_path_dirname(&ct_parent_path, ct->path);
+ err = got_path_dirname(&ct_parent_path, ct->in_repo_path);
if (err)
return err;
*match = (strcmp(path, ct_parent_path) == 0);
blob - fa62e4aace284747229f3636273843d3bf884f9a
blob + 4cb5ebe8d9b79632a89a80262c7cc8f7585ad5cb
--- regress/cmdline/commit.sh
+++ regress/cmdline/commit.sh
echo "A epsilon/new" > $testroot/stdout.expected
echo "M epsilon/zeta" >> $testroot/stdout.expected
echo "Created commit $head_rev" >> $testroot/stdout.expected
+
+ cmp -s $testroot/stdout.expected $testroot/stdout
+ ret="$?"
+ if [ "$ret" != "0" ]; then
+ diff -u $testroot/stdout.expected $testroot/stdout
+ fi
+ test_done "$testroot" "$ret"
+}
+
+function test_commit_path_prefix {
+ local testroot=`test_init commit_path_prefix`
+ local commit1=`git_show_head $testroot/repo`
+
+ got checkout -p gamma $testroot/repo $testroot/wt > /dev/null
+ ret="$?"
+ if [ "$ret" != "0" ]; then
+ test_done "$testroot" "$ret"
+ return 1
+ fi
+
+ echo "modified delta" > $testroot/wt/delta
+
+ (cd $testroot/wt && got commit -m 'changed gamma/delta' > $testroot/stdout)
+
+ local commit2=`git_show_head $testroot/repo`
+ echo "M delta" > $testroot/stdout.expected
+ echo "Created commit $commit2" >> $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 $commit1 $commit2" > $testroot/stdout.expected
+ echo -n 'blob - ' >> $testroot/stdout.expected
+ got tree -r $testroot/repo -c $commit1 -i gamma | grep 'delta$' \
+ | cut -d' ' -f 1 >> $testroot/stdout.expected
+ echo -n 'blob + ' >> $testroot/stdout.expected
+ got tree -r $testroot/repo -c $commit2 -i gamma | grep 'delta$' | \
+ cut -d' ' -f 1 >> $testroot/stdout.expected
+ echo '--- gamma/delta' >> $testroot/stdout.expected
+ echo '+++ gamma/delta' >> $testroot/stdout.expected
+ echo '@@ -1 +1 @@' >> $testroot/stdout.expected
+ echo '-delta' >> $testroot/stdout.expected
+ 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
+ fi
test_done "$testroot" "$ret"
}
run_test test_commit_rejects_conflicted_file
run_test test_commit_single_file_multiple
run_test test_commit_added_and_modified_in_same_dir
+run_test test_commit_path_prefix