Commit fa740529 authored by Shawn O. Pearce's avatar Shawn O. Pearce Committed by Junio C Hamano

Always obtain fetch-pack arguments from struct fetch_pack_args

Copying the arguments from a fetch_pack_args into static globals
within the builtin-fetch-pack module is error-prone and may lead
rise to cases where arguments supplied via the struct from the
new fetch_pack() API may not be honored by the implementation.

Here we reorganize all of the static globals into a single static
struct fetch_pack_args instance and use memcpy() to move the data
from the caller supplied structure into the globals before we
execute our pack fetching implementation.  This strategy is more
robust to additions and deletions of properties.

As keep_pack is a single bit we have also introduced lock_pack to
mean not only download and store the packfile via index-pack but
also to lock it against repacking by creating a .keep file when
the packfile itself is stored.  The caller must remove the .keep
file when it is safe to do so.
Signed-off-by: default avatarShawn O. Pearce <[email protected]>
Signed-off-by: default avatarJunio C Hamano <[email protected]>
parent 824d5776
This diff is collapsed.
......@@ -8,14 +8,17 @@ struct fetch_pack_args
int depth;
unsigned quiet:1,
keep_pack:1,
lock_pack:1,
use_thin_pack:1,
fetch_all:1,
verbose:1,
no_progress:1;
};
void setup_fetch_pack(struct fetch_pack_args *args);
struct ref *fetch_pack(const char *dest, int nr_heads, char **heads, char **pack_lockfile);
struct ref *fetch_pack(struct fetch_pack_args *args,
const char *dest,
int nr_heads,
char **heads,
char **pack_lockfile);
#endif
......@@ -314,21 +314,18 @@ static int fetch_refs_via_pack(struct transport *transport,
struct fetch_pack_args args;
int i;
memset(&args, 0, sizeof(args));
args.uploadpack = data->uploadpack;
args.quiet = 0;
args.keep_pack = data->keep;
args.lock_pack = 1;
args.unpacklimit = data->unpacklimit;
args.use_thin_pack = data->thin;
args.fetch_all = 0;
args.verbose = transport->verbose;
args.depth = data->depth;
args.no_progress = 0;
setup_fetch_pack(&args);
for (i = 0; i < nr_heads; i++)
origh[i] = heads[i] = xstrdup(to_fetch[i]->name);
refs = fetch_pack(dest, nr_heads, heads, &transport->pack_lockfile);
refs = fetch_pack(&args, dest, nr_heads, heads, &transport->pack_lockfile);
for (i = 0; i < nr_heads; i++)
free(origh[i]);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment