Skip to content

Commit c72fc40

Browse files
szedergitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 8a64881 commit c72fc40

File tree

1 file changed

+33
-33
lines changed

1 file changed

+33
-33
lines changed

path.c

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -101,36 +101,36 @@ struct common_dir {
101101
/* Not considered garbage for report_linked_checkout_garbage */
102102
unsigned ignore_garbage:1;
103103
unsigned is_dir:1;
104-
/* Not common even though its parent is */
105-
unsigned exclude:1;
106-
const char *dirname;
104+
/* Belongs to the common dir, though it may contain paths that don't */
105+
unsigned is_common:1;
106+
const char *path;
107107
};
108108

109109
static struct common_dir common_list[] = {
110-
{ 0, 1, 0, "branches" },
111-
{ 0, 1, 0, "common" },
112-
{ 0, 1, 0, "hooks" },
113-
{ 0, 1, 0, "info" },
114-
{ 0, 0, 1, "info/sparse-checkout" },
115-
{ 1, 1, 0, "logs" },
116-
{ 1, 0, 1, "logs/HEAD" },
117-
{ 0, 1, 1, "logs/refs/bisect" },
118-
{ 0, 1, 1, "logs/refs/rewritten" },
119-
{ 0, 1, 1, "logs/refs/worktree" },
120-
{ 0, 1, 0, "lost-found" },
121-
{ 0, 1, 0, "objects" },
122-
{ 0, 1, 0, "refs" },
123-
{ 0, 1, 1, "refs/bisect" },
124-
{ 0, 1, 1, "refs/rewritten" },
125-
{ 0, 1, 1, "refs/worktree" },
126-
{ 0, 1, 0, "remotes" },
127-
{ 0, 1, 0, "worktrees" },
128-
{ 0, 1, 0, "rr-cache" },
129-
{ 0, 1, 0, "svn" },
130-
{ 0, 0, 0, "config" },
131-
{ 1, 0, 0, "gc.pid" },
132-
{ 0, 0, 0, "packed-refs" },
133-
{ 0, 0, 0, "shallow" },
110+
{ 0, 1, 1, "branches" },
111+
{ 0, 1, 1, "common" },
112+
{ 0, 1, 1, "hooks" },
113+
{ 0, 1, 1, "info" },
114+
{ 0, 0, 0, "info/sparse-checkout" },
115+
{ 1, 1, 1, "logs" },
116+
{ 1, 0, 0, "logs/HEAD" },
117+
{ 0, 1, 0, "logs/refs/bisect" },
118+
{ 0, 1, 0, "logs/refs/rewritten" },
119+
{ 0, 1, 0, "logs/refs/worktree" },
120+
{ 0, 1, 1, "lost-found" },
121+
{ 0, 1, 1, "objects" },
122+
{ 0, 1, 1, "refs" },
123+
{ 0, 1, 0, "refs/bisect" },
124+
{ 0, 1, 0, "refs/rewritten" },
125+
{ 0, 1, 0, "refs/worktree" },
126+
{ 0, 1, 1, "remotes" },
127+
{ 0, 1, 1, "worktrees" },
128+
{ 0, 1, 1, "rr-cache" },
129+
{ 0, 1, 1, "svn" },
130+
{ 0, 0, 1, "config" },
131+
{ 1, 0, 1, "gc.pid" },
132+
{ 0, 0, 1, "packed-refs" },
133+
{ 0, 0, 1, "shallow" },
134134
{ 0, 0, 0, NULL }
135135
};
136136

@@ -331,8 +331,8 @@ static void init_common_trie(void)
331331
if (common_trie_done_setup)
332332
return;
333333

334-
for (p = common_list; p->dirname; p++)
335-
add_to_trie(&common_trie, p->dirname, p);
334+
for (p = common_list; p->path; p++)
335+
add_to_trie(&common_trie, p->path, p);
336336

337337
common_trie_done_setup = 1;
338338
}
@@ -349,10 +349,10 @@ static int check_common(const char *unmatched, void *value, void *baton)
349349
return 0;
350350

351351
if (dir->is_dir && (unmatched[0] == 0 || unmatched[0] == '/'))
352-
return !dir->exclude;
352+
return dir->is_common;
353353

354354
if (!dir->is_dir && unmatched[0] == 0)
355-
return !dir->exclude;
355+
return dir->is_common;
356356

357357
return 0;
358358
}
@@ -376,8 +376,8 @@ void report_linked_checkout_garbage(void)
376376
return;
377377
strbuf_addf(&sb, "%s/", get_git_dir());
378378
len = sb.len;
379-
for (p = common_list; p->dirname; p++) {
380-
const char *path = p->dirname;
379+
for (p = common_list; p->path; p++) {
380+
const char *path = p->path;
381381
if (p->ignore_garbage)
382382
continue;
383383
strbuf_setlen(&sb, len);

0 commit comments

Comments
 (0)