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