# git_ui: Fix history tab empty and detached HEAD states \(\#57959\) · gitcafe/zed

[View on GitCafe](https://git.cafe/gitcafe/zed/commit/35ffa8f480838257ae9650027cb9847505a0882b)

Repository: [gitcafe/zed](https://git.cafe/gitcafe/zed)

Visibility: public

Requested revision: 35ffa8f480838257ae9650027cb9847505a0882b

Requested commit: 35ffa8f480838257ae9650027cb9847505a0882b

Commit: 35ffa8f480838257ae9650027cb9847505a0882b

Tree: ba71624d4f76d40fb21203919670055ed9a35523

Author: Revantark

Committer: GitHub

## Message

```
git_ui: Fix history tab empty and detached HEAD states (#57959)

This PR fixes a few History tab edge cases in the Git Panel.

For a fresh repo with no commits, the History tab now finishes loading
and shows No commits yet instead
of sitting on Loading… indefinitely or falling into a misleading
empty/error state.

It also fixes detached HEAD history loading. In that case, the Git Panel
asks the backend to load history
from the current commit SHA. The local git backend was accidentally
treating the raw object ID bytes as a
string instead of formatting them as a normal hex SHA, so git log could
fail before returning any
commits. The backend now passes the SHA in the format git expects.

**Repro for empty repo:**

mkdir /tmp/zed-empty-history
cd /tmp/zed-empty-history
git init
zed .

Open Git Panel → History.

Before: History could stay stuck on Loading….
After: History shows No commits yet.

**Repro for detached HEAD:**

mkdir /tmp/zed-detached-history
cd /tmp/zed-detached-history
git init
echo hi > file
git add file
git commit -m initial
git checkout --detach HEAD
zed .

Open Git Panel → History.

Before: History could fail to load commits.
After: History shows the commit history normally.




Self-Review Checklist:

- [x] I've reviewed my own diff for quality, security, and reliability
- [x] Unsafe blocks (if any) have justifying comments
- [x] The content is consistent with the [UI/UX
checklist](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist)
- [x] Tests cover the new/changed behavior
- [x] Performance impact has been considered and is acceptable


Release Notes:

- Fixed Git history tab states for empty repositories and detached HEAD
history.

Co-authored-by: Smit Barmase <heysmitbarmase@gmail.com>
```

## Parents

- [d8c8040462c50f5fc43ef263da4cc8b753f718e1](https://git.cafe/gitcafe/zed/commit/d8c8040462c50f5fc43ef263da4cc8b753f718e1?format=markdown)

[Source at this commit](https://git.cafe/gitcafe/zed/tree/35ffa8f480838257ae9650027cb9847505a0882b?format=markdown)
