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

Re: [PATCH 4/4] replace: add a --raw mode for --edit

From
Jeff King <peff@peff.net>
Date
Jun 26, 2014, 15:55 UTC
Message-ID
<20140626155530.GB10402@sigill.intra.peff.net>
In-Reply-To
<xmqqsims62m1.fsf@gitster.dls.corp.google.com>
On Wed, Jun 25, 2014 at 03:33:42PM -0700, Junio C Hamano wrote:
Show 25 quoted lines
> Jeff King <peff@peff.net> writes:
> 
> > One of the purposes of "git replace --edit" is to help a
> > user repair objects which are malformed or corrupted.
> > Usually we pretty-print trees with "ls-tree", which is much
> > easier to work with than the raw binary data.  However, some
> > forms of corruption break the tree-walker, in which case our
> > pretty-printing fails, rendering "--edit" useless for the
> > user.
> >
> > This patch introduces a "--raw" option, which lets you edit
> > the binary data in these instances.
> >
> > Signed-off-by: Jeff King <peff@peff.net>
> > ---
> 
> Hmmmmm, this feels almost like inviting accidents to make it easy
> and limiting the attempt to only one shot at the "transformation"
> step.
> 
> Will queue, but we can do the same with "cat-file $type >temp", do
> some transformation on "temp", doubly make sure what is in "temp" is
> sensible and then finally "hash-object -w -t $type temp".  And it
> makes me feel uneasy that the new feature seems to make it harder to
> do the "doubly make sure" part.

I do not think it is any worse than "--edit" is by itself. True, editing the binary contents is hard, but we do check that the format is sane when we read it back in (using the same checks that hash-object does). I think it would be nice to take that a step further and actually let hash-object (and "replace --edit") do the more rigorous fsck checks on created objects.

I do still think even with those automated sanity checks that it makes sense to double-check the replacement manually. But I think that is one of the features of replace objects: you are not doing anything permanent, and can view the object in place. So not only can you examine the object by "git show $new_sha1", you can see it in place as "git log -p", etc. And easily back it out with "git replace -d" (or fix it up again with "git replace --edit") if need be.

-Peff
Previous: Junio C Hamano
Message 9 of 9 in “git replace --edit --raw”
  1. 0/4 git replace --edit --rawJeff King, Jun 24, 2014
  2. 1/4 replace: replace spaces with tabs in indentationJeff King, Jun 24, 2014
  3. 2/4 avoid double close of descriptors handed to run_commandJeff King, Jun 24, 2014
  4. 3/4 replace: use argv_array in export_objectJeff King, Jun 24, 2014
  5. 4/4 replace: add a --raw mode for --editJeff King, Jun 24, 2014
  6. Eric SunshineJun 25, 2014
  7. Jeff KingJun 25, 2014
  8. Junio C HamanoJun 25, 2014
  9. Jeff KingJun 26, 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.