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

fast-import, merges, and file changes -- lack of clarity in docs, possible minor bug, or PEBKAC?

From
Elijah Newren <newren@gmail.com>
Date
Feb 17, 2009, 00:28 UTC
Message-ID
<51419b2c0902161628x7a3475e6p2a70310e5b294444@mail.gmail.com>
Hi,
It appears the documentation for fast-import does not specify the
basis on which a commit command's file changes (filemodify,
filedelete, filecopy, or filerename) are relative to.  For a non-merge
commit, it's obvious, and I thought that it would be obvious for a
merge commit too -- and then found out I had assumed the wrong answer.
 I assumed the file changes would be relative to the *combined* set of
files from the parents, whereas fast-import apparently treats them as
relative to the first (or 'from') parent.  (Since the combined set of
files may have conflicts, I'd expect it to be an error if the merge
commit didn't specify an appropriate filemodify command for at least
each of the filenames with conflicts.)

In case my description above isn't clear, I've got a simple example at the end of this email that has a file 'world' on one branch, a file 'bar' on another branch, and a merge of the two branches. In the merge commit, I do not need to mention the 'world' file; it will be included automatically. However, unless I mention the 'bar' file (by adding a 'M 100644 :1 bar' line to the end of the input), it will not be included in the merge commit.

Is this intentional? I believe we could change this behavior without breaking backward compatibility with older fast-export output streams, since such older streams would simply be providing redundant information. But is there a reason for this behavior that I'm missing?

Thanks, Elijah

Sample input file for git fast-import (which merges two commits but silently drops one of the files):

blob mark :1 data 4 foo

reset refs/heads/other commit refs/heads/other mark :2 author Elijah Newren <newren@gmail.com> 1234815015 -0700 committer Elijah Newren <newren@gmail.com> 1234815015 -0700 data 29 Initial commit, other branch M 100644 :1 bar

blob mark :3 data 3 hi

reset refs/heads/master commit refs/heads/master mark :4 author Elijah Newren <newren@gmail.com> 1234814943 -0700 committer Elijah Newren <newren@gmail.com> 1234814943 -0700 data 30 Initial commit, master branch M 100644 :3 world

commit refs/heads/master mark :5 author Elijah Newren <newren@gmail.com> 1234815029 -0700 committer Elijah Newren <newren@gmail.com> 1234815029 -0700 data 21 Merge branch 'other' from :4 merge :2

Next: Elijah Newren
Message 1 of 2 in “fast-import, merges, and file changes -- lack of clarity in docs, possible minor bug, or PEBKAC?”
  1. Elijah NewrenFeb 17, 2009
  2. Elijah NewrenFeb 17, 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.