[BUG] Silent data loss on merge with uncommited changes + renames

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

Following the discussion on "merge with uncommited changes" inside the
"git pull --autostash" thread, I did a bit of testing, and encountered a
case with silent data loss. In short: merge a branch introducing changes
to a file. If the file has been renamed in the current branch, then "git
merge" follows the rename and brings changes to the renamed file, but
uncommited changes in this file are overriden silently.

I could have expected "git merge --abort" to fail, but the problem is
really more serious here: data loss is done silently before giving me an
opportunity to do or abort anything.

Reproduction script below:

#! /bin/sh

# Create repo
git init git.$$
cd git.$$
echo init > test.txt
git add test.txt
git commit -m init

# Make a branch changing test.txt
git checkout -b branch
echo new > test.txt
git commit -am new

# Move test.txt on master
git checkout master
git mv test.txt moved.txt
git commit -m move

# Make uncommited changes to moved.txt
echo precious > moved.txt

# Merge loses uncommited content "precious" in "moved.txt" silently
git merge --no-edit branch
ls # lists just moved.txt
git status # nothing to commit, working directory clean
cat moved.txt # Says "new".

-- 
Matthieu Moy
http://www-verimag.imag.fr/~moy/
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]