Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSZEDER Gábor <szeder.dev@gmail.com>2022-09-05 21:50:06 +0300
committerJunio C Hamano <gitster@pobox.com>2022-09-07 22:06:12 +0300
commit1c7c25aef12918b9305df19142ab5755297274a6 (patch)
treeecda28fb384fb53c0499f56d38a1e28f33cfd03e /builtin/notes.c
parent45bec2ead294b5f3565903995d3503ba31b8ad4a (diff)
notes: simplify default operation mode arguments check
'git notes' has a default operation mode, but when invoked without a subcommand it doesn't accept any arguments (although the 'list' subcommand implementing the default operation mode does accept arguments). The condition checking this ended up a bit awkward, so let's make it clearer. Signed-off-by: SZEDER Gábor <szeder.dev@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin/notes.c')
-rw-r--r--builtin/notes.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/builtin/notes.c b/builtin/notes.c
index 42cbae4659..60410af572 100644
--- a/builtin/notes.c
+++ b/builtin/notes.c
@@ -995,7 +995,7 @@ static int get_ref(int argc, const char **argv, const char *prefix)
int cmd_notes(int argc, const char **argv, const char *prefix)
{
const char *override_notes_ref = NULL;
- parse_opt_subcommand_fn *fn = list;
+ parse_opt_subcommand_fn *fn = NULL;
struct option options[] = {
OPT_STRING(0, "ref", &override_notes_ref, N_("notes-ref"),
N_("use notes from <notes-ref>")),
@@ -1015,9 +1015,12 @@ int cmd_notes(int argc, const char **argv, const char *prefix)
git_config(git_default_config, NULL);
argc = parse_options(argc, argv, prefix, options, git_notes_usage,
PARSE_OPT_SUBCOMMAND_OPTIONAL);
- if (fn == list && argc && strcmp(argv[0], "list")) {
- error(_("unknown subcommand: %s"), argv[0]);
- usage_with_options(git_notes_usage, options);
+ if (!fn) {
+ if (argc) {
+ error(_("unknown subcommand: %s"), argv[0]);
+ usage_with_options(git_notes_usage, options);
+ }
+ fn = list;
}
if (override_notes_ref) {