37
38
static int edit, record_origin, no_commit, mainline, signoff, allow_ff;
39
static enum { REVERT, CHERRY_PICK } action;
40
-static struct commit *commit;
40
static int commit_argc;
41
static const char **commit_argv;
42
static int allow_rerere_auto;
115
const char *message;
116
};
117
119
-static int get_message(const char *raw_message, struct commit_message *out)
118
+static int get_message(struct commit *commit, struct commit_message *out)
119
{
120
const char *encoding;
121
const char *abbrev, *subject;
122
int abbrev_len, subject_len;
123
char *q;
124
126
- if (!raw_message)
125
+ if (!commit->buffer)
126
return -1;
128
- encoding = get_encoding(raw_message);
127
+ encoding = get_encoding(commit->buffer);
128
if (!encoding)
129
encoding = "UTF-8";
130
if (!git_commit_encoding)
131
git_commit_encoding = "UTF-8";
132
133
out->reencoded_message = NULL;
135
- out->message = raw_message;
134
+ out->message = commit->buffer;
135
if (strcmp(encoding, git_commit_encoding))
137
- out->reencoded_message = reencode_string(raw_message,
136
+ out->reencoded_message = reencode_string(commit->buffer,
137
git_commit_encoding, encoding);
138
if (out->reencoded_message)
139
out->message = out->reencoded_message;
181
return NULL;
182
}
183
185
-static void write_cherry_pick_head(void)
184
+static void write_cherry_pick_head(struct commit *commit)
185
{
186
int fd;
187
struct strbuf buf = STRBUF_INIT;
354
return run_command_v_opt(args, RUN_GIT_CMD);
355
}
356
358
-static int do_pick_commit(void)
357
+static int do_pick_commit(struct commit *commit)
358
{
359
unsigned char head[20];
360
struct commit *base, *next, *parent;
416
die(_("%s: cannot parse parent commit %s"),
417
me, sha1_to_hex(parent->object.sha1));
418
420
- if (get_message(commit->buffer, &msg) != 0)
419
+ if (get_message(commit, &msg) != 0)
420
die(_("Cannot get commit message for %s"),
421
sha1_to_hex(commit->object.sha1));
422
469
strbuf_addstr(&msgbuf, ")\n");
470
}
471
if (!no_commit)
473
- write_cherry_pick_head();
472
+ write_cherry_pick_head(commit);
473
}
474
475
if (!strategy || !strcmp(strategy, "recursive") || action == REVERT) {
547
static int revert_or_cherry_pick(int argc, const char **argv)
548
{
549
struct rev_info revs;
550
+ struct commit *commit;
551
552
git_config(git_default_config, NULL);
553
me = action == REVERT ? "revert" : "cherry-pick";
570
prepare_revs(&revs);
571
572
while ((commit = get_revision(&revs))) {
573
- int res = do_pick_commit();
573
+ int res = do_pick_commit(commit);
574
if (res)
575
return res;
576
}