diff options
author | Jeff King <peff@peff.net> | 2011-04-29 18:24:32 -0400 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2011-04-29 15:37:43 -0700 |
commit | 6aaeca900b05a8265d1930d3dc0a2df19002771f (patch) | |
tree | 7e10c6dbec648234bf52d789583d8d74cb0c124e /t | |
parent | cf1af1b1f3ddd2554f64aae120635952801a9632 (diff) | |
download | git-6aaeca900b05a8265d1930d3dc0a2df19002771f.tar.gz git-6aaeca900b05a8265d1930d3dc0a2df19002771f.tar.xz |
merge-one-file: fix broken merges with alternate work trees
The merge-one-file tool predates the invention of
GIT_WORK_TREE. By the time GIT_WORK_TREE was invented, most
people were using the merge-recursive strategy, which
handles resolving internally. Therefore these features have
had very little testing together.
For the most part, merge-one-file just works with
GIT_WORK_TREE; most of its heavy lifting is done by plumbing
commands which do respect GIT_WORK_TREE properly. The one
exception is a shell redirection which touches the worktree
directly, writing results to the wrong place in the presence
of a GIT_WORK_TREE variable.
This means that merges won't even fail; they will silently
produce incorrect results, throwing out the entire "theirs"
side of files which need content-level merging!
This patch makes merge-one-file chdir to the toplevel of the
working tree (and exit if we don't have one). This most
closely matches the assumption made by the original script
(before separate work trees were invented), and matches what
happens when the script is called as part of a merge
strategy.
While we're at it, we'll also error-check the call to cat.
Merging a file in a subdirectory could in fact fail, as the
redirection relies on the "checkout-index" call just prior
to create leading directories. But we never noticed, since
we ignored the error return from running cat.
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't')
-rwxr-xr-x | t/t6060-merge-index.sh | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/t/t6060-merge-index.sh b/t/t6060-merge-index.sh index 895f079c9..debadbd29 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 && |