chiark / gitweb /
git-debrebase: break out read_tree_subdir (nfc)
[dgit.git] / git-debrebase
index b27393802ba67e029d71473288b30fdb0180c1af..01595c45a116b333eb0cd4af55f66c5da4dc60c4 100755 (executable)
@@ -252,6 +252,17 @@ sub calculate_committer_authline () {
     return $&;
 }
 
+sub rm_subdir_cached ($) {
+    my ($subdir) = @_;
+    runcmd @git, qw(rm --quiet -rf --cached --ignore-unmatch), $subdir;
+}
+
+sub read_tree_subdir ($$) {
+    my ($subdir, $new_tree_object) = @_;
+    rm_subdir_cached $subdir;
+    runcmd @git, qw(read-tree), "--prefix=$subdir/";
+}
+
 # classify returns an info hash like this
 #   CommitId => $objid
 #   Hdr => # commit headers, including 1 final newline
@@ -635,14 +646,9 @@ sub walk ($;$$) {
 
     my $rewriting = 0;
 
-    my $rm_tree_cached = sub {
-       my ($subdir) = @_;
-       runcmd @git, qw(rm --quiet -rf --cached --ignore-unmatch), $subdir;
-    };
     my $read_tree_debian = sub {
        my ($treeish) = @_;
-       $rm_tree_cached->(qw(debian));
-       runcmd @git, qw(read-tree --prefix=debian/), "$treeish:debian";
+       read_tree_subdir 'debian', "$treeish:debian";
     };
     my $read_tree_upstream = sub {
        my ($treeish) = @_;
@@ -684,7 +690,7 @@ sub walk ($;$$) {
                next;
            } elsif ($method eq 'DgitImportDebianUpdate') {
                $read_tree_debian->($cltree);
-               $rm_tree_cached->(qw(debian/patches));
+               rm_subdir_cached qw(debian/patches);
            } elsif ($method eq 'DgitImportUpstreamUpdate') {
                $read_tree_upstream->($cltree);
                push @parents, map { $_->{CommitId} } @{ $cl->{OrigParents} };