From: Junio C Hamano Date: Tue, 1 Sep 2015 23:31:15 +0000 (-0700) Subject: Merge branch 'ah/read-tree-usage-string' X-Git-Tag: v2.6.0-rc0~12 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/0b20a4680bf668ba2719fa48a9bdbf137253a4b6?ds=inline;hp=-c Merge branch 'ah/read-tree-usage-string' Usage string fix. * ah/read-tree-usage-string: read-tree: replace bracket set with parentheses to clarify usage --- 0b20a4680bf668ba2719fa48a9bdbf137253a4b6 diff --combined builtin/read-tree.c index 43b47f72f1,70dc100b43..2379e11069 --- a/builtin/read-tree.c +++ b/builtin/read-tree.c @@@ -5,7 -5,6 +5,7 @@@ */ #include "cache.h" +#include "lockfile.h" #include "object.h" #include "tree.h" #include "tree-walk.h" @@@ -34,7 -33,7 +34,7 @@@ static int list_tree(unsigned char *sha } static const char * const read_tree_usage[] = { - N_("git read-tree [[-m [--trivial] [--aggressive] | --reset | --prefix=] [-u [--exclude-per-directory=] | -i]] [--no-sparse-checkout] [--index-output=] (--empty | [ []])"), + N_("git read-tree [(-m [--trivial] [--aggressive] | --reset | --prefix=) [-u [--exclude-per-directory=] | -i]] [--no-sparse-checkout] [--index-output=] (--empty | [ []])"), NULL }; @@@ -67,7 -66,7 +67,7 @@@ static int exclude_per_directory_cb(con return 0; } -static void debug_stage(const char *label, struct cache_entry *ce, +static void debug_stage(const char *label, const struct cache_entry *ce, struct unpack_trees_options *o) { printf("%s ", label); @@@ -81,8 -80,7 +81,8 @@@ sha1_to_hex(ce->sha1)); } -static int debug_merge(struct cache_entry **stages, struct unpack_trees_options *o) +static int debug_merge(const struct cache_entry * const *stages, + struct unpack_trees_options *o) { int i; @@@ -100,7 -98,7 +100,7 @@@ static struct lock_file lock_file int cmd_read_tree(int argc, const char **argv, const char *unused_prefix) { - int i, newfd, stage = 0; + int i, stage = 0; unsigned char sha1[20]; struct tree_desc t[MAX_UNPACK_TREES]; struct unpack_trees_options opts; @@@ -150,21 -148,12 +150,21 @@@ argc = parse_options(argc, argv, unused_prefix, read_tree_options, read_tree_usage, 0); - newfd = hold_locked_index(&lock_file, 1); + hold_locked_index(&lock_file, 1); prefix_set = opts.prefix ? 1 : 0; if (1 < opts.merge + opts.reset + prefix_set) die("Which one? -m, --reset, or --prefix?"); + /* + * NEEDSWORK + * + * The old index should be read anyway even if we're going to + * destroy all index entries because we still need to preserve + * certain information such as index version or split-index + * mode. + */ + if (opts.reset || opts.merge || opts.prefix) { if (read_cache_unmerged() && (opts.prefix || opts.merge)) die("You need to resolve your current index first"); @@@ -188,7 -177,7 +188,7 @@@ if (1 < opts.index_only + opts.update) die("-u and -i at the same time makes no sense"); - if ((opts.update||opts.index_only) && !opts.merge) + if ((opts.update || opts.index_only) && !opts.merge) die("%s is meaningless without -m, --reset, or --prefix", opts.update ? "-u" : "-i"); if ((opts.dir && !opts.update)) @@@ -241,9 -230,10 +241,9 @@@ * what came from the tree. */ if (nr_trees == 1 && !opts.prefix) - prime_cache_tree(&active_cache_tree, trees[0]); + prime_cache_tree(&the_index, trees[0]); - if (write_cache(newfd, active_cache, active_nr) || - commit_locked_index(&lock_file)) + if (write_locked_index(&the_index, &lock_file, COMMIT_LOCK)) die("unable to write new index file"); return 0; }