summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2008-02-27 19:53:48 (GMT)
committerJunio C Hamano <gitster@pobox.com>2008-02-27 19:53:48 (GMT)
commit42dd2cd3a3f5228db77826d4d6a8490a9a710e45 (patch)
tree087ec72c0254b26c155f17a43d61e66281e49bb5
parentc6a7c606a6fb89f51258d2a60bc27cfe2530a0a1 (diff)
parent4cd883d724ec36a120263d47058e65c6d1de642f (diff)
downloadgit-42dd2cd3a3f5228db77826d4d6a8490a9a710e45.zip
git-42dd2cd3a3f5228db77826d4d6a8490a9a710e45.tar.gz
git-42dd2cd3a3f5228db77826d4d6a8490a9a710e45.tar.bz2
Merge branch 'bc/reflog-fix'
* bc/reflog-fix: builtin-reflog.c: don't install new reflog on write failure
-rw-r--r--builtin-reflog.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/builtin-reflog.c b/builtin-reflog.c
index 4836ec9..ab53c8c 100644
--- a/builtin-reflog.c
+++ b/builtin-reflog.c
@@ -276,10 +276,11 @@ static int expire_reflog(const char *ref, const unsigned char *sha1, int unused,
for_each_reflog_ent(ref, expire_reflog_ent, &cb);
finish:
if (cb.newlog) {
- if (fclose(cb.newlog))
+ if (fclose(cb.newlog)) {
status |= error("%s: %s", strerror(errno),
newlog_path);
- if (rename(newlog_path, log_file)) {
+ unlink(newlog_path);
+ } else if (rename(newlog_path, log_file)) {
status |= error("cannot rename %s to %s",
newlog_path, log_file);
unlink(newlog_path);