Merge branch 'jk/gitweb-with-newer-cgi-multi-param' into maint
[gitweb.git] / fast-import.c
index 96b0f4236a2083044e4ae1dfa3b8180e3e586ba1..d0bd285a16d0161b50d0b43e0315f8fa003e0e32 100644 (file)
@@ -153,6 +153,7 @@ Format of STDIN stream:
 
 #include "builtin.h"
 #include "cache.h"
+#include "lockfile.h"
 #include "object.h"
 #include "blob.h"
 #include "tree.h"
@@ -1715,8 +1716,8 @@ static int update_branch(struct branch *b)
        transaction = ref_transaction_begin(&err);
        if (!transaction ||
            ref_transaction_update(transaction, b->name, b->sha1, old_sha1,
-                                  0, 1, &err) ||
-           ref_transaction_commit(transaction, msg, &err)) {
+                                  0, 1, msg, &err) ||
+           ref_transaction_commit(transaction, &err)) {
                ref_transaction_free(transaction);
                error("%s", err.buf);
                strbuf_release(&err);
@@ -1756,12 +1757,12 @@ static void dump_tags(void)
                strbuf_addf(&ref_name, "refs/tags/%s", t->name);
 
                if (ref_transaction_update(transaction, ref_name.buf, t->sha1,
-                                          NULL, 0, 0, &err)) {
+                                          NULL, 0, 0, msg, &err)) {
                        failure |= error("%s", err.buf);
                        goto cleanup;
                }
        }
-       if (ref_transaction_commit(transaction, msg, &err))
+       if (ref_transaction_commit(transaction, &err))
                failure |= error("%s", err.buf);
 
  cleanup:
@@ -1793,20 +1794,18 @@ static void dump_marks_helper(FILE *f,
 static void dump_marks(void)
 {
        static struct lock_file mark_lock;
-       int mark_fd;
        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;
        }
 
-       f = fdopen(mark_fd, "w");
+       f = fdopen_lock_file(&mark_lock, "w");
        if (!f) {
                int saved_errno = errno;
                rollback_lock_file(&mark_lock);
@@ -1815,27 +1814,10 @@ static void dump_marks(void)
                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);
-       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)) {
-               int saved_errno = errno;
-               rollback_lock_file(&mark_lock);
                failure |= error("Unable to commit marks file %s: %s",
-                       export_marks_file, strerror(saved_errno));
+                       export_marks_file, strerror(errno));
                return;
        }
 }