From: Junio C Hamano Date: Thu, 04 Feb 2016 23:56:58 GMT Subject: Re: [PATCH v2 11/25] fetch-pack: use skip_prefix() instead of starts_with() when possible Message-ID: In-Reply-To: <1454576641-29615-12-git-send-email-pclouds@gmail.com> Nguyễn Thái Ngọc Duy writes: > Signed-off-by: Nguyễn Thái Ngọc Duy > --- OK, with the same comment on "when possible". I would have reused the same "arg" without inventing a separate variable "value" if I were doing this conversion, but either way would be OK. > builtin/fetch-pack.c | 13 +++++++------ > 1 file changed, 7 insertions(+), 6 deletions(-) > > diff --git a/builtin/fetch-pack.c b/builtin/fetch-pack.c > index 9b2a514..0482077 100644 > --- a/builtin/fetch-pack.c > +++ b/builtin/fetch-pack.c > @@ -58,13 +58,14 @@ int cmd_fetch_pack(int argc, const char **argv, const char *prefix) > > for (i = 1; i < argc && *argv[i] == '-'; i++) { > const char *arg = argv[i]; > + const char *value; > > - if (starts_with(arg, "--upload-pack=")) { > - args.uploadpack = arg + 14; > + if (skip_prefix(arg, "--upload-pack=", &value)) { > + args.uploadpack = value; > continue; > } > - if (starts_with(arg, "--exec=")) { > - args.uploadpack = arg + 7; > + if (skip_prefix(arg, "--exec=", &value)) { > + args.uploadpack = value; > continue; > } > if (!strcmp("--quiet", arg) || !strcmp("-q", arg)) { > @@ -100,8 +101,8 @@ int cmd_fetch_pack(int argc, const char **argv, const char *prefix) > args.verbose = 1; > continue; > } > - if (starts_with(arg, "--depth=")) { > - args.depth = strtol(arg + 8, NULL, 0); > + if (skip_prefix(arg, "--depth=", &value)) { > + args.depth = strtol(value, NULL, 0); > continue; > } > if (!strcmp("--no-progress", arg)) {