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

Re: [PATCH] Fix broken sha1 locking

From
Linus Torvalds <torvalds@osdl.org>
Date
Sep 19, 2006, 22:10 UTC
Message-ID
<Pine.LNX.4.64.0609191501311.4388@g5.osdl.org>
In-Reply-To
<20060919212340.GC8259@pasky.or.cz>
On Tue, 19 Sep 2006, Petr Baudis wrote:
>
> lock_ref_sha1_basic() never strdup()s ref (at least the reference used
> for git_path() later).

Ahh. So how did that ever work? Even in the current "master" branch, we call "resolve_ref()", which calls "git_path()", and historically we only had a single buffer..

So we're doing
	lock_ref_sha1_basic(git_path("refs/%s", ref),...
with that single buffer, and we _do_ do "xstrdup(path)" in between.
[ looks.. ]
Ahh.

We re-assign the "path" to point to the result value of the resolve_ref(), and so we do re-use the buffer, but we apparently never have any overlapping use. The packed-ref changes make us need pathnames in the middle, which we didn't use to do.

I do agree that we tend to use too many static buffers there. The static buffers are fine for the low-level functions ("mkpath()" and "git_path()"), but once they start getting passed around as arguments to other functions, they should be xstrdup'd or something.

		Linus
Previous: Petr Baudis
Message 4 of 4 in “Fix broken sha1 locking”
  1. Fix broken sha1 lockingPetr Baudis, Sep 19, 2006
  2. Linus TorvaldsSep 19, 2006
  3. Petr BaudisSep 19, 2006
  4. Linus TorvaldsSep 19, 2006

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.