#!/usr/bin/perl -W # # convert git commit id to a pretty patch we can apply to the stable tree # # Written in perl because the bash version is broken, it doesn't pass # through the patch correctly :( # my $base_id = ""; my $line; my $firstline = "true"; my $git_id; my $header_complete = "false"; my $tmpfile; $numArgs = $#ARGV + 1; if ($numArgs != 1) { print "must provide git id\n"; exit; } $base_id = shift; if ($base_id eq "") { print "must provide git id\n"; exit; } #print "handing commit id $base_id\n"; $tmpfile = `mktemp patch.XXXXX` || die "Failed to run mktemp"; chomp($tmpfile); $from = `git show --pretty=email $base_id | head -n 2 | grep "From: "` || die "Failed to run git"; open FILE, ">$tmpfile" || die "Failed to create $tmpfile"; open GIT, "git show --pretty=email $base_id |" || die "Failed to run git"; while ($line = ) { $line =~ s/^Subject: \[PATCH\]/Subject:/; # if (($line =~ m/^diff --git/) { print FILE $line; # } if ($firstline eq "true") { my @from = split(/ /, $line); $git_id = $from[1]; #print "git_id = $git_id\n"; $firstline = "false"; } if ($header_complete eq "false") { if ($line eq "\n") { print FILE "$from\n"; print FILE "commit $git_id upstream.\n\n"; $header_complete = "true"; } } } close GIT; close FILE; #print "$tmpfile\n"; system "vim $tmpfile"; system "reset"; $new_file = `rename-patch $tmpfile`; chomp($new_file); system "mv $new_file ~/linux/stable/"; #print "moved $new_file to ~/linux/stable/\n"; system "cd ~/linux/stable && ./apply_it $new_file"; system "cp ~/linux/stable/$new_file ~/linux/longterm"; system "cd ~/linux/longterm && ./apply_it $new_file"; #TMPFILE1=`mktemp patch.XXXXXX` || exit 1 #TMPFILE2=`mktemp patch.XXXXXX` || exit 1 # #GIT_ID=`git show $COMMIT_ID | head -n 1 | cut -f 2 -d ' '` #FROM=`git show --pretty=email $COMMIT_ID | head -n 2 | grep "From: "` # #git show --pretty=email $COMMIT_ID > $TMPFILE1 # #HEADER_COMPLETE=false #while read line #do # # Strip out the [PATCH] portion of the subject line, it's annoying. # new=`echo "$line" | sed -e 's/^Subject: \[PATCH\]/Subject:/g'` # # # copy the line out to the new file # echo "$new" >> $TMPFILE2 # # # add our special text (author and git id) right before # # the changelog text happens. # if [ "$line" == "" ] ; then # if [ $HEADER_COMPLETE == false ] ; then # echo "$FROM" >> $TMPFILE2 # echo "" >> $TMPFILE2 # echo "commit $GIT_ID upstream." >> $TMPFILE2 # echo "" >> $TMPFILE2 # HEADER_COMPLETE=true # fi # fi #done < $TMPFILE1 #rm $TMPFILE1 #vim $TMPFILE2 #PATCH=`rename-patch $TMPFILE2` #mv $PATCH ~/linux/stable/ # #echo "moved $PATCH to ~/linux/stable/" #