Re: [PATCH] branch: optionally setup branch.*.merge from upstream local branches

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

On Mon, 18 Feb 2008, Jay Soffian wrote:

> On Feb 18, 2008 9:07 PM, Jay Soffian <jaysoffian@xxxxxxxxx> wrote:
> > diff --git a/branch.c b/branch.c
> > index 1fc8788..9d7585e 100644
> > --- a/branch.c
> > +++ b/branch.c
> > @@ -37,7 +37,8 @@ static int find_tracked_branch(struct remote *remote, void *priv)
> >   * to infer the settings for branch.<new_ref>.{remote,merge} from the
> >   * config.
> >   */
> > -static int setup_tracking(const char *new_ref, const char *orig_ref)
> > +static int setup_tracking(const char *new_ref, const char *orig_ref,
> > +                          enum branch_track track)
> >  {
> >         char key[1024];
> >         struct tracking tracking;
> > @@ -48,10 +49,14 @@ static int setup_tracking(const char *new_ref, const char *orig_ref)
> >
> >         memset(&tracking, 0, sizeof(tracking));
> >         tracking.spec.dst = (char *)orig_ref;
> > -       if (for_each_remote(find_tracked_branch, &tracking) ||
> > -                       !tracking.matches)
> > +       if (for_each_remote(find_tracked_branch, &tracking))
> >                 return 1;
> >
> > +       if (!tracking.matches && track == BRANCH_TRACK_ALWAYS) {
> > +               tracking.matches = 1;
> > +               tracking.src = xstrdup(orig_ref);
> > +       }
> > +
> 
> Well that's obviously wrong (though it causes no problems, setup_tracking()
> would return 0 when it should return 1, but its return value is currently
> ignored). I changed it to:
> 
> 	if (!tracking.matches) {
> 		if (track != BRANCH_TRACK_ALWAYS)
> 			return 1;
> 		tracking.matches = 1;
> 		tracking.src = xstrdup(orig_ref);
> 	}

Ah, yes.  But I still maintain that xstrdup()ing orig_ref only to free it 
later is ugly.  Why not have the "tracking.src ? tracking.src : orig_ref" 
as I suggested?  The free() obviously can stay, since it will say 
"free(NULL)" in the case of tracking.matches == 0.

Ciao,
Dscho

-
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux