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>
This commit is contained in:
committed by
Junio C Hamano
parent
d6cf61bfd4
commit
4ed7cd3ab0
14
bundle.c
14
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)
|
||||
|
||||
Reference in New Issue
Block a user