bug: Segfault with git diff

jake roggenbuck
2024-05-19T03:02:35Z

> Thank you for filling out a Git bug report!
> Please answer the following questions to help us understand your issue.

I have found a segfault when running git diff.

> What did you do before the bug happened? (Steps to reproduce your issue)

1. After running `git diff`, git showed me that object files were empty.
2. I deleted the empty object files, and ran `git diff` again.
3. I continued deleting the empty files until `git diff` segfaulted.

> What did you expect to happen? (Expected behavior)
An error message of some type or a graceful exit.

> What happened instead? (Actual behavior)
A segmentation fault.

`Segmentation fault (core dumped)`

> What's different between what you expected and what actually happened?
Instead of closing gracefully, there was a segmentation fault.

> Anything else you want to add:
git log displays:
fatal: bad object HEAD

git branch displays:
fatal: missing object 7610511b1b4db888e8e6bb8d0ff158f932961345 for
refs/heads/main

Neither log nor branch causes the segfault.

[System Info]
git version:
git version 2.45.1
cpu: x86_64
no commit associated with this build
sizeof-long: 8
sizeof-size_t: 8
shell-path: /bin/sh
uname: Linux 6.7.3-arch1-1 #1 SMP PREEMPT_DYNAMIC Thu, 01 Feb 2024
10:30:35 +0000 x86_64
compiler info: gnuc: 14.1
libc info: glibc: 2.39
$SHELL (typically, interactive shell): /bin/bash

[Enabled Hooks]

Best,
Jake Roggenbuck