@@ -198,7 +198,7 @@ static int init_basic_state(struct replay_opts *opts, const char *head_name,
198
198
static int do_interactive_rebase (struct replay_opts * opts , unsigned flags ,
199
199
const char * switch_to , struct commit * upstream ,
200
200
struct commit * onto , const char * onto_name ,
201
- const char * squash_onto , const char * head_name ,
201
+ struct object_id * squash_onto , const char * head_name ,
202
202
struct commit * restrict_revision , char * raw_strategies ,
203
203
struct string_list * commands , unsigned autosquash )
204
204
{
@@ -226,7 +226,8 @@ static int do_interactive_rebase(struct replay_opts *opts, unsigned flags,
226
226
}
227
227
228
228
if (!upstream && squash_onto )
229
- write_file (path_squash_onto (), "%s\n" , squash_onto );
229
+ write_file (path_squash_onto (), "%s\n" ,
230
+ oid_to_hex (squash_onto ));
230
231
231
232
argv_array_pushl (& make_script_args , "" , revisions , NULL );
232
233
if (restrict_revision )
@@ -267,10 +268,11 @@ int cmd_rebase__interactive(int argc, const char **argv, const char *prefix)
267
268
struct replay_opts opts = REPLAY_OPTS_INIT ;
268
269
unsigned flags = 0 , keep_empty = 0 , rebase_merges = 0 , autosquash = 0 ;
269
270
int abbreviate_commands = 0 , rebase_cousins = -1 , ret = 0 ;
270
- const char * onto_name = NULL ,
271
- * squash_onto = NULL , * head_name = NULL ,
272
- * switch_to = NULL , * cmd = NULL ;
271
+ const char * onto_name = NULL , * head_name = NULL , * switch_to = NULL ,
272
+ * cmd = NULL ;
273
273
struct commit * onto = NULL , * upstream = NULL , * restrict_revision = NULL ;
274
+ struct object_id squash_onto = null_oid ;
275
+ struct object_id * squash_onto_opt = NULL ;
274
276
struct string_list commands = STRING_LIST_INIT_DUP ;
275
277
char * raw_strategies = NULL ;
276
278
enum {
@@ -311,8 +313,8 @@ int cmd_rebase__interactive(int argc, const char **argv, const char *prefix)
311
313
{ OPTION_CALLBACK , 0 , "restrict-revision" , & restrict_revision ,
312
314
N_ ("restrict-revision" ), N_ ("restrict revision" ),
313
315
PARSE_OPT_NONEG , parse_opt_commit , 0 },
314
- OPT_STRING ( 0 , "squash-onto" , & squash_onto , N_ ("squash-onto" ),
315
- N_ ("squash onto" )) ,
316
+ { OPTION_CALLBACK , 0 , "squash-onto" , & squash_onto , N_ ("squash-onto" ),
317
+ N_ ("squash onto" ), PARSE_OPT_NONEG , parse_opt_object_id , 0 } ,
316
318
{ OPTION_CALLBACK , 0 , "upstream" , & upstream , N_ ("upstream" ),
317
319
N_ ("the upstream commit" ), PARSE_OPT_NONEG , parse_opt_commit ,
318
320
0 },
@@ -349,6 +351,9 @@ int cmd_rebase__interactive(int argc, const char **argv, const char *prefix)
349
351
350
352
opts .gpg_sign = xstrdup_or_null (opts .gpg_sign );
351
353
354
+ if (!is_null_oid (& squash_onto ))
355
+ squash_onto_opt = & squash_onto ;
356
+
352
357
flags |= keep_empty ? TODO_LIST_KEEP_EMPTY : 0 ;
353
358
flags |= abbreviate_commands ? TODO_LIST_ABBREVIATE_CMDS : 0 ;
354
359
flags |= rebase_merges ? TODO_LIST_REBASE_MERGES : 0 ;
@@ -373,7 +378,7 @@ int cmd_rebase__interactive(int argc, const char **argv, const char *prefix)
373
378
die (_ ("a base commit must be provided with --upstream or --onto" ));
374
379
375
380
ret = do_interactive_rebase (& opts , flags , switch_to , upstream , onto ,
376
- onto_name , squash_onto , head_name , restrict_revision ,
381
+ onto_name , squash_onto_opt , head_name , restrict_revision ,
377
382
raw_strategies , & commands , autosquash );
378
383
break ;
379
384
case SKIP : {
0 commit comments