Skip to content

Commit 2a4037d

Browse files
j6tgitster
authored andcommitted
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 <[email protected]> Acked-by: Jonathan Nieder <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent b4524d3 commit 2a4037d

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

builtin/revert.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -931,8 +931,10 @@ static int sequencer_rollback(struct replay_opts *opts)
931931
if (strbuf_getline(&buf, f, '\n')) {
932932
error(_("cannot read %s: %s"), filename, ferror(f) ?
933933
strerror(errno) : _("unexpected end of file"));
934+
fclose(f);
934935
goto fail;
935936
}
937+
fclose(f);
936938
if (get_sha1_hex(buf.buf, sha1) || buf.buf[40] != '\0') {
937939
error(_("stored pre-cherry-pick HEAD file '%s' is corrupt"),
938940
filename);
@@ -941,11 +943,9 @@ static int sequencer_rollback(struct replay_opts *opts)
941943
if (reset_for_rollback(sha1))
942944
goto fail;
943945
strbuf_release(&buf);
944-
fclose(f);
945946
return 0;
946947
fail:
947948
strbuf_release(&buf);
948-
fclose(f);
949949
return -1;
950950
}
951951

0 commit comments

Comments
 (0)