[PATCH 2/4] nmbug: Handle missing @upstream in is_unmerged

2014-07-19 Thread David Bremner
"W. Trevor King"  writes:

> On Wed, Jul 16, 2014 at 07:36:10PM -0300, David Bremner wrote:
>> W. Trevor King writes:
>> > If we don't have an upstream, there is nothing to merge, so
>> > nothing is unmerged.  This avoids errors like:
>> 
>> pushed this one patch.
>
> Without the stderr-catching of something like patch 3, this means
> folks without an upstream are going to see a distracting:
>
>   error: No upstream configured for branch 'master'
>

On reflection, I don't think that patch made things worse for this use
case. So I don't think it really hurts to leave it there for now.

d


Re: [PATCH 2/4] nmbug: Handle missing @upstream in is_unmerged

2014-07-19 Thread David Bremner
W. Trevor King wk...@tremily.us writes:

 On Wed, Jul 16, 2014 at 07:36:10PM -0300, David Bremner wrote:
 W. Trevor King writes:
  If we don't have an upstream, there is nothing to merge, so
  nothing is unmerged.  This avoids errors like:
 
 pushed this one patch.

 Without the stderr-catching of something like patch 3, this means
 folks without an upstream are going to see a distracting:

   error: No upstream configured for branch 'master'


On reflection, I don't think that patch made things worse for this use
case. So I don't think it really hurts to leave it there for now.

d
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


[PATCH 2/4] nmbug: Handle missing @upstream in is_unmerged

2014-07-17 Thread David Bremner
"W. Trevor King"  writes:

> On Wed, Jul 16, 2014 at 07:36:10PM -0300, David Bremner wrote:
>> W. Trevor King writes:
>> > If we don't have an upstream, there is nothing to merge, so
>> > nothing is unmerged.  This avoids errors like:
>> 
>> pushed this one patch.
>
> Without the stderr-catching of something like patch 3, this means
> folks without an upstream are going to see a distracting:
>
>   error: No upstream configured for branch 'master'
>
> if they run 'nmbug status' without an @upstream.
>
> I'm working through the Python translation now ;).

Perhaps the best thing is to revert that patch then?

d


Re: [PATCH 2/4] nmbug: Handle missing @upstream in is_unmerged

2014-07-17 Thread David Bremner
W. Trevor King wk...@tremily.us writes:

 On Wed, Jul 16, 2014 at 07:36:10PM -0300, David Bremner wrote:
 W. Trevor King writes:
  If we don't have an upstream, there is nothing to merge, so
  nothing is unmerged.  This avoids errors like:
 
 pushed this one patch.

 Without the stderr-catching of something like patch 3, this means
 folks without an upstream are going to see a distracting:

   error: No upstream configured for branch 'master'

 if they run 'nmbug status' without an @upstream.

 I'm working through the Python translation now ;).

Perhaps the best thing is to revert that patch then?

d
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


Re: [PATCH 2/4] nmbug: Handle missing @upstream in is_unmerged

2014-07-17 Thread W. Trevor King
On Thu, Jul 17, 2014 at 06:28:55AM -0300, David Bremner wrote:
 W. Trevor King writes:
  On Wed, Jul 16, 2014 at 07:36:10PM -0300, David Bremner wrote:
  W. Trevor King writes:
   If we don't have an upstream, there is nothing to merge, so
   nothing is unmerged.  This avoids errors like:
  
  pushed this one patch.
 
  Without the stderr-catching of something like patch 3, this means
  folks without an upstream are going to see a distracting:
 
error: No upstream configured for branch 'master'
 
  if they run 'nmbug status' without an @upstream.
 
  I'm working through the Python translation now ;).
 
 Perhaps the best thing is to revert that patch then?

Sure.

Trevor

-- 
This email may be signed or encrypted with GnuPG (http://www.gnupg.org).
For more information, see http://en.wikipedia.org/wiki/Pretty_Good_Privacy


signature.asc
Description: OpenPGP digital signature
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


Re: [PATCH 2/4] nmbug: Handle missing @upstream in is_unmerged

2014-07-16 Thread David Bremner
W. Trevor King wk...@tremily.us writes:

 If we don't have an upstream, there is nothing to merge, so nothing is
 unmerged.  This avoids errors like:

pushed this one patch.

d
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


Re: [PATCH 2/4] nmbug: Handle missing @upstream in is_unmerged

2014-07-16 Thread W. Trevor King
On Wed, Jul 16, 2014 at 07:36:10PM -0300, David Bremner wrote:
 W. Trevor King writes:
  If we don't have an upstream, there is nothing to merge, so
  nothing is unmerged.  This avoids errors like:
 
 pushed this one patch.

Without the stderr-catching of something like patch 3, this means
folks without an upstream are going to see a distracting:

  error: No upstream configured for branch 'master'

if they run 'nmbug status' without an @upstream.

I'm working through the Python translation now ;).

Cheers,
Trevor

-- 
This email may be signed or encrypted with GnuPG (http://www.gnupg.org).
For more information, see http://en.wikipedia.org/wiki/Pretty_Good_Privacy


signature.asc
Description: OpenPGP digital signature
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


[PATCH 2/4] nmbug: Handle missing @upstream in is_unmerged

2014-07-15 Thread David Bremner
"W. Trevor King"  writes:

> -  my $fetch_head = git ('rev-parse', $commit);
> +  my ($fetch_head, $status) = git_with_status ('rev-parse', $commit);
> +  if ($status) {
> +return 0;
> +  }

Could there be other errors here, other than @{upstream} not existing?
At first glance it seems like there is potential to hide errors here.

d



[PATCH 2/4] nmbug: Handle missing @upstream in is_unmerged

2014-07-15 Thread W. Trevor King
On Tue, Jul 15, 2014 at 08:44:53PM -0300, David Bremner wrote:
> W. Trevor King writes:
> > -  my $fetch_head = git ('rev-parse', $commit);
> > +  my ($fetch_head, $status) = git_with_status ('rev-parse', $commit);
> > +  if ($status) {
> > +return 0;
> > +  }
> 
> Could there be other errors here, other than @{upstream} not
> existing?  At first glance it seems like there is potential to hide
> errors here.

Possible errors that I can find:

* fatal: Not a git repository: ? (with a poor GIT_DIR config)
* fatal: ambiguous argument ? (with an invalid/missing revision name)
* fatal: No upstream configured for branch ? (when
  branch..remote or branch..merge aren't set)

All of which return 128 as of Git v1.9.1.  We're only interested in
the last.  I'm fine looking for ?No upstream configured for branch?
after we capture stderr with ?nmbug: Catch stderr in is_unmerged? [1],
but I don't expect the other two error cases to happen very often.  At
least, I doubt you could get this far into do_status with a broken
GIT_DIR, and we're hard-coding '@{upstream}' here.

Cheers,
Trevor

[1]: id:d55cf02465c5f2d83f2dd0bc666831ee524b0fb7.1404678709.git.wking at 
tremily.us
 http://article.gmane.org/gmane.mail.notmuch.general/18627

-- 
This email may be signed or encrypted with GnuPG (http://www.gnupg.org).
For more information, see http://en.wikipedia.org/wiki/Pretty_Good_Privacy
-- next part --
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: OpenPGP digital signature
URL: 



Re: [PATCH 2/4] nmbug: Handle missing @upstream in is_unmerged

2014-07-15 Thread David Bremner
W. Trevor King wk...@tremily.us writes:

 -  my $fetch_head = git ('rev-parse', $commit);
 +  my ($fetch_head, $status) = git_with_status ('rev-parse', $commit);
 +  if ($status) {
 +return 0;
 +  }

Could there be other errors here, other than @{upstream} not existing?
At first glance it seems like there is potential to hide errors here.

d

___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


Re: [PATCH 2/4] nmbug: Handle missing @upstream in is_unmerged

2014-07-15 Thread W. Trevor King
On Tue, Jul 15, 2014 at 08:44:53PM -0300, David Bremner wrote:
 W. Trevor King writes:
  -  my $fetch_head = git ('rev-parse', $commit);
  +  my ($fetch_head, $status) = git_with_status ('rev-parse', $commit);
  +  if ($status) {
  +return 0;
  +  }
 
 Could there be other errors here, other than @{upstream} not
 existing?  At first glance it seems like there is potential to hide
 errors here.

Possible errors that I can find:

* fatal: Not a git repository: … (with a poor GIT_DIR config)
* fatal: ambiguous argument … (with an invalid/missing revision name)
* fatal: No upstream configured for branch … (when
  branch.name.remote or branch.name.merge aren't set)

All of which return 128 as of Git v1.9.1.  We're only interested in
the last.  I'm fine looking for “No upstream configured for branch”
after we capture stderr with “nmbug: Catch stderr in is_unmerged” [1],
but I don't expect the other two error cases to happen very often.  At
least, I doubt you could get this far into do_status with a broken
GIT_DIR, and we're hard-coding '@{upstream}' here.

Cheers,
Trevor

[1]: id:d55cf02465c5f2d83f2dd0bc666831ee524b0fb7.1404678709.git.wk...@tremily.us
 http://article.gmane.org/gmane.mail.notmuch.general/18627

-- 
This email may be signed or encrypted with GnuPG (http://www.gnupg.org).
For more information, see http://en.wikipedia.org/wiki/Pretty_Good_Privacy


signature.asc
Description: OpenPGP digital signature
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


[PATCH 2/4] nmbug: Handle missing @upstream in is_unmerged

2014-07-06 Thread W. Trevor King
If we don't have an upstream, there is nothing to merge, so nothing is
unmerged.  This avoids errors like:

  $ nmbug status
  error: No upstream configured for branch 'master'
  error: No upstream configured for branch 'master'
  fatal: ambiguous argument '@{upstream}': unknown revision or path not in the 
working tree.
  Use '--' to separate paths from revisions, like this:
  'git  [...] -- [...]'
  'git rev-parse @{upstream}' exited with nonzero value

You might not have an upstream if you're only using nmbug locally to
version-control your tags.
---
 devel/nmbug/nmbug | 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/devel/nmbug/nmbug b/devel/nmbug/nmbug
index 4a79722..998ee6b 100755
--- a/devel/nmbug/nmbug
+++ b/devel/nmbug/nmbug
@@ -430,7 +430,10 @@ sub do_status {
 sub is_unmerged {
   my $commit = shift || '@{upstream}';

-  my $fetch_head = git ('rev-parse', $commit);
+  my ($fetch_head, $status) = git_with_status ('rev-parse', $commit);
+  if ($status) {
+return 0;
+  }
   my $base = git ( 'merge-base', 'HEAD', $commit);

   return ($base ne $fetch_head);
-- 
1.9.1.353.gc66d89d