diff options
author | Nicolas Pitre <nico@cam.org> | 2007-01-26 17:26:05 -0500 |
---|---|---|
committer | Junio C Hamano <junkio@cox.net> | 2007-01-28 02:16:46 -0800 |
commit | 9a13f0b71b887af42c3be854344f185c6dfa1d0d (patch) | |
tree | 964f450071a6726be9269c60d800e8fa1906aae6 /builtin-reflog.c | |
parent | 1b600e659abc7e409c9d830e332d3cef01062c1c (diff) | |
download | git-9a13f0b71b887af42c3be854344f185c6dfa1d0d.tar.gz |
make reflog filename independent from struct ref_lock
This allows for ref_log_write() to be used in a more flexible way,
and is needed for future changes.
This is only code reorg with no behavior change.
Signed-off-by: Nicolas Pitre <nico@cam.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
Diffstat (limited to 'builtin-reflog.c')
-rw-r--r-- | builtin-reflog.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/builtin-reflog.c b/builtin-reflog.c index b443ed9ef6..b6612a90ed 100644 --- a/builtin-reflog.c +++ b/builtin-reflog.c @@ -242,7 +242,7 @@ static int expire_reflog(const char *ref, const unsigned char *sha1, int unused, struct cmd_reflog_expire_cb *cmd = cb_data; struct expire_reflog_cb cb; struct ref_lock *lock; - char *newlog_path = NULL; + char *log_file, *newlog_path = NULL; int status = 0; if (strncmp(ref, "refs/", 5)) @@ -255,7 +255,8 @@ static int expire_reflog(const char *ref, const unsigned char *sha1, int unused, lock = lock_ref_sha1(ref + 5, sha1); if (!lock) return error("cannot lock ref '%s'", ref); - if (!file_exists(lock->log_file)) + log_file = xstrdup(git_path("logs/%s", ref)); + if (!file_exists(log_file)) goto finish; if (!cmd->dry_run) { newlog_path = xstrdup(git_path("logs/%s.lock", ref)); @@ -271,13 +272,14 @@ static int expire_reflog(const char *ref, const unsigned char *sha1, int unused, if (fclose(cb.newlog)) status |= error("%s: %s", strerror(errno), newlog_path); - if (rename(newlog_path, lock->log_file)) { + if (rename(newlog_path, log_file)) { status |= error("cannot rename %s to %s", - newlog_path, lock->log_file); + newlog_path, log_file); unlink(newlog_path); } } free(newlog_path); + free(log_file); unlock_ref(lock); return status; } |