Merge branch 'zh/cat-file-batch-fix' into zh/ref-filter-raw-data

* zh/cat-file-batch-fix:
  cat-file: merge two block into one
  cat-file: handle trivial --batch format with --batch-all-objects
This commit is contained in:
Junio C Hamano 2021-07-01 12:16:34 -07:00
Родитель 670b81a890 ee02ac6164
Коммит bff9703f0a
2 изменённых файлов: 26 добавлений и 6 удалений

Просмотреть файл

@ -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)
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.");

Просмотреть файл

@ -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