Re: [PATCH v2 21/25] fetch: define shallow boundary with --shallow-exclude
- From
Duy Nguyen <pclouds@gmail.com>
- Date
- Feb 15, 2016, 08:15 UTC
- Message-ID
- <20160215081539.GA12609@lanh>
- In-Reply-To
- <CAPig+cR01WCgyJQuDcq-j5Z6u3S-LO5kUVuT+g-jdu-hoH-5yw@mail.gmail.com>
On Mon, Feb 15, 2016 at 12:52:26AM -0500, Eric Sunshine wrote:
Show 5 quoted lines
> Yes, dropping 'const' was implied. I didn't examine it too deeply, but > it did not appear as if there would be any major fallout from dropping > 'const'. It feels a bit cleaner to keep it all self-contained than to > have that somewhat oddball static string_list*, but it's not such a > big deal that I'd insist upon a rewrite.
Dropping 'const' is not a big deal. But before we do that, how about this instead? I think the code looks better, and the compiler can still catch invalid updates to deepen_not.
diff --git a/builtin/fetch-pack.c b/builtin/fetch-pack.c index 0402e27..07570be 100644 --- a/builtin/fetch-pack.c +++ b/builtin/fetch-pack.c @@ -50,6 +50,7 @@ int cmd_fetch_pack(int argc, const char **argv, const char *prefix) struct child_process *conn; struct fetch_pack_args args; struct sha1_array shallow = SHA1_ARRAY_INIT; + struct string_list deepen_not = STRING_LIST_INIT_DUP; packet_trace_identity("fetch-pack"); @@ -108,6 +109,10 @@ int cmd_fetch_pack(int argc, const char **argv, const char *prefix) args.deepen_since = xstrdup(arg); continue; } + if (skip_prefix(arg, "--shallow-exclude=", &arg)) { + string_list_append(&deepen_not, arg); + continue; + } if (!strcmp("--no-progress", arg)) { args.no_progress = 1; continue; @@ -135,6 +140,8 @@ int cmd_fetch_pack(int argc, const char **argv, const char *prefix) } usage(fetch_pack_usage); } + if (deepen_not.nr) + args.deepen_not = &deepen_not; if (i < argc) dest = argv[i++]; -- Duy