revert: refactor commit code into a new run_git_commit() function
Signed-off-by: Christian Couder <chriscool@tuxfamily.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Christian Couder committed
Jul 14, 2010 at 01:28 UTC
5df16453d4da41e5a36de536acf9acc8aab98041
1 file changed
+27
-25
builtin/revert.c
+27
-25
@@ -361,6 +361,32 @@ static int do_recursive_merge(struct commit *base, struct commit *next,
361
return !clean;
362
}
363
364
+/*
365
+ * If we are cherry-pick, and if the merge did not result in
366
+ * hand-editing, we will hit this commit and inherit the original
367
+ * author date and name.
368
+ * If we are revert, or if our cherry-pick results in a hand merge,
369
+ * we had better say that the current user is responsible for that.
370
+ */
371
+static int run_git_commit(const char *defmsg)
372
+{
373
+ /* 6 is max possible length of our args array including NULL */
374
+ const char *args[6];
375
+ int i = 0;
376
+
377
+ args[i++] = "commit";
378
+ args[i++] = "-n";
379
+ if (signoff)
380
+ args[i++] = "-s";
381
+ if (!edit) {
382
+ args[i++] = "-F";
383
+ args[i++] = defmsg;
384
+ }
385
+ args[i] = NULL;
386
+
387
+ return run_command_v_opt(args, RUN_GIT_CMD);
388
+}
389
+
390
static int do_pick_commit(void)
391
{
392
unsigned char head[20];
@@ -501,33 +527,9 @@ static int do_pick_commit(void)
527
if (res)
528
return 1;
529
504
- /*
505
- *
506
- * If we are cherry-pick, and if the merge did not result in
507
- * hand-editing, we will hit this commit and inherit the original
508
- * author date and name.
509
- * If we are revert, or if our cherry-pick results in a hand merge,
510
- * we had better say that the current user is responsible for that.
511
- */
512
-
530
if (!no_commit) {
514
- /* 6 is max possible length of our args array including NULL */
515
- const char *args[6];
516
- int res;
517
- int i = 0;
518
-
519
- args[i++] = "commit";
520
- args[i++] = "-n";
521
- if (signoff)
522
- args[i++] = "-s";
523
- if (!edit) {
524
- args[i++] = "-F";
525
- args[i++] = defmsg;
526
- }
527
- args[i] = NULL;
528
- res = run_command_v_opt(args, RUN_GIT_CMD);
531
+ res = run_git_commit(defmsg);
532
free(defmsg);
530
-
533
return res;
534
}
535