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

Two bugs with renaming

From
JGJohn Goerzen <jgoerzen@complete.org>
Date
Mar 19, 2008, 23:21 UTC
Message-ID
<slrnfu37vn.d2i.jgoerzen@katherina.lan.complete.org>
Hi folks,

I have a transcript of a Git session that illustrates two odd bugs with Git renaming. Command output is truncated except where interesting.

Bug #1 causes git to refuse to change to a different branch, claiming that uncommitted changes exist, even when git status says there are none. Bug #2 causes git to refuse to merge unrelated changes.

Tested with Git 1.5.4.4.
jgoerzen@katherina:/tmp$ mkdir testrepo
jgoerzen@katherina:/tmp$ cd testrepo
jgoerzen@katherina:/tmp/testrepo$ git init
jgoerzen@katherina:/tmp/testrepo$ mkdir files
jgoerzen@katherina:/tmp/testrepo$ echo hi > files/delete.me
jgoerzen@katherina:/tmp/testrepo$ git add .
jgoerzen@katherina:/tmp/testrepo$ git commit -m 'Added files/delete.me'
jgoerzen@katherina:/tmp/testrepo$ git checkout -b testbranch
Switched to a new branch "testbranch"
jgoerzen@katherina:/tmp/testrepo$ git mv files files.upstream
jgoerzen@katherina:/tmp/testrepo$ git commit -m 'Renamed files to files.upstream'
Created commit 7b6e9c5: Renamed files to files.upstream
 1 files changed, 0 insertions(+), 0 deletions(-)
 rename {files => files.upstream}/delete.me (100%)
jgoerzen@katherina:/tmp/testrepo$ git status
# On branch testbranch
nothing to commit (working directory clean)

####### # We can still change branches here...

jgoerzen@katherina:/tmp/testrepo$ git co master Switched to branch "master" jgoerzen@katherina:/tmp/testrepo$ git co testbranch Switched to branch "testbranch"

####### # Now here comes bug #1...

jgoerzen@katherina:/tmp/testrepo$ ln -s /tmp/nonexistant files jgoerzen@katherina:/tmp/testrepo$ git add files jgoerzen@katherina:/tmp/testrepo$ git commit -m 'Added files as symlink' jgoerzen@katherina:/tmp/testrepo$ git status # On branch testbranch nothing to commit (working directory clean) jgoerzen@katherina:/tmp/testrepo$ git checkout master fatal: Untracked working tree file 'files.upstream/delete.me' would be removed by merge.

####### # Hrm, but that file really is tracked, AND it didn't show up in git status!

$ git log files.upstream/delete.me | cat
commit 7b6e9c5d0fb268b5bca4985b407fe35aa2a7bd6d
Author: John Goerzen <jgoerzen@complete.org>
Date:   Wed Mar 19 18:12:12 2008 -0500
    Renamed files to files.upstream

####### # Well, let's work around this and check out master anyhow.

jgoerzen@katherina:/tmp/testrepo$ git checkout -f master Switched to branch "master" jgoerzen@katherina:/tmp/testrepo$ ls -l total 0 drwxr-xr-x 2 jgoerzen jgoerzen 22 Mar 19 18:13 files drwxr-xr-x 2 jgoerzen jgoerzen 22 Mar 19 18:12 files.upstream

####### # Yeow! What's files.upstream doing here? It wasn't on this branch, and # we had no uncommitted changes on the other branch.

jgoerzen@katherina:/tmp/testrepo$ rm -r files.upstream jgoerzen@katherina:/tmp/testrepo$ git rm files.upstream/delete.me rm 'files.upstream/delete.me' jgoerzen@katherina:/tmp/testrepo$ git status # On branch master nothing to commit (working directory clean)

####### # Set up bug #2

jgoerzen@katherina:/tmp/testrepo$ echo foo > foo jgoerzen@katherina:/tmp/testrepo$ git add foo jgoerzen@katherina:/tmp/testrepo$ git commit -m 'Added foo' jgoerzen@katherina:/tmp/testrepo$ git checkout testbranch Switched to branch "testbranch" jgoerzen@katherina:/tmp/testrepo$ ls -l total 0 lrwxrwxrwx 1 jgoerzen jgoerzen 16 Mar 19 18:14 files -> /tmp/nonexistant drwxr-xr-x 2 jgoerzen jgoerzen 22 Mar 19 18:14 files.upstream jgoerzen@katherina:/tmp/testrepo$ git merge master fatal: Entry 'files/delete.me' would be overwritten by merge. Cannot merge. Merge with strategy recursive failed.

######## # And there's bug #2 # # Note that it doesn't matter what strategy is attempted.

Thanks for any insight.
-- John
Next: Junio C Hamano
Message 1 of 9 in “Two bugs with renaming”
  1. John GoerzenMar 19, 2008
  2. Junio C HamanoMar 20, 2008
  3. Jeff KingMar 20, 2008
  4. John GoerzenMar 20, 2008
  5. Jeff KingMar 20, 2008
  6. Björn SteinbrinkMar 20, 2008
  7. Linus TorvaldsMar 20, 2008
  8. Linus TorvaldsMar 20, 2008
  9. Junio C HamanoMar 20, 2008

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.