diff options
Diffstat (limited to 'builtin-update-index.c')
-rw-r--r-- | builtin-update-index.c | 34 |
1 files changed, 21 insertions, 13 deletions
diff --git a/builtin-update-index.c b/builtin-update-index.c index 38eb53ccba..417f9724ab 100644 --- a/builtin-update-index.c +++ b/builtin-update-index.c @@ -14,7 +14,7 @@ * Default to not allowing changes to the list of files. The * tool doesn't actually care, but this makes it harder to add * files to the revision control by mistake by doing something - * like "git-update-index *" and suddenly having all the object + * like "git update-index *" and suddenly having all the object * files be revision controlled. */ static int allow_add; @@ -194,6 +194,10 @@ static int process_path(const char *path) int len; struct stat st; + len = strlen(path); + if (has_symlink_leading_path(len, path)) + return error("'%s' is beyond a symbolic link", path); + /* * First things first: get the stat information, to decide * what to do about the pathname! @@ -201,7 +205,6 @@ static int process_path(const char *path) if (lstat(path, &st) < 0) return process_lstat_error(path, errno); - len = strlen(path); if (S_ISDIR(st.st_mode)) return process_directory(path, len, &st); @@ -262,7 +265,7 @@ static void chmod_path(int flip, const char *path) report("chmod %cx '%s'", flip, path); return; fail: - die("git-update-index: cannot chmod %cx '%s'", flip, path); + die("git update-index: cannot chmod %cx '%s'", flip, path); } static void update_one(const char *path, const char *prefix, int prefix_length) @@ -280,7 +283,7 @@ static void update_one(const char *path, const char *prefix, int prefix_length) if (force_remove) { if (remove_file_from_cache(p)) - die("git-update-index: unable to remove %s", path); + die("git update-index: unable to remove %s", path); report("remove '%s'", path); goto free_return; } @@ -310,18 +313,18 @@ static void read_index_info(int line_termination) /* This reads lines formatted in one of three formats: * * (1) mode SP sha1 TAB path - * The first format is what "git-apply --index-info" + * The first format is what "git apply --index-info" * reports, and used to reconstruct a partial tree * that is used for phony merge base tree when falling * back on 3-way merge. * * (2) mode SP type SP sha1 TAB path - * The second format is to stuff git-ls-tree output + * The second format is to stuff "git ls-tree" output * into the index file. * * (3) mode SP sha1 SP stage TAB path * This format is to put higher order stages into the - * index file and matches git-ls-files --stage output. + * index file and matches "git ls-files --stage" output. */ errno = 0; ul = strtoul(buf.buf, &ptr, 8); @@ -351,7 +354,7 @@ static void read_index_info(int line_termination) if (line_termination && path_name[0] == '"') { strbuf_reset(&uq); if (unquote_c_style(&uq, path_name, NULL)) { - die("git-update-index: bad quoting of path name"); + die("git update-index: bad quoting of path name"); } path_name = uq.buf; } @@ -364,7 +367,7 @@ static void read_index_info(int line_termination) if (!mode) { /* mode == 0 means there is no such path -- remove */ if (remove_file_from_cache(path_name)) - die("git-update-index: unable to remove %s", + die("git update-index: unable to remove %s", ptr); } else { @@ -374,7 +377,7 @@ static void read_index_info(int line_termination) */ ptr[-42] = ptr[-1] = 0; if (add_cacheinfo(mode, sha1, path_name, stage)) - die("git-update-index: unable to update %s", + die("git update-index: unable to update %s", path_name); } continue; @@ -614,10 +617,12 @@ int cmd_update_index(int argc, const char **argv, const char *prefix) continue; } if (!strcmp(path, "--refresh")) { + setup_work_tree(); has_errors |= refresh_cache(refresh_flags); continue; } if (!strcmp(path, "--really-refresh")) { + setup_work_tree(); has_errors |= refresh_cache(REFRESH_REALLY | refresh_flags); continue; } @@ -626,12 +631,12 @@ int cmd_update_index(int argc, const char **argv, const char *prefix) unsigned int mode; if (i+3 >= argc) - die("git-update-index: --cacheinfo <mode> <sha1> <path>"); + die("git update-index: --cacheinfo <mode> <sha1> <path>"); if (strtoul_ui(argv[i+1], 8, &mode) || get_sha1_hex(argv[i+2], sha1) || add_cacheinfo(mode, sha1, argv[i+3], 0)) - die("git-update-index: --cacheinfo" + die("git update-index: --cacheinfo" " cannot add %s", argv[i+3]); i += 3; continue; @@ -639,7 +644,7 @@ int cmd_update_index(int argc, const char **argv, const char *prefix) if (!strcmp(path, "--chmod=-x") || !strcmp(path, "--chmod=+x")) { if (argc <= i+1) - die("git-update-index: %s <path>", path); + die("git update-index: %s <path>", path); set_executable_bit = path[8]; continue; } @@ -684,6 +689,7 @@ int cmd_update_index(int argc, const char **argv, const char *prefix) goto finish; } if (!strcmp(path, "--again") || !strcmp(path, "-g")) { + setup_work_tree(); has_errors = do_reupdate(argc - i, argv + i, prefix, prefix_length); if (has_errors) @@ -702,6 +708,7 @@ int cmd_update_index(int argc, const char **argv, const char *prefix) usage(update_index_usage); die("unknown option %s", path); } + setup_work_tree(); p = prefix_path(prefix, prefix_length, path); update_one(p, NULL, 0); if (set_executable_bit) @@ -714,6 +721,7 @@ int cmd_update_index(int argc, const char **argv, const char *prefix) strbuf_init(&buf, 0); strbuf_init(&nbuf, 0); + setup_work_tree(); while (strbuf_getline(&buf, stdin, line_termination) != EOF) { const char *p; if (line_termination && buf.buf[0] == '"') { |