Added a script to generate android patches from mainline.
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 13 Feb 2012 07:10:46 +0000 (23:10 -0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 13 Feb 2012 07:10:46 +0000 (23:10 -0800)
Use with care.

scripts/android_patch_generation.pl [new file with mode: 0755]

diff --git a/scripts/android_patch_generation.pl b/scripts/android_patch_generation.pl
new file mode 100755 (executable)
index 0000000..f20003f
--- /dev/null
@@ -0,0 +1,53 @@
+#!/usr/bin/perl -w
+
+
+
+$start = shift;
+$end = shift;
+
+if (($start eq "") || ($end eq "")) {
+       print "Error, must provide 2 git ids to generate patches between\n";
+       die;
+}
+
+open GIT, "git rev-list --no-merges --reverse $start..$end drivers/staging/android/ | " || die "can't run git";
+
+my $commit;
+my $patch_num = 0;
+my $patch_string;
+my $git_filename;
+my $filename;
+my $line;
+
+
+while (<GIT>) {
+       my $header_complete = "false";
+       $patch_num++;
+       $patch_string = sprintf("%.4d", $patch_num);
+       my @arr = split;
+       $commit = $arr[0];
+
+       $git_filename = `git show --pretty=format:%f $commit | head -n 1`;
+       chomp($git_filename);
+
+       $filename = sprintf("android-%.4d-%.60s.patch", $patch_num, $git_filename);
+
+       open FILE, ">$filename" || die "Failed to create $filename";
+       print "$filename\n";
+
+       open PATCH, "git show --pretty=email $commit |" || die "Could not get commit $commit";
+       while ($line = <PATCH>) {
+               $line =~ s/^Subject: \[PATCH\]/Subject:/;
+
+               if ($header_complete eq "false") {
+                       if ($line eq "\n") {
+                               print FILE "Patch-mainline: $end\n";
+                               print FILE "Git-commit: $commit\n";
+                               $header_complete = "true";
+                       }
+               }
+               print FILE $line;
+       }
+       close PATCH;
+       close FILE;
+}