* Git confused when file is renamed/renamed+modified and result merged
@ 2009-06-05 20:06 Tomas Carnecky
0 siblings, 0 replies; only message in thread
From: Tomas Carnecky @ 2009-06-05 20:06 UTC (permalink / raw)
To: git mailing list
I was helping someone on IRC with merge problems and it boiled down to
this. Git is confused when one branch renames a file while another
branch renames the file in the same way and then modifies the file.
When merging the two branches git will indicate a conflict in the
'source' file (rename/delete) but not the 'destination' file and will
put the destination file from the first branch into the working tree,
even though the second branch has a file with the same name but
conflicting contents.
Git commands that lead up to this situation, with interleaved
comments. A usability suggestion is also included in the following
transcript:
bash-3.2$ git --version
git version 1.6.3.2.198.g6096d
bash-3.2$ git init
Initialized empty Git repository in /Users/tomc/gitest/.git/
bash-3.2$ echo arst > file1
bash-3.2$ git add file1
bash-3.2$ git commit -m 'initial commit'
[master (root-commit) fdad65c] initial commit
1 files changed, 1 insertions(+), 0 deletions(-)
create mode 100644 file1
bash-3.2$ git branch new
# branch master renames the file without modifying it
bash-3.2$ git mv file1 file2
bash-3.2$ git commit -m 'move file1 to file2'
[master 053cc6f] move file1 to file2
1 files changed, 0 insertions(+), 0 deletions(-)
rename file1 => file2 (100%)
bash-3.2$ git checkout new
Switched to branch 'new'
# branch new moves the file while modifying it so heavily that git
doesn't
# recognize it as a rename anymore
bash-3.2$ git rm file1
rm 'file1'
bash-3.2$ echo qwfp > file2
bash-3.2$ git add file2
bash-3.2$ git commit -m 'move file1 to file2, while heavily modifying
it'
[new 4118625] rename file1 to file2, while heavily modifying it
2 files changed, 1 insertions(+), 1 deletions(-)
delete mode 100644 file1
create mode 100644 file2
# merge new into master
bash-3.2$ git checkout master
Switched to branch 'master'
bash-3.2$ git merge new
# Usability suggestion: Not clear to which file the 'deleted in new' is
# referring to. Maybe change the message to:
# CONFLICT in 'file1' (rename/delete): Renamed to file2 in HEAD,
deleted in new.
CONFLICT (rename/delete): Rename file1->file2 in HEAD and deleted in new
Automatic merge failed; fix conflicts and then commit the result.
# as expected, there's a conflict in 'file1'. But 'file2' is silently
accepted
# from the 'master' branch, even though the 'new' branch has a file
with the
# same name but different contents
bash-3.2$ git show :2:file2
arst
bash-3.2$ git show :3:file2
fatal: ambiguous argument ':3:file2': unknown revision or path not in
the working tree.
Use '--' to separate paths from revisions
bash-3.2$ git show new:file2
qwfp
bash-3.2$
tom
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2009-06-05 20:06 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-06-05 20:06 Git confused when file is renamed/renamed+modified and result merged Tomas Carnecky
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).