diff --git a/src/command/maintenance.rs b/src/command/maintenance.rs index 29e63b33b..00fa97d15 100644 --- a/src/command/maintenance.rs +++ b/src/command/maintenance.rs @@ -59,6 +59,12 @@ const MAINTENANCE_LAST_RUN_KEY: &str = "maintenance.last-run"; const DEFAULT_LOOSE_OBJECT_THRESHOLD: usize = 100; const DEFAULT_PACK_COUNT_THRESHOLD: usize = 5; const LOOSE_OBJECT_AGE_SECONDS: u64 = 14 * 24 * 60 * 60; // 2 weeks +/// Grace period before an unreachable loose object may be deleted by `gc`. +/// +/// This protects concurrent commands (add/commit/fetch/hash-object) that have +/// just written objects but not yet updated refs/reflogs/index. Objects newer +/// than this grace period are left in place even when unreachable. +const GC_PRUNE_GRACE_SECONDS: u64 = 60 * 60; // 1 hour /// `--help` examples shown in `libra maintenance --help` output. pub const MAINTENANCE_EXAMPLES: &str = "\ diff --git a/src/command/stash.rs b/src/command/stash.rs index c7ceb5469..95ecbc8e4 100644 --- a/src/command/stash.rs +++ b/src/command/stash.rs @@ -340,7 +340,11 @@ async fn run_push(options: StashPushOptions) -> Result let index_tree = tree::create_tree_from_index(&index).map_err(|e| StashError::WriteObject(e.to_string()))?; - let index_tree_hash = index_tree.id; + let index_tree_data = index_tree + .to_data() + .map_err(|e| StashError::WriteObject(e.to_string()))?; + let index_tree_hash = object::write_git_object(&git_dir, "tree", &index_tree_data) + .map_err(|e| StashError::WriteObject(e.to_string()))?; let (author, committer) = util::create_signatures().await; let (current_branch_name, head_commit_summary) = match Head::current().await {