]> git.ipfire.org Git - thirdparty/git.git/commitdiff
refresh_index(): add flag to ignore SKIP_WORKTREE entries
authorMatheus Tavares <matheus.bernardino@usp.br>
Thu, 8 Apr 2021 20:41:26 +0000 (17:41 -0300)
committerJunio C Hamano <gitster@pobox.com>
Thu, 8 Apr 2021 21:18:03 +0000 (14:18 -0700)
refresh_index() doesn't update SKIP_WORKTREE entries, but it still
matches them against the given pathspecs, marks the matches on the
seen[] array, check if unmerged, etc. In the following patch, one caller
will need refresh_index() to ignore SKIP_WORKTREE entries entirely, so
add a flag that implements this behavior.

While we are here, also realign the REFRESH_* flags and convert the hex
values to the more natural bit shift format, which makes it easier to
spot holes.

Signed-off-by: Matheus Tavares <matheus.bernardino@usp.br>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
cache.h
read-cache.c

diff --git a/cache.h b/cache.h
index 6fda8091f11de129b2f52a8d3aa58216023d6c34..5a91e793ec17e686d7b51682a58670e897271dc7 100644 (file)
--- a/cache.h
+++ b/cache.h
@@ -879,13 +879,14 @@ int match_stat_data_racy(const struct index_state *istate,
 
 void fill_stat_cache_info(struct index_state *istate, struct cache_entry *ce, struct stat *st);
 
-#define REFRESH_REALLY         0x0001  /* ignore_valid */
-#define REFRESH_UNMERGED       0x0002  /* allow unmerged */
-#define REFRESH_QUIET          0x0004  /* be quiet about it */
-#define REFRESH_IGNORE_MISSING 0x0008  /* ignore non-existent */
-#define REFRESH_IGNORE_SUBMODULES      0x0010  /* ignore submodules */
-#define REFRESH_IN_PORCELAIN   0x0020  /* user friendly output, not "needs update" */
-#define REFRESH_PROGRESS       0x0040  /* show progress bar if stderr is tty */
+#define REFRESH_REALLY                   (1 << 0) /* ignore_valid */
+#define REFRESH_UNMERGED                 (1 << 1) /* allow unmerged */
+#define REFRESH_QUIET                    (1 << 2) /* be quiet about it */
+#define REFRESH_IGNORE_MISSING           (1 << 3) /* ignore non-existent */
+#define REFRESH_IGNORE_SUBMODULES        (1 << 4) /* ignore submodules */
+#define REFRESH_IN_PORCELAIN             (1 << 5) /* user friendly output, not "needs update" */
+#define REFRESH_PROGRESS                 (1 << 6) /* show progress bar if stderr is tty */
+#define REFRESH_IGNORE_SKIP_WORKTREE     (1 << 7) /* ignore skip_worktree entries */
 int refresh_index(struct index_state *, unsigned int flags, const struct pathspec *pathspec, char *seen, const char *header_msg);
 /*
  * Refresh the index and write it to disk.
index 1e9a50c6c734374aa59ff97b9f9e5432918bf1f8..62594a8f510ff54acb68f42069bfe125f1eab1ba 100644 (file)
@@ -1514,6 +1514,7 @@ int refresh_index(struct index_state *istate, unsigned int flags,
        int quiet = (flags & REFRESH_QUIET) != 0;
        int not_new = (flags & REFRESH_IGNORE_MISSING) != 0;
        int ignore_submodules = (flags & REFRESH_IGNORE_SUBMODULES) != 0;
+       int ignore_skip_worktree = (flags & REFRESH_IGNORE_SKIP_WORKTREE) != 0;
        int first = 1;
        int in_porcelain = (flags & REFRESH_IN_PORCELAIN);
        unsigned int options = (CE_MATCH_REFRESH |
@@ -1556,6 +1557,8 @@ int refresh_index(struct index_state *istate, unsigned int flags,
                ce = istate->cache[i];
                if (ignore_submodules && S_ISGITLINK(ce->ce_mode))
                        continue;
+               if (ignore_skip_worktree && ce_skip_worktree(ce))
+                       continue;
 
                if (pathspec && !ce_path_match(istate, ce, pathspec, seen))
                        filtered = 1;