Properly count the number of commits

The "git log --pretty=format:" command eats up the line feed for the
last commit, and thus "wc -l" counts one commit less than there are.
This is easy to demonstrate with:

$ git log '2.95.3^..2.95.3' --oneline
e84de34 config/version: set version to 2.95.3 (OpenELEC-3.0 Beta 3)

$ git log '2.95.3^..2.95.3' --pretty=format: | wc -l
0

Even though this is a minor discrepancy, "git rev-list" and "git
rev-parse" are simpler and more accurate tools for this task (their
output format is not going to change).
This commit is contained in:
Georgi Georgiev 2012-11-19 00:11:06 +09:00
parent 32483de7c6
commit 5265597861

View File

@ -35,8 +35,8 @@ export INSTALL=$BUILD/image/system
BUILD_DATE=`date +%Y%m%d%H%M%S`
if [ "$OPENELEC_VERSION" = devel -o "$OPENELEC_VERSION" = debug ]; then
GIT_BUILD=`git log --pretty=format:'' | wc -l`
GIT_HASH=`git log -n1 --format=%H`
GIT_BUILD=`git rev-list HEAD | wc -l`
GIT_HASH=`git rev-parse HEAD`
OPENELEC_VERSION=$OPENELEC_VERSION-$BUILD_DATE-r$GIT_BUILD
fi