[x264-devel] [PATCH] Hack for svnversion equivalent on git
Loren Merritt
lorenm at u.washington.edu
Sun Mar 9 14:48:35 CET 2008
How about this script? (I'm sure it does what I want in the cases I
tried, what I'm not sure of is if I missed some corner cases.)
On Sun, 9 Mar 2008, Pierre d'Herbemont wrote:
> On Mar 9, 2008, at 6:39 AM, Jason Martens wrote:
>> On Mar 8, 2008, at 6:50 AM, Pierre d'Herbemont wrote:
>>
>> But that 2 will increment with each commit regardless of where it's
>> made. It tells you nothing important _about_ the commits. Are they
>> local commits? Are they already in the HEAD at git.videolan.org? You
>> don't know; all you know is that there have been commits on top of
>> that tag. You can't trust the commit_id because git-describe shows
>> its commit_id from master, not HEAD. So you have to compare hashes.
>
> That's the whole point. Git isn't SVN you can have multiple repo.
x264 has a single official repo. If there were more than one in common
use, I'd include both a commit number and which repo it is. Somehow.
> And you can't trust an incremental count of the commit. Simply use the
> Hash, I see nothings wrong here. Do you?
But I want an incremental count, so I'll do whatever it takes to compute
one. Yes I'll keep the hash just to verify it. But the count is
immediately informative, while the hash provides no information to me
without looking up git-log on the official repo to compare.
>> Why force someone to go through that extra step? With every commit
>> tagged you don't have to guess; you know it's a local commit.
>
> You may trust origin, and you can git-describe origin if you prefer.
> Looks a bit hacky too though...
If someone *wants* to include a bogus version number, they can just edit
the code to do so. So yes I trust origin, because if I didn't I would have
bigger problems than version.sh.
You do raise the point where someone clones their local copy rather than
direct from videolan. Can I specify an aboslute url (of course not
actually fetching over the net if it's the same as origin)?
`grep git.videolan.org .git/FETCH_HEAD` ?
>>> I really think that's overkill to tag every single commit. You'll
>>> have to change a bit how downstream work,
>>
>> Yet again, _svnversion equivalent_. This is how downstream worked
>> the whole time x264 was on svn: X264_VERSION reflected the number of
>> commits made to svn.videolan.org. How do you do that reliably in git
>> without tagging each commit or mangling git-rev-list?
>
> Well, fine if every commit is a release it's ok. But definitely that
> seems silly at first sight. Why is every commit a potential release. I
> bet downstream only checkout master, and sometimes if they care in
> version they just checkout master at a certain time.
Every commit is a release because I don't want to keep track of stable
versions.
Every commit is a potential release because even if I did make stable
releases, I couldn't possibly know at the time of commit whether this
commit will be such a release. I would instead say "that commit a few
weeks ago, which has had no bugreports since then, is retroactively a
stable release".
--Loren Merritt
-------------- next part --------------
diff --git a/version.sh b/version.sh
index a91c48b..97600d5 100755
--- a/version.sh
+++ b/version.sh
@@ -1,12 +1,19 @@
#!/bin/sh
-VER=`svnversion .`
-if [ "x$VER" != x -a "$VER" != exported ]
-then
- echo "#define X264_VERSION \" svn-$VER\"" >> config.h
- VER=`echo $VER | sed -e 's/[^0-9].*//'`
+git-rev-list HEAD | sort > config.git-hash
+LOCALVER=`wc -l <config.git-hash`
+if [ $LOCALVER \> 1 ] ; then
+ VER=`git-rev-list origin/master | sort | join config.git-hash - | wc -l`
+ if [ $VER != $LOCALVER ] ; then
+ VER="$VER+$(($LOCALVER-$VER))"
+ elif git-status | grep -q "modified:" ; then
+ VER="${VER}M"
+ fi
+ VER="$VER $(git-rev-list HEAD -n 1 | head -c 7)"
+ echo "#define X264_VERSION \" r$VER\"" >> config.h
else
echo "#define X264_VERSION \"\"" >> config.h
VER="x"
fi
+rm -f config.git-hash
API=`grep '#define X264_BUILD' < x264.h | sed -e 's/.* \([1-9][0-9]*\).*/\1/'`
echo "#define X264_POINTVER \"0.$API.$VER\"" >> config.h
More information about the x264-devel
mailing list