git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Matthieu Moy <Matthieu.Moy@grenoble-inp.fr>
To: git <git@vger.kernel.org>
Subject: [BUG] Silent data loss on merge with uncommited changes + renames
Date: Mon, 22 Apr 2013 11:24:45 +0200	[thread overview]
Message-ID: <vpqobd6q5nm.fsf@grenoble-inp.fr> (raw)

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/

             reply	other threads:[~2013-04-22  9:24 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-04-22  9:24 Matthieu Moy [this message]
2013-04-22 14:23 ` [BUG] Silent data loss on merge with uncommited changes + renames Johannes Sixt
2013-04-22 14:43   ` Matthieu Moy
2013-04-22 15:19 ` Junio C Hamano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=vpqobd6q5nm.fsf@grenoble-inp.fr \
    --to=matthieu.moy@grenoble-inp.fr \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).