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

Expected Behavior?

From
Jon Loeliger <jdl@freescale.com>
Date
Nov 6, 2005, 22:16 UTC
Message-ID
<E1EYsny-0004hq-IW@jdl.com>

I was working through some examples and found some rather curious behavior. I'm wondering if it is expected or not. This isn't quite minimal, but it is still small and shows the weirdness:

    git-init-db
    echo "Stuff for file1" > file1
    echo "Stuff for file2" > file2
    git add file1 file2
    git commit -m "Initial file1 and file2"
    git checkout -b dev
    echo "More for file1" >> file1
    rm -f file2
    echo "Another file!" > file3
    git update-index file1
    git update-index --force-remove file2
    git add file3
    git commit -m "Updated some stuff."
    git checkout master
    echo "Stuff for a conflict." >> file3
    git add file3
    git commit -m "Master update of file3"
    git merge "Grab dev stuff" master dev
Then, the part that I think is odd is demonstrated by "git status":
    $ git status
    #
    # Updated but not checked in:
    #   (will commit)
    #
    #       modified: file1
    #       deleted:  file2
    #       unmerged: file3
    #
    #
    # Changed but not updated:
    #   (use git-update-index to mark for commit)
    #
    #       unmerged: file3
    #
    #
    # Untracked files:
    #   (use "git add" to add to commit)
    #
    #       file3

Why is file3 considered untracked and needing to be added? It was present in both "dev" and "master" branches before the merge. It doesn't end up with "<<< one === other >>>" style diffs either.

My guess is that the file is small, one line, in each branch. When the diff happens, it sees the file as empty in the other branch and considers that "new" directly, rather than asking the index if it knows about it to determine "newness" status.

Or perhaps it is that the file became new in each branch independently and never really had a true common ancestor.

Thanks, jdl

Next: Junio C Hamano
Message 1 of 3 in “Expected Behavior?”
  1. Jon LoeligerNov 6, 2005
  2. Junio C HamanoNov 7, 2005
  3. Junio C HamanoNov 7, 2005

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.