On Tue, Oct 15, 2013 at 03:06:49PM +0200, Guido Günther wrote:
> Hi Brian,
> On Tue, Oct 15, 2013 at 12:29:21AM +0000, brian m. carlson wrote:
> > tags 726260 + patch
> > kthxbye
> > 
> > On Mon, Oct 14, 2013 at 10:29:58AM +0200, Guido Günther wrote:
> > > Thanks for the update! I've read about --porcelain but didn't look take
> > > the time to look when it was introduced, it's form before 2009 so we can
> > > safely use it. A traditional diff is fine.
> > 
> > Attached is a patch to fix this issue.  I've tested it and it seems to
> > work fine.
> 
> Thanks. But when only running --porcelain the output is much less user
> friendly. What about using git status --porcelain to get the repository
> status and then running it without porcelain to get a user friendly
> message?

I've attached a new patch.  It has much more code duplication than I'd
like, but there isn't a remove method for GitArgs, so I ended up having
to.

-- 
brian m. carlson / brian with sandals: Houston, Texas, US
+1 832 623 2791 | http://www.crustytoothpaste.net/~bmc | My opinion only
OpenPGP: RSA v4 4096b: 88AC E9B2 9196 305B A994 7552 F1BA 225C 0223 B187
diff --git a/gbp/git/repository.py b/gbp/git/repository.py
index 4a58eea..2dc9e3d 100644
--- a/gbp/git/repository.py
+++ b/gbp/git/repository.py
@@ -775,9 +775,7 @@ class GitRepository(object):
         if self.bare:
             return (True, '')
 
-        clean_msg = 'nothing to commit'
-
-        args = GitArgs()
+        args = GitArgs('--porcelain')
         args.add_true(ignore_untracked, '-uno')
 
         out, ret = self._git_getoutput('status',
@@ -785,14 +783,18 @@ class GitRepository(object):
                                        extra_env={'LC_ALL': 'C'})
         if ret:
             raise GbpError("Can't get repository status")
-        ret = False
-        for line in out:
-            if line.startswith('#'):
-                continue
-            if line.startswith(clean_msg):
-                ret = True
-            break
-        return (ret, "".join(out))
+        out = "".join(out)
+        if out:
+            # Get a more helpful error message.
+            args = GitArgs()
+            args.add_true(ignore_untracked, '-uno')
+
+            out, ret = self._git_getoutput('status',
+                                      args.args,
+                                      extra_env={'LC_ALL': 'C'})
+            return (False, "".join(out))
+
+        return (True, '')
 
     def clean(self, directories=False, force=False, dry_run=False):
         """

Attachment: signature.asc
Description: Digital signature

Reply via email to