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