[LEDE-DEV] [PATCH] scripts/getver.sh: use --count for git rev-list to count commits
Rafał Miłecki
zajec5 at gmail.com
Wed Nov 16 21:59:23 PST 2016
From: Rafał Miłecki <rafal at milecki.pl>
It should be faster than printing them and piping to the wc.
Signed-off-by: Rafał Miłecki <rafal at milecki.pl>
---
scripts/getver.sh | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/scripts/getver.sh b/scripts/getver.sh
index e718485..9b84602 100755
--- a/scripts/getver.sh
+++ b/scripts/getver.sh
@@ -20,18 +20,18 @@ try_git() {
case "$GET_REV" in
r*)
GET_REV="$(echo $GET_REV | tr -d 'r')"
- BASE_REV="$(git rev-list ${REBOOT}..HEAD | wc -l | awk '{print $1}')"
+ BASE_REV="$(git rev-list --count ${REBOOT}..HEAD)"
REV="$(git rev-parse HEAD~$((BASE_REV - GET_REV)))"
;;
*)
BRANCH="$(git rev-parse --abbrev-ref HEAD)"
ORIGIN="$(git rev-parse --verify --symbolic-full-name ${BRANCH}@{u} 2>/dev/null)"
[ -n "$ORIGIN" ] || ORIGIN="$(git rev-parse --verify --symbolic-full-name master@{u} 2>/dev/null)"
- REV="$(git rev-list ${REBOOT}..$GET_REV | wc -l | awk '{print $1}')"
+ REV="$(git rev-list --count ${REBOOT}..$GET_REV)"
if [ -n "$ORIGIN" ]; then
UPSTREAM_BASE="$(git merge-base $GET_REV $ORIGIN)"
- UPSTREAM_REV="$(git rev-list ${REBOOT}..$UPSTREAM_BASE | wc -l | awk '{print $1}')"
+ UPSTREAM_REV="$(git rev-list --count ${REBOOT}..$UPSTREAM_BASE)"
else
UPSTREAM_REV=$REV
fi
--
2.10.1
More information about the Lede-dev
mailing list