Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2008-03-18 02:47:18 +0300
committerJunio C Hamano <gitster@pobox.com>2008-03-19 08:17:17 +0300
commit29dc13319883f97618de6f03e8ffc5dc810d8786 (patch)
treec89ed8648f02e797999c10b98f6af3445698aab1
parentdeda26b9935bdca8d140006b224a278ec0377a33 (diff)
git-merge-one-file: fix longstanding stupid thinko
When a merge result creates a new file, and when our side already has a file in the path, taking the merge result may clobber the untracked file. However, the logic to detect this situation was totally the wrong way. We should complain when the file exists, not when the file does not exist. Signed-off-by: Junio C Hamano <gitster@pobox.com>
-rwxr-xr-xgit-merge-one-file.sh5
-rwxr-xr-xt/t1004-read-tree-m-u-wf.sh46
2 files changed, 49 insertions, 2 deletions
diff --git a/git-merge-one-file.sh b/git-merge-one-file.sh
index 9ee3f80452..e1eb963266 100755
--- a/git-merge-one-file.sh
+++ b/git-merge-one-file.sh
@@ -48,10 +48,11 @@ case "${1:-.}${2:-.}${3:-.}" in
;;
"..$3")
echo "Adding $4"
- test -f "$4" || {
+ if test -f "$4"
+ then
echo "ERROR: untracked $4 is overwritten by the merge."
exit 1
- }
+ fi
git update-index --add --cacheinfo "$7" "$3" "$4" &&
exec git checkout-index -u -f -- "$4"
;;
diff --git a/t/t1004-read-tree-m-u-wf.sh b/t/t1004-read-tree-m-u-wf.sh
index 9d1371c2c6..283e77cc51 100755
--- a/t/t1004-read-tree-m-u-wf.sh
+++ b/t/t1004-read-tree-m-u-wf.sh
@@ -157,4 +157,50 @@ test_expect_success '3-way not overwriting local changes (their side)' '
'
+test_expect_success 'D/F setup' '
+
+ git reset --hard &&
+
+ git checkout side-a &&
+ rm -f subdir/file2 &&
+ mkdir subdir/file2 &&
+ echo qfwfq >subdir/file2/another &&
+ git add subdir/file2/another &&
+ test_tick &&
+ git commit -m "side-a changes file2 to directory"
+
+'
+
+test_expect_success 'D/F' '
+
+ git checkout side-b &&
+ git read-tree -m -u branch-point side-b side-a &&
+ git ls-files -u >actual &&
+ (
+ a=$(git rev-parse branch-point:subdir/file2)
+ b=$(git rev-parse side-a:subdir/file2/another)
+ echo "100644 $a 1 subdir/file2"
+ echo "100644 $a 2 subdir/file2"
+ echo "100644 $b 3 subdir/file2/another"
+ ) >expect &&
+ test_cmp actual expect
+
+'
+
+test_expect_success 'D/F resolve' '
+
+ git reset --hard &&
+ git checkout side-b &&
+ git merge-resolve branch-point -- side-b side-a
+
+'
+
+test_expect_success 'D/F recursive' '
+
+ git reset --hard &&
+ git checkout side-b &&
+ git merge-recursive branch-point -- side-b side-a
+
+'
+
test_done