Skip to content

Commit a75f28c

Browse files
pcloudsgitster
authored andcommitted
diff-parseopt: convert --find-object
While at it, mark one more string for translation. Signed-off-by: Nguyễn Thái Ngọc Duy <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent f731814 commit a75f28c

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

diff.c

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4799,12 +4799,15 @@ static int diff_opt_ws_error_highlight(const struct option *option,
47994799
return 0;
48004800
}
48014801

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)
48034804
{
4805+
struct diff_options *opt = option->value;
48044806
struct object_id oid;
48054807

4808+
BUG_ON_OPT_NEG(unset);
48064809
if (get_oid(arg, &oid))
4807-
return error("unable to resolve '%s'", arg);
4810+
return error(_("unable to resolve '%s'"), arg);
48084811

48094812
if (!opt->objfind)
48104813
opt->objfind = xcalloc(1, sizeof(*opt->objfind));
@@ -4813,7 +4816,7 @@ static int parse_objfind_opt(struct diff_options *opt, const char *arg)
48134816
opt->flags.recursive = 1;
48144817
opt->flags.tree_in_recursive = 1;
48154818
oidset_insert(opt->objfind, &oid);
4816-
return 1;
4819+
return 0;
48174820
}
48184821

48194822
static int diff_opt_anchored(const struct option *opt,
@@ -5383,6 +5386,9 @@ static void prep_parse_options(struct diff_options *options)
53835386
DIFF_PICKAXE_REGEX, PARSE_OPT_NONEG),
53845387
OPT_FILENAME('O', NULL, &options->orderfile,
53855388
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),
53865392
{ OPTION_CALLBACK, 0, "output", options, N_("<file>"),
53875393
N_("Output to a specific file"),
53885394
PARSE_OPT_NONEG, NULL, 0, diff_opt_output },
@@ -5435,8 +5441,6 @@ int diff_opt_parse(struct diff_options *options,
54355441
}
54365442

54375443
/* misc options */
5438-
else if (skip_prefix(arg, "--find-object=", &arg))
5439-
return parse_objfind_opt(options, arg);
54405444
else if ((argcount = parse_long_opt("diff-filter", av, &optarg))) {
54415445
int offending = parse_diff_filter_opt(optarg, options);
54425446
if (offending)

0 commit comments

Comments
 (0)