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

Re: [RFC/PATCH] replace: add --graft option

From
Michael Haggerty <mhagger@alum.mit.edu>
Date
May 19, 2014, 09:42 UTC
Message-ID
<5379D1EF.8040203@alum.mit.edu>
In-Reply-To
<20140518182939.5260.91202.chriscool@tuxfamily.org>
On 05/18/2014 08:29 PM, Christian Couder wrote:
Show 15 quoted lines
> The usage string for this option is:
> 
> git replace [-f] --graft <commit> [<parent>...]
> 
> First we create a new commit that is the same as <commit>
> except that its parents are [<parents>...]
> 
> Then we create a replace ref that replace <commit> with
> the commit we just created.
> 
> With this new option, it should be straightforward to
> convert grafts to replace refs, with something like:
> 
> cat .git/info/grafts | while read line
> do git replace --graft $line; done

I love the functionality; I think it's a great step towards making grafts obsolete.

I haven't worked with Git's object reading/writing code much, but it surprised me that you are editing the commit object basically as a string, using hard-coded length constants and stuff. It seems error-prone, and we already have a commit parser.

Would it be possible to program this at a higher layer of abstraction based on the commit object produced by the existing commit parser? E.g., edit the object it produces, and write the result? Or create a new commit object out of the parsed commit object and write that?

It's great that you're working on this!
Michael
-- 
Michael Haggerty
mhagger@alum.mit.edu
http://softwareswirl.blogspot.com/
Previous: Christian CouderNext: Jeff King
Message 2 of 8 in “replace: add --graft option”
  1. replace: add --graft optionChristian Couder, May 18, 2014
  2. Michael HaggertyMay 19, 2014
  3. Jeff KingMay 19, 2014
  4. Junio C HamanoMay 19, 2014
  5. Jeff KingMay 19, 2014
  6. Junio C HamanoMay 19, 2014
  7. Christian CouderMay 23, 2014
  8. Jeff KingMay 19, 2014

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.