Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions builtin/am.c
Original file line number Diff line number Diff line change
Expand Up @@ -1216,7 +1216,7 @@ static int parse_mail(struct am_state *state, const char *mail)
setup_mailinfo(the_repository, &mi);

if (state->utf8)
mi.metainfo_charset = get_commit_output_encoding();
mi.metainfo_charset = get_commit_output_encoding(the_repository);
else
mi.metainfo_charset = NULL;

Expand Down Expand Up @@ -1355,7 +1355,7 @@ static void get_commit_info(struct am_state *state, struct commit *commit)
struct ident_split id;

buffer = repo_logmsg_reencode(the_repository, commit, NULL,
get_commit_output_encoding());
get_commit_output_encoding(the_repository));

ident_line = find_commit_header(buffer, "author", &ident_len);
if (!ident_line)
Expand Down Expand Up @@ -1699,7 +1699,7 @@ static void do_commit(const struct am_state *state)
: state->author_date,
IDENT_STRICT);

if (commit_tree_extended(state->msg, state->msg_len, &tree, parents,
if (commit_tree_extended(the_repository, state->msg, state->msg_len, &tree, parents,
&commit, author, committer, state->sign_commit,
NULL))
die(_("failed to write commit object"));
Expand Down
2 changes: 1 addition & 1 deletion builtin/blame.c
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ static void get_commit_info(struct commit *commit, struct commit_info *ret)
const char *subject, *encoding;
const char *message;

encoding = get_log_output_encoding();
encoding = get_log_output_encoding(the_repository);
message = repo_logmsg_reencode(the_repository, commit, NULL, encoding);
get_ac_line(message, "\nauthor ",
&ret->author, &ret->author_mail,
Expand Down
4 changes: 2 additions & 2 deletions builtin/checkout.c
Original file line number Diff line number Diff line change
Expand Up @@ -676,7 +676,7 @@ static void describe_detached_head(const char *msg, struct commit *commit)
struct strbuf sb = STRBUF_INIT;

if (!repo_parse_commit(the_repository, commit))
pp_commit_easy(CMIT_FMT_ONELINE, commit, &sb);
pp_commit_easy(the_repository, CMIT_FMT_ONELINE, commit, &sb);
if (print_sha1_ellipsis()) {
fprintf(stderr, "%s %s... %s\n", msg,
repo_find_unique_abbrev(the_repository, &commit->object.oid, DEFAULT_ABBREV),
Expand Down Expand Up @@ -1064,7 +1064,7 @@ static void describe_one_orphan(struct strbuf *sb, struct commit *commit)
strbuf_add_unique_abbrev(sb, &commit->object.oid, DEFAULT_ABBREV);
strbuf_addch(sb, ' ');
if (!repo_parse_commit(the_repository, commit))
pp_commit_easy(CMIT_FMT_ONELINE, commit, sb);
pp_commit_easy(the_repository, CMIT_FMT_ONELINE, commit, sb);
strbuf_addch(sb, '\n');
}

Expand Down
2 changes: 1 addition & 1 deletion builtin/commit-tree.c
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ int cmd_commit_tree(int argc,
die_errno(_("git commit-tree: failed to read"));
}

if (commit_tree(buffer.buf, buffer.len, &tree_oid, parents, &commit_oid,
if (commit_tree(the_repository, buffer.buf, buffer.len, &tree_oid, parents, &commit_oid,
NULL, sign_commit)) {
ret = 1;
goto out;
Expand Down
8 changes: 4 additions & 4 deletions builtin/commit.c
Original file line number Diff line number Diff line change
Expand Up @@ -794,7 +794,7 @@ static int prepare_to_commit(const char *index_file, const char *prefix,
c = lookup_commit_reference_by_name(squash_message);
if (!c)
die(_("could not lookup commit '%s'"), squash_message);
ctx.output_encoding = get_commit_output_encoding();
ctx.output_encoding = get_commit_output_encoding(the_repository);
repo_format_commit_message(the_repository, c,
"squash! %s\n\n", &sb,
&ctx);
Expand Down Expand Up @@ -829,7 +829,7 @@ static int prepare_to_commit(const char *index_file, const char *prefix,
commit = lookup_commit_reference_by_name(fixup_commit);
if (!commit)
die(_("could not lookup commit '%s'"), fixup_commit);
ctx.output_encoding = get_commit_output_encoding();
ctx.output_encoding = get_commit_output_encoding(the_repository);
fmt = xstrfmt("%s! %%s\n\n", fixup_prefix);
repo_format_commit_message(the_repository, commit, fmt, &sb,
&ctx);
Expand Down Expand Up @@ -1235,7 +1235,7 @@ static const char *read_commit_message(const char *name)
commit = lookup_commit_reference_by_name(name);
if (!commit)
die(_("could not lookup commit '%s'"), name);
out_enc = get_commit_output_encoding();
out_enc = get_commit_output_encoding(the_repository);
return repo_logmsg_reencode(the_repository, commit, NULL, out_enc);
}

Expand Down Expand Up @@ -1931,7 +1931,7 @@ int cmd_commit(int argc,
append_merge_tag_headers(parents, &tail);
}

if (commit_tree_extended(sb.buf, sb.len, &the_repository->index->cache_tree->oid,
if (commit_tree_extended(the_repository, sb.buf, sb.len, &the_repository->index->cache_tree->oid,
parents, &oid, author_ident.buf, NULL,
sign_commit, extra)) {
rollback_index_files();
Expand Down
2 changes: 1 addition & 1 deletion builtin/history.c
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ static int commit_tree_with_edited_message(struct repository *repo,

original_extra_headers = read_commit_extra_headers(original, exclude_gpgsig);

ret = commit_tree_extended(commit_message.buf, commit_message.len, &original_tree_oid,
ret = commit_tree_extended(repo, commit_message.buf, commit_message.len, &original_tree_oid,
original->parents, &rewritten_commit_oid, original_author,
NULL, NULL, original_extra_headers);
if (ret < 0)
Expand Down
4 changes: 2 additions & 2 deletions builtin/log.c
Original file line number Diff line number Diff line change
Expand Up @@ -568,7 +568,7 @@ static void show_tagger(const char *buf, struct rev_info *rev)

pp.fmt = rev->commit_format;
pp.date_mode = rev->date_mode;
pp_user_info(&pp, "Tagger", &out, buf, get_log_output_encoding());
pp_user_info(&pp, "Tagger", &out, buf, get_log_output_encoding(the_repository));
fprintf(rev->diffopt.file, "%s", out.buf);
strbuf_release(&out);
}
Expand Down Expand Up @@ -2521,7 +2521,7 @@ static void print_commit(char sign, struct commit *commit, int verbose,
repo_find_unique_abbrev(the_repository, &commit->object.oid, abbrev));
} else {
struct strbuf buf = STRBUF_INIT;
pp_commit_easy(CMIT_FMT_ONELINE, commit, &buf);
pp_commit_easy(the_repository, CMIT_FMT_ONELINE, commit, &buf);
fprintf(file, "%c %s %s\n", sign,
repo_find_unique_abbrev(the_repository, &commit->object.oid, abbrev),
buf.buf);
Expand Down
6 changes: 3 additions & 3 deletions builtin/mailinfo.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ static int parse_opt_quoted_cr(const struct option *opt, const char *arg, int un
int cmd_mailinfo(int argc,
const char **argv,
const char *prefix,
struct repository *repo UNUSED)
struct repository *repo)
{
struct metainfo_charset meta_charset;
struct mailinfo mi;
Expand Down Expand Up @@ -83,7 +83,7 @@ int cmd_mailinfo(int argc,
OPT_END()
};

setup_mailinfo(the_repository, &mi);
setup_mailinfo(repo, &mi);
meta_charset.policy = CHARSET_DEFAULT;

argc = parse_options(argc, argv, prefix, options, mailinfo_usage, 0);
Expand All @@ -93,7 +93,7 @@ int cmd_mailinfo(int argc,

switch (meta_charset.policy) {
case CHARSET_DEFAULT:
mi.metainfo_charset = get_commit_output_encoding();
mi.metainfo_charset = get_commit_output_encoding(repo);
break;
case CHARSET_NO_REENCODE:
mi.metainfo_charset = NULL;
Expand Down
6 changes: 3 additions & 3 deletions builtin/merge.c
Original file line number Diff line number Diff line change
Expand Up @@ -470,7 +470,7 @@ static void squash_message(struct commit *commit, struct commit_list *remotehead
strbuf_addch(&out, '\n');
strbuf_addf(&out, "commit %s\n",
oid_to_hex(&commit->object.oid));
pretty_print_commit(&ctx, commit, &out);
pretty_print_commit(the_repository, &ctx, commit, &out);
}
write_file_buf(git_path_squash_msg(the_repository), out.buf, out.len);
strbuf_release(&out);
Expand Down Expand Up @@ -1000,7 +1000,7 @@ static int merge_trivial(struct commit *head, struct commit_list *remoteheads)
pptr = commit_list_append(head, pptr);
pptr = commit_list_append(remoteheads->item, pptr);
prepare_to_commit(remoteheads);
if (commit_tree(merge_msg.buf, merge_msg.len, &result_tree, parents,
if (commit_tree(the_repository, merge_msg.buf, merge_msg.len, &result_tree, parents,
&result_commit, NULL, sign_commit))
die(_("failed to write commit object"));
finish(head, remoteheads, &result_commit, "In-index merge");
Expand All @@ -1027,7 +1027,7 @@ static int finish_automerge(struct commit *head,
if (!head_subsumed || fast_forward == FF_NO)
commit_list_insert(head, &parents);
prepare_to_commit(remoteheads);
if (commit_tree(merge_msg.buf, merge_msg.len, result_tree, parents,
if (commit_tree(the_repository, merge_msg.buf, merge_msg.len, result_tree, parents,
&result_commit, NULL, sign_commit))
die(_("failed to write commit object"));
strbuf_addf(&buf, "Merge made by the '%s' strategy.", wt_strategy);
Expand Down
2 changes: 1 addition & 1 deletion builtin/rebase.c
Original file line number Diff line number Diff line change
Expand Up @@ -1647,7 +1647,7 @@ int cmd_rebase(int argc,
options.upstream_arg = options.upstream_name;
} else {
if (!options.onto_name) {
if (commit_tree("", 0, the_hash_algo->empty_tree, NULL,
if (commit_tree(the_repository, "", 0, the_hash_algo->empty_tree, NULL,
&squash_onto, NULL, NULL) < 0)
die(_("Could not create new root commit"));
options.squash_onto = &squash_onto;
Expand Down
2 changes: 1 addition & 1 deletion builtin/reset.c
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ static void print_new_head_line(struct commit *commit)
printf(_("HEAD is now at %s"),
repo_find_unique_abbrev(the_repository, &commit->object.oid, DEFAULT_ABBREV));

pp_commit_easy(CMIT_FMT_ONELINE, commit, &buf);
pp_commit_easy(the_repository, CMIT_FMT_ONELINE, commit, &buf);
if (buf.len > 0)
printf(" %s", buf.buf);
putchar('\n');
Expand Down
4 changes: 2 additions & 2 deletions builtin/rev-list.c
Original file line number Diff line number Diff line change
Expand Up @@ -304,10 +304,10 @@ static void show_commit(struct commit *commit, void *data)
ctx.date_mode = revs->date_mode;
ctx.date_mode_explicit = revs->date_mode_explicit;
ctx.fmt = revs->commit_format;
ctx.output_encoding = get_log_output_encoding();
ctx.output_encoding = get_log_output_encoding(the_repository);
ctx.color = revs->diffopt.use_color;
ctx.rev = revs;
pretty_print_commit(&ctx, commit, &buf);
pretty_print_commit(the_repository, &ctx, commit, &buf);
if (buf.len) {
if (revs->commit_format != CMIT_FMT_ONELINE)
graph_show_oneline(revs->graph);
Expand Down
4 changes: 2 additions & 2 deletions builtin/shortlog.c
Original file line number Diff line number Diff line change
Expand Up @@ -248,11 +248,11 @@ void shortlog_add_commit(struct shortlog *log, struct commit *commit)
ctx.fmt = CMIT_FMT_USERFORMAT;
ctx.abbrev = log->abbrev;
ctx.date_mode = log->date_mode;
ctx.output_encoding = get_log_output_encoding();
ctx.output_encoding = get_log_output_encoding(the_repository);

if (!log->summary) {
if (log->user_format)
pretty_print_commit(&ctx, commit, &oneline);
pretty_print_commit(the_repository, &ctx, commit, &oneline);
else
repo_format_commit_message(the_repository, commit,
"%s", &oneline, &ctx);
Expand Down
2 changes: 1 addition & 1 deletion builtin/show-branch.c
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ static void show_one_commit(struct commit *commit, int no_name)
struct commit_name *name = commit_to_name(commit);

if (commit->object.parsed) {
pp_commit_easy(CMIT_FMT_ONELINE, commit, &pretty);
pp_commit_easy(the_repository, CMIT_FMT_ONELINE, commit, &pretty);
pretty_str = pretty.buf;
}
skip_prefix(pretty_str, "[PATCH] ", &pretty_str);
Expand Down
12 changes: 6 additions & 6 deletions builtin/stash.c
Original file line number Diff line number Diff line change
Expand Up @@ -1258,7 +1258,7 @@ static int save_untracked_files(struct stash_info *info, struct strbuf *msg,
goto done;
}

if (commit_tree(untracked_msg.buf, untracked_msg.len,
if (commit_tree(the_repository, untracked_msg.buf, untracked_msg.len,
&info->u_tree, NULL, &info->u_commit, NULL, NULL)) {
ret = -1;
goto done;
Expand Down Expand Up @@ -1480,13 +1480,13 @@ static int do_create_stash(const struct pathspec *ps, struct strbuf *stash_msg_b
&head_commit->object.oid,
DEFAULT_ABBREV);
strbuf_addf(&msg, "%s: %s ", branch_name, head_short_sha1);
pp_commit_easy(CMIT_FMT_ONELINE, head_commit, &msg);
pp_commit_easy(the_repository, CMIT_FMT_ONELINE, head_commit, &msg);

strbuf_addf(&commit_tree_label, "index on %s\n", msg.buf);
commit_list_insert(head_commit, &parents);
if (write_index_as_tree(&info->i_tree, the_repository->index,
repo_get_index_file(the_repository), 0, NULL) ||
commit_tree(commit_tree_label.buf, commit_tree_label.len,
commit_tree(the_repository, commit_tree_label.buf, commit_tree_label.len,
&info->i_tree, parents, &info->i_commit, NULL, NULL)) {
if (!quiet)
fprintf_ln(stderr, _("Cannot save the current "
Expand Down Expand Up @@ -1551,7 +1551,7 @@ static int do_create_stash(const struct pathspec *ps, struct strbuf *stash_msg_b
&parents);
commit_list_insert(head_commit, &parents);

if (commit_tree(stash_msg_buf->buf, stash_msg_buf->len, &info->w_tree,
if (commit_tree(the_repository, stash_msg_buf->buf, stash_msg_buf->len, &info->w_tree,
parents, &info->w_commit, NULL, NULL)) {
if (!quiet)
fprintf_ln(stderr, _("Cannot record "
Expand Down Expand Up @@ -2043,7 +2043,7 @@ static int write_commit_with_parents(struct repository *r,
author = xmemdupz(orig_author, author_len);
committer = xmemdupz(orig_committer, committer_len);

if (commit_tree_extended(msg.buf, msg.len,
if (commit_tree_extended(r, msg.buf, msg.len,
r->hash_algo->empty_tree, parents,
out, author, committer,
NULL, NULL)) {
Expand Down Expand Up @@ -2266,7 +2266,7 @@ static int do_export_stash(struct repository *r,
"2001-09-17T00:00:00Z", 0);

/* First, we create a single empty commit. */
if (commit_tree_extended("", 0, r->hash_algo->empty_tree, NULL,
if (commit_tree_extended(the_repository, "", 0, r->hash_algo->empty_tree, NULL,
&base, author, committer, NULL, NULL))
return error(_("unable to write base commit"));

Expand Down
4 changes: 2 additions & 2 deletions bundle.c
Original file line number Diff line number Diff line change
Expand Up @@ -461,9 +461,9 @@ static void write_bundle_prerequisites(struct commit *commit, void *data)
write_or_die(bpi->fd, buf.buf, buf.len);

ctx.fmt = CMIT_FMT_ONELINE;
ctx.output_encoding = get_log_output_encoding();
ctx.output_encoding = get_log_output_encoding(the_repository);
strbuf_reset(&buf);
pretty_print_commit(&ctx, commit, &buf);
pretty_print_commit(the_repository, &ctx, commit, &buf);
strbuf_trim(&buf);

object = (struct object *)commit;
Expand Down
20 changes: 10 additions & 10 deletions commit.c
Original file line number Diff line number Diff line change
Expand Up @@ -1556,15 +1556,15 @@ void free_commit_extra_headers(struct commit_extra_header *extra)
}
}

int commit_tree(const char *msg, size_t msg_len, const struct object_id *tree,
int commit_tree(struct repository *r, const char *msg, size_t msg_len, const struct object_id *tree,
const struct commit_list *parents, struct object_id *ret,
const char *author, const char *sign_commit)
{
struct commit_extra_header *extra = NULL, **tail = &extra;
int result;

append_merge_tag_headers(parents, &tail);
result = commit_tree_extended(msg, msg_len, tree, parents, ret, author,
result = commit_tree_extended(r, msg, msg_len, tree, parents, ret, author,
NULL, sign_commit, extra);
free_commit_extra_headers(extra);
return result;
Expand Down Expand Up @@ -1685,7 +1685,8 @@ N_("Warning: commit message did not conform to UTF-8.\n"
"You may want to amend it after fixing the message, or set the config\n"
"variable i18n.commitEncoding to the encoding your project uses.\n");

static void write_commit_tree(struct strbuf *buffer, const char *msg, size_t msg_len,
static void write_commit_tree(struct repository *r, struct strbuf *buffer,
const char *msg, size_t msg_len,
const struct object_id *tree,
const struct object_id *parents, size_t parents_len,
const char *author, const char *committer,
Expand All @@ -1695,7 +1696,7 @@ static void write_commit_tree(struct strbuf *buffer, const char *msg, size_t msg
size_t i;

/* Not having i18n.commitencoding is the same as having utf-8 */
encoding_is_utf8 = is_encoding_utf8(git_commit_encoding);
encoding_is_utf8 = is_encoding_utf8(get_commit_output_encoding(r));

strbuf_grow(buffer, 8192); /* should avoid reallocs for the headers */
strbuf_addf(buffer, "tree %s\n", oid_to_hex(tree));
Expand All @@ -1716,7 +1717,7 @@ static void write_commit_tree(struct strbuf *buffer, const char *msg, size_t msg
committer = git_committer_info(IDENT_STRICT);
strbuf_addf(buffer, "committer %s\n", committer);
if (!encoding_is_utf8)
strbuf_addf(buffer, "encoding %s\n", git_commit_encoding);
strbuf_addf(buffer, "encoding %s\n", get_commit_output_encoding(r));

while (extra) {
add_extra_header(buffer, extra);
Expand All @@ -1728,14 +1729,13 @@ static void write_commit_tree(struct strbuf *buffer, const char *msg, size_t msg
strbuf_add(buffer, msg, msg_len);
}

int commit_tree_extended(const char *msg, size_t msg_len,
int commit_tree_extended(struct repository *r, const char *msg, size_t msg_len,
const struct object_id *tree,
const struct commit_list *parents, struct object_id *ret,
const char *author, const char *committer,
const char *sign_commit,
const struct commit_extra_header *extra)
{
struct repository *r = the_repository;
int result = 0;
int encoding_is_utf8;
struct strbuf buffer = STRBUF_INIT, compat_buffer = STRBUF_INIT;
Expand All @@ -1745,7 +1745,7 @@ int commit_tree_extended(const char *msg, size_t msg_len,
size_t i, nparents;

/* Not having i18n.commitencoding is the same as having utf-8 */
encoding_is_utf8 = is_encoding_utf8(git_commit_encoding);
encoding_is_utf8 = is_encoding_utf8(get_commit_output_encoding(r));

odb_assert_oid_type(the_repository->objects, tree, OBJ_TREE);

Expand All @@ -1758,7 +1758,7 @@ int commit_tree_extended(const char *msg, size_t msg_len,
for (const struct commit_list *p = parents; p; p = p->next)
oidcpy(&parent_buf[i++], &p->item->object.oid);

write_commit_tree(&buffer, msg, msg_len, tree, parent_buf, nparents, author, committer, extra);
write_commit_tree(r, &buffer, msg, msg_len, tree, parent_buf, nparents, author, committer, extra);
if (sign_commit && sign_commit_to_strbuf(&sig, &buffer, sign_commit)) {
result = -1;
goto out;
Expand Down Expand Up @@ -1786,7 +1786,7 @@ int commit_tree_extended(const char *msg, size_t msg_len,
free(mapped_parents);
goto out;
}
write_commit_tree(&compat_buffer, msg, msg_len, &mapped_tree,
write_commit_tree(r, &compat_buffer, msg, msg_len, &mapped_tree,
mapped_parents, nparents, author, committer, compat_extra);
free_commit_extra_headers(compat_extra);
free(mapped_parents);
Expand Down
Loading
Loading