summaryrefslogtreecommitdiff
path: root/git-merge-one-file.sh
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2008-03-17 23:47:18 (GMT)
committerJunio C Hamano <gitster@pobox.com>2008-03-19 05:17:17 (GMT)
commit29dc13319883f97618de6f03e8ffc5dc810d8786 (patch)
treec89ed8648f02e797999c10b98f6af3445698aab1 /git-merge-one-file.sh
parentdeda26b9935bdca8d140006b224a278ec0377a33 (diff)
downloadgit-29dc13319883f97618de6f03e8ffc5dc810d8786.zip
git-29dc13319883f97618de6f03e8ffc5dc810d8786.tar.gz
git-29dc13319883f97618de6f03e8ffc5dc810d8786.tar.bz2
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>
Diffstat (limited to 'git-merge-one-file.sh')
-rwxr-xr-xgit-merge-one-file.sh5
1 files changed, 3 insertions, 2 deletions
diff --git a/git-merge-one-file.sh b/git-merge-one-file.sh
index 9ee3f80..e1eb963 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"
;;