mygit

[UNMAINTAINED] A cgit/webgit alternative, written in Rust
Log | Files | Refs | README | LICENSE

commit b73edd0d787e00e3d552040c1eeeb7b45bd223b4
parent 949458921497d379c0b8cbe8a6fc68243325e9c1
Author: Johann150 <johann@qwertqwefsday.eu>
Date:   Fri,  2 Apr 2021 15:32:24 +0200

show first commit correctly

Diffstat:
Msrc/main.rs | 7+++----
1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/src/main.rs b/src/main.rs @@ -413,10 +413,9 @@ async fn repo_commit(req: Request<()>) -> tide::Result { // This is identical to getting "commit^" and on merges this will be the // merged into branch before the merge. - let first_parent = commit.parent(0)?; - // TODO root commit - let mut diff = - repo.diff_tree_to_tree(Some(&first_parent.tree()?), Some(&commit.tree()?), None)?; + let parent_tree = commit.parent(0).ok().map(|parent| parent.tree().unwrap()); + + let mut diff = repo.diff_tree_to_tree(parent_tree.as_ref(), Some(&commit.tree()?), None)?; let mut find_options = git2::DiffFindOptions::new(); // try to find moved/renamed files find_options.all(true);