# --- T2-COPYRIGHT-NOTE-BEGIN --- # T2 SDE: package/*/git/svn-messages-prog.patch # Copyright (C) 2024 The T2 SDE Project # # This Copyright note is generated by scripts/Create-CopyPatch, # more information can be found in the files COPYING and README. # # This patch file is dual-licensed. It is available under the license the # patched project is licensed under, as long as it is an OpenSource license # as defined at http://www.opensource.org/ (e.g. BSD, X11) or under the terms # of the GNU General Public License version 2 as used by the T2 SDE. # --- T2-COPYRIGHT-NOTE-END --- https://stackoverflow.com/questions/10764746/how-to-modify-commit-messages-when-converting-from-svn-to-git --- git-2.45.2/perl/Git/SVN.pm.vanilla 2024-06-17 11:21:39.989933253 +0200 +++ git-2.45.2/perl/Git/SVN.pm 2024-06-17 11:31:23.862909973 +0200 @@ -9,6 +9,7 @@ $_use_log_author $_add_author_from $_localtime $_use_fsync/; use Carp qw/croak/; use File::Path qw/mkpath/; +use IPC::Open2; use IPC::Open3; use Memoize; # core since 5.8.0, Jul 2002 use POSIX qw(:signal_h); @@ -1473,6 +1474,22 @@ $gs } +sub call_messages_prog { + my ($orig_message) = @_; + my ($pid, $in, $out); + + $pid = open2($in, $out, $::_messages_prog) + or die "$::_messages_prog failed with exit code $?\n"; + print $out $orig_message; + close($out); + my ($message) = ""; + while (<$in>) { + $message .= $_; + } + close($in); + return $message; +} + sub call_authors_prog { my ($orig_author) = @_; $orig_author = command_oneline('rev-parse', '--sq-quote', $orig_author); @@ -1973,6 +1990,9 @@ $log_entry{date} = parse_svn_date($log_entry{date}); $log_entry{log} .= "\n"; + if (defined $::_messages_prog) { + $log_entry{log} = call_messages_prog($log_entry{log}); + } my $author = $log_entry{author} = check_author($log_entry{author}); my ($name, $email) = defined $::users{$author} ? @{$::users{$author}} : ($author, undef); --- git-2.45.2/git-svn.perl.vanilla 2024-05-31 02:43:41.000000000 +0200 +++ git-2.45.2/git-svn.perl 2024-06-17 11:10:55.627958946 +0200 @@ -7,7 +7,7 @@ use vars qw/ $AUTHOR $VERSION $oid $oid_short $oid_length $_revision $_repository - $_q $_authors $_authors_prog %users/; + $_q $_authors $_authors_prog $_messages_prog %users/; $AUTHOR = 'Eric Wong '; $VERSION = '@@GIT_VERSION@@'; @@ -130,6 +130,7 @@ my %fc_opts = ( 'follow-parent|follow!' => \$Git::SVN::_follow_parent, 'authors-file|A=s' => \$_authors, 'authors-prog=s' => \$_authors_prog, + 'messages-prog=s' => \$_messages_prog, 'repack:i' => \$Git::SVN::_repack, 'noMetadata' => \$Git::SVN::_no_metadata, 'useSvmProps' => \$Git::SVN::_use_svm_props, @@ -364,6 +365,11 @@ $_authors_prog = "'" . $abs_file . "'" if -x $abs_file; } +if (defined $_messages_prog) { + my $abs_file = File::Spec->rel2abs($_messages_prog); + $_messages_prog = "'" . $abs_file . "'" if -x $abs_file; +} + unless ($cmd =~ /^(?:clone|init|multi-init|commit-diff)$/) { Git::SVN::Migration::migration_check(); }