summaryrefslogtreecommitdiff
path: root/builtin/revert.c
diff options
context:
space:
mode:
authorJohannes Sixt <j6t@kdbg.org>2011-11-23 09:49:38 +0100
committerJunio C Hamano <gitster@pobox.com>2011-11-23 10:54:57 -0800
commit2a4037d0a745134a3b94cb3d60d2793a26bd9027 (patch)
tree3d56aae62910b694c47737da1eabc5c24e1d1754 /builtin/revert.c
parentb4524d343b085b63c68cf5e0a70007c19a048197 (diff)
downloadgit-2a4037d0a745134a3b94cb3d60d2793a26bd9027.tar.gz
Fix revert --abort on Windows
On Windows, it is not possible to rename or remove a directory that has open files. 'revert --abort' renamed .git/sequencer when it still had .git/sequencer/head open. Close the file as early as possible to allow the rename operation on Windows. Signed-off-by: Johannes Sixt <j6t@kdbg.org> Acked-by: Jonathan Nieder <jrnieder@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin/revert.c')
-rw-r--r--builtin/revert.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/builtin/revert.c b/builtin/revert.c
index 9b9b2e5747..c0b2592251 100644
--- a/builtin/revert.c
+++ b/builtin/revert.c
@@ -931,8 +931,10 @@ static int sequencer_rollback(struct replay_opts *opts)
if (strbuf_getline(&buf, f, '\n')) {
error(_("cannot read %s: %s"), filename, ferror(f) ?
strerror(errno) : _("unexpected end of file"));
+ fclose(f);
goto fail;
}
+ fclose(f);
if (get_sha1_hex(buf.buf, sha1) || buf.buf[40] != '\0') {
error(_("stored pre-cherry-pick HEAD file '%s' is corrupt"),
filename);
@@ -941,11 +943,9 @@ static int sequencer_rollback(struct replay_opts *opts)
if (reset_for_rollback(sha1))
goto fail;
strbuf_release(&buf);
- fclose(f);
return 0;
fail:
strbuf_release(&buf);
- fclose(f);
return -1;
}