diff options
author | Junio C Hamano <gitster@pobox.com> | 2008-02-27 11:53:48 -0800 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2008-02-27 11:53:48 -0800 |
commit | 42dd2cd3a3f5228db77826d4d6a8490a9a710e45 (patch) | |
tree | 087ec72c0254b26c155f17a43d61e66281e49bb5 | |
parent | c6a7c606a6fb89f51258d2a60bc27cfe2530a0a1 (diff) | |
parent | 4cd883d724ec36a120263d47058e65c6d1de642f (diff) | |
download | git-42dd2cd3a3f5228db77826d4d6a8490a9a710e45.tar.gz |
Merge branch 'bc/reflog-fix'
* bc/reflog-fix:
builtin-reflog.c: don't install new reflog on write failure
-rw-r--r-- | builtin-reflog.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/builtin-reflog.c b/builtin-reflog.c index 4836ec951b..ab53c8cb7c 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); |