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

Function run_git_commit

sequencer.c:1122–1184  ·  view source on GitHub ↗

* If we are cherry-pick, and if the merge did not result in * hand-editing, we will hit this commit and inherit the original * author date and name. * * If we are revert, or if our cherry-pick results in a hand merge, * we had better say that the current user is responsible for that. * * An exception is when run_git_commit() is called during an * interactive rebase: in that case, we will w

Source from the content-addressed store, hash-verified

1120 * author metadata.
1121 */
1122static int run_git_commit(const char *defmsg,
1123 const char *reflog_action,
1124 struct replay_opts *opts,
1125 unsigned int flags)
1126{
1127 struct child_process cmd = CHILD_PROCESS_INIT;
1128
1129 cmd.git_cmd = 1;
1130
1131 if (is_rebase_i(opts) &&
1132 ((opts->committer_date_is_author_date && !opts->ignore_date) ||
1133 !(!defmsg && (flags & AMEND_MSG))) &&
1134 read_env_script(&cmd.env)) {
1135 const char *gpg_opt = gpg_sign_opt_quoted(opts);
1136
1137 return error(_(staged_changes_advice),
1138 gpg_opt, gpg_opt);
1139 }
1140
1141 strvec_pushf(&cmd.env, GIT_REFLOG_ACTION "=%s", reflog_action);
1142
1143 if (opts->committer_date_is_author_date)
1144 strvec_pushf(&cmd.env, "GIT_COMMITTER_DATE=%s",
1145 opts->ignore_date ?
1146 "" :
1147 author_date_from_env(&cmd.env));
1148 if (opts->ignore_date)
1149 strvec_push(&cmd.env, "GIT_AUTHOR_DATE=");
1150
1151 strvec_push(&cmd.args, "commit");
1152
1153 if (!(flags & VERIFY_MSG))
1154 strvec_push(&cmd.args, "-n");
1155 if ((flags & AMEND_MSG))
1156 strvec_push(&cmd.args, "--amend");
1157 if (opts->gpg_sign)
1158 strvec_pushf(&cmd.args, "-S%s", opts->gpg_sign);
1159 else
1160 strvec_push(&cmd.args, "--no-gpg-sign");
1161 if (defmsg)
1162 strvec_pushl(&cmd.args, "-F", defmsg, NULL);
1163 else if (!(flags & EDIT_MSG))
1164 strvec_pushl(&cmd.args, "-C", "HEAD", NULL);
1165 if ((flags & CLEANUP_MSG))
1166 strvec_push(&cmd.args, "--cleanup=strip");
1167 if ((flags & EDIT_MSG))
1168 strvec_push(&cmd.args, "-e");
1169 else if (!(flags & CLEANUP_MSG) &&
1170 !opts->signoff && !opts->record_origin &&
1171 !opts->explicit_cleanup)
1172 strvec_push(&cmd.args, "--cleanup=verbatim");
1173
1174 if ((flags & ALLOW_EMPTY))
1175 strvec_push(&cmd.args, "--allow-empty");
1176
1177 if (!(flags & EDIT_MSG))
1178 strvec_push(&cmd.args, "--allow-empty-message");
1179

Callers 4

do_commitFunction · 0.85
do_pick_commitFunction · 0.85
do_mergeFunction · 0.85
commit_staged_changesFunction · 0.85

Calls 10

is_rebase_iFunction · 0.85
read_env_scriptFunction · 0.85
gpg_sign_opt_quotedFunction · 0.85
errorFunction · 0.85
strvec_pushfFunction · 0.85
author_date_from_envFunction · 0.85
strvec_pushFunction · 0.85
strvec_pushlFunction · 0.85
run_commandFunction · 0.85

Tested by

no test coverage detected