# git: Fix buffer diff crash that could occur during the stage all operation \(\#47265\) · gitcafe/zed

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

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

Visibility: public

Requested revision: 8c8639ffcce20547f6fee194b814caa5af20b9c6

Requested commit: 8c8639ffcce20547f6fee194b814caa5af20b9c6

Commit: 8c8639ffcce20547f6fee194b814caa5af20b9c6

Tree: 0ed41b4a73f60d0ad1654497cb55e24cc3cffacc

Author: Anthony Eid

Committer: GitHub

## Message

```
git: Fix buffer diff crash that could occur during the stage all operation (#47265)

Closes https://github.com/zed-industries/zed/issues/46519

This crash happened because we were incorrectly merging pending and
unstaged hunks together by always using the pending hunk end offset as
the merged hunk bound instead of the max of both hunks.

The fix is to use `max()` when updating `buffer_offset_range.end` during
pending hunk merging, matching the behavior used for unstaged hunk
merging.

Release Notes:

- N/A
```

## Parents

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

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