summaryrefslogtreecommitdiff
path: root/builtin/read-tree.c
diff options
context:
space:
mode:
authorJan Krüger <jk@jk.gs>2010-09-10 13:28:59 (GMT)
committerJunio C Hamano <gitster@pobox.com>2010-09-10 15:37:14 (GMT)
commitfb1bb96516d4bc985393c0bfb8bb7a6d6ce95045 (patch)
treee7010c8fff88d55fb74d1c3c8c2574bc242dea49 /builtin/read-tree.c
parent8ac8cf5bc17ef11a9c5d51ab128ad010cb37c464 (diff)
downloadgit-fb1bb96516d4bc985393c0bfb8bb7a6d6ce95045.zip
git-fb1bb96516d4bc985393c0bfb8bb7a6d6ce95045.tar.gz
git-fb1bb96516d4bc985393c0bfb8bb7a6d6ce95045.tar.bz2
read-tree: deprecate syntax without tree-ish args
Currently, read-tree can be run without tree-ish arguments, in which case it will empty the index. Since this behavior is undocumented and perhaps a bit too invasive to be the "default" action for read-tree, deprecate it in favor of a new --empty option that does the same thing. Signed-off-by: Jan Krüger <jk@jk.gs> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin/read-tree.c')
-rw-r--r--builtin/read-tree.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/builtin/read-tree.c b/builtin/read-tree.c
index 9ad1e66..eb1e3e7 100644
--- a/builtin/read-tree.c
+++ b/builtin/read-tree.c
@@ -16,6 +16,7 @@
#include "resolve-undo.h"
static int nr_trees;
+static int read_empty;
static struct tree *trees[MAX_UNPACK_TREES];
static int list_tree(unsigned char *sha1)
@@ -32,7 +33,7 @@ static int list_tree(unsigned char *sha1)
}
static const char * const read_tree_usage[] = {
- "git read-tree [[-m [--trivial] [--aggressive] | --reset | --prefix=<prefix>] [-u [--exclude-per-directory=<gitignore>] | -i]] [--no-sparse-checkout] [--index-output=<file>] <tree-ish1> [<tree-ish2> [<tree-ish3>]]",
+ "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
};
@@ -106,6 +107,8 @@ int cmd_read_tree(int argc, const char **argv, const char *unused_prefix)
{ OPTION_CALLBACK, 0, "index-output", NULL, "FILE",
"write resulting index to <FILE>",
PARSE_OPT_NONEG, index_output_cb },
+ OPT_SET_INT(0, "empty", &read_empty,
+ "only empty the index", 1),
OPT__VERBOSE(&opts.verbose_update),
OPT_GROUP("Merging"),
OPT_SET_INT('m', NULL, &opts.merge,
@@ -166,6 +169,11 @@ int cmd_read_tree(int argc, const char **argv, const char *unused_prefix)
die("failed to unpack tree object %s", arg);
stage++;
}
+ if (nr_trees == 0 && !read_empty)
+ warning("read-tree: emptying the index with no arguments is deprecated; use --empty");
+ else if (nr_trees > 0 && read_empty)
+ die("passing trees as arguments contradicts --empty");
+
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)