* Normally when an entry is added or removed from a directory, * invalidating that directory is enough. No need to touch its * ancestors. When a directory is shown as "foo/bar/" in git-status * however, deleting or adding an entry may have cascading effect. * * Say the "foo/bar/file" has become untracked, we need to tell the * untracked_cache_dir of "foo" that "bar/" is not an untracked * d
| 3991 | * stick to something safe and simple. |
| 3992 | */ |
| 3993 | static int invalidate_one_component(struct untracked_cache *uc, |
| 3994 | struct untracked_cache_dir *dir, |
| 3995 | const char *path, int len) |
| 3996 | { |
| 3997 | const char *rest = strchr(path, '/'); |
| 3998 | |
| 3999 | if (rest) { |
| 4000 | int component_len = rest - path; |
| 4001 | struct untracked_cache_dir *d = |
| 4002 | lookup_untracked(uc, dir, path, component_len); |
| 4003 | int ret = |
| 4004 | invalidate_one_component(uc, d, rest + 1, |
| 4005 | len - (component_len + 1)); |
| 4006 | if (ret) |
| 4007 | invalidate_one_directory(uc, dir); |
| 4008 | return ret; |
| 4009 | } |
| 4010 | |
| 4011 | invalidate_one_directory(uc, dir); |
| 4012 | return uc->dir_flags & DIR_SHOW_OTHER_DIRECTORIES; |
| 4013 | } |
| 4014 | |
| 4015 | void untracked_cache_invalidate_path(struct index_state *istate, |
| 4016 | const char *path, int safe_path) |
no test coverage detected