summaryrefslogtreecommitdiff
path: root/git-debrebase
diff options
context:
space:
mode:
authorIan Jackson <ijackson@chiark.greenend.org.uk>2018-01-23 15:19:33 +0000
committerIan Jackson <ijackson@chiark.greenend.org.uk>2018-06-16 12:25:49 +0100
commitc0e4a8e072c2b133c5aa27a9636ce97521ad3ebf (patch)
treea19eac5253d588287799a61d0ed2eaff4db96280 /git-debrebase
parent747c6f2eaf1929665a4c19ad4654bba0790b9e01 (diff)
git-debrebase: break out parsecommit
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
Diffstat (limited to 'git-debrebase')
-rwxr-xr-xgit-debrebase34
1 files changed, 26 insertions, 8 deletions
diff --git a/git-debrebase b/git-debrebase
index 5808cf3..62fbc4d 100755
--- a/git-debrebase
+++ b/git-debrebase
@@ -285,31 +285,49 @@ sub calculate_committer_authline () {
# has additional entry in classification result
# OrigParents = [ subset of Parents ] # singleton list
-sub classify ($) {
- my ($objid) = @_;
+sub parsecommit ($;$) {
+ my ($objid, $p_ref) = @_;
+ # => hash with CommitId Hdr Msg Tree Parents
+ # Parents entries have only Ix CommitId
+ # $p_ref, if provided, must be [] and is used as a base for Parents
+
+ $p_ref //= [];
+ die if @$p_ref;
my ($h,$m) = get_commit $objid;
my ($t) = $h =~ m/^tree (\w+)$/m or die $objid;
my (@ph) = $h =~ m/^parent (\w+)$/mg;
- my @p;
my $r = {
CommitId => $objid,
Hdr => $h,
Msg => $m,
Tree => $t,
- Parents => \@p,
+ Parents => $p_ref,
};
foreach my $ph (@ph) {
- push @p, {
- Ix => $#p,
+ push @$p_ref, {
+ Ix => $#$p_ref,
CommitId => $ph,
- Differs => (get_differs $ph, $t),
};
}
+ return $r;
+}
+
+sub classify ($) {
+ my ($objid) = @_;
+
+ my @p;
+ my $r = parsecommit($objid, \@p);
+ my $t = $r->{Tree};
+
+ foreach my $p (@p) {
+ $p->{Differs} => (get_differs $p->{CommitId}, $t),
+ }
+
printdebug "classify $objid \$t=$t \@p",
(map { sprintf " %s/%#x", $_->{CommitId}, $_->{Differs} } @p),
"\n";
@@ -389,7 +407,7 @@ sub classify ($) {
($p->{IsDgitImport},) = $p_m =~ m/^\[dgit import ([0-9a-z]+) .*\]$/m;
}
my @orig_ps = grep { ($_->{IsDgitImport}//'X') eq 'orig' } @p;
- my $m2 = $m;
+ my $m2 = $r->{Msg};
if (!(grep { !$_->{IsOrigin} } @p) and
(@orig_ps >= @p - 1) and
$m2 =~ s{^\[(dgit import unpatched .*)\]$}{[was: $1]}m) {