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>
This commit is contained in:
parent
8ac8cf5bc1
commit
fb1bb96516
@ -11,7 +11,7 @@ SYNOPSIS
|
|||||||
'git read-tree' [[-m [--trivial] [--aggressive] | --reset | --prefix=<prefix>]
|
'git read-tree' [[-m [--trivial] [--aggressive] | --reset | --prefix=<prefix>]
|
||||||
[-u [--exclude-per-directory=<gitignore>] | -i]]
|
[-u [--exclude-per-directory=<gitignore>] | -i]]
|
||||||
[--index-output=<file>] [--no-sparse-checkout]
|
[--index-output=<file>] [--no-sparse-checkout]
|
||||||
<tree-ish1> [<tree-ish2> [<tree-ish3>]]
|
(--empty | <tree-ish1> [<tree-ish2> [<tree-ish3>]])
|
||||||
|
|
||||||
|
|
||||||
DESCRIPTION
|
DESCRIPTION
|
||||||
@ -114,6 +114,10 @@ OPTIONS
|
|||||||
Disable sparse checkout support even if `core.sparseCheckout`
|
Disable sparse checkout support even if `core.sparseCheckout`
|
||||||
is true.
|
is true.
|
||||||
|
|
||||||
|
--empty::
|
||||||
|
Instead of reading tree object(s) into the index, just empty
|
||||||
|
it.
|
||||||
|
|
||||||
<tree-ish#>::
|
<tree-ish#>::
|
||||||
The id of the tree object(s) to be read/merged.
|
The id of the tree object(s) to be read/merged.
|
||||||
|
|
||||||
|
@ -16,6 +16,7 @@
|
|||||||
#include "resolve-undo.h"
|
#include "resolve-undo.h"
|
||||||
|
|
||||||
static int nr_trees;
|
static int nr_trees;
|
||||||
|
static int read_empty;
|
||||||
static struct tree *trees[MAX_UNPACK_TREES];
|
static struct tree *trees[MAX_UNPACK_TREES];
|
||||||
|
|
||||||
static int list_tree(unsigned char *sha1)
|
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[] = {
|
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
|
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",
|
{ OPTION_CALLBACK, 0, "index-output", NULL, "FILE",
|
||||||
"write resulting index to <FILE>",
|
"write resulting index to <FILE>",
|
||||||
PARSE_OPT_NONEG, index_output_cb },
|
PARSE_OPT_NONEG, index_output_cb },
|
||||||
|
OPT_SET_INT(0, "empty", &read_empty,
|
||||||
|
"only empty the index", 1),
|
||||||
OPT__VERBOSE(&opts.verbose_update),
|
OPT__VERBOSE(&opts.verbose_update),
|
||||||
OPT_GROUP("Merging"),
|
OPT_GROUP("Merging"),
|
||||||
OPT_SET_INT('m', NULL, &opts.merge,
|
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);
|
die("failed to unpack tree object %s", arg);
|
||||||
stage++;
|
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)
|
if (1 < opts.index_only + opts.update)
|
||||||
die("-u and -i at the same time makes no sense");
|
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)
|
||||||
|
Loading…
Reference in New Issue
Block a user