MCPcopy Index your code
hub / github.com/git/git / cmd_notes

Function cmd_notes

builtin/notes.c:1127–1170  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1125}
1126
1127int cmd_notes(int argc,
1128 const char **argv,
1129 const char *prefix,
1130 struct repository *repo)
1131{
1132 const char *override_notes_ref = NULL;
1133 parse_opt_subcommand_fn *fn = NULL;
1134 struct option options[] = {
1135 OPT_STRING(0, "ref", &override_notes_ref, N_("notes-ref"),
1136 N_("use notes from <notes-ref>")),
1137 OPT_SUBCOMMAND("list", &fn, list),
1138 OPT_SUBCOMMAND("add", &fn, add),
1139 OPT_SUBCOMMAND("copy", &fn, copy),
1140 OPT_SUBCOMMAND("append", &fn, append_edit),
1141 OPT_SUBCOMMAND("edit", &fn, append_edit),
1142 OPT_SUBCOMMAND("show", &fn, show),
1143 OPT_SUBCOMMAND("merge", &fn, merge),
1144 OPT_SUBCOMMAND("remove", &fn, remove_cmd),
1145 OPT_SUBCOMMAND("prune", &fn, prune),
1146 OPT_SUBCOMMAND("get-ref", &fn, get_ref),
1147 OPT_END()
1148 };
1149
1150 repo_config(the_repository, git_default_config, NULL);
1151 argc = parse_options(argc, argv, prefix, options, git_notes_usage,
1152 PARSE_OPT_SUBCOMMAND_OPTIONAL);
1153 if (!fn) {
1154 if (argc) {
1155 error(_("unknown subcommand: `%s'"), argv[0]);
1156 usage_with_options(git_notes_usage, options);
1157 }
1158 fn = list;
1159 }
1160
1161 if (override_notes_ref) {
1162 struct strbuf sb = STRBUF_INIT;
1163 strbuf_addstr(&sb, override_notes_ref);
1164 expand_notes_ref(&sb);
1165 setenv("GIT_NOTES_REF", sb.buf, 1);
1166 strbuf_release(&sb);
1167 }
1168
1169 return !!fn(argc, argv, prefix, repo);
1170}

Callers

nothing calls this directly

Calls 7

parse_optionsFunction · 0.85
errorFunction · 0.85
usage_with_optionsFunction · 0.85
strbuf_addstrFunction · 0.85
expand_notes_refFunction · 0.85
strbuf_releaseFunction · 0.85
repo_configFunction · 0.50

Tested by

no test coverage detected