From faf6f813927720c5adf62102f9ce46606ff2617c Mon Sep 17 00:00:00 2001 From: Sebastian Thiel Date: Wed, 22 Sep 2021 17:08:42 +0800 Subject: [PATCH] =?UTF-8?q?fix(pack-create):=20don't=20include=20submodule?= =?UTF-8?q?s=20in=20count=E2=80=A6=20(#67)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit …to avoid dealing with missing objects. It's still a good idea to handle these gracefully though, git itself seems to ignore them. --- git-pack/src/data/output/count/objects/tree.rs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/git-pack/src/data/output/count/objects/tree.rs b/git-pack/src/data/output/count/objects/tree.rs index 7026fb209e2..da512c88e42 100644 --- a/git-pack/src/data/output/count/objects/tree.rs +++ b/git-pack/src/data/output/count/objects/tree.rs @@ -7,6 +7,7 @@ pub mod changes { use git_object::bstr::BStr; use crate::data::output::count::objects_impl::util::InsertImmutable; + use git_object::tree::EntryMode; pub struct AllNew<'a, H> { pub objects: Vec, @@ -42,7 +43,10 @@ pub mod changes { fn visit(&mut self, change: Change) -> Action { match change { - Change::Addition { oid, .. } | Change::Modification { oid, .. } => { + Change::Addition { oid, entry_mode } | Change::Modification { oid, entry_mode, .. } => { + if entry_mode == EntryMode::Commit { + return Action::Continue; + } let inserted = self.all_seen.insert(oid); if inserted { self.objects.push(oid); @@ -61,6 +65,7 @@ pub mod traverse { use git_traverse::tree::{visit::Action, Visit}; use crate::data::output::count::objects_impl::util::InsertImmutable; + use git_object::tree::EntryMode; pub struct AllUnseen<'a, H> { pub non_trees: Vec, @@ -104,6 +109,10 @@ pub mod traverse { } fn visit_nontree(&mut self, entry: &EntryRef<'_>) -> Action { + if entry.mode == EntryMode::Commit { + // links don't have a representation + return Action::Continue; + } let inserted = self.all_seen.insert(entry.oid.to_owned()); if inserted { self.non_trees.push(entry.oid.to_owned());