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

Re: [PATCH] pull: do not segfault when HEAD refers to missing object file

From
Jeff King <peff@peff.net>
Date
Mar 6, 2017, 07:33 UTC
Message-ID
<20170306073317.p2txecat56zvzbmz@sigill.intra.peff.net>
In-Reply-To
<6726b36d-6f50-d258-12e3-8b7b56159631@kdbg.org>
On Mon, Mar 06, 2017 at 07:52:10AM +0100, Johannes Sixt wrote:
Show 10 quoted lines
> > Yeah, it is. You can do it easily with 'sed', of course, but if you want
> > to avoid the extra process and do it in pure shell, it's more like:
> > 
> >   last38=${REV#??}
> >   first2=${REV%$last38}
> >   rm -f .git/objects/$first2/$last38
> 
> Is it "HEAD points to non-existent object" or ".git/HEAD contains junk"? In
> both cases there are simpler solutions than to remove an object. For
> example, `echo "$_x40" >.git/HEAD` or `echo "this is junk" >.git/HEAD`?

Good point. Unfortunately, it's a little tricky. You can't use "this is junk" because then git does not recognize it as a git repo at all. You can't use $_x40 because the null sha1 is used internally to signal an unborn branch, so we mix it up with that case.

Something like "111..." for 40 characters would work, though at that point I think just simulating an actual corruption might be less convoluted.

-Peff
Previous: Johannes SixtNext: Jeff King
Message 5 of 6 in “pull: do not segfault when HEAD refers to missing object file”
  1. pull: do not segfault when HEAD refers to missing object fileAndré Laszlo, Mar 5, 2017
  2. brian m. carlsonMar 5, 2017
  3. Jeff KingMar 6, 2017
  4. Johannes SixtMar 6, 2017
  5. Jeff KingMar 6, 2017
  6. Jeff KingMar 6, 2017

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.