summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: b531394)
raw | patch | inline | side by side (parent: b531394)
author | Brandon Casey <casey@nrlssc.navy.mil> | |
Thu, 17 Jan 2008 16:58:34 +0000 (10:58 -0600) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Fri, 18 Jan 2008 06:11:42 +0000 (22:11 -0800) |
We also move the assignment of -1 to the lock file descriptor
up, so that rollback_lock_file() can be called safely after a
possible attempt to fclose(). This matches the contents of
the 'if' statement just above testing success of fdopen().
Signed-off-by: Brandon Casey <casey@nrlssc.navy.mil>
Acked-by: Shawn O. Pearce <spearce@spearce.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
up, so that rollback_lock_file() can be called safely after a
possible attempt to fclose(). This matches the contents of
the 'if' statement just above testing success of fdopen().
Signed-off-by: Brandon Casey <casey@nrlssc.navy.mil>
Acked-by: Shawn O. Pearce <spearce@spearce.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
fast-import.c | patch | blob | history |
diff --git a/fast-import.c b/fast-import.c
index 3609c24288dedb5b5e1b46d77ebfce6c305a434e..4cf50929765f56f339cd3479312c80c747a78eba 100644 (file)
--- a/fast-import.c
+++ b/fast-import.c
return;
}
- dump_marks_helper(f, 0, marks);
- if (ferror(f) || fclose(f))
- failure |= error("Unable to write marks file %s: %s",
- mark_file, strerror(errno));
/*
- * Since the lock file was fdopen()'ed and then fclose()'ed above,
- * assign -1 to the lock file descriptor so that commit_lock_file()
+ * Since the lock file was fdopen()'ed, it should not be close()'ed.
+ * Assign -1 to the lock file descriptor so that commit_lock_file()
* won't try to close() it.
*/
mark_lock.fd = -1;
- if (commit_lock_file(&mark_lock))
- failure |= error("Unable to write commit file %s: %s",
+
+ dump_marks_helper(f, 0, marks);
+ if (ferror(f) || fclose(f)) {
+ rollback_lock_file(&mark_lock);
+ failure |= error("Unable to write marks file %s: %s",
mark_file, strerror(errno));
+ return;
+ }
+
+ if (commit_lock_file(&mark_lock)) {
+ rollback_lock_file(&mark_lock);
+ failure |= error("Unable to commit marks file %s: %s",
+ mark_file, strerror(errno));
+ return;
+ }
}
static int read_next_command(void)