Skip to content

Commit b243012

Browse files
matheustavaresgitster
authored andcommitted
refresh_index(): add flag to ignore SKIP_WORKTREE entries
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 719630e commit b243012

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

cache.h

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -879,13 +879,14 @@ int match_stat_data_racy(const struct index_state *istate,
879879

880880
void fill_stat_cache_info(struct index_state *istate, struct cache_entry *ce, struct stat *st);
881881

882-
#define REFRESH_REALLY 0x0001 /* ignore_valid */
883-
#define REFRESH_UNMERGED 0x0002 /* allow unmerged */
884-
#define REFRESH_QUIET 0x0004 /* be quiet about it */
885-
#define REFRESH_IGNORE_MISSING 0x0008 /* ignore non-existent */
886-
#define REFRESH_IGNORE_SUBMODULES 0x0010 /* ignore submodules */
887-
#define REFRESH_IN_PORCELAIN 0x0020 /* user friendly output, not "needs update" */
888-
#define REFRESH_PROGRESS 0x0040 /* show progress bar if stderr is tty */
882+
#define REFRESH_REALLY (1 << 0) /* ignore_valid */
883+
#define REFRESH_UNMERGED (1 << 1) /* allow unmerged */
884+
#define REFRESH_QUIET (1 << 2) /* be quiet about it */
885+
#define REFRESH_IGNORE_MISSING (1 << 3) /* ignore non-existent */
886+
#define REFRESH_IGNORE_SUBMODULES (1 << 4) /* ignore submodules */
887+
#define REFRESH_IN_PORCELAIN (1 << 5) /* user friendly output, not "needs update" */
888+
#define REFRESH_PROGRESS (1 << 6) /* show progress bar if stderr is tty */
889+
#define REFRESH_IGNORE_SKIP_WORKTREE (1 << 7) /* ignore skip_worktree entries */
889890
int refresh_index(struct index_state *, unsigned int flags, const struct pathspec *pathspec, char *seen, const char *header_msg);
890891
/*
891892
* Refresh the index and write it to disk.

read-cache.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1514,6 +1514,7 @@ int refresh_index(struct index_state *istate, unsigned int flags,
15141514
int quiet = (flags & REFRESH_QUIET) != 0;
15151515
int not_new = (flags & REFRESH_IGNORE_MISSING) != 0;
15161516
int ignore_submodules = (flags & REFRESH_IGNORE_SUBMODULES) != 0;
1517+
int ignore_skip_worktree = (flags & REFRESH_IGNORE_SKIP_WORKTREE) != 0;
15171518
int first = 1;
15181519
int in_porcelain = (flags & REFRESH_IN_PORCELAIN);
15191520
unsigned int options = (CE_MATCH_REFRESH |
@@ -1556,6 +1557,8 @@ int refresh_index(struct index_state *istate, unsigned int flags,
15561557
ce = istate->cache[i];
15571558
if (ignore_submodules && S_ISGITLINK(ce->ce_mode))
15581559
continue;
1560+
if (ignore_skip_worktree && ce_skip_worktree(ce))
1561+
continue;
15591562

15601563
if (pathspec && !ce_path_match(istate, ce, pathspec, seen))
15611564
filtered = 1;

0 commit comments

Comments
 (0)