Skip to content

Commit b815e29

Browse files
committed
read-cache: update submodule need --force given ignore=all configuration
Submodules configured with ignore=all are now skipped during add operations unless overridden by --force and the submodule path is explicitly specified. A message is printed (like ignored files) guiding the user to use the --force flag if the user has explicitely want to update the submodule reference. The reason for the change is support submodule branch tracking or similar and git status states nothing and git add should not add either as a default behaviour. The workflow is more logic and similar to regular ignored files even the submodule is already tracked. The change opens up a lot of possibilities for submodules to be used more freely and simular to the repo tool. A submodule can be added for many more reason and loosely coupled dependencies to the super repo which often gives the friction of handle the explicit commits and updates without the need for tracking the submodule sha1 by sha1. Signed-off-by: Claus Schneider(Eficode) <[email protected]>
1 parent 2e5242e commit b815e29

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

read-cache.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@
4848
#include "csum-file.h"
4949
#include "promisor-remote.h"
5050
#include "hook.h"
51+
#include "submodule.h"
52+
#include "submodule-config.h"
5153

5254
/* Mask for the name length in ce_flags in the on-disk index */
5355

@@ -3955,16 +3957,16 @@ static void update_callback(struct diff_queue_struct *q,
39553957
}
39563958
}
39573959
if (pathspec_matches) {
3958-
if (data->include_ignored_submodules && data->include_ignored_submodules > 0) {
3959-
trace_printf("Add ignored=all submodule due to --include_ignored_submodules: %s\n", path);
3960+
if (data->ignored_too && data->ignored_too > 0) {
3961+
trace_printf("Add submodule due to --force: %s\n", path);
39603962
} else {
39613963
printf(_("Skipping submodule due to ignore=all: %s"), path);
3962-
printf(_("Use --include_ignored_submodules, if you really want to add them.") );
3964+
printf(_("Use --force, if you really want to add them.") );
39633965
continue;
39643966
}
39653967
} else {
39663968
/* No explicit pathspec match -> skip silently (or with trace). */
3967-
trace_printf("pathspec does not match %s\n", path);
3969+
trace_printf("Pathspec to submodule does not match explicitly: %s\n", path);
39683970
continue;
39693971
}
39703972
}
@@ -3975,6 +3977,7 @@ static void update_callback(struct diff_queue_struct *q,
39753977
data->add_errors++;
39763978
}
39773979
break;
3980+
}
39783981
case DIFF_STATUS_DELETED:
39793982
if (data->flags & ADD_CACHE_IGNORE_REMOVAL)
39803983
break;

0 commit comments

Comments
 (0)