Andrew's git
/
gitweb.git
/ diff
summary
|
log
|
commit
| diff |
tree
commit
grep
author
committer
pickaxe
?
re
dump_marks(): reimplement using fdopen_lock_file()
author
Michael Haggerty
<mhagger@alum.mit.edu>
Wed, 1 Oct 2014 11:14:48 +0000
(13:14 +0200)
committer
Junio C Hamano
<gitster@pobox.com>
Wed, 1 Oct 2014 21:20:22 +0000
(14:20 -0700)
Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
fast-import.c
patch
|
blob
|
history
raw
|
patch
|
inline
| side by side (parent:
013870c
)
diff --git
a/fast-import.c
b/fast-import.c
index deadc33f942276af95b2c71bdf3f403a1751de77..fee7906e51792f4bfbfab0b1db2dec3082025edb 100644
(file)
--- a/
fast-import.c
+++ b/
fast-import.c
@@
-1794,20
+1794,18
@@
static void dump_marks_helper(FILE *f,
static void dump_marks(void)
{
static struct lock_file mark_lock;
static void dump_marks(void)
{
static struct lock_file mark_lock;
- int mark_fd;
FILE *f;
if (!export_marks_file)
return;
FILE *f;
if (!export_marks_file)
return;
- mark_fd = hold_lock_file_for_update(&mark_lock, export_marks_file, 0);
- if (mark_fd < 0) {
+ if (hold_lock_file_for_update(&mark_lock, export_marks_file, 0) < 0) {
failure |= error("Unable to write marks file %s: %s",
export_marks_file, strerror(errno));
return;
}
failure |= error("Unable to write marks file %s: %s",
export_marks_file, strerror(errno));
return;
}
- f = fdopen
(mark_fd
, "w");
+ f = fdopen
_lock_file(&mark_lock
, "w");
if (!f) {
int saved_errno = errno;
rollback_lock_file(&mark_lock);
if (!f) {
int saved_errno = errno;
rollback_lock_file(&mark_lock);
@@
-1816,22
+1814,7
@@
static void dump_marks(void)
return;
}
return;
}
- /*
- * 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;
-
dump_marks_helper(f, 0, marks);
dump_marks_helper(f, 0, marks);
- if (ferror(f) || fclose(f)) {
- int saved_errno = errno;
- rollback_lock_file(&mark_lock);
- failure |= error("Unable to write marks file %s: %s",
- export_marks_file, strerror(saved_errno));
- return;
- }
-
if (commit_lock_file(&mark_lock)) {
failure |= error("Unable to commit marks file %s: %s",
export_marks_file, strerror(errno));
if (commit_lock_file(&mark_lock)) {
failure |= error("Unable to commit marks file %s: %s",
export_marks_file, strerror(errno));