@@ -26,8 +26,6 @@ static int take_worktree_changes;
2626struct update_callback_data {
2727 int flags ;
2828 int add_errors ;
29- /* only needed for 2.0 transition preparation */
30- int warn_add_would_remove ;
3129};
3230
3331static int fix_unmerged_status (struct diff_filepair * p ,
@@ -51,24 +49,6 @@ static int fix_unmerged_status(struct diff_filepair *p,
5149 return DIFF_STATUS_MODIFIED ;
5250}
5351
54- static const char * add_would_remove_warning = N_ (
55- "You ran 'git add' with neither '-A (--all)' or '--ignore-removal',\n"
56- "whose behaviour will change in Git 2.0 with respect to paths you removed.\n"
57- "Paths like '%s' that are\n"
58- "removed from your working tree are ignored with this version of Git.\n"
59- "\n"
60- "* 'git add --ignore-removal <pathspec>', which is the current default,\n"
61- " ignores paths you removed from your working tree.\n"
62- "\n"
63- "* 'git add --all <pathspec>' will let you also record the removals.\n"
64- "\n"
65- "Run 'git status' to check the paths you removed from your working tree.\n" );
66-
67- static void warn_add_would_remove (const char * path )
68- {
69- warning (_ (add_would_remove_warning ), path );
70- }
71-
7252static void update_callback (struct diff_queue_struct * q ,
7353 struct diff_options * opt , void * cbdata )
7454{
@@ -90,10 +70,6 @@ static void update_callback(struct diff_queue_struct *q,
9070 }
9171 break ;
9272 case DIFF_STATUS_DELETED :
93- if (data -> warn_add_would_remove ) {
94- warn_add_would_remove (path );
95- data -> warn_add_would_remove = 0 ;
96- }
9773 if (data -> flags & ADD_CACHE_IGNORE_REMOVAL )
9874 break ;
9975 if (!(data -> flags & ADD_CACHE_PRETEND ))
@@ -105,31 +81,24 @@ static void update_callback(struct diff_queue_struct *q,
10581 }
10682}
10783
108- static void update_files_in_cache (const char * prefix ,
109- const struct pathspec * pathspec ,
110- struct update_callback_data * data )
84+ int add_files_to_cache (const char * prefix ,
85+ const struct pathspec * pathspec , int flags )
11186{
87+ struct update_callback_data data ;
11288 struct rev_info rev ;
11389
90+ memset (& data , 0 , sizeof (data ));
91+ data .flags = flags ;
92+
11493 init_revisions (& rev , prefix );
11594 setup_revisions (0 , NULL , & rev , NULL );
11695 if (pathspec )
11796 copy_pathspec (& rev .prune_data , pathspec );
11897 rev .diffopt .output_format = DIFF_FORMAT_CALLBACK ;
11998 rev .diffopt .format_callback = update_callback ;
120- rev .diffopt .format_callback_data = data ;
99+ rev .diffopt .format_callback_data = & data ;
121100 rev .max_count = 0 ; /* do not compare unmerged paths with stage #2 */
122101 run_diff_files (& rev , DIFF_RACY_IS_MODIFIED );
123- }
124-
125- int add_files_to_cache (const char * prefix ,
126- const struct pathspec * pathspec , int flags )
127- {
128- struct update_callback_data data ;
129-
130- memset (& data , 0 , sizeof (data ));
131- data .flags = flags ;
132- update_files_in_cache (prefix , pathspec , & data );
133102 return !!data .add_errors ;
134103}
135104
@@ -265,7 +234,7 @@ N_("The following paths are ignored by one of your .gitignore files:\n");
265234static int verbose , show_only , ignored_too , refresh_only ;
266235static int ignore_add_errors , intent_to_add , ignore_missing ;
267236
268- #define ADDREMOVE_DEFAULT 0 /* Change to 1 in Git 2.0 */
237+ #define ADDREMOVE_DEFAULT 1
269238static int addremove = ADDREMOVE_DEFAULT ;
270239static int addremove_explicit = -1 ; /* unspecified */
271240
@@ -338,7 +307,6 @@ int cmd_add(int argc, const char **argv, const char *prefix)
338307 int add_new_files ;
339308 int require_pathspec ;
340309 char * seen = NULL ;
341- struct update_callback_data update_data ;
342310
343311 git_config (add_config , NULL );
344312
@@ -362,25 +330,14 @@ int cmd_add(int argc, const char **argv, const char *prefix)
362330 if (addremove && take_worktree_changes )
363331 die (_ ("-A and -u are mutually incompatible" ));
364332
365- /*
366- * Warn when "git add pathspec..." was given without "-u" or "-A"
367- * and pathspec... covers a removed path.
368- */
369- memset (& update_data , 0 , sizeof (update_data ));
370- if (!take_worktree_changes && addremove_explicit < 0 )
371- update_data .warn_add_would_remove = 1 ;
372-
373333 if (!take_worktree_changes && addremove_explicit < 0 && argc )
374- /*
375- * Turn "git add pathspec..." to "git add -A pathspec..."
376- * in Git 2.0 but not yet
377- */
378- ; /* addremove = 1; */
334+ /* Turn "git add pathspec..." to "git add -A pathspec..." */
335+ addremove = 1 ;
379336
380337 if (!show_only && ignore_missing )
381338 die (_ ("Option --ignore-missing can only be used together with --dry-run" ));
382339
383- if ((addremove || take_worktree_changes ) && !argc ) {
340+ if ((0 < addremove_explicit || take_worktree_changes ) && !argc ) {
384341 static const char * whole [2 ] = { ":/" , NULL };
385342 argc = 1 ;
386343 argv = whole ;
@@ -478,10 +435,8 @@ int cmd_add(int argc, const char **argv, const char *prefix)
478435
479436 plug_bulk_checkin ();
480437
481- update_data .flags = flags ;
482- update_files_in_cache (prefix , & pathspec , & update_data );
438+ exit_status |= add_files_to_cache (prefix , & pathspec , flags );
483439
484- exit_status |= !!update_data .add_errors ;
485440 if (add_new_files )
486441 exit_status |= add_files (& dir , flags );
487442
0 commit comments