Skip to content

Commit

Permalink
microrefactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
demidko committed Apr 4, 2024
1 parent 4d4df97 commit e564e8e
Showing 1 changed file with 1 addition and 8 deletions.
9 changes: 1 addition & 8 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,13 @@ fn main() {
let help = "Usage: archdiff [OLD_BRANCH] [NEW_BRANCH]";
let old_branch = args().nth(1).expect(help);
let new_branch = args().nth(2).expect(help);
let repo = open_current_repo();
let repo = Repository::open(".").unwrap();
let diff = diff_branches(&repo, &old_branch, &new_branch);
let mut printer = DiffPrinter::new();
diff.print(Patch, |d, h, l| print_diff_line(d, h, l, &mut printer)).unwrap();
printer.flush();
}

fn open_current_repo() -> Repository {
match Repository::open(".") {
Ok(repo) => repo,
Err(e) => panic!("Failed to open repo: {}", e.message())
}
}

fn diff_branches<'a>(repo: &'a Repository, old_branch: &str, new_branch: &str) -> Diff<'a> {
let old_obj = make_tree_object(repo, old_branch);
let old_tree = old_obj.as_tree();
Expand Down

0 comments on commit e564e8e

Please sign in to comment.