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

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

Date: Tue, 15 Jul 2014 17:11:02 -0700

To: David Bremner

Cc: notmuch@notmuchmail.org

From: 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.wking@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 (application/pgp-signature)

Thread: