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

Function parse_and_validate_options

builtin/commit.c:1309–1426  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1307}
1308
1309static int parse_and_validate_options(int argc, const char *argv[],
1310 const struct option *options,
1311 const char * const usage[],
1312 const char *prefix,
1313 struct commit *current_head,
1314 struct wt_status *s)
1315{
1316 argc = parse_options(argc, argv, prefix, options, usage, 0);
1317 finalize_deferred_config(s);
1318
1319 if (force_author && !strchr(force_author, '>'))
1320 force_author = find_author_by_nickname(force_author);
1321
1322 if (force_author && renew_authorship)
1323 die(_("options '%s' and '%s' cannot be used together"), "--reset-author", "--author");
1324
1325 if (logfile || have_option_m || use_message)
1326 use_editor = 0;
1327
1328 /* Sanity check options */
1329 if (amend && !current_head)
1330 die(_("You have nothing to amend."));
1331 if (amend && whence != FROM_COMMIT) {
1332 if (whence == FROM_MERGE)
1333 die(_("You are in the middle of a merge -- cannot amend."));
1334 else if (is_from_cherry_pick(whence))
1335 die(_("You are in the middle of a cherry-pick -- cannot amend."));
1336 else if (whence == FROM_REBASE_PICK)
1337 die(_("You are in the middle of a rebase -- cannot amend."));
1338 }
1339 if (fixup_message && squash_message)
1340 die(_("options '%s' and '%s' cannot be used together"), "--squash", "--fixup");
1341 die_for_incompatible_opt4(!!use_message, "-C",
1342 !!edit_message, "-c",
1343 !!logfile, "-F",
1344 !!fixup_message, "--fixup");
1345 die_for_incompatible_opt4(have_option_m, "-m",
1346 !!edit_message, "-c",
1347 !!use_message, "-C",
1348 !!logfile, "-F");
1349 if (use_message || edit_message || logfile ||fixup_message || have_option_m)
1350 FREE_AND_NULL(template_file);
1351 if (edit_message)
1352 use_message = edit_message;
1353 if (amend && !use_message && !fixup_message)
1354 use_message = "HEAD";
1355 if (!use_message && !is_from_cherry_pick(whence) &&
1356 !is_from_rebase(whence) && renew_authorship)
1357 die(_("--reset-author can be used only with -C, -c or --amend."));
1358 if (use_message) {
1359 use_message_buffer = read_commit_message(use_message);
1360 if (!renew_authorship) {
1361 author_message = use_message;
1362 author_message_buffer = use_message_buffer;
1363 }
1364 }
1365 if ((is_from_cherry_pick(whence) || whence == FROM_REBASE_PICK) &&
1366 !renew_authorship) {

Callers 1

cmd_commitFunction · 0.85

Calls 10

parse_optionsFunction · 0.85
finalize_deferred_configFunction · 0.85
find_author_by_nicknameFunction · 0.85
is_from_cherry_pickFunction · 0.85
is_from_rebaseFunction · 0.85
read_commit_messageFunction · 0.85
dieFunction · 0.50

Tested by

no test coverage detected