Skip to content

Commit 946b66a

Browse files
committed
Allow sourcing from a higher-level spec.
1 parent 09ddf6f commit 946b66a

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

bin/xcommit.pl

+10-8
Original file line numberDiff line numberDiff line change
@@ -39,30 +39,32 @@
3939
$sourcedir =~ m#(.*)/([^/]+)-([\d+])$#;
4040
my $rootdir = $1;
4141
my $specname = $2;
42-
my $speclevel = $3;
42+
my $sourcelevel = $3;
4343
my @failed = ();
4444

4545
# confirm before continuing
46-
print "Sourcing diffs from $specname level $speclevel under root $rootdir:\n";
46+
print "Sourcing diffs from $specname level $sourcelevel under root $rootdir:\n";
4747
chdir $rootdir;
4848
$_ = `ls -d $specname-*`;
4949
my @dirlist = split;
5050
print "Matching specs: @dirlist\n";
5151

52-
print "Press enter to continue, q to quit:";
52+
# ask what levels to patch
53+
print "Press enter to patch levels higher than $sourcelevel, q to quit, or an integer for a different lowest level to patch:\n";
5354
$_ = <STDIN>;
5455
chomp;
55-
exit if ($_);
56+
exit if ($_ && $_ == undef); # abort if any value other than a number
57+
my $minlevel = $_ || $sourcelevel;
5658

5759
# main patching loop
5860
foreach (@dirlist) {
5961
/(\d+)$/;
6062
my $level = $1;
61-
if ($level > $speclevel) {
63+
if (($level >= $minlevel) && ($level != $sourcelevel)) {
6264
print "\nPatching $_ ...\n";
6365
chdir $_;
64-
print `git diff $sourcedir | patch -p2`;
65-
push @failed, $specname . '-' . $speclevel if $?;
66+
print `git diff -U3 --minimal $sourcedir | patch -p2`;
67+
push @failed, $specname . '-' . $level if $?;
6668
chdir $rootdir;
6769
}
6870
}
@@ -81,5 +83,5 @@
8183
}
8284
}
8385
else {
84-
die "Patching failed for @failed, please fix and commit manually.\n";
86+
die "\n\nPatching failed for @failed, please fix and commit manually.\n";
8587
}

0 commit comments

Comments
 (0)