250
va_end(params);
251
}
252
253
-static char *help_msg(void)
253
+static void print_advice(void)
254
{
255
- struct strbuf helpbuf = STRBUF_INIT;
255
char *msg = getenv("GIT_CHERRY_PICK_HELP");
256
258
- if (msg)
259
- return msg;
257
+ if (msg) {
258
+ fprintf(stderr, "%s\n", msg);
259
+ return;
260
+ }
261
261
- strbuf_addstr(&helpbuf, " After resolving the conflicts,\n"
262
- "mark the corrected paths with 'git add <paths>' or 'git rm <paths>'\n"
263
- "and commit the result");
262
+ advise("after resolving the conflicts, mark the corrected paths");
263
+ advise("with 'git add <paths>' or 'git rm <paths>'");
264
265
- if (action == CHERRY_PICK) {
266
- strbuf_addf(&helpbuf, " with: \n"
267
- "\n"
268
- " git commit -c %s\n",
269
- sha1_to_hex(commit->object.sha1));
270
- }
271
- else
272
- strbuf_addch(&helpbuf, '.');
273
- return strbuf_detach(&helpbuf, NULL);
265
+ if (action == CHERRY_PICK)
266
+ advise("and commit the result with 'git commit -c %s'",
267
+ find_unique_abbrev(commit->object.sha1, DEFAULT_ABBREV));
268
}
269
270
static void write_message(struct strbuf *msgbuf, const char *filename)
398
struct commit_message msg = { NULL, NULL, NULL, NULL, NULL };
399
char *defmsg = NULL;
400
struct strbuf msgbuf = STRBUF_INIT;
407
- struct strbuf mebuf = STRBUF_INIT;
401
int res;
402
403
if (no_commit) {
494
}
495
}
496
504
- strbuf_addf(&mebuf, "%s of commit %s", me,
505
- find_unique_abbrev(commit->object.sha1, DEFAULT_ABBREV));
506
-
497
if (!strategy || !strcmp(strategy, "recursive") || action == REVERT) {
498
res = do_recursive_merge(base, next, base_label, next_label,
499
head, &msgbuf);
502
struct commit_list *common = NULL;
503
struct commit_list *remotes = NULL;
504
515
- strbuf_addf(&mebuf, " with strategy %s", strategy);
505
write_message(&msgbuf, defmsg);
506
507
commit_list_insert(base, &common);
517
action == REVERT ? "revert" : "apply",
518
find_unique_abbrev(commit->object.sha1, DEFAULT_ABBREV),
519
msg.subject);
531
- fprintf(stderr, help_msg());
520
+ print_advice();
521
rerere(allow_rerere_auto);
522
} else {
523
if (!no_commit)
524
res = run_git_commit(defmsg);
525
}
526
538
- strbuf_release(&mebuf);
527
free_message(&msg);
528
free(defmsg);
529