From 71e3d9a9b85eb271e7bf5dd1be8bcb09880ab39e Mon Sep 17 00:00:00 2001 From: Stephan Dilly Date: Wed, 11 Aug 2021 13:13:44 +0200 Subject: [PATCH] get_commit_diff on commit with unknown parent (#836) --- CHANGELOG.md | 1 + asyncgit/src/sync/commit_files.rs | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d7cb6751..d5eb2b44 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## Fixed - do not allow to ignore .gitignore files ([#825](https://github.com/extrawurst/gitui/issues/825)) +- crash in shallow repo ([#836](https://github.com/extrawurst/gitui/issues/836)) ## [0.16.2] - 2021-07-10 diff --git a/asyncgit/src/sync/commit_files.rs b/asyncgit/src/sync/commit_files.rs index 70c3afe3..ca9a1224 100644 --- a/asyncgit/src/sync/commit_files.rs +++ b/asyncgit/src/sync/commit_files.rs @@ -49,7 +49,9 @@ pub(crate) fn get_commit_diff( let commit = repo.find_commit(id.into())?; let commit_tree = commit.tree()?; let parent = if commit.parent_count() > 0 { - Some(repo.find_commit(commit.parent_id(0)?)?.tree()?) + repo.find_commit(commit.parent_id(0)?) + .ok() + .and_then(|c| c.tree().ok()) } else { None };