@matheusbsbs / matheus-bagliano / commits / 21bb3083c3
Fork 0

cmd_add: prepare for next patch

Some code blocks were moved down to be able to test for `pathspec.nr` in the next patch. Blocks are moved as is without any changes. This is done as separate patch to reduce the amount of diffs in next patch. Signed-off-by: Alexandr Miloslavskiy <alexandr.miloslavskiy@syntevo.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Alexandr Miloslavskiy committed Dec 3, 2019 at 14:02 UTC 21bb3083c3859b4d1d222e9f883ecad42f2e886c
1 file changed +17 -17
builtin/add.c
+17 -17
@@ -418,10 +418,6 @@ int cmd_add(int argc, const char **argv, const char *prefix)
418 if (addremove && take_worktree_changes)
419 die(_("-A and -u are mutually incompatible"));
420
421 - if (!take_worktree_changes && addremove_explicit < 0 && argc)
422 - /* Turn "git add pathspec..." to "git add -A pathspec..." */
423 - addremove = 1;
424 -
421 if (!show_only && ignore_missing)
422 die(_("Option --ignore-missing can only be used together with --dry-run"));
423
@@ -434,19 +430,6 @@ int cmd_add(int argc, const char **argv, const char *prefix)
430
431 hold_locked_index(&lock_file, LOCK_DIE_ON_ERROR);
432
437 - flags = ((verbose ? ADD_CACHE_VERBOSE : 0) |
438 - (show_only ? ADD_CACHE_PRETEND : 0) |
439 - (intent_to_add ? ADD_CACHE_INTENT : 0) |
440 - (ignore_add_errors ? ADD_CACHE_IGNORE_ERRORS : 0) |
441 - (!(addremove || take_worktree_changes)
442 - ? ADD_CACHE_IGNORE_REMOVAL : 0));
443 -
444 - if (require_pathspec && argc == 0) {
445 - fprintf(stderr, _("Nothing specified, nothing added.\n"));
446 - fprintf(stderr, _("Maybe you wanted to say 'git add .'?\n"));
447 - return 0;
448 - }
449 -
433 /*
434 * Check the "pathspec '%s' did not match any files" block
435 * below before enabling new magic.
@@ -456,6 +439,23 @@ int cmd_add(int argc, const char **argv, const char *prefix)
439 PATHSPEC_SYMLINK_LEADING_PATH,
440 prefix, argv);
441
442 + if (require_pathspec && argc == 0) {
443 + fprintf(stderr, _("Nothing specified, nothing added.\n"));
444 + fprintf(stderr, _("Maybe you wanted to say 'git add .'?\n"));
445 + return 0;
446 + }
447 +
448 + if (!take_worktree_changes && addremove_explicit < 0 && argc)
449 + /* Turn "git add pathspec..." to "git add -A pathspec..." */
450 + addremove = 1;
451 +
452 + flags = ((verbose ? ADD_CACHE_VERBOSE : 0) |
453 + (show_only ? ADD_CACHE_PRETEND : 0) |
454 + (intent_to_add ? ADD_CACHE_INTENT : 0) |
455 + (ignore_add_errors ? ADD_CACHE_IGNORE_ERRORS : 0) |
456 + (!(addremove || take_worktree_changes)
457 + ? ADD_CACHE_IGNORE_REMOVAL : 0));
458 +
459 if (read_cache_preload(&pathspec) < 0)
460 die(_("index file corrupt"));
461