Commit d248161e authored by Robert Ricci's avatar Robert Ricci Committed by Ryan Jackson

Add functions to filter out objects that exist in another repository.

parent 63525f01
......@@ -190,6 +190,8 @@ sub send_mail($$@);
sub short_refname($);
sub debug(@);
sub rev_string($$);
sub object_exists($$);
sub filter_out_objects_in_repo($@);
######################################################################
# Main Body
......@@ -772,3 +774,32 @@ sub rev_string($$) {
return undef;
}
}
#
# Returns 1 if the given object (identified by hash) exists in the given
# repository (identified by path); 0 if it does not .
#
sub object_exists($$) {
my ($obj, $repo) = @_;
#
# 'cat-file -e' is like 'test -e', and don't be fooled by the name, it
# works on non-files too
#
debug("running $GIT --git-dir='$repo' cat-file -e $obj");
my $rv = system "$GIT --git-dir='$repo' cat-file -e $obj";
if ($rv) {
return 0;
} else {
return 1;
}
}
#
# Return a list of all objects from the input list that do *not* exist in
# the given repo
#
sub filter_out_objects_in_repo($@) {
my $repo = shift @_;
return grep { !object_exists($_,$repo)} @_;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment