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

Miklos Vajna <[email protected]> Mon, 6 Sep 2010 22:28:48 +0200
Newsgroups gmane.comp.gnome.ximian.openoffice
Message-ID <[email protected]>
--===============0565618871==
Content-Type: multipart/signed; micalg=pgp-sha1;
	protocol="application/pgp-signature"; boundary="hW3Q5Oh0pcvvyJMS"
Content-Disposition: inline


--hW3Q5Oh0pcvvyJMS
Content-Type: multipart/mixed; boundary="eUqGrSc0O7wKBRnC"
Content-Disposition: inline


--eUqGrSc0O7wKBRnC
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline

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.

--eUqGrSc0O7wKBRnC
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="0001-bin-g-don-t-use-git-status.patch"
Content-Transfer-Encoding: quoted-printable

=46rom eb1df3fcc92fe710dc5f728992fc30fad3075fa7 Mon Sep 17 00:00:00 2001
=46rom: Miklos Vajna <[email protected]>
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" !=3D "1" ] ; then
-                        git status | grep -qs '^# Your branch is ahead of'=
 || exit 0
+                        [ -n "`git rev-list HEAD@{upstream}..`" ] || exit 0
                     fi
                     ;;
                 status)
-                    AHEAD=3D"`git status | grep '^# Your branch is ahead o=
f'`"
-                    if [ -z "$AHEAD" ] ; then
-                        git status | grep -qs '^nothing to commit' && exit=
 0
+                    LOCALCOMMITS=3D"`git rev-list HEAD@{upstream}..`"
+                    if [ -z "$LOCALCOMMITS" ] ; then
+                        [ -z "`git diff-index --name-only HEAD --`" ] && e=
xit 0
                     fi
                     ;;
             esac
@@ -194,4 +194,4 @@ if [ "$COMMAND" =3D "apply" ] ; then
     echo
 fi
=20
-# vi:set expandtab:
+# vi:set shiftwidth=3D4 expandtab:
--=20
1.7.2.3


--eUqGrSc0O7wKBRnC--

--hW3Q5Oh0pcvvyJMS
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)

iEYEARECAAYFAkyFTwAACgkQe81tAgORUJblXQCeLayOdR2FRLdhW8nPrEtOZ7DL
HUAAoKZHVPXplh5+eOJK6mVTZWm8KLYp
=oT/8
-----END PGP SIGNATURE-----

--hW3Q5Oh0pcvvyJMS--

--===============0565618871==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline