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

Re: [bug?] git-format-patch produces a 0-byte long patch for the first commit

From
GLGuennadi Liakhovetski <g.liakhovetski@gmx.de>
Date
Mar 23, 2009, 16:46 UTC
Message-ID
<Pine.LNX.4.64.0903231732150.6370@axis700.grange>
In-Reply-To
<200903231729.08216.trast@student.ethz.ch>
On Mon, 23 Mar 2009, Thomas Rast wrote:
Show 13 quoted lines
> Guennadi Liakhovetski wrote:
> > mkdir x
> > cd x
> > git-init
> > echo hi > greating
> > git-commit -a
> [...]
> > git-format-patch HEAD^ produces an error, 
> 
> There is no HEAD^ in this case.  HEAD is always the currently checked
> out commit.  Since it has a root commit, it has no parent, so you
> cannot apply ^ ("the first parent of") to it.  Similarly, HEAD~2 will
> not work if HEAD~1 has no parent, etc.

Yes, I can understand this, still from the high-level PoV, this looks inconsistent:

git-format-patch HEAD

never produces anything, which means for me, I'm trying to extract commits for a 0-length range.

git-format-patch HEAD^

Usually produces the "current" or the "last" commit - except if you're currently on the first commit... But I'm not insisting on this one - maybe you're right, it just _does_ look weird.

Just try to forget about the meaning of the command. You are somewhere on the commit timeline. You enter "some" command, which usually produces exactly one - the most recent commit. So, I would expect this to work always when there is at least one commit in the tree.

So, maybe it would make sense to refer to the point before-the-root-commit every time root's parent is requested?

Show 6 quoted lines
> > git-format-patch -1 produces a 0-byte long patch.
> 
> That is admittedly weird and probably deserves a fix and/or suggestion
> to use --root.
> 
> I'm not sure what else I can add to the explanations I gave on IRC.

Thanks for answering again, I just wanted to make sure this "weirdness" doesn't get lost, and possibly gets fixed. I think, you suggested yourself to post to the list, so I did.

Thanks Guennadi --- Guennadi Liakhovetski, Ph.D. Freelance Open-Source Software Developer

Previous: Thomas RastNext: Thomas Rast
Message 3 of 8 in “[bug?] git-format-patch produces a 0-byte long patch for the first commit”
  1. Guennadi LiakhovetskiMar 23, 2009
  2. Thomas RastMar 23, 2009
  3. Guennadi LiakhovetskiMar 23, 2009
  4. Documentation: format-patch --root clarificationsThomas Rast, Mar 26, 2009
  5. Jeff KingMar 24, 2009
  6. Guennadi LiakhovetskiMar 24, 2009
  7. Johannes SchindelinMar 24, 2009
  8. Guennadi LiakhovetskiMar 24, 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.