From: Junio C Hamano Date: Mon, 12 Jan 2015 19:38:23 +0000 (-0800) Subject: Merge branch 'es/checkout-index-temp' X-Git-Tag: v2.3.0-rc0~8 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/c00e1c59d8be28acb505e66eb32757c95b1aa840?ds=inline;hp=-c Merge branch 'es/checkout-index-temp' "git checkout-index --temp=$target $path" did not work correctly for paths outside the current subdirectory in the project. * es/checkout-index-temp: checkout-index: fix --temp relative path mangling t2004: demonstrate broken relative path printing t2004: standardize file naming in symlink test t2004: drop unnecessary write-tree/read-tree t2004: modernize style --- c00e1c59d8be28acb505e66eb32757c95b1aa840 diff --combined builtin/checkout-index.c index 383dccf93e,256310f629..031780f49e --- a/builtin/checkout-index.c +++ b/builtin/checkout-index.c @@@ -5,7 -5,7 +5,7 @@@ * */ #include "builtin.h" -#include "cache.h" +#include "lockfile.h" #include "quote.h" #include "cache-tree.h" #include "parse-options.h" @@@ -18,7 -18,7 +18,7 @@@ static char topath[4][TEMPORARY_FILENAM static struct checkout state; - static void write_tempfile_record(const char *name, int prefix_length) + static void write_tempfile_record(const char *name, const char *prefix) { int i; @@@ -35,14 -35,14 +35,14 @@@ fputs(topath[checkout_stage], stdout); putchar('\t'); - write_name_quoted(name + prefix_length, stdout, line_termination); + write_name_quoted_relative(name, prefix, stdout, line_termination); for (i = 0; i < 4; i++) { topath[i][0] = 0; } } - static int checkout_file(const char *name, int prefix_length) + static int checkout_file(const char *name, const char *prefix) { int namelen = strlen(name); int pos = cache_name_pos(name, namelen); @@@ -71,7 -71,7 +71,7 @@@ if (did_checkout) { if (to_tempfile) - write_tempfile_record(name, prefix_length); + write_tempfile_record(name, prefix); return errs > 0 ? -1 : 0; } @@@ -106,7 -106,7 +106,7 @@@ static void checkout_all(const char *pr if (last_ce && to_tempfile) { if (ce_namelen(last_ce) != ce_namelen(ce) || memcmp(last_ce->name, ce->name, ce_namelen(ce))) - write_tempfile_record(last_ce->name, prefix_length); + write_tempfile_record(last_ce->name, prefix); } if (checkout_entry(ce, &state, to_tempfile ? topath[ce_stage(ce)] : NULL) < 0) @@@ -114,7 -114,7 +114,7 @@@ last_ce = ce; } if (last_ce && to_tempfile) - write_tempfile_record(last_ce->name, prefix_length); + write_tempfile_record(last_ce->name, prefix); if (errs) /* we have already done our error reporting. * exit with the same code as die(). @@@ -135,7 -135,6 +135,7 @@@ static int option_parse_u(const struct int *newfd = opt->value; state.refresh_cache = 1; + state.istate = &the_index; if (*newfd < 0) *newfd = hold_locked_index(&lock_file, 1); return 0; @@@ -248,7 -247,7 +248,7 @@@ int cmd_checkout_index(int argc, const if (read_from_stdin) die("git checkout-index: don't mix '--stdin' and explicit filenames"); p = prefix_path(prefix, prefix_length, arg); - checkout_file(p, prefix_length); + checkout_file(p, prefix); if (p < arg || p > arg + strlen(arg)) free((char *)p); } @@@ -268,7 -267,7 +268,7 @@@ strbuf_swap(&buf, &nbuf); } p = prefix_path(prefix, prefix_length, buf.buf); - checkout_file(p, prefix_length); + checkout_file(p, prefix); if (p < buf.buf || p > buf.buf + buf.len) free((char *)p); } @@@ -280,7 -279,8 +280,7 @@@ checkout_all(prefix, prefix_length); if (0 <= newfd && - (write_cache(newfd, active_cache, active_nr) || - commit_locked_index(&lock_file))) + write_locked_index(&the_index, &lock_file, COMMIT_LOCK)) die("Unable to write new index file"); return 0; }