Skip to content

Commit 7366096

Browse files
avargitster
authored andcommitted
bundle API: change "flags" to be "extra_index_pack_args"
Since the "flags" parameter was added in be042af (Teach progress eye-candy to fetch_refs_from_bundle(), 2011-09-18) there's never been more than the one flag: BUNDLE_VERBOSE. Let's have the only caller who cares about that pass "-v" itself instead through new "extra_index_pack_args" parameter. The flexibility of being able to pass arbitrary arguments to "unbundle" will be used in a subsequent commit. Signed-off-by: Ævar Arnfjörð Bjarmason <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 0834257 commit 7366096

File tree

4 files changed

+19
-10
lines changed

4 files changed

+19
-10
lines changed

builtin/bundle.c

+3-1
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,7 @@ static int cmd_bundle_unbundle(int argc, const char **argv, const char *prefix)
166166
OPT_END()
167167
};
168168
char *bundle_file;
169+
struct strvec extra_index_pack_args = STRVEC_INIT;
169170

170171
argc = parse_options_cmd_bundle(argc, argv, prefix,
171172
builtin_bundle_unbundle_usage, options, &bundle_file);
@@ -177,7 +178,8 @@ static int cmd_bundle_unbundle(int argc, const char **argv, const char *prefix)
177178
}
178179
if (!startup_info->have_repository)
179180
die(_("Need a repository to unbundle."));
180-
ret = !!unbundle(the_repository, &header, bundle_fd, 0) ||
181+
ret = !!unbundle(the_repository, &header, bundle_fd,
182+
&extra_index_pack_args) ||
181183
list_bundle_refs(&header, argc, argv);
182184
bundle_header_release(&header);
183185
cleanup:

bundle.c

+6-6
Original file line numberDiff line numberDiff line change
@@ -569,18 +569,18 @@ int create_bundle(struct repository *r, const char *path,
569569
}
570570

571571
int unbundle(struct repository *r, struct bundle_header *header,
572-
int bundle_fd, int flags)
572+
int bundle_fd, struct strvec *extra_index_pack_args)
573573
{
574-
const char *argv_index_pack[] = {"index-pack",
575-
"--fix-thin", "--stdin", NULL, NULL};
576574
struct child_process ip = CHILD_PROCESS_INIT;
575+
strvec_pushl(&ip.args, "index-pack", "--fix-thin", "--stdin", NULL);
577576

578-
if (flags & BUNDLE_VERBOSE)
579-
argv_index_pack[3] = "-v";
577+
if (extra_index_pack_args) {
578+
strvec_pushv(&ip.args, extra_index_pack_args->v);
579+
strvec_clear(extra_index_pack_args);
580+
}
580581

581582
if (verify_bundle(r, header, 0))
582583
return -1;
583-
ip.argv = argv_index_pack;
584584
ip.in = bundle_fd;
585585
ip.no_stdout = 1;
586586
ip.git_cmd = 1;

bundle.h

+5-2
Original file line numberDiff line numberDiff line change
@@ -26,16 +26,19 @@ int create_bundle(struct repository *r, const char *path,
2626
int argc, const char **argv, struct strvec *pack_options,
2727
int version);
2828
int verify_bundle(struct repository *r, struct bundle_header *header, int verbose);
29-
#define BUNDLE_VERBOSE 1
3029

3130
/**
3231
* Unbundle after reading the header with read_bundle_header().
3332
*
3433
* We'll invoke "git index-pack --stdin --fix-thin" for you on the
3534
* provided `bundle_fd` from read_bundle_header().
35+
*
36+
* Provide "extra_index_pack_args" to pass any extra arguments
37+
* (e.g. "-v" for verbose/progress), NULL otherwise. The provided
38+
* "extra_index_pack_args" (if any) will be strvec_clear()'d for you.
3639
*/
3740
int unbundle(struct repository *r, struct bundle_header *header,
38-
int bundle_fd, int flags);
41+
int bundle_fd, struct strvec *extra_index_pack_args);
3942
int list_bundle_refs(struct bundle_header *header,
4043
int argc, const char **argv);
4144

transport.c

+5-1
Original file line numberDiff line numberDiff line change
@@ -162,12 +162,16 @@ static int fetch_refs_from_bundle(struct transport *transport,
162162
int nr_heads, struct ref **to_fetch)
163163
{
164164
struct bundle_transport_data *data = transport->data;
165+
struct strvec extra_index_pack_args = STRVEC_INIT;
165166
int ret;
166167

168+
if (transport->progress)
169+
strvec_push(&extra_index_pack_args, "-v");
170+
167171
if (!data->get_refs_from_bundle_called)
168172
get_refs_from_bundle(transport, 0, NULL);
169173
ret = unbundle(the_repository, &data->header, data->fd,
170-
transport->progress ? BUNDLE_VERBOSE : 0);
174+
&extra_index_pack_args);
171175
transport->hash_algo = data->header.hash_algo;
172176
return ret;
173177
}

0 commit comments

Comments
 (0)