From: Jeff King Date: Mon, 15 Feb 2016 18:21:13 GMT Subject: Re: [PATCH 2/4] remote: simplify remote_is_configured() Message-ID: <20160215182113.GF26443@sigill.intra.peff.net> In-Reply-To: <1455558150-30267-3-git-send-email-t.gummerer@gmail.com> On Mon, Feb 15, 2016 at 06:42:28PM +0100, Thomas Gummerer wrote: > The remote_is_configured() function allows checking whether a remote > exists or not. The function however only works if remote_get() wasn't > called before calling it. In addition, it only checks the configuration > for remotes, but not remotes or branches files. > > Make use of the origin member of struct remote instead, which indicates > where the remote comes from. It will be set to some value if the remote > is configured in any file in the repository, but is initialized to 0 if > the remote is only created in make_remote(). Makes sense. I wonder if we would want to give this an explicit slot in the enum. I.e.: > diff --git a/remote.h b/remote.h > index 4fd7a0f..7a5ee77 100644 > --- a/remote.h > +++ b/remote.h > @@ -5,7 +5,7 @@ > #include "hashmap.h" > > enum { > - REMOTE_CONFIG, > + REMOTE_CONFIG = 1, > REMOTE_REMOTES, > REMOTE_BRANCHES > }; Add in "REMOTE_UNCONFIGURED = 0" here. It makes no difference to correctness, but is perhaps documents what is going on a bit better. -Peff