diff --git a/git-merge-one-file.sh b/git-merge-one-file.sh index d067894bf4..bb64a72ad3 100755 --- a/git-merge-one-file.sh +++ b/git-merge-one-file.sh @@ -22,6 +22,11 @@ LONG_USAGE="Usage: git merge-one-file $USAGE Blob ids and modes should be empty for missing files." +SUBDIRECTORY_OK=Yes +. git-sh-setup +cd_to_toplevel +require_work_tree + if ! test "$#" -eq 7 then echo "$LONG_USAGE" @@ -132,7 +137,7 @@ case "${1:-.}${2:-.}${3:-.}" in # Create the working tree file, using "our tree" version from the # index, and then store the result of the merge. - git checkout-index -f --stage=2 -- "$4" && cat "$src1" >"$4" + git checkout-index -f --stage=2 -- "$4" && cat "$src1" >"$4" || exit 1 rm -f -- "$orig" "$src1" "$src2" if [ "$6" != "$7" ]; then diff --git a/t/t6060-merge-index.sh b/t/t6060-merge-index.sh index 895f079c92..debadbd299 100755 --- a/t/t6060-merge-index.sh +++ b/t/t6060-merge-index.sh @@ -68,7 +68,7 @@ test_expect_success 'merge-one-file fails without a work tree' ' ) ' -test_expect_failure 'merge-one-file respects GIT_WORK_TREE' ' +test_expect_success 'merge-one-file respects GIT_WORK_TREE' ' (cd bare.git && mkdir work && GIT_WORK_TREE=$PWD/work && @@ -82,7 +82,7 @@ test_expect_failure 'merge-one-file respects GIT_WORK_TREE' ' test_cmp expect-merged bare.git/work/file-index ' -test_expect_failure 'merge-one-file respects core.worktree' ' +test_expect_success 'merge-one-file respects core.worktree' ' mkdir subdir && git clone . subdir/child && (cd subdir &&