summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: c22a7f0)
raw | patch | inline | side by side (parent: c22a7f0)
author | Shawn Pearce <spearce@spearce.org> | |
Fri, 19 May 2006 07:29:05 +0000 (03:29 -0400) | ||
committer | Junio C Hamano <junkio@cox.net> | |
Fri, 19 May 2006 22:02:43 +0000 (15:02 -0700) |
Normally we try to skip writing a ref if its value hasn't changed
but in the special case that the ref doesn't exist but the new
value is going to be 0{40} then force writing the ref anyway.
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
but in the special case that the ref doesn't exist but the new
value is going to be 0{40} then force writing the ref anyway.
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
refs.c | patch | blob | history | |
refs.h | patch | blob | history |
index 9d37a028c3aabeefe06095e03be72a071ff66740..31cf27668df705ae0dda6d28a2e1e78d568a170d 100644 (file)
--- a/refs.c
+++ b/refs.c
const unsigned char *old_sha1, int mustexist)
{
struct ref_lock *lock;
+ struct stat st;
lock = xcalloc(1, sizeof(struct ref_lock));
lock->lock_fd = -1;
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;
if (safe_create_leading_directories(lock->lock_file))
die("unable to create directory for %s", lock->lock_file);
if (!lock)
return -1;
- if (!memcmp(lock->old_sha1, sha1, 20)) {
+ if (!lock->force_write && !memcmp(lock->old_sha1, sha1, 20)) {
unlock_ref(lock);
return 0;
}