Skip to content

Commit

Permalink
support arbitrary object IDs in --upstream
Browse files Browse the repository at this point in the history
  • Loading branch information
sxlijin committed Oct 13, 2022
1 parent 89e9d03 commit 8df2408
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/git.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use git2::{Delta, DiffOptions, Repository};
use git2::{Delta, DiffOptions, Oid, Repository};
use std::collections::HashSet;
use std::path::PathBuf;

Expand All @@ -21,7 +21,10 @@ pub struct NewOrModified {
pub fn modified_since(upstream: &str) -> anyhow::Result<NewOrModified> {
let repo = Repository::open(".")?;

let upstream_tree = repo.find_reference(upstream)?.peel_to_tree()?;
let upstream_tree = match repo.find_reference(upstream) {
Ok(reference) => reference.peel_to_tree()?,
_ => repo.find_object(Oid::from_str(upstream)?, None)?.peel_to_tree()?,
};

let diff = {
let mut diff_opts = DiffOptions::new();
Expand Down

0 comments on commit 8df2408

Please sign in to comment.