commit - b66cd6f325e3fa7ddd17ff6dd41cf6e59d04ebf5
commit + 69d57f3de25cfb3fd0cbfef22bd20090b36cee5e
blob - 61cc47cf16c65800bfc0db8525b875e9f2878054
blob + d3a3569afd8e1161702e6fba6e579b31db71ff2a
--- lib/worktree.c
+++ lib/worktree.c
char *label_orig = NULL;
if (commit_id1) {
- char *id_str;
-
err = got_object_id_by_path(&tree_id1, repo, commit_id1,
worktree->path_prefix);
- if (err)
+ if (err && err->code != GOT_ERR_NO_TREE_ENTRY)
goto done;
+ }
+ if (tree_id1) {
+ char *id_str;
err = got_object_open_as_tree(&tree1, repo, tree_id1);
if (err)
blob - cb7dd89554f0b55182721b03135d3a63add638f9
blob + 95862835bab2b3bd688acdbf129886876cf210ec
--- regress/cmdline/cherrypick.sh
+++ regress/cmdline/cherrypick.sh
fi
test_done "$testroot" "0"
+}
+
+function test_cherrypick_with_path_prefix_and_empty_tree {
+ local testroot=`test_init cherrypick_with_path_prefix_and_empty_tree 1`
+
+ (cd $testroot/repo && git commit --allow-empty \
+ -m "initial empty commit" >/dev/null)
+
+ (cd $testroot/repo && got br bar >/dev/null)
+
+ mkdir -p $testroot/repo/epsilon
+ echo "file foo" > $testroot/repo/epsilon/foo
+ (cd $testroot/repo && git add .)
+ git_commit $testroot/repo -m "add file foo"
+ local commit_id=`git_show_head $testroot/repo`
+
+ got checkout -b bar $testroot/repo $testroot/wt > /dev/null
+ ret="$?"
+ if [ "$ret" != "0" ]; then
+ echo "got checkout failed unexpectedly" >&2
+ test_done "$testroot" "$ret"
+ return 1
+ fi
+
+ mkdir -p $testroot/wt/epsilon
+ echo "new file" > $testroot/wt/epsilon/new
+ (cd $testroot/wt && got add epsilon/new >/dev/null)
+ (cd $testroot/wt && got commit -m "add file on branch bar" > /dev/null)
+
+ got checkout -b bar -p epsilon $testroot/repo $testroot/wt2 > /dev/null
+ ret="$?"
+ if [ "$ret" != "0" ]; then
+ echo "got checkout failed unexpectedly" >&2
+ test_done "$testroot" "$ret"
+ return 1
+ fi
+ (cd $testroot/wt2 && got cherrypick $commit_id > $testroot/stdout)
+
+ echo "A foo" > $testroot/stdout.expected
+ echo "Merged commit $commit_id" >> $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"
}
run_test test_cherrypick_basic
run_test test_cherrypick_conflict_wt_file_vs_repo_submodule
run_test test_cherrypick_modified_symlinks
run_test test_cherrypick_symlink_conflicts
+run_test test_cherrypick_with_path_prefix_and_empty_tree