Skip to content

Commit

Permalink
Fix revert --abort on Windows
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Johannes Sixt authored and Junio C Hamano committed Nov 23, 2011
1 parent b4524d3 commit 2a4037d
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions builtin/revert.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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;
}

Expand Down

0 comments on commit 2a4037d

Please sign in to comment.