Skip to content

Commit 21bb308

Browse files
SyntevoAlexgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent e440fc5 commit 21bb308

File tree

1 file changed

+17
-17
lines changed

1 file changed

+17
-17
lines changed

builtin/add.c

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -418,10 +418,6 @@ int cmd_add(int argc, const char **argv, const char *prefix)
418418
if (addremove && take_worktree_changes)
419419
die(_("-A and -u are mutually incompatible"));
420420

421-
if (!take_worktree_changes && addremove_explicit < 0 && argc)
422-
/* Turn "git add pathspec..." to "git add -A pathspec..." */
423-
addremove = 1;
424-
425421
if (!show_only && ignore_missing)
426422
die(_("Option --ignore-missing can only be used together with --dry-run"));
427423

@@ -434,19 +430,6 @@ int cmd_add(int argc, const char **argv, const char *prefix)
434430

435431
hold_locked_index(&lock_file, LOCK_DIE_ON_ERROR);
436432

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-
450433
/*
451434
* Check the "pathspec '%s' did not match any files" block
452435
* below before enabling new magic.
@@ -456,6 +439,23 @@ int cmd_add(int argc, const char **argv, const char *prefix)
456439
PATHSPEC_SYMLINK_LEADING_PATH,
457440
prefix, argv);
458441

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+
459459
if (read_cache_preload(&pathspec) < 0)
460460
die(_("index file corrupt"));
461461

0 commit comments

Comments
 (0)