chiark / gitweb /
migrate_tree.pl: Call 'git am --abort' if it failed to apply.
authorSven Eden <yamakuzure@gmx.net>
Tue, 15 May 2018 06:22:08 +0000 (08:22 +0200)
committerSven Eden <yamakuzure@gmx.net>
Tue, 15 May 2018 06:22:08 +0000 (08:22 +0200)
pwx/migrate_tree.pl

index ea744c386761064b93199e8cade67b68f78463b0..02960963bee3b3809b45c703cc8fdade2c937a2e 100755 (executable)
@@ -265,15 +265,14 @@ sub apply_patch {
        # ---------------------------------------------------------------
        my $result = 1;
        try {
-               @lGitRes = $git->am(
-                       {
+               @lGitRes = $git->am( {
                                "3"    => 1,
-                               stdin  => 1,
                                -STDIN => $patch_lines
                        } );
        } catch {
                # We try again without 3-way-merging
-               show_prg( sprintf("Applying  %s (2nd try)"), basename($pFile) );
+               $git->am( { "abort" => 1 } );
+               show_prg( sprintf("Applying  %s (2nd try)", basename($pFile) ) );
                $result = 0;
        };
        $result and return $result;
@@ -281,13 +280,12 @@ sub apply_patch {
        # --- 3) Try to apply the patch without 3-way-merging         ---
        # ---------------------------------------------------------------
        try {
-               @lGitRes = $git->am(
-                       {
-                               stdin  => 1,
+               @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";