From: Dave O'Neill Date: Thu, 21 Jun 2007 02:14:55 GMT Subject: [PATCH] Let git-svnimport clean up SVK commit messages. Message-ID: <1182392095394-git-send-email-dmo@roaringpenguin.com> SVK likes to begin all commit messages with a line of the format: r12345@hostname: user | YYYY-MM-DD HH:MM:SS -ZZZZ which makes the import desperately ugly in git. This adds a -k option to move this extra SVK commit line to the end of the commit message, rather than keeping it at the beginning. --- Documentation/git-svnimport.txt | 6 +++++- git-svnimport.perl | 18 +++++++++++++++--- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/Documentation/git-svnimport.txt b/Documentation/git-svnimport.txt index e97d15e..23a54b0 100644 --- a/Documentation/git-svnimport.txt +++ b/Documentation/git-svnimport.txt @@ -11,7 +11,7 @@ SYNOPSIS -------- [verse] 'git-svnimport' [ -o ] [ -h ] [ -v ] [ -d | -D ] - [ -C ] [ -i ] [ -u ] [-l limit_rev] + [ -C ] [ -i ] [ -k ] [ -u ] [-l limit_rev] [ -b branch_subdir ] [ -T trunk_subdir ] [ -t tag_subdir ] [ -s start_chg ] [ -m ] [ -r ] [ -M regex ] [ -I ] [ -A ] @@ -68,6 +68,10 @@ When importing incrementally, you might need to edit the .git/svn2git file. Prepend 'rX: ' to commit messages, where X is the imported subversion revision. +-k:: + Remove SVK-style revision/commiter info from the top of commit + messages and move it to the bottom. + -I :: Import the svn:ignore directory property to files with this name in each directory. (The Subversion and GIT ignore diff --git a/git-svnimport.perl b/git-svnimport.perl index f459762..7076f41 100755 --- a/git-svnimport.perl +++ b/git-svnimport.perl @@ -32,20 +32,20 @@ $ENV{'TZ'}="UTC"; our($opt_h,$opt_o,$opt_v,$opt_u,$opt_C,$opt_i,$opt_m,$opt_M,$opt_t,$opt_T, $opt_b,$opt_r,$opt_I,$opt_A,$opt_s,$opt_l,$opt_d,$opt_D,$opt_S,$opt_F, - $opt_P,$opt_R); + $opt_P,$opt_R,$opt_k); sub usage() { print STDERR <writer(); $pr->reader(); + + if ( $opt_k ) { + # Remove SVK cruft in commit message + my ($svk_info) = $message =~ s{(r\d+\@[^:]+:\s+\S+\s+\|\s+\d{4}-\d{2}-\d{2}\s+\d{2}:\d{2}:\d{2}\s[\+-]\d{4})\s*}{}; + if( $svk_info ) { + # and stick it on the end so we don't lose it + $message .= "\n$svk_info" + } + } + + $message =~ s/[\s\n]+\z//; + $message = "r$revision: $message" if $opt_r; print $pw "$message\n" -- 1.5.2.2.239.g89630