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

[PATCH 1/5] Correct force_write bug in refs.c

From
Shawn Pearce <spearce@spearce.org>
Date
May 19, 2006, 09:15 UTC
Message-ID
<20060519091528.GI22257@spearce.org>

My earlier attempt at forcing a write for non-existant refs worked; it forced a write for pretty much all refs. This corrects the condition to only force a write for refs which don't exist yet.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
---
 refs.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
5ee16115982c52fa9b8fa15c14b234608a8b935d
diff --git a/refs.c b/refs.c
index d3ddc82..eeb1196 100644
--- a/refs.c
+++ b/refs.c
@@ -305,7 +305,7 @@ static struct ref_lock* lock_ref_sha1_ba
 	lock->ref_file = strdup(path);
 	lock->lock_file = strdup(mkpath("%s.lock", lock->ref_file));
 	lock->log_file = strdup(git_path("logs/%s", lock->ref_file + plen));
-	lock->force_write = !lstat(lock->ref_file, &st) || errno == ENOENT;
+	lock->force_write = lstat(lock->ref_file, &st) && errno == ENOENT;
 
 	if (safe_create_leading_directories(lock->lock_file))
 		die("unable to create directory for %s", lock->lock_file);
-- 
1.3.2.g7278
Message 1 of 1 in “Correct force_write bug in refs.c”
  1. 1/5 Correct force_write bug in refs.cShawn Pearce, May 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.