All of lore.kernel.org
 help / color / mirror / Atom feed
* Troubles when directory is replaced by symlink
@ 2009-06-05  5:43 Alexander Gladysh
  2009-06-09  8:18 ` Alexander Gladysh
  0 siblings, 1 reply; 9+ messages in thread
From: Alexander Gladysh @ 2009-06-05  5:43 UTC (permalink / raw)
  To: git

Hi, list!

OS X 10.5.7

$ git --version
git version 1.6.3.2

In my master branch I've had this structure:

root /
    directory1 /
        some-files
    directory2 /
        copy-of-directory1 /
            some-files

In a separate branch I replaced copy-of-directory1 with a symlink to
../directory1. I did it in two commits: first remove
copy-of-directory1, in second commit -- create the symlink.

My master branch is then moved by couple commits ahead.

Now I have nasty problems when I try to merge that separate branch
back to master (see log below).

If I split the branch history in two, and first merge up to commit
with deletion, and then separately merge the rest of it with symlink
creation -- all goes well.

Below is the log on how to reproduce the problem:

Alexander.

$ mkdir test
$ cd test
$ git init
Initialized empty Git repository in /users/agladysh/tmp/test/.git/
$ mkdir alpha
$ echo "file1" > alpha/file1
$ git add .
$ git commit -m "first commit"
[master (root-commit) 1df90a8] first commit
 1 files changed, 1 insertions(+), 0 deletions(-)
 create mode 100644 alpha/file1

$ mkdir beta
$ cp -R alpha beta/
$ git add .
$ git commit -m "second commit"
[master 0eddb98] second commit
 1 files changed, 1 insertions(+), 0 deletions(-)
 create mode 100644 beta/alpha/file1

$ git checkout -b branch
Switched to a new branch 'branch'
$ rm -rf beta/alpha
$ git add -u
$ git commit -m "deleted"
[branch 34134ea] deleted
 1 files changed, 0 insertions(+), 1 deletions(-)
 delete mode 100644 beta/alpha/file1

$ cd beta/
$ ln -s ../alpha
$ cd ..
$ git add .
$ git commit -m "symlink"
[branch b8dfba0] symlink
 1 files changed, 1 insertions(+), 0 deletions(-)
 create mode 120000 beta/alpha

$ git checkout master
Switched to branch 'master'

### All works if we're just fast-forwarding ###

$ git branch backup
$ git merge branch
Updating 0eddb98..b8dfba0
Fast forward
 beta/alpha       |    1 +
 beta/alpha/file1 |    1 -
 2 files changed, 1 insertions(+), 1 deletions(-)
 create mode 120000 beta/alpha
 delete mode 100644 beta/alpha/file1

### Trying to restore to backup
$ git reset --hard backup
error: Invalid path ''
HEAD is now at 0eddb98 second commit
$ git status
# On branch master
# Changed but not updated:
#   (use "git add/rm <file>..." to update what will be committed)
#   (use "git checkout -- <file>..." to discard changes in working directory)
#
#	deleted:    alpha/file1
#
no changes added to commit (use "git add" and/or "git commit -a")

### Needed second reset --hard.

$ git reset --hard
HEAD is now at 0eddb98 second commit

$ git status
# On branch master
nothing to commit (working directory clean)

### We're back to original master now

$ echo "change" >> alpha/file1
$ git commit -a -m "third commit"
[master 0f64b88] third commit
 1 files changed, 1 insertions(+), 0 deletions(-)

### Here it goes

$ git merge branch
CONFLICT (directory/file): There is a directory with name beta/alpha
in HEAD. Adding beta/alpha as beta/alpha~branch
Removing beta/alpha/file1
Automatic merge failed; fix conflicts and then commit the result.
[4168][agladysh.agmac: test]$ git status
beta/alpha: needs merge
# On branch master
# Changes to be committed:
#   (use "git reset HEAD <file>..." to unstage)
#
#	deleted:    beta/alpha/file1
#
# Changed but not updated:
#   (use "git add <file>..." to update what will be committed)
#   (use "git checkout -- <file>..." to discard changes in working directory)
#
#	unmerged:   beta/alpha
#
# Untracked files:
#   (use "git add <file>..." to include in what will be committed)
#
#	beta/alpha~branch
$ git mergetool
Merging the files: beta/alpha

mv: rename beta/alpha to ./beta/alpha.BACKUP.55777: No such file or directory
cp: ./beta/alpha.BACKUP.55777: No such file or directory
Deleted merge conflict for 'beta/alpha':
  {local}: deleted
  {remote}: a symbolic link -> '../alpha'
Use (c)reated or (d)eleted file, or (a)bort? c
fatal: beta/alpha: unable to stat (No such file or directory)
mv: rename ./beta/alpha.BACKUP.55777 to beta/alpha.orig: No such file
or directory

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2009-06-26 14:15 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-06-05  5:43 Troubles when directory is replaced by symlink Alexander Gladysh
2009-06-09  8:18 ` Alexander Gladysh
2009-06-11 11:48   ` Jeff King
2009-06-11 14:37     ` Kjetil Barvik
2009-06-14 14:34     ` Kjetil Barvik
2009-06-24 22:07       ` James Pickens
2009-06-25 22:51         ` Kjetil Barvik
2009-06-26 13:14         ` Kjetil Barvik
2009-06-26 14:14           ` Johannes Sixt

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.