git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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

From
Jay Soffian <jaysoffian@gmail.com>
Date
Feb 19, 2008, 13:59 UTC
Message-ID
<76718490802190559m3f5def8ej667d4d4a1ae8e6c7@mail.gmail.com>
In-Reply-To
<alpine.LSU.1.00.0802191054070.30505@racer.site>
On Feb 19, 2008 5:55 AM, Johannes Schindelin <Johannes.Schindelin@gmx.de> wrote:
Show 5 quoted lines
>
> 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.
How about this?
static int setup_tracking(const char *new_ref, const char *orig_ref,
                          enum branch_track track)
{
	char key[1024];
	struct tracking tracking;
	if (strlen(new_ref) > 1024 - 7 - 7 - 1)
		return error("Tracking not set up: name too long: %s",
				new_ref);
	memset(&tracking, 0, sizeof(tracking));
	tracking.spec.dst = (char *)orig_ref;
	if (for_each_remote(find_tracked_branch, &tracking))
		return 1;
	if (!tracking.matches && track != BRANCH_TRACK_ALWAYS)
		return 1;
	if (tracking.matches > 1)
		return error("Not tracking: ambiguous information for ref %s",
				orig_ref);
	sprintf(key, "branch.%s.remote", new_ref);
	git_config_set(key, tracking.remote ?  tracking.remote : ".");
	sprintf(key, "branch.%s.merge", new_ref);
	git_config_set(key, tracking.src ? tracking.src : orig_ref);
	free(tracking.src);
	printf("Branch %s set up to track %s branch %s.\n", new_ref,
		tracking.remote ? "remote" : "local", orig_ref);
	return 0;
}
j.
Previous: Jay SoffianNext: Johannes Schindelin
Message 5 of 14 in “branch: optionally setup branch.*.merge from upstream local branches”
  1. branch: optionally setup branch.*.merge from upstream local branchesJay Soffian, Feb 19, 2008
  2. Jay SoffianFeb 19, 2008
  3. Johannes SchindelinFeb 19, 2008
  4. Jay SoffianFeb 19, 2008
  5. Jay SoffianFeb 19, 2008
  6. Johannes SchindelinFeb 19, 2008
  7. Junio C HamanoFeb 19, 2008
  8. Jay SoffianFeb 19, 2008
  9. Alex RiesenFeb 19, 2008
  10. Jay SoffianFeb 19, 2008
  11. Johannes SchindelinFeb 19, 2008
  12. Alex RiesenFeb 20, 2008
  13. Junio C HamanoFeb 20, 2008
  14. Junio C HamanoFeb 20, 2008

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.