git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Analyzing a corrupted index file
@ 2024-01-07 15:22 Nathan Manceaux-Panot
  2024-01-08 19:51 ` Junio C Hamano
  0 siblings, 1 reply; 4+ messages in thread
From: Nathan Manceaux-Panot @ 2024-01-07 15:22 UTC (permalink / raw)
  To: git

Hello all,

I have a corrupted git index file, and am trying to read it by hand, to understand what's wrong with it. Are there any tools that'll let me parse the on-disk, binary version of the index file, to unpack it into a human-readable data structure?
I found the spec for the index binary format, but reading it in that way is beyond my abilities.

For context, I'm writing a git tool, and my code is causing the index file to be screwed up in some unknown way. When it's in that state, git (v2.43) becomes inconsistent with itself:
- In the workdir, the file contains A
- According to `git show :file`, the file in the index contains B
- But `git diff` reports no changes!
The inconsistency goes away with a simple `git reset`, but can then be easily reproduced by re-executing my tool.

Thank you,
Nathan


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Analyzing a corrupted index file
  2024-01-07 15:22 Analyzing a corrupted index file Nathan Manceaux-Panot
@ 2024-01-08 19:51 ` Junio C Hamano
  2024-01-09 14:42   ` Nathan Manceaux-Panot
  0 siblings, 1 reply; 4+ messages in thread
From: Junio C Hamano @ 2024-01-08 19:51 UTC (permalink / raw)
  To: Nathan Manceaux-Panot; +Cc: git

Nathan Manceaux-Panot <fresh.tree3651@lemon.garden> writes:

> I have a corrupted git index file, and am trying to read it by
> hand, to understand what's wrong with it. Are there any tools
> that'll let me parse the on-disk, binary version of the index
> file, to unpack it into a human-readable data structure?

"git ls-files" with its various options is probably the closest, but
even the command is not meant for "debugging the bits".  It is more
about showing lower-level details of a working index file to help
diagnose the mismatch between end-user expectation and the reality
(e.g. the user says the conflicts were all resolved, an expert asks
to run "ls-files -u" and together they discover that there are paths
that are still unmerged).


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Analyzing a corrupted index file
  2024-01-08 19:51 ` Junio C Hamano
@ 2024-01-09 14:42   ` Nathan Manceaux-Panot
  2024-01-09 17:16     ` Junio C Hamano
  0 siblings, 1 reply; 4+ messages in thread
From: Nathan Manceaux-Panot @ 2024-01-09 14:42 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git

> On Jan 8, 2024, at 20:51, Junio C Hamano <gitster@pobox.com> wrote:
> 
> "git ls-files" with its various options is probably the closest, but
> even the command is not meant for "debugging the bits"

Thanks for the pointer. In the meantime I've started to make sense of the binary representation, against all odds, so there's hope for me there!


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Analyzing a corrupted index file
  2024-01-09 14:42   ` Nathan Manceaux-Panot
@ 2024-01-09 17:16     ` Junio C Hamano
  0 siblings, 0 replies; 4+ messages in thread
From: Junio C Hamano @ 2024-01-09 17:16 UTC (permalink / raw)
  To: Nathan Manceaux-Panot; +Cc: git

Nathan Manceaux-Panot <fresh.tree3651@lemon.garden> writes:

>> On Jan 8, 2024, at 20:51, Junio C Hamano <gitster@pobox.com> wrote:
>> 
>> "git ls-files" with its various options is probably the closest, but
>> even the command is not meant for "debugging the bits"
>
> Thanks for the pointer. In the meantime I've started to make sense
> of the binary representation, against all odds, so there's hope
> for me there!

Documentation/gitformat-index.txt may be a good place to start, of
course.

https://github.com/git/htmldocs/blob/gh-pages/gitformat-index.txt


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2024-01-09 17:16 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-01-07 15:22 Analyzing a corrupted index file Nathan Manceaux-Panot
2024-01-08 19:51 ` Junio C Hamano
2024-01-09 14:42   ` Nathan Manceaux-Panot
2024-01-09 17:16     ` Junio C Hamano

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).