@@ -90,9 +90,27 @@ sub stitch {
9090
9191 # initiate the Git::FastExport stream
9292 my $stream =
93- $export -> command(qw( fast-export --progress=1 --all --date-order ) )
93+ $export -> command(split " " , " fast-export -M -C --all --date-order --export-marks=/tmp/marks- $name " )
9494 -> stdout;
9595
96+ # Force fast-export to finish by dumping everything to memory.
97+ # This ensures that the export-marks file is written, so we can read it.
98+ my $dump_content = do { local $/ ; <$stream > };
99+ close ($stream );
100+ open ($stream , ' <' , \$dump_content );
101+
102+ my %mark_hashes ;
103+ open (FILE, " /tmp/marks-$name " );
104+ while (<FILE>) {
105+ chomp ;
106+ my @entry = split / /, $_ ;
107+ $mark_hashes {substr ($entry [0],1)} = $entry [1];
108+ }
109+ $self -> {repo }{$repo }{mark_hashes } = \%mark_hashes ;
110+
111+ close (FILE);
112+ unlink (" /tmp/marks-$name " );
113+
96114 # set up the internal structures
97115 $self -> {repo }{$repo }{repo } = $repo ;
98116 $self -> {repo }{$repo }{dir } = $dir ;
@@ -162,6 +180,17 @@ sub next_block {
162180
163181 # mark our original source
164182 $commit -> {header } =~ s / $/ -$repo ->{name}/ ;
183+ my @comment = split /\n/, $commit -> {data };
184+ # Insert an additional blank line to separate the original ID if the commit
185+ # has a description body.
186+ if (@comment > 1) { push @comment , " " ; }
187+ $commit -> {data } = join " \n " , @comment ;
188+
189+ if ($repo -> {name } ne " root" ) {
190+ $commit -> {data } =
191+ " [$repo ->{name}] " . $commit -> {data } . " \n Original commit:\n " .
192+ $repo -> {mark_hashes }{$commit -> {original_mark }}." \n " ;
193+ }
165194
166195 # this commit's parents
167196 my @parents = map {/ :(\d +)/g } @{ $commit -> {from } || [] },
@@ -219,6 +248,7 @@ sub _translate_block {
219248 for ( @{ $block -> {mark } || [] } ) {
220249 s / :(\d +)/ :$self ->{mark}/ ;
221250 $mark_map -> {$repo }{$1 } = $self -> {mark }++;
251+ $block -> {original_mark } = $1 ;
222252 }
223253
224254 # update marks in from & merge
0 commit comments