From fda8f0f8ad669b10a0a9fc5839d8fc877c949730 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Wed, 12 Feb 2025 19:11:14 +0000 Subject: [PATCH] Bug 39114: The auto-rebase script - Fix files removal It's using `$git->rm($file)` but this does not work. Test plan: git checkout HEAD~100 (so you are before 38664) git rm mainpage.pl edit C4/Auth.pm and make some changes git commit -a --no-verify -m"Bug 12345: test" then rebase your branch Retrieve the auto_rebase.pl version from this patch and run it perl auto_rebase.pl The resulted commit should not contain mainpage.pl --- misc/devel/auto_rebase.pl | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/misc/devel/auto_rebase.pl b/misc/devel/auto_rebase.pl index 3dd01c4d253..120306e0531 100755 --- a/misc/devel/auto_rebase.pl +++ b/misc/devel/auto_rebase.pl @@ -152,19 +152,20 @@ FILE: while ( my ( $ii, $file ) = each @modified_files ) { say BLUE sprintf "\t\tProcessing file %s... (%s/%s)", $file, $ii + 1, scalar @modified_files; # Retrieve the content of the file from this commit - my @content = try { + my $file_was_deleted = 0; + my @content = try { $git->RUN( "show", "$commit:$file" ); } catch { if ( $_->error =~ m{fatal: path '.*' exists on disk, but not in '$commit'} ) { say BLUE "\t\t\tFile does not exist, removing..."; - $git->rm($file); + $file_was_deleted = 1; } else { say RED "Something wrong happened when retrieving the file from the branch."; exit 2; } }; - next unless @content; # We removed the file + next if !@content || $file_was_deleted; # We removed the file my $parent_directory = dirname($file); unless ( -f $parent_directory ) { -- 2.34.1