From: Alexander Gladysh Date: Tue, 09 Jun 2009 08:18:16 GMT Subject: Re: Troubles when directory is replaced by symlink Message-ID: In-Reply-To: Any help here? This bug is pretty annoying (especially that it requires double hard resets). Should I provide any extra information? Alexander. On Fri, Jun 5, 2009 at 9:43 AM, Alexander Gladysh wrote: > 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 ..." to update what will be committed) > #   (use "git checkout -- ..." 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 ..." to unstage) > # > #       deleted:    beta/alpha/file1 > # > # Changed but not updated: > #   (use "git add ..." to update what will be committed) > #   (use "git checkout -- ..." to discard changes in working directory) > # > #       unmerged:   beta/alpha > # > # Untracked files: > #   (use "git add ..." 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 >