6 * Basic handler for bundle files to connect repositories via sneakernet.
7 * Invocation must include action.
8 * This function can create a bundle or provide information on an existing
9 * bundle supporting git-fetch, git-pull, and git-ls-remote
12 static const char *bundle_usage
="git-bundle (create <bundle> <git-rev-list args> | verify <bundle> | list-heads <bundle> [refname]... | unbundle <bundle> [refname]... )";
14 int cmd_bundle(int argc
, const char **argv
, const char *prefix
)
16 struct bundle_header header
;
18 const char *cmd
, *bundle_file
;
20 char buffer
[PATH_MAX
];
26 bundle_file
= argv
[2];
30 prefix
= setup_git_directory_gently(&nongit
);
31 if (prefix
&& bundle_file
[0] != '/') {
32 snprintf(buffer
, sizeof(buffer
), "%s/%s", prefix
, bundle_file
);
36 memset(&header
, 0, sizeof(header
));
37 if (strcmp(cmd
, "create") && (bundle_fd
=
38 read_bundle_header(bundle_file
, &header
)) < 0)
41 if (!strcmp(cmd
, "verify")) {
43 if (verify_bundle(&header
, 1))
45 fprintf(stderr
, "%s is okay\n", bundle_file
);
48 if (!strcmp(cmd
, "list-heads")) {
50 return !!list_bundle_refs(&header
, argc
, argv
);
52 if (!strcmp(cmd
, "create")) {
54 die("Need a repository to create a bundle.");
55 return !!create_bundle(&header
, bundle_file
, argc
, argv
);
56 } else if (!strcmp(cmd
, "unbundle")) {
58 die("Need a repository to unbundle.");
59 return !!unbundle(&header
, bundle_fd
) ||
60 list_bundle_refs(&header
, argc
, argv
);