summaryrefslogtreecommitdiff
path: root/path.c
diff options
context:
space:
mode:
authorSZEDER Gábor <szeder.dev@gmail.com>2019-10-21 16:00:42 (GMT)
committerJunio C Hamano <gitster@pobox.com>2019-10-23 03:53:51 (GMT)
commitc72fc40d0904cbf3199258c2f471c2351e024b1e (patch)
treef5a673af242d74fe738ee6dd0318e343e5eb7ce8 /path.c
parent8a64881b44e03264fb0c3c26fc00a01c12cd67ff (diff)
downloadgit-c72fc40d0904cbf3199258c2f471c2351e024b1e.zip
git-c72fc40d0904cbf3199258c2f471c2351e024b1e.tar.gz
git-c72fc40d0904cbf3199258c2f471c2351e024b1e.tar.bz2
path.c: clarify two field names in 'struct common_dir'
An array of 'struct common_dir' instances is used to specify whether various paths in $GIT_DIR are specific to a worktree, or are common, i.e. belong to main worktree. The names of two fields in this struct are somewhat confusing or ambigious: - The path is recorded in the struct's 'dirname' field, even though several entries are regular files e.g. 'gc.pid', 'packed-refs', etc. Rename this field to 'path' to reduce confusion. - The field 'exclude' tells whether the path is excluded... from where? Excluded from the common dir or from the worktree? It means the former, but it's ambigious. Rename this field to 'is_common' to make it unambigious what it means. This, however, means the exact opposite of what 'exclude' meant, so we have to negate the field's value in all entries as well. The diff is best viewed with '--color-words'. Signed-off-by: SZEDER Gábor <szeder.dev@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'path.c')
-rw-r--r--path.c66
1 files changed, 33 insertions, 33 deletions
diff --git a/path.c b/path.c
index 7f243f3..81e9bfe 100644
--- a/path.c
+++ b/path.c
@@ -101,36 +101,36 @@ struct common_dir {
/* Not considered garbage for report_linked_checkout_garbage */
unsigned ignore_garbage:1;
unsigned is_dir:1;
- /* Not common even though its parent is */
- unsigned exclude:1;
- const char *dirname;
+ /* Belongs to the common dir, though it may contain paths that don't */
+ unsigned is_common:1;
+ const char *path;
};
static struct common_dir common_list[] = {
- { 0, 1, 0, "branches" },
- { 0, 1, 0, "common" },
- { 0, 1, 0, "hooks" },
- { 0, 1, 0, "info" },
- { 0, 0, 1, "info/sparse-checkout" },
- { 1, 1, 0, "logs" },
- { 1, 0, 1, "logs/HEAD" },
- { 0, 1, 1, "logs/refs/bisect" },
- { 0, 1, 1, "logs/refs/rewritten" },
- { 0, 1, 1, "logs/refs/worktree" },
- { 0, 1, 0, "lost-found" },
- { 0, 1, 0, "objects" },
- { 0, 1, 0, "refs" },
- { 0, 1, 1, "refs/bisect" },
- { 0, 1, 1, "refs/rewritten" },
- { 0, 1, 1, "refs/worktree" },
- { 0, 1, 0, "remotes" },
- { 0, 1, 0, "worktrees" },
- { 0, 1, 0, "rr-cache" },
- { 0, 1, 0, "svn" },
- { 0, 0, 0, "config" },
- { 1, 0, 0, "gc.pid" },
- { 0, 0, 0, "packed-refs" },
- { 0, 0, 0, "shallow" },
+ { 0, 1, 1, "branches" },
+ { 0, 1, 1, "common" },
+ { 0, 1, 1, "hooks" },
+ { 0, 1, 1, "info" },
+ { 0, 0, 0, "info/sparse-checkout" },
+ { 1, 1, 1, "logs" },
+ { 1, 0, 0, "logs/HEAD" },
+ { 0, 1, 0, "logs/refs/bisect" },
+ { 0, 1, 0, "logs/refs/rewritten" },
+ { 0, 1, 0, "logs/refs/worktree" },
+ { 0, 1, 1, "lost-found" },
+ { 0, 1, 1, "objects" },
+ { 0, 1, 1, "refs" },
+ { 0, 1, 0, "refs/bisect" },
+ { 0, 1, 0, "refs/rewritten" },
+ { 0, 1, 0, "refs/worktree" },
+ { 0, 1, 1, "remotes" },
+ { 0, 1, 1, "worktrees" },
+ { 0, 1, 1, "rr-cache" },
+ { 0, 1, 1, "svn" },
+ { 0, 0, 1, "config" },
+ { 1, 0, 1, "gc.pid" },
+ { 0, 0, 1, "packed-refs" },
+ { 0, 0, 1, "shallow" },
{ 0, 0, 0, NULL }
};
@@ -331,8 +331,8 @@ static void init_common_trie(void)
if (common_trie_done_setup)
return;
- for (p = common_list; p->dirname; p++)
- add_to_trie(&common_trie, p->dirname, p);
+ for (p = common_list; p->path; p++)
+ add_to_trie(&common_trie, p->path, p);
common_trie_done_setup = 1;
}
@@ -349,10 +349,10 @@ static int check_common(const char *unmatched, void *value, void *baton)
return 0;
if (dir->is_dir && (unmatched[0] == 0 || unmatched[0] == '/'))
- return !dir->exclude;
+ return dir->is_common;
if (!dir->is_dir && unmatched[0] == 0)
- return !dir->exclude;
+ return dir->is_common;
return 0;
}
@@ -376,8 +376,8 @@ void report_linked_checkout_garbage(void)
return;
strbuf_addf(&sb, "%s/", get_git_dir());
len = sb.len;
- for (p = common_list; p->dirname; p++) {
- const char *path = p->dirname;
+ for (p = common_list; p->path; p++) {
+ const char *path = p->path;
if (p->ignore_garbage)
continue;
strbuf_setlen(&sb, len);