Skip to content

Commit

Permalink
fix(pack-create): don't include submodules in count… (#67)
Browse files Browse the repository at this point in the history
…to avoid dealing with missing objects.

It's still a good idea to handle these gracefully though, git itself
seems to ignore them.
  • Loading branch information
Byron committed Sep 22, 2021
1 parent 60c9fad commit faf6f81
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion git-pack/src/data/output/count/objects/tree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<ObjectId>,
Expand Down Expand Up @@ -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);
Expand All @@ -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<ObjectId>,
Expand Down Expand Up @@ -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());
Expand Down

0 comments on commit faf6f81

Please sign in to comment.