add, reset: ensure submodules can be added or reset
authorBrandon Williams <bmwill@google.com>
Tue, 25 Jul 2017 21:39:16 +0000 (14:39 -0700)
committerJunio C Hamano <gitster@pobox.com>
Wed, 2 Aug 2017 21:35:08 +0000 (14:35 -0700)
Commit aee9c7d65 (Submodules: Add the new "ignore" config option for
diff and status) introduced the ignore configuration option for
submodules so that configured submodules could be omitted from the
status and diff commands. Because this flag is respected in the diff
machinery it has the unintended consequence of potentially prohibiting
users from adding or resetting a submodule, even when a path to the
submodule is explicitly given.

Ensure that submodules can be added or set, even if they are configured
to be ignored, by setting the `DIFF_OPT_OVERRIDE_SUBMODULE_CONFIG` diff
flag.

Signed-off-by: Brandon Williams <bmwill@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/add.c
builtin/reset.c
index e888fb8c5f2a1fa2be33e834724460dec8072726..6f271512f86e264037542a94654b2d664e4870be 100644 (file)
@@ -116,6 +116,7 @@ int add_files_to_cache(const char *prefix,
        rev.diffopt.output_format = DIFF_FORMAT_CALLBACK;
        rev.diffopt.format_callback = update_callback;
        rev.diffopt.format_callback_data = &data;
+       rev.diffopt.flags |= DIFF_OPT_OVERRIDE_SUBMODULE_CONFIG;
        rev.max_count = 0; /* do not compare unmerged paths with stage #2 */
        run_diff_files(&rev, DIFF_RACY_IS_MODIFIED);
        return !!data.add_errors;
index 046403ed6881f452271c636e935ad3ab05da0b78..772d078b8531a7740652a5f39ad2d4c6ef885004 100644 (file)
@@ -156,6 +156,7 @@ static int read_from_tree(const struct pathspec *pathspec,
        opt.output_format = DIFF_FORMAT_CALLBACK;
        opt.format_callback = update_index_from_diff;
        opt.format_callback_data = &intent_to_add;
+       opt.flags |= DIFF_OPT_OVERRIDE_SUBMODULE_CONFIG;
 
        if (do_diff_cache(tree_oid, &opt))
                return 1;