2 # Copyright 2004 - Ryan Anderson <ryan@michonline.com> GPL v2
11 Usage: setlocalversion <srctree>
16 my ($srctree) = @ARGV;
19 my @LOCALVERSIONS = ();
21 # We are going to use the following commands to try and determine if this
22 # repository is at a Version boundary (i.e, 2.6.10 vs 2.6.10 + some patches) We
23 # currently assume that all meaningful version boundaries are marked by a tag.
24 # We don't care what the tag is, just that something exists.
26 # Git/Cogito store the top-of-tree "commit" in .git/HEAD
27 # A list of known tags sits in .git/refs/tags/
29 # The simple trick here is to just compare the two of these, and if we get a
30 # match, return nothing, otherwise, return a subset of the SHA-1 hash in
34 open(H,"<.git/HEAD") or return;
39 opendir(D,".git/refs/tags") or return;
40 foreach my $tagfile (grep !/^\.{1,2}$/, readdir(D)) {
41 open(F,"<.git/refs/tags/" . $tagfile) or return;
45 return if ($tag eq $head);
49 push @LOCALVERSIONS, "g" . substr($head,0,8);
56 printf "-%s\n", join("-",@LOCALVERSIONS) if (scalar @LOCALVERSIONS > 0);