5 # This is a quickie script which I wrote to generate the .patch file for
6 # an arbitrary commit. It takes on sha1 as an argument, or saving that
7 # uses the sha1 associated to HEAD.
8 # It tries to find which of our primary branches the sha1 can be found on,
9 # and then prints to standard out something similar to what our rsync feed
10 # would produce for that situation. The main difference being, in that case
11 # we KNOW what branch we are on, and in this one we dont, and in that case
12 # the $tstamp field holds the time the snapshot was generated (so that multiple
13 # fetches will always have an increasing tstamp field), however in this case
14 # we use the commit date of the sha1.
16 # This is more or less intended to be used as a utility to generated .patch
17 # files for other processes, like gitweb and snapshots.
19 # The script assumes it is being run from a git WD.
23 use POSIX qw(strftime);
24 sub isotime { strftime "%Y-%m-%d.%H:%M:%S",gmtime(shift||time) }
26 my $sha1= shift || `git rev-parse HEAD`;
32 'origin/maint-5.8-dor',
38 foreach my $b (@branches) {
40 if `git log --pretty='format:%H' $b | grep $sha1`;
43 $branch ||= "unknown-branch";
44 my $tstamp= isotime(`git log -1 --pretty="format:%ct" $sha1`);
45 chomp(my $describe= `git describe`);
46 print join(" ", $branch, $tstamp, $sha1, $describe) . "\n";