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

Re: [PATCH 1/1] clone: replace relative paths in the alternates

From
Junio C Hamano <gitster@pobox.com>
Date
Aug 19, 2011, 06:22 UTC
Message-ID
<7vy5yp53aj.fsf@alter.siamese.dyndns.org>
In-Reply-To
<1313731396-10458-2-git-send-email-jason77.wang@gmail.com>
Hui Wang <jason77.wang@gmail.com> writes:
Show 5 quoted lines
> +	mapsz = xsize_t(st.st_size);
> +	map = xmmap(NULL, mapsz, PROT_READ, MAP_PRIVATE, fd, 0);
> +	close(fd);
> +
> +	tmpbuf = mapsz > 4096 ? xmalloc(mapsz * 2) : xmalloc(mapsz + 4096);

Where do these magic numbers come from, and what guarantee do we have that these magic numbers give safe upper bound for pathnames that are expanded to be absolute?

Wouldn't it be a lot cleaner and much less error prone if you open the original, read from it with strbuf_readline(), convert the path using strbuf manipulation functions and write the resulting line out to the lockfile you obtained to update it, line by line?

Previous: Hui WangNext: Hui Wang
Message 3 of 4 in “git-clone: fix relative path problem in the alternates”
  1. 0/1 git-clone: fix relative path problem in the alternatesHui Wang, Aug 19, 2011
  2. 1/1 clone: replace relative paths in the alternatesHui Wang, Aug 19, 2011
  3. Junio C HamanoAug 19, 2011
  4. Hui WangAug 19, 2011

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.