summaryrefslogtreecommitdiff
path: root/bundle.c
diff options
context:
space:
mode:
authorBrandon Casey <casey@nrlssc.navy.mil>2008-01-16 13:12:46 -0600
committerJunio C Hamano <gitster@pobox.com>2008-01-16 15:35:35 -0800
commit4ed7cd3ab07f7c721daf4241fe1dac306fefd1fb (patch)
treee3b03a59cd0bca192fb396522f813210451404b8 /bundle.c
parentd6cf61bfd4bccffcc8b095f8469dbe749d70abdf (diff)
downloadgit-4ed7cd3ab07f7c721daf4241fe1dac306fefd1fb.tar.gz
Improve use of lockfile API
Remove remaining double close(2)'s. i.e. close() before commit_locked_index() or commit_lock_file(). Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'bundle.c')
-rw-r--r--bundle.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/bundle.c b/bundle.c
index 316aa7420d..5c95eca07d 100644
--- a/bundle.c
+++ b/bundle.c
@@ -317,6 +317,14 @@ int create_bundle(struct bundle_header *header, const char *path,
rls.git_cmd = 1;
if (start_command(&rls))
return error("Could not spawn pack-objects");
+
+ /*
+ * start_command closed bundle_fd if it was > 1
+ * so set the lock fd to -1 so commit_lock_file()
+ * won't fail trying to close it.
+ */
+ lock.fd = -1;
+
for (i = 0; i < revs.pending.nr; i++) {
struct object *object = revs.pending.objects[i].item;
if (object->flags & UNINTERESTING)
@@ -326,10 +334,8 @@ int create_bundle(struct bundle_header *header, const char *path,
}
if (finish_command(&rls))
return error ("pack-objects died");
- close(bundle_fd);
- if (!bundle_to_stdout)
- commit_lock_file(&lock);
- return 0;
+
+ return bundle_to_stdout ? close(bundle_fd) : commit_lock_file(&lock);
}
int unbundle(struct bundle_header *header, int bundle_fd)