From 8aac47a81cf0949282d761a607b44c589b941fe2 Mon Sep 17 00:00:00 2001 From: Fontrodona Nicolas <nicolas.fontrodona@ens-lyon.fr> Date: Wed, 8 Jun 2022 17:47:13 +0200 Subject: [PATCH] src/diff.rs: add a diff subcommand to compute the difference between two commits --- src/diff.rs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 src/diff.rs diff --git a/src/diff.rs b/src/diff.rs new file mode 100644 index 0000000..07f5480 --- /dev/null +++ b/src/diff.rs @@ -0,0 +1,18 @@ +use crate::checkout; +use crate::commit; + +pub fn compute_diff(commit1: &str, commit2: &Option<String>) { + let (borg_path, _) = commit::check_path(); + match commit2 { + Some(c2) => { + checkout::is_diff(commit1, c2, &borg_path); + } + None => { + // Create an archive with the content of the current commit + let tmp_name = format!("{}-tmp", commit1); + checkout::silent_commit(String::from("none"), tmp_name.clone(), false); + checkout::is_diff(&commit1, &tmp_name, &borg_path); + commit::delete_commit(&tmp_name, &borg_path); + } + } +} -- GitLab