chiark / gitweb /
Break out remove_stray_gits
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Sun, 26 Jul 2015 21:20:24 +0000 (22:20 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Sun, 26 Jul 2015 21:25:41 +0000 (22:25 +0100)
dgit

diff --git a/dgit b/dgit
index 109f79c74ce6d6c178a2bceb8e10ef204cd6a598..31b08d3ea46a6e1ed90ab2b586ae63234d7c4cb4 100755 (executable)
--- a/dgit
+++ b/dgit
@@ -1139,14 +1139,7 @@ sub git_write_tree () {
     return $tree;
 }
 
-sub mktree_in_ud_from_only_subdir () {
-    # changes into the subdir
-    my (@dirs) = <*/.>;
-    die unless @dirs==1;
-    $dirs[0] =~ m#^([^/]+)/\.$# or die;
-    my $dir = $1;
-    changedir $dir;
-
+sub remove_stray_gits () {
     my @gitscmd = qw(find -name .git -prune -print0);
     debugcmd "|",@gitscmd;
     open GITS, "-|", @gitscmd or failedcmd @gitscmd;
@@ -1160,7 +1153,17 @@ sub mktree_in_ud_from_only_subdir () {
        }
     }
     $!=0; $?=0; close GITS or failedcmd @gitscmd;
+}
+
+sub mktree_in_ud_from_only_subdir () {
+    # changes into the subdir
+    my (@dirs) = <*/.>;
+    die unless @dirs==1;
+    $dirs[0] =~ m#^([^/]+)/\.$# or die;
+    my $dir = $1;
+    changedir $dir;
 
+    remove_stray_gits();
     mktree_in_ud_here();
     my $format=get_source_format();
     if (madformat($format)) {