311
return write_ref_sha1(ref_lock, to, "cherry-pick");
312
}
313
314
-static void do_recursive_merge(struct commit *base, struct commit *next,
315
- const char *base_label, const char *next_label,
316
- unsigned char *head, struct strbuf *msgbuf,
317
- char *defmsg)
314
+static int do_recursive_merge(struct commit *base, struct commit *next,
315
+ const char *base_label, const char *next_label,
316
+ unsigned char *head, struct strbuf *msgbuf)
317
{
318
struct merge_options o;
319
struct tree *result, *next_tree, *base_tree, *head_tree;
356
i++;
357
}
358
}
360
- write_message(msgbuf, defmsg);
361
- fprintf(stderr, "Automatic %s failed.%s\n",
362
- me, help_msg());
363
- rerere(allow_rerere_auto);
364
- exit(1);
359
}
366
- write_message(msgbuf, defmsg);
367
- fprintf(stderr, "Finished one %s.\n", me);
360
+
361
+ return !clean;
362
}
363
364
static int do_pick_commit(void)
369
struct commit_message msg = { NULL, NULL, NULL, NULL, NULL };
370
char *defmsg = NULL;
371
struct strbuf msgbuf = STRBUF_INIT;
372
+ struct strbuf mebuf = STRBUF_INIT;
373
+ int res;
374
375
if (no_commit) {
376
/*
466
}
467
}
468
473
- if (!strategy || !strcmp(strategy, "recursive") || action == REVERT)
474
- do_recursive_merge(base, next, base_label, next_label,
475
- head, &msgbuf, defmsg);
476
- else {
477
- int res;
469
+ strbuf_addstr(&mebuf, me);
470
+
471
+ if (!strategy || !strcmp(strategy, "recursive") || action == REVERT) {
472
+ res = do_recursive_merge(base, next, base_label, next_label,
473
+ head, &msgbuf);
474
+ write_message(&msgbuf, defmsg);
475
+ } else {
476
struct commit_list *common = NULL;
477
struct commit_list *remotes = NULL;
478
+
479
+ strbuf_addf(&mebuf, " with strategy %s", strategy);
480
write_message(&msgbuf, defmsg);
481
+
482
commit_list_insert(base, &common);
483
commit_list_insert(next, &remotes);
484
res = try_merge_command(strategy, common,
485
sha1_to_hex(head), remotes);
486
free_commit_list(common);
487
free_commit_list(remotes);
487
- if (res) {
488
- fprintf(stderr, "Automatic %s with strategy %s failed.%s\n",
489
- me, strategy, help_msg());
490
- rerere(allow_rerere_auto);
491
- exit(1);
492
- }
488
}
489
490
+ if (res) {
491
+ fprintf(stderr, "Automatic %s failed.%s\n",
492
+ mebuf.buf, help_msg());
493
+ rerere(allow_rerere_auto);
494
+ } else {
495
+ fprintf(stderr, "Finished one %s.\n", mebuf.buf);
496
+ }
497
+
498
+ strbuf_release(&mebuf);
499
free_message(&msg);
500
501
+ if (res)
502
+ return 1;
503
+
504
/*
505
*
506
* If we are cherry-pick, and if the merge did not result in