@@ -198,7 +198,7 @@ static int init_basic_state(struct replay_opts *opts, const char *head_name,
198198static int do_interactive_rebase (struct replay_opts * opts , unsigned flags ,
199199 const char * switch_to , struct commit * upstream ,
200200 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 ,
202202 struct commit * restrict_revision , char * raw_strategies ,
203203 struct string_list * commands , unsigned autosquash )
204204{
@@ -226,7 +226,8 @@ static int do_interactive_rebase(struct replay_opts *opts, unsigned flags,
226226 }
227227
228228 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 ));
230231
231232 argv_array_pushl (& make_script_args , "" , revisions , NULL );
232233 if (restrict_revision )
@@ -267,10 +268,11 @@ int cmd_rebase__interactive(int argc, const char **argv, const char *prefix)
267268 struct replay_opts opts = REPLAY_OPTS_INIT ;
268269 unsigned flags = 0 , keep_empty = 0 , rebase_merges = 0 , autosquash = 0 ;
269270 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 ;
273273 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 ;
274276 struct string_list commands = STRING_LIST_INIT_DUP ;
275277 char * raw_strategies = NULL ;
276278 enum {
@@ -311,8 +313,8 @@ int cmd_rebase__interactive(int argc, const char **argv, const char *prefix)
311313 { OPTION_CALLBACK , 0 , "restrict-revision" , & restrict_revision ,
312314 N_ ("restrict-revision" ), N_ ("restrict revision" ),
313315 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 } ,
316318 { OPTION_CALLBACK , 0 , "upstream" , & upstream , N_ ("upstream" ),
317319 N_ ("the upstream commit" ), PARSE_OPT_NONEG , parse_opt_commit ,
318320 0 },
@@ -349,6 +351,9 @@ int cmd_rebase__interactive(int argc, const char **argv, const char *prefix)
349351
350352 opts .gpg_sign = xstrdup_or_null (opts .gpg_sign );
351353
354+ if (!is_null_oid (& squash_onto ))
355+ squash_onto_opt = & squash_onto ;
356+
352357 flags |= keep_empty ? TODO_LIST_KEEP_EMPTY : 0 ;
353358 flags |= abbreviate_commands ? TODO_LIST_ABBREVIATE_CMDS : 0 ;
354359 flags |= rebase_merges ? TODO_LIST_REBASE_MERGES : 0 ;
@@ -373,7 +378,7 @@ int cmd_rebase__interactive(int argc, const char **argv, const char *prefix)
373378 die (_ ("a base commit must be provided with --upstream or --onto" ));
374379
375380 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 ,
377382 raw_strategies , & commands , autosquash );
378383 break ;
379384 case SKIP : {
0 commit comments