Skip to content

Commit

Permalink
checkout-index: disallow "--no-stage" option
Browse files Browse the repository at this point in the history
We do not really expect people to use "--no-stage", but if
they do, git currently segfaults. We could instead have it
undo the effects of a previous "--stage", but this gets
tricky around the "to_tempfile" flag. We cannot simply reset
it to 0, because we don't know if it was set by a previous
"--stage=all" or an explicit "--temp" option.

We could solve this by setting a flag and resolving
to_tempfile later, but it's not worth the effort. Nobody
actually wants to use "--no-stage"; we are just trying to
fix a potential segfault here.

While we're in the area, let's improve the user-facing
messages for this option. The error string should be
translatable, and we should give some hint in the "-h"
output about what can go in the argument field.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
Jeff King authored and Junio C Hamano committed Feb 1, 2016
1 parent 6a6df8a commit 2239617
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions builtin/checkout-index.c
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ static int option_parse_stage(const struct option *opt,
if ('1' <= ch && ch <= '3')
checkout_stage = arg[0] - '0';
else
die("stage should be between 1 and 3 or all");
die(_("stage should be between 1 and 3 or all"));
}
return 0;
}
Expand Down Expand Up @@ -173,9 +173,9 @@ int cmd_checkout_index(int argc, const char **argv, const char *prefix)
N_("write the content to temporary files")),
OPT_STRING(0, "prefix", &state.base_dir, N_("string"),
N_("when creating files, prepend <string>")),
OPT_CALLBACK(0, "stage", NULL, NULL,
{ OPTION_CALLBACK, 0, "stage", NULL, "1-3|all",
N_("copy out the files from named stage"),
option_parse_stage),
PARSE_OPT_NONEG, option_parse_stage },
OPT_END()
};

Expand Down

0 comments on commit 2239617

Please sign in to comment.