@@ -326,13 +326,93 @@ static void add_var(struct strbuf *buf, const char *name, const char *value)
326
326
}
327
327
}
328
328
329
+ static const char * resolvemsg =
330
+ N_ ("Resolve all conflicts manually, mark them as resolved with\n"
331
+ "\"git add/rm <conflicted_files>\", then run \"git rebase --continue\".\n"
332
+ "You can instead skip this commit: run \"git rebase --skip\".\n"
333
+ "To abort and get back to the state before \"git rebase\", run "
334
+ "\"git rebase --abort\"." );
335
+
329
336
static int run_specific_rebase (struct rebase_options * opts )
330
337
{
331
338
const char * argv [] = { NULL , NULL };
332
339
struct strbuf script_snippet = STRBUF_INIT ;
333
340
int status ;
334
341
const char * backend , * backend_func ;
335
342
343
+ if (opts -> type == REBASE_INTERACTIVE ) {
344
+ /* Run builtin interactive rebase */
345
+ struct child_process child = CHILD_PROCESS_INIT ;
346
+
347
+ argv_array_pushf (& child .env_array , "GIT_CHERRY_PICK_HELP=%s" ,
348
+ resolvemsg );
349
+ if (!(opts -> flags & REBASE_INTERACTIVE_EXPLICIT )) {
350
+ argv_array_push (& child .env_array , "GIT_EDITOR=:" );
351
+ opts -> autosquash = 0 ;
352
+ }
353
+
354
+ child .git_cmd = 1 ;
355
+ argv_array_push (& child .args , "rebase--interactive" );
356
+
357
+ if (opts -> action )
358
+ argv_array_pushf (& child .args , "--%s" , opts -> action );
359
+ if (opts -> keep_empty )
360
+ argv_array_push (& child .args , "--keep-empty" );
361
+ if (opts -> rebase_merges )
362
+ argv_array_push (& child .args , "--rebase-merges" );
363
+ if (opts -> rebase_cousins )
364
+ argv_array_push (& child .args , "--rebase-cousins" );
365
+ if (opts -> autosquash )
366
+ argv_array_push (& child .args , "--autosquash" );
367
+ if (opts -> flags & REBASE_VERBOSE )
368
+ argv_array_push (& child .args , "--verbose" );
369
+ if (opts -> flags & REBASE_FORCE )
370
+ argv_array_push (& child .args , "--no-ff" );
371
+ if (opts -> restrict_revision )
372
+ argv_array_pushf (& child .args ,
373
+ "--restrict-revision=^%s" ,
374
+ oid_to_hex (& opts -> restrict_revision -> object .oid ));
375
+ if (opts -> upstream )
376
+ argv_array_pushf (& child .args , "--upstream=%s" ,
377
+ oid_to_hex (& opts -> upstream -> object .oid ));
378
+ if (opts -> onto )
379
+ argv_array_pushf (& child .args , "--onto=%s" ,
380
+ oid_to_hex (& opts -> onto -> object .oid ));
381
+ if (opts -> squash_onto )
382
+ argv_array_pushf (& child .args , "--squash-onto=%s" ,
383
+ oid_to_hex (opts -> squash_onto ));
384
+ if (opts -> onto_name )
385
+ argv_array_pushf (& child .args , "--onto-name=%s" ,
386
+ opts -> onto_name );
387
+ argv_array_pushf (& child .args , "--head-name=%s" ,
388
+ opts -> head_name ?
389
+ opts -> head_name : "detached HEAD" );
390
+ if (opts -> strategy )
391
+ argv_array_pushf (& child .args , "--strategy=%s" ,
392
+ opts -> strategy );
393
+ if (opts -> strategy_opts )
394
+ argv_array_pushf (& child .args , "--strategy-opts=%s" ,
395
+ opts -> strategy_opts );
396
+ if (opts -> switch_to )
397
+ argv_array_pushf (& child .args , "--switch-to=%s" ,
398
+ opts -> switch_to );
399
+ if (opts -> cmd )
400
+ argv_array_pushf (& child .args , "--cmd=%s" , opts -> cmd );
401
+ if (opts -> allow_empty_message )
402
+ argv_array_push (& child .args , "--allow-empty-message" );
403
+ if (opts -> allow_rerere_autoupdate > 0 )
404
+ argv_array_push (& child .args , "--rerere-autoupdate" );
405
+ else if (opts -> allow_rerere_autoupdate == 0 )
406
+ argv_array_push (& child .args , "--no-rerere-autoupdate" );
407
+ if (opts -> gpg_sign_opt )
408
+ argv_array_push (& child .args , opts -> gpg_sign_opt );
409
+ if (opts -> signoff )
410
+ argv_array_push (& child .args , "--signoff" );
411
+
412
+ status = run_command (& child );
413
+ goto finished_rebase ;
414
+ }
415
+
336
416
add_var (& script_snippet , "GIT_DIR" , absolute_path (get_git_dir ()));
337
417
add_var (& script_snippet , "state_dir" , opts -> state_dir );
338
418
@@ -418,6 +498,7 @@ static int run_specific_rebase(struct rebase_options *opts)
418
498
argv [0 ] = script_snippet .buf ;
419
499
420
500
status = run_command_v_opt (argv , RUN_USING_SHELL );
501
+ finished_rebase :
421
502
if (opts -> dont_finish_rebase )
422
503
; /* do nothing */
423
504
else if (status == 0 ) {
0 commit comments