diff-parseopt: convert --find-object

While at it, mark one more string for translation. Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Nguyễn Thái Ngọc Duy committed Mar 24, 2019 at 15:20 UTC a75f28cbda5ec4b478287f452d77ef7137ef50fa
1 file changed +9 -5
diff.c
+9 -5
@@ -4799,12 +4799,15 @@ static int diff_opt_ws_error_highlight(const struct option *option,
4799 return 0;
4800 }
4801
4802 -static int parse_objfind_opt(struct diff_options *opt, const char *arg)
4802 +static int diff_opt_find_object(const struct option *option,
4803 + const char *arg, int unset)
4804 {
4805 + struct diff_options *opt = option->value;
4806 struct object_id oid;
4807
4808 + BUG_ON_OPT_NEG(unset);
4809 if (get_oid(arg, &oid))
4807 - return error("unable to resolve '%s'", arg);
4810 + return error(_("unable to resolve '%s'"), arg);
4811
4812 if (!opt->objfind)
4813 opt->objfind = xcalloc(1, sizeof(*opt->objfind));
@@ -4813,7 +4816,7 @@ static int parse_objfind_opt(struct diff_options *opt, const char *arg)
4816 opt->flags.recursive = 1;
4817 opt->flags.tree_in_recursive = 1;
4818 oidset_insert(opt->objfind, &oid);
4816 - return 1;
4819 + return 0;
4820 }
4821
4822 static int diff_opt_anchored(const struct option *opt,
@@ -5383,6 +5386,9 @@ static void prep_parse_options(struct diff_options *options)
5386 DIFF_PICKAXE_REGEX, PARSE_OPT_NONEG),
5387 OPT_FILENAME('O', NULL, &options->orderfile,
5388 N_("control the order in which files appear in the output")),
5389 + OPT_CALLBACK_F(0, "find-object", options, N_("<object-id>"),
5390 + N_("look for differences that change the number of occurrences of the specified object"),
5391 + PARSE_OPT_NONEG, diff_opt_find_object),
5392 { OPTION_CALLBACK, 0, "output", options, N_("<file>"),
5393 N_("Output to a specific file"),
5394 PARSE_OPT_NONEG, NULL, 0, diff_opt_output },
@@ -5435,8 +5441,6 @@ int diff_opt_parse(struct diff_options *options,
5441 }
5442
5443 /* misc options */
5438 - else if (skip_prefix(arg, "--find-object=", &arg))
5439 - return parse_objfind_opt(options, arg);
5444 else if ((argcount = parse_long_opt("diff-filter", av, &optarg))) {
5445 int offending = parse_diff_filter_opt(optarg, options);
5446 if (offending)