Skip to content

Commit 81fb70f

Browse files
rscharfegitster
authored andcommitted
revision, rev-parse: factorize incompatibility messages about - -exclude-hidden
Use the standard parameterized message for reporting incompatible options to report options that are not accepted in combination with --exclude-hidden. This reduces the number of strings to translate and makes the UI a bit more consistent. Signed-off-by: René Scharfe <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent fa518ae commit 81fb70f

File tree

4 files changed

+22
-15
lines changed

4 files changed

+22
-15
lines changed

builtin/rev-parse.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -893,13 +893,15 @@ int cmd_rev_parse(int argc, const char **argv, const char *prefix)
893893
}
894894
if (opt_with_value(arg, "--branches", &arg)) {
895895
if (ref_excludes.hidden_refs_configured)
896-
return error(_("--exclude-hidden cannot be used together with --branches"));
896+
return error(_("options '%s' and '%s' cannot be used together"),
897+
"--exclude-hidden", "--branches");
897898
handle_ref_opt(arg, "refs/heads/");
898899
continue;
899900
}
900901
if (opt_with_value(arg, "--tags", &arg)) {
901902
if (ref_excludes.hidden_refs_configured)
902-
return error(_("--exclude-hidden cannot be used together with --tags"));
903+
return error(_("options '%s' and '%s' cannot be used together"),
904+
"--exclude-hidden", "--tags");
903905
handle_ref_opt(arg, "refs/tags/");
904906
continue;
905907
}
@@ -909,7 +911,8 @@ int cmd_rev_parse(int argc, const char **argv, const char *prefix)
909911
}
910912
if (opt_with_value(arg, "--remotes", &arg)) {
911913
if (ref_excludes.hidden_refs_configured)
912-
return error(_("--exclude-hidden cannot be used together with --remotes"));
914+
return error(_("options '%s' and '%s' cannot be used together"),
915+
"--exclude-hidden", "--remotes");
913916
handle_ref_opt(arg, "refs/remotes/");
914917
continue;
915918
}

revision.c

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2709,7 +2709,8 @@ static int handle_revision_pseudo_opt(struct rev_info *revs,
27092709
clear_ref_exclusions(&revs->ref_excludes);
27102710
} else if (!strcmp(arg, "--branches")) {
27112711
if (revs->ref_excludes.hidden_refs_configured)
2712-
return error(_("--exclude-hidden cannot be used together with --branches"));
2712+
return error(_("options '%s' and '%s' cannot be used together"),
2713+
"--exclude-hidden", "--branches");
27132714
handle_refs(refs, revs, *flags, refs_for_each_branch_ref);
27142715
clear_ref_exclusions(&revs->ref_excludes);
27152716
} else if (!strcmp(arg, "--bisect")) {
@@ -2720,12 +2721,14 @@ static int handle_revision_pseudo_opt(struct rev_info *revs,
27202721
revs->bisect = 1;
27212722
} else if (!strcmp(arg, "--tags")) {
27222723
if (revs->ref_excludes.hidden_refs_configured)
2723-
return error(_("--exclude-hidden cannot be used together with --tags"));
2724+
return error(_("options '%s' and '%s' cannot be used together"),
2725+
"--exclude-hidden", "--tags");
27242726
handle_refs(refs, revs, *flags, refs_for_each_tag_ref);
27252727
clear_ref_exclusions(&revs->ref_excludes);
27262728
} else if (!strcmp(arg, "--remotes")) {
27272729
if (revs->ref_excludes.hidden_refs_configured)
2728-
return error(_("--exclude-hidden cannot be used together with --remotes"));
2730+
return error(_("options '%s' and '%s' cannot be used together"),
2731+
"--exclude-hidden", "--remotes");
27292732
handle_refs(refs, revs, *flags, refs_for_each_remote_ref);
27302733
clear_ref_exclusions(&revs->ref_excludes);
27312734
} else if ((argcount = parse_long_opt("glob", argv, &optarg))) {
@@ -2743,21 +2746,24 @@ static int handle_revision_pseudo_opt(struct rev_info *revs,
27432746
} else if (skip_prefix(arg, "--branches=", &optarg)) {
27442747
struct all_refs_cb cb;
27452748
if (revs->ref_excludes.hidden_refs_configured)
2746-
return error(_("--exclude-hidden cannot be used together with --branches"));
2749+
return error(_("options '%s' and '%s' cannot be used together"),
2750+
"--exclude-hidden", "--branches");
27472751
init_all_refs_cb(&cb, revs, *flags);
27482752
for_each_glob_ref_in(handle_one_ref, optarg, "refs/heads/", &cb);
27492753
clear_ref_exclusions(&revs->ref_excludes);
27502754
} else if (skip_prefix(arg, "--tags=", &optarg)) {
27512755
struct all_refs_cb cb;
27522756
if (revs->ref_excludes.hidden_refs_configured)
2753-
return error(_("--exclude-hidden cannot be used together with --tags"));
2757+
return error(_("options '%s' and '%s' cannot be used together"),
2758+
"--exclude-hidden", "--tags");
27542759
init_all_refs_cb(&cb, revs, *flags);
27552760
for_each_glob_ref_in(handle_one_ref, optarg, "refs/tags/", &cb);
27562761
clear_ref_exclusions(&revs->ref_excludes);
27572762
} else if (skip_prefix(arg, "--remotes=", &optarg)) {
27582763
struct all_refs_cb cb;
27592764
if (revs->ref_excludes.hidden_refs_configured)
2760-
return error(_("--exclude-hidden cannot be used together with --remotes"));
2765+
return error(_("options '%s' and '%s' cannot be used together"),
2766+
"--exclude-hidden", "--remotes");
27612767
init_all_refs_cb(&cb, revs, *flags);
27622768
for_each_glob_ref_in(handle_one_ref, optarg, "refs/remotes/", &cb);
27632769
clear_ref_exclusions(&revs->ref_excludes);

t/t6018-rev-list-glob.sh

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -214,15 +214,13 @@ do
214214
for pseudoopt in branches tags remotes
215215
do
216216
test_expect_success "rev-parse --exclude-hidden=$section fails with --$pseudoopt" '
217-
echo "error: --exclude-hidden cannot be used together with --$pseudoopt" >expected &&
218217
test_must_fail git rev-parse --exclude-hidden=$section --$pseudoopt 2>err &&
219-
test_cmp expected err
218+
test_grep "error: options .--exclude-hidden. and .--$pseudoopt. cannot be used together" err
220219
'
221220

222221
test_expect_success "rev-parse --exclude-hidden=$section fails with --$pseudoopt=pattern" '
223-
echo "error: --exclude-hidden cannot be used together with --$pseudoopt" >expected &&
224222
test_must_fail git rev-parse --exclude-hidden=$section --$pseudoopt=pattern 2>err &&
225-
test_cmp expected err
223+
test_grep "error: options .--exclude-hidden. and .--$pseudoopt. cannot be used together" err
226224
'
227225
done
228226
done

t/t6021-rev-list-exclude-hidden.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,12 +151,12 @@ do
151151
do
152152
test_expect_success "$section: fails with --$pseudoopt" '
153153
test_must_fail git rev-list --exclude-hidden=$section --$pseudoopt 2>err &&
154-
test_grep "error: --exclude-hidden cannot be used together with --$pseudoopt" err
154+
test_grep "error: options .--exclude-hidden. and .--$pseudoopt. cannot be used together" err
155155
'
156156

157157
test_expect_success "$section: fails with --$pseudoopt=pattern" '
158158
test_must_fail git rev-list --exclude-hidden=$section --$pseudoopt=pattern 2>err &&
159-
test_grep "error: --exclude-hidden cannot be used together with --$pseudoopt" err
159+
test_grep "error: options .--exclude-hidden. and .--$pseudoopt. cannot be used together" err
160160
'
161161
done
162162
done

0 commit comments

Comments
 (0)