]> git.ipfire.org Git - thirdparty/git.git/commitdiff
cmd_add: prepare for next patch
authorAlexandr Miloslavskiy <alexandr.miloslavskiy@syntevo.com>
Tue, 3 Dec 2019 14:02:12 +0000 (14:02 +0000)
committerJunio C Hamano <gitster@pobox.com>
Wed, 4 Dec 2019 18:10:37 +0000 (10:10 -0800)
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>
builtin/add.c

index dd18e5c9b67038307401e8d33970d5c424c03cb7..4fabdc72e6d8ddc15aaca5811ec0570bf0a9d7fc 100644 (file)
@@ -418,10 +418,6 @@ int cmd_add(int argc, const char **argv, const char *prefix)
        if (addremove && take_worktree_changes)
                die(_("-A and -u are mutually incompatible"));
 
-       if (!take_worktree_changes && addremove_explicit < 0 && argc)
-               /* Turn "git add pathspec..." to "git add -A pathspec..." */
-               addremove = 1;
-
        if (!show_only && ignore_missing)
                die(_("Option --ignore-missing can only be used together with --dry-run"));
 
@@ -434,19 +430,6 @@ int cmd_add(int argc, const char **argv, const char *prefix)
 
        hold_locked_index(&lock_file, LOCK_DIE_ON_ERROR);
 
-       flags = ((verbose ? ADD_CACHE_VERBOSE : 0) |
-                (show_only ? ADD_CACHE_PRETEND : 0) |
-                (intent_to_add ? ADD_CACHE_INTENT : 0) |
-                (ignore_add_errors ? ADD_CACHE_IGNORE_ERRORS : 0) |
-                (!(addremove || take_worktree_changes)
-                 ? ADD_CACHE_IGNORE_REMOVAL : 0));
-
-       if (require_pathspec && argc == 0) {
-               fprintf(stderr, _("Nothing specified, nothing added.\n"));
-               fprintf(stderr, _("Maybe you wanted to say 'git add .'?\n"));
-               return 0;
-       }
-
        /*
         * Check the "pathspec '%s' did not match any files" block
         * below before enabling new magic.
@@ -456,6 +439,23 @@ int cmd_add(int argc, const char **argv, const char *prefix)
                       PATHSPEC_SYMLINK_LEADING_PATH,
                       prefix, argv);
 
+       if (require_pathspec && argc == 0) {
+               fprintf(stderr, _("Nothing specified, nothing added.\n"));
+               fprintf(stderr, _("Maybe you wanted to say 'git add .'?\n"));
+               return 0;
+       }
+
+       if (!take_worktree_changes && addremove_explicit < 0 && argc)
+               /* Turn "git add pathspec..." to "git add -A pathspec..." */
+               addremove = 1;
+
+       flags = ((verbose ? ADD_CACHE_VERBOSE : 0) |
+                (show_only ? ADD_CACHE_PRETEND : 0) |
+                (intent_to_add ? ADD_CACHE_INTENT : 0) |
+                (ignore_add_errors ? ADD_CACHE_IGNORE_ERRORS : 0) |
+                (!(addremove || take_worktree_changes)
+                 ? ADD_CACHE_IGNORE_REMOVAL : 0));
+
        if (read_cache_preload(&pathspec) < 0)
                die(_("index file corrupt"));