#include "cache.h"
#include "strbuf.h"
#include "string-list.h"
+#include "dir.h"
static int get_st_mode_bits(const char *path, int *mode)
{
}
static const char *common_list[] = {
- "/branches", "/hooks", "/info", "/logs", "/lost-found", "/modules",
- "/objects", "/refs", "/remotes", "/rr-cache", "/svn",
- "config", "gc.pid", "packed-refs", "shallow",
+ "/branches", "/hooks", "/info", "!/logs", "/lost-found",
+ "/objects", "/refs", "/remotes", "/worktrees", "/rr-cache", "/svn",
+ "config", "!gc.pid", "packed-refs", "shallow",
NULL
};
char *base = buf->buf + git_dir_len;
const char **p;
- if (is_dir_file(base, "logs", "HEAD"))
+ 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;
}
}
+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;