summaryrefslogtreecommitdiff
path: root/path.c
diff options
context:
space:
mode:
authorNguyễn Thái Ngọc Duy <pclouds@gmail.com>2014-11-30 15:24:54 +0700
committerJunio C Hamano <gitster@pobox.com>2014-12-01 11:00:18 -0800
commit77a6d84045c8b558d1e08ff2ffe70347b19be6ef (patch)
treed233e6d0b456a28b1102294f8ebc8e37f9a2f2f2 /path.c
parente3df33bb1b14207848ff339ca27644a01ef17c26 (diff)
downloadgit-77a6d84045c8b558d1e08ff2ffe70347b19be6ef.tar.gz
count-objects: report unused files in $GIT_DIR/worktrees/...
In linked checkouts, borrowed parts like config is taken from $GIT_COMMON_DIR. $GIT_DIR/config is never used. Report them as garbage. Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'path.c')
-rw-r--r--path.c29
1 files changed, 27 insertions, 2 deletions
diff --git a/path.c b/path.c
index 72eca6dfa5..cd8e2d6e68 100644
--- a/path.c
+++ b/path.c
@@ -4,6 +4,7 @@
#include "cache.h"
#include "strbuf.h"
#include "string-list.h"
+#include "dir.h"
static int get_st_mode_bits(const char *path, int *mode)
{
@@ -91,9 +92,9 @@ static void replace_dir(struct strbuf *buf, int len, const char *newdir)
}
static const char *common_list[] = {
- "/branches", "/hooks", "/info", "/logs", "/lost-found", "/modules",
+ "/branches", "/hooks", "/info", "!/logs", "/lost-found", "/modules",
"/objects", "/refs", "/remotes", "/worktrees", "/rr-cache", "/svn",
- "config", "gc.pid", "packed-refs", "shallow",
+ "config", "!gc.pid", "packed-refs", "shallow",
NULL
};
@@ -107,6 +108,8 @@ static void update_common_dir(struct strbuf *buf, int git_dir_len)
for (p = common_list; *p; p++) {
const char *path = *p;
int is_dir = 0;
+ if (*path == '!')
+ path++;
if (*path == '/') {
path++;
is_dir = 1;
@@ -122,6 +125,28 @@ 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;
+ 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 == '!')
+ continue;
+ strbuf_setlen(&sb, len);
+ strbuf_addstr(&sb, path);
+ if (file_exists(sb.buf))
+ report_garbage("unused in linked checkout", sb.buf);
+ }
+ strbuf_release(&sb);
+}
+
static void adjust_git_path(struct strbuf *buf, int git_dir_len)
{
const char *base = buf->buf + git_dir_len;