update-index: drop unused argc from do_reupdate()

The parse-options callback for --again soaks up all remaining options by
manipulating the parse_opt_ctx's argc and argv fields. Even though it
has to look at both, the actual parsing happens via the do_reupdate()
helper, which only looks at the argv half (by passing it along to
parse_pathspec). So that helper doesn't need to see argc at all.

Note that the helper does look at "argv + 1" without confirming that
argc is greater than 0. We know this is correct because it is skipping
past the actual "--again" string, which will always be present. However,
to make what's going on more obvious, let's move that "+1" into the
caller, which has the matching "-1" when fixing up the ctx's argc/argv.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Jeff King 2022-10-17 21:04:45 -04:00 committed by Junio C Hamano
parent 70aa1d7576
commit 827f8305c4

View File

@ -732,7 +732,7 @@ static int do_unresolve(int ac, const char **av,
return err; return err;
} }
static int do_reupdate(int ac, const char **av, static int do_reupdate(const char **paths,
const char *prefix) const char *prefix)
{ {
/* Read HEAD and run update-index on paths that are /* Read HEAD and run update-index on paths that are
@ -744,7 +744,7 @@ static int do_reupdate(int ac, const char **av,
parse_pathspec(&pathspec, 0, parse_pathspec(&pathspec, 0,
PATHSPEC_PREFER_CWD, PATHSPEC_PREFER_CWD,
prefix, av + 1); prefix, paths);
if (read_ref("HEAD", &head_oid)) if (read_ref("HEAD", &head_oid))
/* If there is no HEAD, that means it is an initial /* If there is no HEAD, that means it is an initial
@ -970,7 +970,7 @@ static enum parse_opt_result reupdate_callback(
/* consume remaining arguments. */ /* consume remaining arguments. */
setup_work_tree(); setup_work_tree();
*has_errors = do_reupdate(ctx->argc, ctx->argv, prefix); *has_errors = do_reupdate(ctx->argv + 1, prefix);
if (*has_errors) if (*has_errors)
active_cache_changed = 0; active_cache_changed = 0;