Teach update-index about --ignore-submodules
Like with the diff machinery, update-index should sometimes just ignore submodules (e.g. to determine a clean state before a rebase). Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Johannes Schindelin committed
May 14, 2008 at 18:03 UTC
5fdeacb0ca3935923ab988c81414c16080db6a32
4 files changed
+14
Documentation/git-update-index.txt
+5
@@ -15,6 +15,7 @@ SYNOPSIS
15
[--cacheinfo <mode> <object> <file>]\*
16
[--chmod=(+|-)x]
17
[--assume-unchanged | --no-assume-unchanged]
18
+ [--ignore-submodules]
19
[--really-refresh] [--unresolve] [--again | -g]
20
[--info-only] [--index-info]
21
[-z] [--stdin]
@@ -54,6 +55,10 @@ OPTIONS
55
default behavior is to error out. This option makes
56
git-update-index continue anyway.
57
58
+--ignore-submodules:
59
+ Do not try to update submodules. This option is only respected
60
+ when passed before --refresh.
61
+
62
--unmerged::
63
If --refresh finds unmerged changes in the index, the default
64
behavior is to error out. This option makes git-update-index
builtin-update-index.c
+4
@@ -593,6 +593,10 @@ int cmd_update_index(int argc, const char **argv, const char *prefix)
593
refresh_flags |= REFRESH_QUIET;
594
continue;
595
}
596
+ if (!strcmp(path, "--ignore-submodules")) {
597
+ refresh_flags |= REFRESH_IGNORE_SUBMODULES;
598
+ continue;
599
+ }
600
if (!strcmp(path, "--add")) {
601
allow_add = 1;
602
continue;
cache.h
+1
@@ -388,6 +388,7 @@ extern void fill_stat_cache_info(struct cache_entry *ce, struct stat *st);
388
#define REFRESH_UNMERGED 0x0002 /* allow unmerged */
389
#define REFRESH_QUIET 0x0004 /* be quiet about it */
390
#define REFRESH_IGNORE_MISSING 0x0008 /* ignore non-existent */
391
+#define REFRESH_IGNORE_SUBMODULES 0x0008 /* ignore submodules */
392
extern int refresh_index(struct index_state *, unsigned int flags, const char **pathspec, char *seen);
393
394
struct lock_file {
read-cache.c
+4
@@ -942,6 +942,7 @@ int refresh_index(struct index_state *istate, unsigned int flags, const char **p
942
int allow_unmerged = (flags & REFRESH_UNMERGED) != 0;
943
int quiet = (flags & REFRESH_QUIET) != 0;
944
int not_new = (flags & REFRESH_IGNORE_MISSING) != 0;
945
+ int ignore_submodules = (flags & REFRESH_IGNORE_SUBMODULES) != 0;
946
unsigned int options = really ? CE_MATCH_IGNORE_VALID : 0;
947
948
for (i = 0; i < istate->cache_nr; i++) {
@@ -949,6 +950,9 @@ int refresh_index(struct index_state *istate, unsigned int flags, const char **p
950
int cache_errno = 0;
951
952
ce = istate->cache[i];
953
+ if (ignore_submodules && S_ISGITLINK(ce->ce_mode))
954
+ continue;
955
+
956
if (ce_stage(ce)) {
957
while ((i < istate->cache_nr) &&
958
! strcmp(istate->cache[i]->name, ce->name))