git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@linux-foundation.org>
To: Daniel Barkalow <barkalow@iabervon.org>
Cc: Junio C Hamano <gitster@pobox.com>, git@vger.kernel.org
Subject: Re: [PATCH] Fix branches file configuration
Date: Tue, 25 Mar 2008 16:50:27 -0700	[thread overview]
Message-ID: <20080325165027.c23b6ebb.akpm@linux-foundation.org> (raw)
In-Reply-To: <alpine.LNX.1.00.0803251931500.19665@iabervon.org>

On Tue, 25 Mar 2008 19:35:28 -0400 (EDT) Daniel Barkalow <barkalow@iabervon.org> wrote:

> It turns out that .git/branches/foo should fetch into refs/heads/foo.
> 
> Signed-off-by: Daniel Barkalow <barkalow@iabervon.org>
> ---
> We still don't have a test for that bit of the behavior, so I could have 
> it still doing the wrong thing. But it at least should do what I think 
> people want.
> 
> Andrew, could you give this a try, on top of current master (or, for that 
> matter, any released version that doesn't work), and let me know if it 
> does the wrong thing?
> 

I tried it on 1.5.5-rc1.  It seems to dtrt from a quick test.

> diff --git a/remote.c b/remote.c
> index 40ed246..a027bca 100644
> --- a/remote.c
> +++ b/remote.c
> @@ -232,7 +232,7 @@ static void read_branches_file(struct remote *remote)
>  {
>  	const char *slash = strchr(remote->name, '/');
>  	char *frag;
> -	char *branch;
> +	struct strbuf branch;
>  	int n = slash ? slash - remote->name : 1000;
>  	FILE *f = fopen(git_path("branches/%.*s", n, remote->name), "r");
>  	char *s, *p;
> @@ -258,17 +258,16 @@ static void read_branches_file(struct remote *remote)
>  	strcpy(p, s);
>  	if (slash)
>  		strcat(p, slash);
> +	strbuf_init(&branch, 0);
>  	frag = strchr(p, '#');
>  	if (frag) {
>  		*(frag++) = '\0';
> -		branch = xmalloc(strlen(frag) + 12);
> -		strcpy(branch, "refs/heads/");
> -		strcat(branch, frag);
> -	} else {
> -		branch = "refs/heads/master";
> -	}
> +		strbuf_addf(&branch, "refs/heads/%s", frag);
> +	} else
> +		strbuf_addstr(&branch, "refs/heads/master");
>  	add_url_alias(remote, p);
> -	add_fetch_refspec(remote, branch);
> +	strbuf_addf(&branch, ":refs/heads/%s", remote->name);
> +	add_fetch_refspec(remote, strbuf_detach(&branch, 0));
>  	remote->fetch_tags = 1; /* always auto-follow */
>  }
>  
> -- 
> 1.5.4.3.610.gea6cd

  reply	other threads:[~2008-03-25 23:51 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-03-25 23:35 [PATCH] Fix branches file configuration Daniel Barkalow
2008-03-25 23:50 ` Andrew Morton [this message]
2008-03-25 23:56 ` Junio C Hamano
2008-03-26  0:03   ` Andrew Morton
2008-03-26  6:51   ` Daniel Barkalow
2008-03-26  7:29     ` Junio C Hamano
2008-03-26  8:03       ` Junio C Hamano
2008-03-26  8:33 ` [PATCH] git-fetch test: test tracking fetch results, not just FETCH_HEAD Junio C Hamano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20080325165027.c23b6ebb.akpm@linux-foundation.org \
    --to=akpm@linux-foundation.org \
    --cc=barkalow@iabervon.org \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).