Thread (35 messages) 35 messages, 3 authors, 2016-06-15
STALE3671d
Revisions (4)
  1. v1 [diff vs current]
  2. v2 [diff vs current]
  3. v3 current
  4. v4 [diff vs current]

[PATCH v3 2/6] path.c: new (identical) list for worktree v1

From: Nguyễn Thái Ngọc Duy <hidden>
Date: 2016-06-15 23:07:54
Subsystem: the rest · Maintainer: Linus Torvalds

Worktree v1 may have different .git file split than v0. Add support
code to change common file list based on extensions.worktree. The list
for now is identical to v0.

Signed-off-by: Nguyễn Thái Ngọc Duy <redacted>
---
 path.c | 40 +++++++++++++++++++++++++++++++++++++---
 1 file changed, 37 insertions(+), 3 deletions(-)
diff --git a/path.c b/path.c
index 3cd155e..14adf5d 100644
--- a/path.c
+++ b/path.c
@@ -100,7 +100,7 @@ struct common_dir {
 	const char *dirname;
 };
 
-static struct common_dir common_list[] = {
+static struct common_dir common_list_v0[] = {
 	{ 0, 1, 0, "branches" },
 	{ 0, 1, 0, "hooks" },
 	{ 0, 1, 0, "info" },
@@ -123,6 +123,40 @@ static struct common_dir common_list[] = {
 	{ 0, 0, 0, NULL }
 };
 
+static struct common_dir common_list_v1[] = {
+	{ 0, 1, 0, "branches" },
+	{ 0, 1, 0, "hooks" },
+	{ 0, 1, 0, "info" },
+	{ 0, 0, 1, "info/sparse-checkout" },
+	{ 1, 1, 0, "logs" },
+	{ 1, 1, 1, "logs/HEAD" },
+	{ 0, 1, 1, "logs/refs/bisect" },
+	{ 0, 1, 0, "lost-found" },
+	{ 0, 1, 0, "objects" },
+	{ 0, 1, 0, "refs" },
+	{ 0, 1, 1, "refs/bisect" },
+	{ 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, 0, 0, NULL }
+};
+
+static struct common_dir *get_common_list(void)
+{
+	switch (repository_format_worktree_version) {
+	case 0: return common_list_v0;
+	case 1: return common_list_v1;
+	default:
+		die(_("unsupported worktree format version %d"),
+		    repository_format_worktree_version);
+	}
+}
+
 /*
  * A compressed trie.  A trie node consists of zero or more characters that
  * are common to all elements with this prefix, optionally followed by some
@@ -309,7 +343,7 @@ static void init_common_trie(void)
 	if (common_trie_done_setup)
 		return;
 
-	for (p = common_list; p->dirname; p++)
+	for (p = get_common_list(); p->dirname; p++)
 		add_to_trie(&common_trie, p->dirname, p);
 
 	common_trie_done_setup = 1;
@@ -356,7 +390,7 @@ void report_linked_checkout_garbage(void)
 		return;
 	strbuf_addf(&sb, "%s/", get_git_dir());
 	len = sb.len;
-	for (p = common_list; p->dirname; p++) {
+	for (p = get_common_list(); p->dirname; p++) {
 		const char *path = p->dirname;
 		if (p->ignore_garbage)
 			continue;
-- 
2.7.0.288.g1d8ad15
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help