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

Function make_patch

sequencer.c:3731–3778  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3729}
3730
3731static int make_patch(struct repository *r,
3732 struct commit *commit,
3733 struct replay_opts *opts)
3734{
3735 struct rev_info log_tree_opt;
3736 const char *subject;
3737 char hex[GIT_MAX_HEXSZ + 1];
3738 int res = 0;
3739
3740 if (!is_rebase_i(opts))
3741 BUG("make_patch should only be called when rebasing");
3742
3743 oid_to_hex_r(hex, &commit->object.oid);
3744 if (write_message(hex, strlen(hex), rebase_path_stopped_sha(), 1) < 0)
3745 return -1;
3746 res |= write_rebase_head(&commit->object.oid);
3747
3748 memset(&log_tree_opt, 0, sizeof(log_tree_opt));
3749 repo_init_revisions(r, &log_tree_opt, NULL);
3750 log_tree_opt.abbrev = 0;
3751 log_tree_opt.diff = 1;
3752 log_tree_opt.diffopt.output_format = DIFF_FORMAT_PATCH;
3753 log_tree_opt.disable_stdin = 1;
3754 log_tree_opt.no_commit_id = 1;
3755 log_tree_opt.diffopt.file = fopen(rebase_path_patch(), "w");
3756 log_tree_opt.diffopt.use_color = GIT_COLOR_NEVER;
3757 if (!log_tree_opt.diffopt.file)
3758 res |= error_errno(_("could not open '%s'"),
3759 rebase_path_patch());
3760 else {
3761 res |= log_tree_commit(&log_tree_opt, commit);
3762 fclose(log_tree_opt.diffopt.file);
3763 }
3764
3765 if (!file_exists(rebase_path_message())) {
3766 const char *encoding = get_commit_output_encoding();
3767 const char *commit_buffer = repo_logmsg_reencode(r,
3768 commit, NULL,
3769 encoding);
3770 find_commit_subject(commit_buffer, &subject);
3771 res |= write_message(subject, strlen(subject), rebase_path_message(), 1);
3772 repo_unuse_commit_buffer(r, commit,
3773 commit_buffer);
3774 }
3775 release_revisions(&log_tree_opt);
3776
3777 return res;
3778}
3779
3780static int intend_to_amend(void)
3781{

Callers 1

error_with_patchFunction · 0.85

Calls 13

is_rebase_iFunction · 0.85
oid_to_hex_rFunction · 0.85
write_messageFunction · 0.85
write_rebase_headFunction · 0.85
repo_init_revisionsFunction · 0.85
error_errnoFunction · 0.85
log_tree_commitFunction · 0.85
file_existsFunction · 0.85
repo_logmsg_reencodeFunction · 0.85
find_commit_subjectFunction · 0.85
repo_unuse_commit_bufferFunction · 0.85

Tested by

no test coverage detected