Skip to content

Commit 8fe9277

Browse files
spearceJunio C Hamano
authored andcommitted
Correct force_write bug in refs.c
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> Signed-off-by: Junio C Hamano <junkio@cox.net>
1 parent cce91a2 commit 8fe9277

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

refs.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,7 @@ static struct ref_lock* lock_ref_sha1_basic(const char *path,
305305
lock->ref_file = strdup(path);
306306
lock->lock_file = strdup(mkpath("%s.lock", lock->ref_file));
307307
lock->log_file = strdup(git_path("logs/%s", lock->ref_file + plen));
308-
lock->force_write = !lstat(lock->ref_file, &st) || errno == ENOENT;
308+
lock->force_write = lstat(lock->ref_file, &st) && errno == ENOENT;
309309

310310
if (safe_create_leading_directories(lock->lock_file))
311311
die("unable to create directory for %s", lock->lock_file);

0 commit comments

Comments
 (0)