summaryrefslogtreecommitdiffstats
path: root/builtin/apply.c
diff options
context:
space:
mode:
authorJeff King <peff@peff.net>2016-01-31 12:35:46 +0100
committerJunio C Hamano <gitster@pobox.com>2016-02-01 23:14:20 +0100
commit1f3c79a9d6c3278753e7fb63b48569a9ff8632df (patch)
tree904b918bc2dd1aa8f62ca578e36384f61662926c /builtin/apply.c
parentcheckout-index: disallow "--no-stage" option (diff)
downloadgit-1f3c79a9d6c3278753e7fb63b48569a9ff8632df.tar.xz
git-1f3c79a9d6c3278753e7fb63b48569a9ff8632df.zip
apply, ls-files: simplify "-z" parsing
As a short option, we cannot handle negation. Thus a callback handling "unset" is overkill, and we can just use OPT_SET_INT instead to handle setting the option. Anybody who adds "--nul" synonym to this later would need to be careful not to break "--no-nul", which should mean that lines are terminated with LF at the end. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin/apply.c')
-rw-r--r--builtin/apply.c16
1 files changed, 3 insertions, 13 deletions
diff --git a/builtin/apply.c b/builtin/apply.c
index deb1364fa8..d61ac65dab 100644
--- a/builtin/apply.c
+++ b/builtin/apply.c
@@ -4464,16 +4464,6 @@ static int option_parse_p(const struct option *opt,
return 0;
}
-static int option_parse_z(const struct option *opt,
- const char *arg, int unset)
-{
- if (unset)
- line_termination = '\n';
- else
- line_termination = 0;
- return 0;
-}
-
static int option_parse_space_change(const struct option *opt,
const char *arg, int unset)
{
@@ -4546,9 +4536,9 @@ int cmd_apply(int argc, const char **argv, const char *prefix_)
N_( "attempt three-way merge if a patch does not apply")),
OPT_FILENAME(0, "build-fake-ancestor", &fake_ancestor,
N_("build a temporary index based on embedded index information")),
- { OPTION_CALLBACK, 'z', NULL, NULL, NULL,
- N_("paths are separated with NUL character"),
- PARSE_OPT_NOARG, option_parse_z },
+ /* Think twice before adding "--nul" synonym to this */
+ OPT_SET_INT('z', NULL, &line_termination,
+ N_("paths are separated with NUL character"), '\0'),
OPT_INTEGER('C', NULL, &p_context,
N_("ensure at least <n> lines of context match")),
{ OPTION_CALLBACK, 0, "whitespace", &whitespace_option, N_("action"),