Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--builtin/cat-file.c25
-rwxr-xr-xt/t1006-cat-file.sh7
2 files changed, 13 insertions, 19 deletions
diff --git a/builtin/cat-file.c b/builtin/cat-file.c
index 6d0f645301..8735620813 100644
--- a/builtin/cat-file.c
+++ b/builtin/cat-file.c
@@ -674,6 +674,8 @@ int cmd_cat_file(int argc, const char **argv, const char *prefix)
N_("for blob objects, run textconv on object's content"), 'c'),
OPT_CMDMODE(0, "filters", &opt,
N_("for blob objects, run filters on object's content"), 'w'),
+ OPT_CMDMODE(0, "batch-all-objects", &opt,
+ N_("show all objects with --batch or --batch-check"), 'b'),
OPT_STRING(0, "path", &force_path, N_("blob"),
N_("use a specific path for --textconv/--filters")),
OPT_BOOL(0, "allow-unknown-type", &unknown_type,
@@ -689,8 +691,6 @@ int cmd_cat_file(int argc, const char **argv, const char *prefix)
batch_option_callback),
OPT_BOOL(0, "follow-symlinks", &batch.follow_symlinks,
N_("follow in-tree symlinks (used with --batch or --batch-check)")),
- OPT_BOOL(0, "batch-all-objects", &batch.all_objects,
- N_("show all objects with --batch or --batch-check")),
OPT_BOOL(0, "unordered", &batch.unordered,
N_("do not order --batch-all-objects output")),
OPT_END()
@@ -699,30 +699,27 @@ int cmd_cat_file(int argc, const char **argv, const char *prefix)
git_config(git_cat_file_config, NULL);
batch.buffer_output = -1;
- argc = parse_options(argc, argv, prefix, options, usage, 0);
- if (opt) {
+ argc = parse_options(argc, argv, prefix, options, usage, 0);
+ if (argc && batch.enabled)
+ usage_with_options(usage, options);
+ if (opt == 'b') {
+ batch.all_objects = 1;
+ } else if (opt) {
if (batch.enabled && (opt == 'c' || opt == 'w'))
batch.cmdmode = opt;
else if (argc == 1)
obj_name = argv[0];
else
usage_with_options(usage, options);
- }
- if (!opt && !batch.enabled) {
+ } else if (!opt && !batch.enabled) {
if (argc == 2) {
exp_type = argv[0];
obj_name = argv[1];
} else
usage_with_options(usage, options);
- }
- if (batch.enabled) {
- if (batch.cmdmode != opt || argc)
- usage_with_options(usage, options);
- if (batch.cmdmode && batch.all_objects)
- die("--batch-all-objects cannot be combined with "
- "--textconv nor with --filters");
- }
+ } else if (batch.enabled && batch.cmdmode != opt)
+ usage_with_options(usage, options);
if ((batch.follow_symlinks || batch.all_objects) && !batch.enabled) {
usage_with_options(usage, options);
diff --git a/t/t1006-cat-file.sh b/t/t1006-cat-file.sh
index fc9191c1b9..ebec2061d2 100755
--- a/t/t1006-cat-file.sh
+++ b/t/t1006-cat-file.sh
@@ -14,7 +14,8 @@ for switches in \
'-p -t' \
'-t -s' \
'-s --textconv' \
- '--textconv --filters'
+ '--textconv --filters' \
+ '--batch-all-objects -e'
do
test_expect_success "usage: cmdmode $switches" '
test_cmdmode_usage git cat-file $switches
@@ -41,10 +42,6 @@ do
test_expect_success "usage: $opt requires another option" '
test_expect_code 129 git cat-file $opt
'
-
- test_expect_failure "usage: incompatible options: --batch-all-objects with $opt" '
- test_incompatible_usage git cat-file --batch-all-objects $opt
- '
done
for opt in $short_modes