Fix compilation when NO_CURL is defined
[git/platforms.git] / transport.c
blob46da754078f3c679e62124fb7e7468e44d85dafc
1 #include "cache.h"
2 #include "transport.h"
3 #include "run-command.h"
4 #ifndef NO_CURL
5 #include "http.h"
6 #endif
7 #include "pkt-line.h"
8 #include "fetch-pack.h"
9 #include "walker.h"
10 #include "bundle.h"
11 #include "dir.h"
12 #include "refs.h"
14 /* rsync support */
17 * We copy packed-refs and refs/ into a temporary file, then read the
18 * loose refs recursively (sorting whenever possible), and then inserting
19 * those packed refs that are not yet in the list (not validating, but
20 * assuming that the file is sorted).
22 * Appears refactoring this from refs.c is too cumbersome.
25 static int str_cmp(const void *a, const void *b)
27 const char *s1 = a;
28 const char *s2 = b;
30 return strcmp(s1, s2);
33 /* path->buf + name_offset is expected to point to "refs/" */
35 static int read_loose_refs(struct strbuf *path, int name_offset,
36 struct ref **tail)
38 DIR *dir = opendir(path->buf);
39 struct dirent *de;
40 struct {
41 char **entries;
42 int nr, alloc;
43 } list;
44 int i, pathlen;
46 if (!dir)
47 return -1;
49 memset (&list, 0, sizeof(list));
51 while ((de = readdir(dir))) {
52 if (de->d_name[0] == '.' && (de->d_name[1] == '\0' ||
53 (de->d_name[1] == '.' &&
54 de->d_name[2] == '\0')))
55 continue;
56 ALLOC_GROW(list.entries, list.nr + 1, list.alloc);
57 list.entries[list.nr++] = xstrdup(de->d_name);
59 closedir(dir);
61 /* sort the list */
63 qsort(list.entries, list.nr, sizeof(char *), str_cmp);
65 pathlen = path->len;
66 strbuf_addch(path, '/');
68 for (i = 0; i < list.nr; i++, strbuf_setlen(path, pathlen + 1)) {
69 strbuf_addstr(path, list.entries[i]);
70 if (read_loose_refs(path, name_offset, tail)) {
71 int fd = open(path->buf, O_RDONLY);
72 char buffer[40];
73 struct ref *next;
75 if (fd < 0)
76 continue;
77 next = alloc_ref(path->len - name_offset + 1);
78 if (read_in_full(fd, buffer, 40) != 40 ||
79 get_sha1_hex(buffer, next->old_sha1)) {
80 close(fd);
81 free(next);
82 continue;
84 close(fd);
85 strcpy(next->name, path->buf + name_offset);
86 (*tail)->next = next;
87 *tail = next;
90 strbuf_setlen(path, pathlen);
92 for (i = 0; i < list.nr; i++)
93 free(list.entries[i]);
94 free(list.entries);
96 return 0;
99 /* insert the packed refs for which no loose refs were found */
101 static void insert_packed_refs(const char *packed_refs, struct ref **list)
103 FILE *f = fopen(packed_refs, "r");
104 static char buffer[PATH_MAX];
106 if (!f)
107 return;
109 for (;;) {
110 int cmp, len;
112 if (!fgets(buffer, sizeof(buffer), f)) {
113 fclose(f);
114 return;
117 if (hexval(buffer[0]) > 0xf)
118 continue;
119 len = strlen(buffer);
120 if (buffer[len - 1] == '\n')
121 buffer[--len] = '\0';
122 if (len < 41)
123 continue;
124 while ((*list)->next &&
125 (cmp = strcmp(buffer + 41,
126 (*list)->next->name)) > 0)
127 list = &(*list)->next;
128 if (!(*list)->next || cmp < 0) {
129 struct ref *next = alloc_ref(len - 40);
130 buffer[40] = '\0';
131 if (get_sha1_hex(buffer, next->old_sha1)) {
132 warning ("invalid SHA-1: %s", buffer);
133 free(next);
134 continue;
136 strcpy(next->name, buffer + 41);
137 next->next = (*list)->next;
138 (*list)->next = next;
139 list = &(*list)->next;
144 static struct ref *get_refs_via_rsync(const struct transport *transport)
146 struct strbuf buf = STRBUF_INIT, temp_dir = STRBUF_INIT;
147 struct ref dummy, *tail = &dummy;
148 struct child_process rsync;
149 const char *args[5];
150 int temp_dir_len;
152 /* copy the refs to the temporary directory */
154 strbuf_addstr(&temp_dir, git_path("rsync-refs-XXXXXX"));
155 if (!mkdtemp(temp_dir.buf))
156 die ("Could not make temporary directory");
157 temp_dir_len = temp_dir.len;
159 strbuf_addstr(&buf, transport->url);
160 strbuf_addstr(&buf, "/refs");
162 memset(&rsync, 0, sizeof(rsync));
163 rsync.argv = args;
164 rsync.stdout_to_stderr = 1;
165 args[0] = "rsync";
166 args[1] = (transport->verbose > 0) ? "-rv" : "-r";
167 args[2] = buf.buf;
168 args[3] = temp_dir.buf;
169 args[4] = NULL;
171 if (run_command(&rsync))
172 die ("Could not run rsync to get refs");
174 strbuf_reset(&buf);
175 strbuf_addstr(&buf, transport->url);
176 strbuf_addstr(&buf, "/packed-refs");
178 args[2] = buf.buf;
180 if (run_command(&rsync))
181 die ("Could not run rsync to get refs");
183 /* read the copied refs */
185 strbuf_addstr(&temp_dir, "/refs");
186 read_loose_refs(&temp_dir, temp_dir_len + 1, &tail);
187 strbuf_setlen(&temp_dir, temp_dir_len);
189 tail = &dummy;
190 strbuf_addstr(&temp_dir, "/packed-refs");
191 insert_packed_refs(temp_dir.buf, &tail);
192 strbuf_setlen(&temp_dir, temp_dir_len);
194 if (remove_dir_recursively(&temp_dir, 0))
195 warning ("Error removing temporary directory %s.",
196 temp_dir.buf);
198 strbuf_release(&buf);
199 strbuf_release(&temp_dir);
201 return dummy.next;
204 static int fetch_objs_via_rsync(struct transport *transport,
205 int nr_objs, struct ref **to_fetch)
207 struct strbuf buf = STRBUF_INIT;
208 struct child_process rsync;
209 const char *args[8];
210 int result;
212 strbuf_addstr(&buf, transport->url);
213 strbuf_addstr(&buf, "/objects/");
215 memset(&rsync, 0, sizeof(rsync));
216 rsync.argv = args;
217 rsync.stdout_to_stderr = 1;
218 args[0] = "rsync";
219 args[1] = (transport->verbose > 0) ? "-rv" : "-r";
220 args[2] = "--ignore-existing";
221 args[3] = "--exclude";
222 args[4] = "info";
223 args[5] = buf.buf;
224 args[6] = get_object_directory();
225 args[7] = NULL;
227 /* NEEDSWORK: handle one level of alternates */
228 result = run_command(&rsync);
230 strbuf_release(&buf);
232 return result;
235 static int write_one_ref(const char *name, const unsigned char *sha1,
236 int flags, void *data)
238 struct strbuf *buf = data;
239 int len = buf->len;
240 FILE *f;
242 /* when called via for_each_ref(), flags is non-zero */
243 if (flags && prefixcmp(name, "refs/heads/") &&
244 prefixcmp(name, "refs/tags/"))
245 return 0;
247 strbuf_addstr(buf, name);
248 if (safe_create_leading_directories(buf->buf) ||
249 !(f = fopen(buf->buf, "w")) ||
250 fprintf(f, "%s\n", sha1_to_hex(sha1)) < 0 ||
251 fclose(f))
252 return error("problems writing temporary file %s", buf->buf);
253 strbuf_setlen(buf, len);
254 return 0;
257 static int write_refs_to_temp_dir(struct strbuf *temp_dir,
258 int refspec_nr, const char **refspec)
260 int i;
262 for (i = 0; i < refspec_nr; i++) {
263 unsigned char sha1[20];
264 char *ref;
266 if (dwim_ref(refspec[i], strlen(refspec[i]), sha1, &ref) != 1)
267 return error("Could not get ref %s", refspec[i]);
269 if (write_one_ref(ref, sha1, 0, temp_dir)) {
270 free(ref);
271 return -1;
273 free(ref);
275 return 0;
278 static int rsync_transport_push(struct transport *transport,
279 int refspec_nr, const char **refspec, int flags)
281 struct strbuf buf = STRBUF_INIT, temp_dir = STRBUF_INIT;
282 int result = 0, i;
283 struct child_process rsync;
284 const char *args[8];
286 /* first push the objects */
288 strbuf_addstr(&buf, transport->url);
289 strbuf_addch(&buf, '/');
291 memset(&rsync, 0, sizeof(rsync));
292 rsync.argv = args;
293 rsync.stdout_to_stderr = 1;
294 args[0] = "rsync";
295 args[1] = (transport->verbose > 0) ? "-av" : "-a";
296 args[2] = "--ignore-existing";
297 args[3] = "--exclude";
298 args[4] = "info";
299 args[5] = get_object_directory();;
300 args[6] = buf.buf;
301 args[7] = NULL;
303 if (run_command(&rsync))
304 return error("Could not push objects to %s", transport->url);
306 /* copy the refs to the temporary directory; they could be packed. */
308 strbuf_addstr(&temp_dir, git_path("rsync-refs-XXXXXX"));
309 if (!mkdtemp(temp_dir.buf))
310 die ("Could not make temporary directory");
311 strbuf_addch(&temp_dir, '/');
313 if (flags & TRANSPORT_PUSH_ALL) {
314 if (for_each_ref(write_one_ref, &temp_dir))
315 return -1;
316 } else if (write_refs_to_temp_dir(&temp_dir, refspec_nr, refspec))
317 return -1;
319 i = (flags & TRANSPORT_PUSH_FORCE) ? 2 : 3;
320 args[i++] = temp_dir.buf;
321 args[i++] = transport->url;
322 args[i++] = NULL;
323 if (run_command(&rsync))
324 result = error("Could not push to %s", transport->url);
326 if (remove_dir_recursively(&temp_dir, 0))
327 warning ("Could not remove temporary directory %s.",
328 temp_dir.buf);
330 strbuf_release(&buf);
331 strbuf_release(&temp_dir);
333 return result;
336 /* Generic functions for using commit walkers */
338 static int fetch_objs_via_walker(struct transport *transport,
339 int nr_objs, struct ref **to_fetch)
341 char *dest = xstrdup(transport->url);
342 struct walker *walker = transport->data;
343 char **objs = xmalloc(nr_objs * sizeof(*objs));
344 int i;
346 walker->get_all = 1;
347 walker->get_tree = 1;
348 walker->get_history = 1;
349 walker->get_verbosely = transport->verbose >= 0;
350 walker->get_recover = 0;
352 for (i = 0; i < nr_objs; i++)
353 objs[i] = xstrdup(sha1_to_hex(to_fetch[i]->old_sha1));
355 if (walker_fetch(walker, nr_objs, objs, NULL, NULL))
356 die("Fetch failed.");
358 for (i = 0; i < nr_objs; i++)
359 free(objs[i]);
360 free(objs);
361 free(dest);
362 return 0;
365 static int disconnect_walker(struct transport *transport)
367 struct walker *walker = transport->data;
368 if (walker)
369 walker_free(walker);
370 return 0;
373 #ifndef NO_CURL
374 static int curl_transport_push(struct transport *transport, int refspec_nr, const char **refspec, int flags) {
375 const char **argv;
376 int argc;
377 int err;
379 argv = xmalloc((refspec_nr + 11) * sizeof(char *));
380 argv[0] = "http-push";
381 argc = 1;
382 if (flags & TRANSPORT_PUSH_ALL)
383 argv[argc++] = "--all";
384 if (flags & TRANSPORT_PUSH_FORCE)
385 argv[argc++] = "--force";
386 argv[argc++] = transport->url;
387 while (refspec_nr--)
388 argv[argc++] = *refspec++;
389 argv[argc] = NULL;
390 err = run_command_v_opt(argv, RUN_GIT_CMD);
391 switch (err) {
392 case -ERR_RUN_COMMAND_FORK:
393 error("unable to fork for %s", argv[0]);
394 case -ERR_RUN_COMMAND_EXEC:
395 error("unable to exec %s", argv[0]);
396 break;
397 case -ERR_RUN_COMMAND_WAITPID:
398 case -ERR_RUN_COMMAND_WAITPID_WRONG_PID:
399 case -ERR_RUN_COMMAND_WAITPID_SIGNAL:
400 case -ERR_RUN_COMMAND_WAITPID_NOEXIT:
401 error("%s died with strange error", argv[0]);
403 return !!err;
406 static int missing__target(int code, int result)
408 return /* file:// URL -- do we ever use one??? */
409 (result == CURLE_FILE_COULDNT_READ_FILE) ||
410 /* http:// and https:// URL */
411 (code == 404 && result == CURLE_HTTP_RETURNED_ERROR) ||
412 /* ftp:// URL */
413 (code == 550 && result == CURLE_FTP_COULDNT_RETR_FILE)
417 #define missing_target(a) missing__target((a)->http_code, (a)->curl_result)
419 static struct ref *get_refs_via_curl(const struct transport *transport)
421 struct buffer buffer;
422 char *data, *start, *mid;
423 char *ref_name;
424 char *refs_url;
425 int i = 0;
427 struct active_request_slot *slot;
428 struct slot_results results;
430 struct ref *refs = NULL;
431 struct ref *ref = NULL;
432 struct ref *last_ref = NULL;
434 data = xmalloc(4096);
435 buffer.size = 4096;
436 buffer.posn = 0;
437 buffer.buffer = data;
439 refs_url = xmalloc(strlen(transport->url) + 11);
440 sprintf(refs_url, "%s/info/refs", transport->url);
442 http_init();
444 slot = get_active_slot();
445 slot->results = &results;
446 curl_easy_setopt(slot->curl, CURLOPT_FILE, &buffer);
447 curl_easy_setopt(slot->curl, CURLOPT_WRITEFUNCTION, fwrite_buffer);
448 curl_easy_setopt(slot->curl, CURLOPT_URL, refs_url);
449 curl_easy_setopt(slot->curl, CURLOPT_HTTPHEADER, NULL);
450 if (start_active_slot(slot)) {
451 run_active_slot(slot);
452 if (results.curl_result != CURLE_OK) {
453 if (missing_target(&results)) {
454 free(buffer.buffer);
455 return NULL;
456 } else {
457 free(buffer.buffer);
458 error("%s", curl_errorstr);
459 return NULL;
462 } else {
463 free(buffer.buffer);
464 error("Unable to start request");
465 return NULL;
468 http_cleanup();
470 data = buffer.buffer;
471 start = NULL;
472 mid = data;
473 while (i < buffer.posn) {
474 if (!start)
475 start = &data[i];
476 if (data[i] == '\t')
477 mid = &data[i];
478 if (data[i] == '\n') {
479 data[i] = 0;
480 ref_name = mid + 1;
481 ref = xmalloc(sizeof(struct ref) +
482 strlen(ref_name) + 1);
483 memset(ref, 0, sizeof(struct ref));
484 strcpy(ref->name, ref_name);
485 get_sha1_hex(start, ref->old_sha1);
486 if (!refs)
487 refs = ref;
488 if (last_ref)
489 last_ref->next = ref;
490 last_ref = ref;
491 start = NULL;
493 i++;
496 free(buffer.buffer);
498 return refs;
501 static int fetch_objs_via_curl(struct transport *transport,
502 int nr_objs, struct ref **to_fetch)
504 if (!transport->data)
505 transport->data = get_http_walker(transport->url);
506 return fetch_objs_via_walker(transport, nr_objs, to_fetch);
509 #endif
511 struct bundle_transport_data {
512 int fd;
513 struct bundle_header header;
516 static struct ref *get_refs_from_bundle(const struct transport *transport)
518 struct bundle_transport_data *data = transport->data;
519 struct ref *result = NULL;
520 int i;
522 if (data->fd > 0)
523 close(data->fd);
524 data->fd = read_bundle_header(transport->url, &data->header);
525 if (data->fd < 0)
526 die ("Could not read bundle '%s'.", transport->url);
527 for (i = 0; i < data->header.references.nr; i++) {
528 struct ref_list_entry *e = data->header.references.list + i;
529 struct ref *ref = alloc_ref(strlen(e->name) + 1);
530 hashcpy(ref->old_sha1, e->sha1);
531 strcpy(ref->name, e->name);
532 ref->next = result;
533 result = ref;
535 return result;
538 static int fetch_refs_from_bundle(struct transport *transport,
539 int nr_heads, struct ref **to_fetch)
541 struct bundle_transport_data *data = transport->data;
542 return unbundle(&data->header, data->fd);
545 static int close_bundle(struct transport *transport)
547 struct bundle_transport_data *data = transport->data;
548 if (data->fd > 0)
549 close(data->fd);
550 free(data);
551 return 0;
554 struct git_transport_data {
555 unsigned thin : 1;
556 unsigned keep : 1;
557 int depth;
558 const char *uploadpack;
559 const char *receivepack;
562 static int set_git_option(struct transport *connection,
563 const char *name, const char *value)
565 struct git_transport_data *data = connection->data;
566 if (!strcmp(name, TRANS_OPT_UPLOADPACK)) {
567 data->uploadpack = value;
568 return 0;
569 } else if (!strcmp(name, TRANS_OPT_RECEIVEPACK)) {
570 data->receivepack = value;
571 return 0;
572 } else if (!strcmp(name, TRANS_OPT_THIN)) {
573 data->thin = !!value;
574 return 0;
575 } else if (!strcmp(name, TRANS_OPT_KEEP)) {
576 data->keep = !!value;
577 return 0;
578 } else if (!strcmp(name, TRANS_OPT_DEPTH)) {
579 if (!value)
580 data->depth = 0;
581 else
582 data->depth = atoi(value);
583 return 0;
585 return 1;
588 static struct ref *get_refs_via_connect(const struct transport *transport)
590 struct git_transport_data *data = transport->data;
591 struct ref *refs;
592 int fd[2];
593 pid_t pid;
594 char *dest = xstrdup(transport->url);
596 pid = git_connect(fd, dest, data->uploadpack, 0);
598 if (pid < 0)
599 die("Failed to connect to \"%s\"", transport->url);
601 get_remote_heads(fd[0], &refs, 0, NULL, 0);
602 packet_flush(fd[1]);
604 finish_connect(pid);
606 free(dest);
608 return refs;
611 static int fetch_refs_via_pack(struct transport *transport,
612 int nr_heads, struct ref **to_fetch)
614 struct git_transport_data *data = transport->data;
615 char **heads = xmalloc(nr_heads * sizeof(*heads));
616 char **origh = xmalloc(nr_heads * sizeof(*origh));
617 struct ref *refs;
618 char *dest = xstrdup(transport->url);
619 struct fetch_pack_args args;
620 int i;
622 memset(&args, 0, sizeof(args));
623 args.uploadpack = data->uploadpack;
624 args.keep_pack = data->keep;
625 args.lock_pack = 1;
626 args.use_thin_pack = data->thin;
627 args.verbose = transport->verbose > 0;
628 args.depth = data->depth;
630 for (i = 0; i < nr_heads; i++)
631 origh[i] = heads[i] = xstrdup(to_fetch[i]->name);
632 refs = fetch_pack(&args, dest, nr_heads, heads, &transport->pack_lockfile);
634 for (i = 0; i < nr_heads; i++)
635 free(origh[i]);
636 free(origh);
637 free(heads);
638 free_refs(refs);
639 free(dest);
640 return 0;
643 static int git_transport_push(struct transport *transport, int refspec_nr, const char **refspec, int flags) {
644 struct git_transport_data *data = transport->data;
645 const char **argv;
646 char *rem;
647 int argc;
648 int err;
650 argv = xmalloc((refspec_nr + 11) * sizeof(char *));
651 argv[0] = "send-pack";
652 argc = 1;
653 if (flags & TRANSPORT_PUSH_ALL)
654 argv[argc++] = "--all";
655 if (flags & TRANSPORT_PUSH_FORCE)
656 argv[argc++] = "--force";
657 if (data->receivepack) {
658 char *rp = xmalloc(strlen(data->receivepack) + 16);
659 sprintf(rp, "--receive-pack=%s", data->receivepack);
660 argv[argc++] = rp;
662 if (data->thin)
663 argv[argc++] = "--thin";
664 rem = xmalloc(strlen(transport->remote->name) + 10);
665 sprintf(rem, "--remote=%s", transport->remote->name);
666 argv[argc++] = rem;
667 argv[argc++] = transport->url;
668 while (refspec_nr--)
669 argv[argc++] = *refspec++;
670 argv[argc] = NULL;
671 err = run_command_v_opt(argv, RUN_GIT_CMD);
672 switch (err) {
673 case -ERR_RUN_COMMAND_FORK:
674 error("unable to fork for %s", argv[0]);
675 case -ERR_RUN_COMMAND_EXEC:
676 error("unable to exec %s", argv[0]);
677 break;
678 case -ERR_RUN_COMMAND_WAITPID:
679 case -ERR_RUN_COMMAND_WAITPID_WRONG_PID:
680 case -ERR_RUN_COMMAND_WAITPID_SIGNAL:
681 case -ERR_RUN_COMMAND_WAITPID_NOEXIT:
682 error("%s died with strange error", argv[0]);
684 return !!err;
687 static int disconnect_git(struct transport *transport)
689 free(transport->data);
690 return 0;
693 static int is_local(const char *url)
695 const char *colon = strchr(url, ':');
696 const char *slash = strchr(url, '/');
697 return !colon || (slash && slash < colon);
700 static int is_file(const char *url)
702 struct stat buf;
703 if (stat(url, &buf))
704 return 0;
705 return S_ISREG(buf.st_mode);
708 struct transport *transport_get(struct remote *remote, const char *url)
710 struct transport *ret = xcalloc(1, sizeof(*ret));
712 ret->remote = remote;
713 ret->url = url;
715 if (!prefixcmp(url, "rsync://")) {
716 ret->get_refs_list = get_refs_via_rsync;
717 ret->fetch = fetch_objs_via_rsync;
718 ret->push = rsync_transport_push;
720 } else if (!prefixcmp(url, "http://")
721 || !prefixcmp(url, "https://")
722 || !prefixcmp(url, "ftp://")) {
723 #ifdef NO_CURL
724 error("git was compiled without libcurl support.");
725 #else
726 ret->get_refs_list = get_refs_via_curl;
727 ret->fetch = fetch_objs_via_curl;
728 ret->push = curl_transport_push;
729 #endif
730 ret->disconnect = disconnect_walker;
732 } else if (is_local(url) && is_file(url)) {
733 struct bundle_transport_data *data = xcalloc(1, sizeof(*data));
734 ret->data = data;
735 ret->get_refs_list = get_refs_from_bundle;
736 ret->fetch = fetch_refs_from_bundle;
737 ret->disconnect = close_bundle;
739 } else {
740 struct git_transport_data *data = xcalloc(1, sizeof(*data));
741 ret->data = data;
742 ret->set_option = set_git_option;
743 ret->get_refs_list = get_refs_via_connect;
744 ret->fetch = fetch_refs_via_pack;
745 ret->push = git_transport_push;
746 ret->disconnect = disconnect_git;
748 data->thin = 1;
749 data->uploadpack = "git-upload-pack";
750 if (remote && remote->uploadpack)
751 data->uploadpack = remote->uploadpack;
752 data->receivepack = "git-receive-pack";
753 if (remote && remote->receivepack)
754 data->receivepack = remote->receivepack;
757 return ret;
760 int transport_set_option(struct transport *transport,
761 const char *name, const char *value)
763 if (transport->set_option)
764 return transport->set_option(transport, name, value);
765 return 1;
768 int transport_push(struct transport *transport,
769 int refspec_nr, const char **refspec, int flags)
771 if (!transport->push)
772 return 1;
773 return transport->push(transport, refspec_nr, refspec, flags);
776 struct ref *transport_get_remote_refs(struct transport *transport)
778 if (!transport->remote_refs)
779 transport->remote_refs = transport->get_refs_list(transport);
780 return transport->remote_refs;
783 int transport_fetch_refs(struct transport *transport, struct ref *refs)
785 int rc;
786 int nr_heads = 0, nr_alloc = 0;
787 struct ref **heads = NULL;
788 struct ref *rm;
790 for (rm = refs; rm; rm = rm->next) {
791 if (rm->peer_ref &&
792 !hashcmp(rm->peer_ref->old_sha1, rm->old_sha1))
793 continue;
794 ALLOC_GROW(heads, nr_heads + 1, nr_alloc);
795 heads[nr_heads++] = rm;
798 rc = transport->fetch(transport, nr_heads, heads);
799 free(heads);
800 return rc;
803 void transport_unlock_pack(struct transport *transport)
805 if (transport->pack_lockfile) {
806 unlink(transport->pack_lockfile);
807 free(transport->pack_lockfile);
808 transport->pack_lockfile = NULL;
812 int transport_disconnect(struct transport *transport)
814 int ret = 0;
815 if (transport->disconnect)
816 ret = transport->disconnect(transport);
817 free(transport);
818 return ret;