git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: Troubles when directory is replaced by symlink

From
Alexander Gladysh <agladysh@gmail.com>
Date
Jun 9, 2009, 08:18 UTC
Message-ID
<c6c947f60906090118n78d3c40fq11d1390f8776c2c0@mail.gmail.com>
In-Reply-To
<c6c947f60906042243v2e36251dn9a46343cf6b8a2f4@mail.gmail.com>

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<agladysh@gmail.com> wrote:
Show 154 quoted lines
> 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
>
Previous: Alexander GladyshNext: Jeff King
Message 2 of 9 in “Troubles when directory is replaced by symlink”
  1. Alexander GladyshJun 5, 2009
  2. Alexander GladyshJun 9, 2009
  3. Jeff KingJun 11, 2009
  4. Kjetil BarvikJun 11, 2009
  5. Kjetil BarvikJun 14, 2009
  6. James PickensJun 24, 2009
  7. Kjetil BarvikJun 25, 2009
  8. Kjetil BarvikJun 26, 2009
  9. Johannes SixtJun 26, 2009

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.