Merge branch 'ah/read-tree-usage-string'
authorJunio C Hamano <gitster@pobox.com>
Tue, 1 Sep 2015 23:31:15 +0000 (16:31 -0700)
committerJunio C Hamano <gitster@pobox.com>
Tue, 1 Sep 2015 23:31:16 +0000 (16:31 -0700)
Usage string fix.

* ah/read-tree-usage-string:
read-tree: replace bracket set with parentheses to clarify usage

1  2 
builtin/read-tree.c
diff --combined builtin/read-tree.c
index 43b47f72f1deffa8fa5e3fa5ac403d4c4a819355,70dc100b43fce41e0a820aba75f0e217cb8ea7c7..2379e11069ef223a82580a9451ede8fbdb1eb8d9
@@@ -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=<prefix>] [-u [--exclude-per-directory=<gitignore>] | -i]] [--no-sparse-checkout] [--index-output=<file>] (--empty | <tree-ish1> [<tree-ish2> [<tree-ish3>]])"),
+       N_("git read-tree [(-m [--trivial] [--aggressive] | --reset | --prefix=<prefix>) [-u [--exclude-per-directory=<gitignore>] | -i]] [--no-sparse-checkout] [--index-output=<file>] (--empty | <tree-ish1> [<tree-ish2> [<tree-ish3>]])"),
        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;
        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");
  
        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))
         * 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;
  }