@@ -4660,112 +4660,37 @@ int transform_todo_file(struct repository *r, unsigned flags)
4660
4660
return 0 ;
4661
4661
}
4662
4662
4663
- enum missing_commit_check_level get_missing_commit_check_level (void )
4664
- {
4665
- const char * value ;
4666
-
4667
- if (git_config_get_value ("rebase.missingcommitscheck" , & value ) ||
4668
- !strcasecmp ("ignore" , value ))
4669
- return MISSING_COMMIT_CHECK_IGNORE ;
4670
- if (!strcasecmp ("warn" , value ))
4671
- return MISSING_COMMIT_CHECK_WARN ;
4672
- if (!strcasecmp ("error" , value ))
4673
- return MISSING_COMMIT_CHECK_ERROR ;
4674
- warning (_ ("unrecognized setting %s for option "
4675
- "rebase.missingCommitsCheck. Ignoring." ), value );
4676
- return MISSING_COMMIT_CHECK_IGNORE ;
4677
- }
4663
+ static const char edit_todo_list_advice [] =
4664
+ N_ ("You can fix this with 'git rebase --edit-todo' "
4665
+ "and then run 'git rebase --continue'.\n"
4666
+ "Or you can abort the rebase with 'git rebase"
4667
+ " --abort'.\n" );
4678
4668
4679
- define_commit_slab (commit_seen , unsigned char );
4680
- /*
4681
- * Check if the user dropped some commits by mistake
4682
- * Behaviour determined by rebase.missingCommitsCheck.
4683
- * Check if there is an unrecognized command or a
4684
- * bad SHA-1 in a command.
4685
- */
4686
- int check_todo_list (struct repository * r )
4669
+ int check_todo_list_from_file (struct repository * r )
4687
4670
{
4688
- enum missing_commit_check_level check_level = get_missing_commit_check_level ();
4689
- struct strbuf todo_file = STRBUF_INIT ;
4690
- struct todo_list todo_list = TODO_LIST_INIT ;
4691
- struct strbuf missing = STRBUF_INIT ;
4692
- int advise_to_edit_todo = 0 , res = 0 , i ;
4693
- struct commit_seen commit_seen ;
4694
-
4695
- init_commit_seen (& commit_seen );
4671
+ struct todo_list old_todo = TODO_LIST_INIT , new_todo = TODO_LIST_INIT ;
4672
+ int res = 0 ;
4696
4673
4697
- strbuf_addstr (& todo_file , rebase_path_todo ());
4698
- if (strbuf_read_file_or_whine (& todo_list .buf , todo_file .buf ) < 0 ) {
4674
+ if (strbuf_read_file_or_whine (& new_todo .buf , rebase_path_todo ()) < 0 ) {
4699
4675
res = -1 ;
4700
- goto leave_check ;
4701
- }
4702
- advise_to_edit_todo = res =
4703
- todo_list_parse_insn_buffer (r , todo_list .buf .buf , & todo_list );
4704
-
4705
- if (res || check_level == MISSING_COMMIT_CHECK_IGNORE )
4706
- goto leave_check ;
4707
-
4708
- /* Mark the commits in git-rebase-todo as seen */
4709
- for (i = 0 ; i < todo_list .nr ; i ++ ) {
4710
- struct commit * commit = todo_list .items [i ].commit ;
4711
- if (commit )
4712
- * commit_seen_at (& commit_seen , commit ) = 1 ;
4676
+ goto out ;
4713
4677
}
4714
4678
4715
- todo_list_release (& todo_list );
4716
- strbuf_addstr (& todo_file , ".backup" );
4717
- if (strbuf_read_file_or_whine (& todo_list .buf , todo_file .buf ) < 0 ) {
4679
+ if (strbuf_read_file_or_whine (& old_todo .buf , rebase_path_todo_backup ()) < 0 ) {
4718
4680
res = -1 ;
4719
- goto leave_check ;
4720
- }
4721
- strbuf_release (& todo_file );
4722
- res = !!todo_list_parse_insn_buffer (r , todo_list .buf .buf , & todo_list );
4723
-
4724
- /* Find commits in git-rebase-todo.backup yet unseen */
4725
- for (i = todo_list .nr - 1 ; i >= 0 ; i -- ) {
4726
- struct todo_item * item = todo_list .items + i ;
4727
- struct commit * commit = item -> commit ;
4728
- if (commit && !* commit_seen_at (& commit_seen , commit )) {
4729
- strbuf_addf (& missing , " - %s %.*s\n" ,
4730
- short_commit_name (commit ),
4731
- item -> arg_len ,
4732
- todo_item_get_arg (& todo_list , item ));
4733
- * commit_seen_at (& commit_seen , commit ) = 1 ;
4734
- }
4681
+ goto out ;
4735
4682
}
4736
4683
4737
- /* Warn about missing commits */
4738
- if (!missing .len )
4739
- goto leave_check ;
4740
-
4741
- if (check_level == MISSING_COMMIT_CHECK_ERROR )
4742
- advise_to_edit_todo = res = 1 ;
4743
-
4744
- fprintf (stderr ,
4745
- _ ("Warning: some commits may have been dropped accidentally.\n"
4746
- "Dropped commits (newer to older):\n" ));
4747
-
4748
- /* Make the list user-friendly and display */
4749
- fputs (missing .buf , stderr );
4750
- strbuf_release (& missing );
4751
-
4752
- fprintf (stderr , _ ("To avoid this message, use \"drop\" to "
4753
- "explicitly remove a commit.\n\n"
4754
- "Use 'git config rebase.missingCommitsCheck' to change "
4755
- "the level of warnings.\n"
4756
- "The possible behaviours are: ignore, warn, error.\n\n" ));
4757
-
4758
- leave_check :
4759
- clear_commit_seen (& commit_seen );
4760
- strbuf_release (& todo_file );
4761
- todo_list_release (& todo_list );
4762
-
4763
- if (advise_to_edit_todo )
4764
- fprintf (stderr ,
4765
- _ ("You can fix this with 'git rebase --edit-todo' "
4766
- "and then run 'git rebase --continue'.\n"
4767
- "Or you can abort the rebase with 'git rebase"
4768
- " --abort'.\n" ));
4684
+ res = todo_list_parse_insn_buffer (r , old_todo .buf .buf , & old_todo );
4685
+ if (!res )
4686
+ res = todo_list_parse_insn_buffer (r , new_todo .buf .buf , & new_todo );
4687
+ if (!res )
4688
+ res = todo_list_check (& old_todo , & new_todo );
4689
+ if (res )
4690
+ fprintf (stderr , _ (edit_todo_list_advice ));
4691
+ out :
4692
+ todo_list_release (& old_todo );
4693
+ todo_list_release (& new_todo );
4769
4694
4770
4695
return res ;
4771
4696
}
@@ -4943,7 +4868,7 @@ int complete_action(struct repository *r, struct replay_opts *opts, unsigned fla
4943
4868
4944
4869
todo_list_release (& todo_list );
4945
4870
4946
- if (check_todo_list (r )) {
4871
+ if (check_todo_list_from_file (r )) {
4947
4872
checkout_onto (opts , onto_name , onto , orig_head );
4948
4873
return -1 ;
4949
4874
}
0 commit comments