From: David Turner <dturner@twopensource.com>
To: git@vger.kernel.org, mhagger@alum.mit.edu,
Christian Couder <christian.couder@gmail.com>
Cc: David Turner <dturner@twopensource.com>,
Junio C Hamano <gitster@pobox.com>
Subject: [PATCH v5 1/3] refs: clean up common_list
Date: Mon, 31 Aug 2015 22:13:09 -0400 [thread overview]
Message-ID: <1441073591-639-2-git-send-email-dturner@twopensource.com> (raw)
In-Reply-To: <1441073591-639-1-git-send-email-dturner@twopensource.com>
Instead of common_list having formatting like ! and /, use a struct to
hold common_list data in a structured form.
We don't use 'exclude' yet; instead, we keep the old codepath that
handles info/sparse-checkout and logs/HEAD. Later, we will use exclude.
Signed-off-by: David Turner <dturner@twopensource.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
path.c | 58 +++++++++++++++++++++++++++++++++++++---------------------
1 file changed, 37 insertions(+), 21 deletions(-)
diff --git a/path.c b/path.c
index 95acbaf..f1ffe37 100644
--- a/path.c
+++ b/path.c
@@ -91,35 +91,51 @@ static void replace_dir(struct strbuf *buf, int len, const char *newdir)
buf->buf[newlen] = '/';
}
-static const char *common_list[] = {
- "/branches", "/hooks", "/info", "!/logs", "/lost-found",
- "/objects", "/refs", "/remotes", "/worktrees", "/rr-cache", "/svn",
- "config", "!gc.pid", "packed-refs", "shallow",
- NULL
+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;
+};
+
+struct common_dir common_list[] = {
+ { 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, 0, "lost-found" },
+ { 0, 1, 0, "objects" },
+ { 0, 1, 0, "refs" },
+ { 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 void update_common_dir(struct strbuf *buf, int git_dir_len)
{
char *base = buf->buf + git_dir_len;
- const char **p;
+ const struct common_dir *p;
if (is_dir_file(base, "logs", "HEAD") ||
is_dir_file(base, "info", "sparse-checkout"))
return; /* keep this in $GIT_DIR */
- for (p = common_list; *p; p++) {
- const char *path = *p;
- int is_dir = 0;
- if (*path == '!')
- path++;
- if (*path == '/') {
- path++;
- is_dir = 1;
- }
- if (is_dir && dir_prefix(base, path)) {
+ for (p = common_list; p->dirname; p++) {
+ const char *path = p->dirname;
+ if (p->is_dir && dir_prefix(base, path)) {
replace_dir(buf, git_dir_len, get_git_common_dir());
return;
}
- if (!is_dir && !strcmp(base, path)) {
+ if (!p->is_dir && !strcmp(base, path)) {
replace_dir(buf, git_dir_len, get_git_common_dir());
return;
}
@@ -129,16 +145,16 @@ static void update_common_dir(struct strbuf *buf, int git_dir_len)
void report_linked_checkout_garbage(void)
{
struct strbuf sb = STRBUF_INIT;
- const char **p;
+ const struct common_dir *p;
int len;
if (!git_common_dir_env)
return;
strbuf_addf(&sb, "%s/", get_git_dir());
len = sb.len;
- for (p = common_list; *p; p++) {
- const char *path = *p;
- if (*path == '!')
+ for (p = common_list; p->dirname; p++) {
+ const char *path = p->dirname;
+ if (p->ignore_garbage)
continue;
strbuf_setlen(&sb, len);
strbuf_addstr(&sb, path);
--
2.0.4.315.gad8727a-twtrsrc
next prev parent reply other threads:[~2015-09-01 2:13 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-09-01 2:13 (unknown), David Turner
2015-09-01 2:13 ` David Turner [this message]
2015-09-01 2:13 ` [PATCH v5 2/3] path: optimize common dir checking David Turner
2015-10-05 3:00 ` Michael Haggerty
2015-10-05 17:22 ` Junio C Hamano
2015-10-05 20:10 ` David Turner
2015-10-05 20:36 ` Junio C Hamano
2015-10-05 20:43 ` Junio C Hamano
2015-09-01 2:13 ` [PATCH v5 3/3] refs: make refs/bisect/* per-worktree David Turner
2015-09-01 16:32 ` making refs/bisect/ per worktree (was Re: (unknown)) Junio C Hamano
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1441073591-639-2-git-send-email-dturner@twopensource.com \
--to=dturner@twopensource.com \
--cc=christian.couder@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=mhagger@alum.mit.edu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).