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

Function cmd_commit_tree

builtin/commit-tree.c:95–160  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

93}
94
95int cmd_commit_tree(int argc,
96 const char **argv,
97 const char *prefix,
98 struct repository *repo UNUSED)
99{
100 static struct strbuf buffer = STRBUF_INIT;
101 struct commit_list *parents = NULL;
102 struct object_id tree_oid;
103 struct object_id commit_oid;
104
105 struct option options[] = {
106 OPT_CALLBACK_F('p', NULL, &parents, N_("parent"),
107 N_("id of a parent commit object"), PARSE_OPT_NONEG,
108 parse_parent_arg_callback),
109 OPT_CALLBACK_F('m', NULL, &buffer, N_("message"),
110 N_("commit message"), PARSE_OPT_NONEG,
111 parse_message_arg_callback),
112 OPT_CALLBACK_F('F', NULL, &buffer, N_("file"),
113 N_("read commit log message from file"), PARSE_OPT_NONEG,
114 parse_file_arg_callback),
115 {
116 .type = OPTION_STRING,
117 .short_name = 'S',
118 .long_name = "gpg-sign",
119 .value = &sign_commit,
120 .argh = N_("key-id"),
121 .help = N_("GPG sign commit"),
122 .flags = PARSE_OPT_OPTARG,
123 .defval = (intptr_t) "",
124 },
125 OPT_END()
126 };
127 int ret;
128
129 repo_config(the_repository, git_default_config, NULL);
130
131 show_usage_with_options_if_asked(argc, argv,
132 commit_tree_usage, options);
133
134 argc = parse_options(argc, argv, prefix, options, commit_tree_usage, 0);
135
136 if (argc != 1)
137 die(_("must give exactly one tree"));
138
139 if (repo_get_oid_tree(the_repository, argv[0], &tree_oid))
140 die(_("not a valid object name %s"), argv[0]);
141
142 if (!buffer.len) {
143 if (strbuf_read(&buffer, 0, 0) < 0)
144 die_errno(_("git commit-tree: failed to read"));
145 }
146
147 if (commit_tree(buffer.buf, buffer.len, &tree_oid, parents, &commit_oid,
148 NULL, sign_commit)) {
149 ret = 1;
150 goto out;
151 }
152

Callers

nothing calls this directly

Calls 11

parse_optionsFunction · 0.85
repo_get_oid_treeFunction · 0.85
strbuf_readFunction · 0.85
die_errnoFunction · 0.85
commit_treeFunction · 0.85
oid_to_hexFunction · 0.85
commit_list_freeFunction · 0.85
strbuf_releaseFunction · 0.85
repo_configFunction · 0.50
dieFunction · 0.50

Tested by

no test coverage detected