Browse Source

Merge branch 'zh/cat-file-batch-fix'

"git cat-file --batch-all-objects"" misbehaved when "--batch" is in
use and did not ask for certain object traits.

* zh/cat-file-batch-fix:
  cat-file: merge two block into one
  cat-file: handle trivial --batch format with --batch-all-objects
maint
Junio C Hamano 4 years ago
parent
commit
5d96bcbc06
  1. 10
      builtin/cat-file.c
  2. 22
      t/t1006-cat-file.sh

10
builtin/cat-file.c

@ -512,12 +512,6 @@ static int batch_objects(struct batch_options *opt) @@ -512,12 +512,6 @@ static int batch_objects(struct batch_options *opt)
if (opt->cmdmode)
data.split_on_whitespace = 1;

if (opt->all_objects) {
struct object_info empty = OBJECT_INFO_INIT;
if (!memcmp(&data.info, &empty, sizeof(empty)))
data.skip_object_info = 1;
}

/*
* If we are printing out the object, then always fill in the type,
* since we will want to decide whether or not to stream.
@ -527,6 +521,10 @@ static int batch_objects(struct batch_options *opt) @@ -527,6 +521,10 @@ static int batch_objects(struct batch_options *opt)

if (opt->all_objects) {
struct object_cb_data cb;
struct object_info empty = OBJECT_INFO_INIT;

if (!memcmp(&data.info, &empty, sizeof(empty)))
data.skip_object_info = 1;

if (has_promisor_remote())
warning("This repository uses promisor remotes. Some objects may not be loaded.");

22
t/t1006-cat-file.sh

@ -586,4 +586,26 @@ test_expect_success 'cat-file --unordered works' ' @@ -586,4 +586,26 @@ test_expect_success 'cat-file --unordered works' '
test_cmp expect actual
'

test_expect_success 'set up object list for --batch-all-objects tests' '
git -C all-two cat-file --batch-all-objects --batch-check="%(objectname)" >objects
'

test_expect_success 'cat-file --batch="%(objectname)" with --batch-all-objects will work' '
git -C all-two cat-file --batch="%(objectname)" <objects >expect &&
git -C all-two cat-file --batch-all-objects --batch="%(objectname)" >actual &&
cmp expect actual
'

test_expect_success 'cat-file --batch="%(rest)" with --batch-all-objects will work' '
git -C all-two cat-file --batch="%(rest)" <objects >expect &&
git -C all-two cat-file --batch-all-objects --batch="%(rest)" >actual &&
cmp expect actual
'

test_expect_success 'cat-file --batch="batman" with --batch-all-objects will work' '
git -C all-two cat-file --batch="batman" <objects >expect &&
git -C all-two cat-file --batch-all-objects --batch="batman" >actual &&
cmp expect actual
'

test_done

Loading…
Cancel
Save