# Automatically generated commit information
# Only edit if you know what these do!
-../systemd-stable v229-stable c7f5a7d89 x x
-../systemd-stable v231-stable 33628598e x x
-../systemd-stable v232-stable 79a5d862a x x
-../systemd-stable v233-stable 589fa9087 x x
-../systemd-stable v234-stable 782c925f7 x x
-../systemd-stable v235-stable b3e823e43 x x
-../systemd-stable v236-stable b3e823e43 x x
-../systemd-upstream master 265710c20 src-efaa3176a x
-../systemd-upstream v234 d6d0473dc src-782c925f7 x
-../systemd-upstream v236 83fefc888 src-f78a88bec x
-../systemd-upstream v237 590171d1c src-6d8c71eb8 x
+../systemd-stable v229-stable c7f5a7d89 x x
+../systemd-stable v231-stable 33628598e x x
+../systemd-stable v232-stable 79a5d862a x x
+../systemd-stable v233-stable 589fa9087 x x
+../systemd-stable v234-stable 782c925f7 x x
+../systemd-stable v235-stable b3e823e43 x x
+../systemd-stable v236-stable b3e823e43 x x
+../systemd-upstream master 265710c20 src-efaa3176a x
+../systemd-upstream v234 d6d0473dc src-782c925f7 x
+../systemd-upstream v236 83fefc888 src-f78a88bec x
+../systemd-upstream v237 a327431bd src-6d8c71eb8 tgt-af44d5dfa
# 0.1.0 2018-05-14 sed, PrydeWorX Application of the reworked patches added.
# 0.2.0 2018-05-15 sed, PrydeWorX First working version.
# 0.2.1 Fixed usage of Try::Tiny.
+# 0.2.2 2018-05-16 sed, PrydeWorX Made sure that the commit file is always written on exit.
#
# ========================
# === Little TODO list ===
# ================================================================
# === ==> ------ Help Text and Version ----- <== ===
# ================================================================
-Readonly my $VERSION => "0.2.0"; # Please keep this current!
+Readonly my $VERSION => "0.2.2"; # Please keep this current!
Readonly my $VERSMIN => "-" x length($VERSION);
Readonly my $PROGDIR => dirname($0);
Readonly my $PROGNAME => basename($0);
sub wanted; # Callback function for File::Find
# set signal-handlers
-$SIG{'INT'} = \&handle_sig;
-$SIG{'QUIT'} = \&handle_sig;
-$SIG{'TERM'} = \&handle_sig;
+local $SIG{'INT'} = \&handle_sig;
+local $SIG{'QUIT'} = \&handle_sig;
+local $SIG{'TERM'} = \&handle_sig;
# ================================================================
# === ==> -------- Prechecks -------- <== ==
show_prg( sprintf("Reworking %s", basename( $lFiles[0] ) ) );
rework_patch( $lFiles[0] ) or exit 1;
+ # If the patch was eventually empty, rework_patch() has deleted it.
+ -f $lFiles[0] or next;
+
# -------------------------------------------------------------
# --- 5) Reworked patches must be applied directly. ---
# --- Otherwise we'll screw up if a newly created file ---
show_prg( sprintf("Applying %s (2nd try)", basename($pFile) ) );
$result = 0;
};
- $result and return $result;
- # --- 3) Try to apply the patch without 3-way-merging ---
- # ---------------------------------------------------------------
- try {
- @lGitRes = $git->am( {
- -STDIN => $patch_lines
- } );
- $result = 1;
- } catch {
- $git->am( { "abort" => 1 } );
- print "\nERROR: Couldn't apply $pFile\n";
- print "Exit Code : " . $_->status . "\n";
- print "Message : " . $_->error . "\n";
- };
- $result or return $result; ## Give up and exit
+ if (0 == $result) {
+ # --- 3) Try to apply the patch without 3-way-merging ---
+ # ---------------------------------------------------------------
+
+ try {
+ @lGitRes = $git->am( {
+ -STDIN => $patch_lines
+ } );
+ $result = 1;
+ } catch {
+ $git->am( { "abort" => 1 } );
+ print "\nERROR: Couldn't apply $pFile\n";
+ print "Exit Code : " . $_->status . "\n";
+ print "Message : " . $_->error . "\n";
+ };
+ $result or return $result; ## Give up and exit
+ }
# --- 4) Get the new commit id, so we can update %hMutuals ---
# ---------------------------------------------------------------
# The commit of the just applied patch file becomes the last mutual commit.
$hMutuals{$upstream_path}{$wanted_refid}{mutual}
= shorten_refid($upstream_path, $hSrcCommits{$pFile});
+ length($hMutuals{$upstream_path}{$wanted_refid}{mutual}) or return 0; # Give up and exit
return $result;
} ## end sub apply_patch
sub handle_sig {
my($sig) = @_;
print "\nCaught SIG${sig}!\n";
- set_last_mutual;
exit 1;
}
# The determination what is valid is different for whether this is
# the modification of an existing or the creation of a new file
if ($isNew) {
- defined( $hDirectories{ dirname($src) } ) and $real = $src;
+ defined( $hDirectories{ dirname($src) } ) and $real = $src or
defined( $hDirectories{ dirname($tgt) } ) and $real = $tgt;
} else {
length($pNew) and push @lFixedPatches, $pNew or return 0;
# If we are here, transfer the file line. It is useful.
+ $line =~ s/$src/$real/;
push @lOut, $line;
} ## End of scanning lines
- scalar @lFixedPatches or return 1;
+ if ( 0 == scalar @lFixedPatches) {
+ unlink $pFile; ## Empty patch...
+ return 1;
+ }
# Load all generated patches and add them to lOut
# ----------------------------------------------------------
sub set_last_mutual {
my $out_text = "# Automatically generated commit information\n"
. "# Only edit if you know what these do!\n\n";
- my $ref_len = 0;
+ my ($pLen, $rLen, $mLen, $sLen) = (0, 0, 0, 0); # Length for the fmt
# First we need a length to set all fields to.
# ---------------------------------------------------------------
# (And build a shortcut while at it so we do ...
for my $path (sort keys %hMutuals) {
- length($path) > $ref_len and $ref_len = length($path);
+ length($path) > $pLen and $pLen = length($path);
for my $refid (sort keys %{$hMutuals{$path}}) {
my $hM = $hMutuals{$path}{$refid}; # Shortcut!
- length($refid) > $ref_len and $ref_len = length($refid);
- length($hM->{mutual}) > $ref_len and $ref_len = length($hM->{mutual});
- defined($hM->{src}) and length($hM->{src})
+ length($refid) > $rLen and $rLen = length($refid);
+ length($hM->{mutual}) > $mLen and $mLen = length($hM->{mutual});
+ defined($hM->{src}) and (length($hM->{src}) > 4)
and $hM->{src} = "src-" . $hM->{src}
or $hM->{src} = "x";
- length($hM->{src}) > $ref_len and $ref_len = length($hM->{src});
- defined($hM->{tgt}) and length($hM->{tgt})
+ length($hM->{src}) > $sLen and $sLen = length($hM->{src});
+ defined($hM->{tgt}) and (length($hM->{tgt}) > 4)
and $hM->{tgt} = "tgt-" . $hM->{tgt}
or $hM->{tgt} = "x";
- length($hM->{tgt}) > $ref_len and $ref_len = length($hM->{tgt});
}
}
# Now we can build the fmt
- my $out_fmt = sprintf("%%-%ds %%-%ds %%-%ds %%-%ds %%s\n", $ref_len, $ref_len, $ref_len, $ref_len);
+ my $out_fmt = sprintf("%%-%ds %%-%ds %%-%ds %%-%ds %%s\n", $pLen, $rLen, $mLen, $sLen);
# Second we build the out text
# ---------------------------------------------------------------