[ooo-build] [PATCH] bin/g: don't use git status

Miklos Vajna vmiklos at frugalware.org
Mon Sep 6 13:28:48 PDT 2010


Hello,

The attached patch removes the usage of git status from bin/g, as its
output is not guaranteed to be stable, I replaced the invocations with
low level ("plumbing") git commands.

This patch is similar to the one which removed git remote show usage.

OK to push?

Thanks.
-------------- next part --------------
From eb1df3fcc92fe710dc5f728992fc30fad3075fa7 Mon Sep 17 00:00:00 2001
From: Miklos Vajna <vmiklos at frugalware.org>
Date: Mon, 6 Sep 2010 22:24:01 +0200
Subject: [PATCH] bin/g: don't use git status

Its output is not guaranteed to be stable, use low level ("plumbing")
git commands instead.
---
 bin/g |   12 ++++++------
 1 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/bin/g b/bin/g
index 5d156e7..ade9f56 100755
--- a/bin/g
+++ b/bin/g
@@ -128,17 +128,17 @@ for DIR in * ; do
                     done
                     ;;
                 commit)
-                    git status | grep -qs '^nothing to commit' && exit 0
+                    [ -z "`git diff-index --name-only HEAD --`" ] && exit 0
                     ;;
                 push)
                     if [ "$PUSH_ALL" != "1" ] ; then
-                        git status | grep -qs '^# Your branch is ahead of' || exit 0
+                        [ -n "`git rev-list HEAD@{upstream}..`" ] || exit 0
                     fi
                     ;;
                 status)
-                    AHEAD="`git status | grep '^# Your branch is ahead of'`"
-                    if [ -z "$AHEAD" ] ; then
-                        git status | grep -qs '^nothing to commit' && exit 0
+                    LOCALCOMMITS="`git rev-list HEAD@{upstream}..`"
+                    if [ -z "$LOCALCOMMITS" ] ; then
+                        [ -z "`git diff-index --name-only HEAD --`" ] && exit 0
                     fi
                     ;;
             esac
@@ -194,4 +194,4 @@ if [ "$COMMAND" = "apply" ] ; then
     echo
 fi
 
-# vi:set expandtab:
+# vi:set shiftwidth=4 expandtab:
-- 
1.7.2.3

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/ooo-build/attachments/20100906/f9b00e99/attachment.pgp>


More information about the ooo-build mailing list