X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=update-index.c;h=fbccc4a67b95dae4ff5c4f9bb02fc28e8887bc67;hb=fd7e9fb7ae206a64b87c7faecfc88716e98a7577;hp=8def9bcd9fc05f205d278c3d8317f1af748f00d8;hpb=283c8eef6c9a4e379c73904d2bc22b19341b15c8;p=git.git diff --git a/update-index.c b/update-index.c index 8def9bcd..fbccc4a6 100644 --- a/update-index.c +++ b/update-index.c @@ -128,70 +128,6 @@ static int add_file_to_cache(const char *path) return 0; } -/* - * We fundamentally don't like some paths: we don't want - * dot or dot-dot anywhere, and for obvious reasons don't - * want to recurse into ".git" either. - * - * Also, we don't want double slashes or slashes at the - * end that can make pathnames ambiguous. - */ -static int verify_dotfile(const char *rest) -{ - /* - * The first character was '.', but that - * has already been discarded, we now test - * the rest. - */ - switch (*rest) { - /* "." is not allowed */ - case '\0': case '/': - return 0; - - /* - * ".git" followed by NUL or slash is bad. This - * shares the path end test with the ".." case. - */ - case 'g': - if (rest[1] != 'i') - break; - if (rest[2] != 't') - break; - rest += 2; - /* fallthrough */ - case '.': - if (rest[1] == '\0' || rest[1] == '/') - return 0; - } - return 1; -} - -static int verify_path(const char *path) -{ - char c; - - goto inside; - for (;;) { - if (!c) - return 1; - if (c == '/') { -inside: - c = *path++; - switch (c) { - default: - continue; - case '/': case '\0': - break; - case '.': - if (verify_dotfile(path)) - continue; - } - return 0; - } - c = *path++; - } -} - static int add_cacheinfo(unsigned int mode, const unsigned char *sha1, const char *path, int stage) { @@ -250,7 +186,7 @@ static void chmod_path(int flip, const char *path) die("git-update-index: cannot chmod %cx '%s'", flip, path); } -static struct cache_file cache_file; +static struct lock_file lock_file; static void update_one(const char *path, const char *prefix, int prefix_length) { @@ -553,9 +489,9 @@ int main(int argc, const char **argv) git_config(git_default_config); - newfd = hold_index_file_for_update(&cache_file, get_index_file()); + newfd = hold_lock_file_for_update(&lock_file, get_index_file()); if (newfd < 0) - die("unable to create new cachefile"); + die("unable to create new index file"); entries = read_cache(); if (entries < 0) @@ -709,8 +645,8 @@ int main(int argc, const char **argv) finish: if (active_cache_changed) { if (write_cache(newfd, active_cache, active_nr) || - commit_index_file(&cache_file)) - die("Unable to write new cachefile"); + commit_lock_file(&lock_file)) + die("Unable to write new index file"); } return has_errors ? 1 : 0;