Skip to content

Commit f286e0a

Browse files
committed
Merge branch 'kl/cat-file-on-sparse-index'
"git cat-file" works well with the sparse-index, and gets marked as such. * kl/cat-file-on-sparse-index: builtin/cat-file: mark 'git cat-file' sparse-index compatible t1092: allow run_on_* functions to use standard input
2 parents b64f249 + e65b0c7 commit f286e0a

File tree

2 files changed

+48
-5
lines changed

2 files changed

+48
-5
lines changed

builtin/cat-file.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1047,6 +1047,9 @@ int cmd_cat_file(int argc, const char **argv, const char *prefix)
10471047
if (batch.buffer_output < 0)
10481048
batch.buffer_output = batch.all_objects;
10491049

1050+
prepare_repo_settings(the_repository);
1051+
the_repository->settings.command_requires_full_index = 0;
1052+
10501053
/* Return early if we're in batch mode? */
10511054
if (batch.enabled) {
10521055
if (opt_cw)

t/t1092-sparse-checkout-compatibility.sh

Lines changed: 45 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -179,22 +179,26 @@ init_repos_as_submodules () {
179179
}
180180

181181
run_on_sparse () {
182+
cat >run-on-sparse-input &&
183+
182184
(
183185
cd sparse-checkout &&
184186
GIT_PROGRESS_DELAY=100000 "$@" >../sparse-checkout-out 2>../sparse-checkout-err
185-
) &&
187+
) <run-on-sparse-input &&
186188
(
187189
cd sparse-index &&
188190
GIT_PROGRESS_DELAY=100000 "$@" >../sparse-index-out 2>../sparse-index-err
189-
)
191+
) <run-on-sparse-input
190192
}
191193

192194
run_on_all () {
195+
cat >run-on-all-input &&
196+
193197
(
194198
cd full-checkout &&
195199
GIT_PROGRESS_DELAY=100000 "$@" >../full-checkout-out 2>../full-checkout-err
196-
) &&
197-
run_on_sparse "$@"
200+
) <run-on-all-input &&
201+
run_on_sparse "$@" <run-on-all-input
198202
}
199203

200204
test_all_match () {
@@ -221,7 +225,7 @@ test_sparse_unstaged () {
221225
done
222226
}
223227

224-
# Usage: test_sprase_checkout_set "<c1> ... <cN>" "<s1> ... <sM>"
228+
# Usage: test_sparse_checkout_set "<c1> ... <cN>" "<s1> ... <sM>"
225229
# Verifies that "git sparse-checkout set <c1> ... <cN>" succeeds and
226230
# leaves the sparse index in a state where <s1> ... <sM> are sparse
227231
# directories (and <c1> ... <cN> are not).
@@ -2354,4 +2358,40 @@ test_expect_success 'advice.sparseIndexExpanded' '
23542358
grep "The sparse index is expanding to a full index" err
23552359
'
23562360

2361+
test_expect_success 'cat-file -p' '
2362+
init_repos &&
2363+
echo "new content" >>full-checkout/deep/a &&
2364+
echo "new content" >>sparse-checkout/deep/a &&
2365+
echo "new content" >>sparse-index/deep/a &&
2366+
run_on_all git add deep/a &&
2367+
2368+
test_all_match git cat-file -p :deep/a &&
2369+
ensure_not_expanded cat-file -p :deep/a &&
2370+
test_all_match git cat-file -p :folder1/a &&
2371+
ensure_expanded cat-file -p :folder1/a
2372+
'
2373+
2374+
test_expect_success 'cat-file --batch' '
2375+
init_repos &&
2376+
echo "new content" >>full-checkout/deep/a &&
2377+
echo "new content" >>sparse-checkout/deep/a &&
2378+
echo "new content" >>sparse-index/deep/a &&
2379+
run_on_all git add deep/a &&
2380+
2381+
echo ":deep/a" >in &&
2382+
test_all_match git cat-file --batch <in &&
2383+
ensure_not_expanded cat-file --batch <in &&
2384+
2385+
echo ":folder1/a" >in &&
2386+
test_all_match git cat-file --batch <in &&
2387+
ensure_expanded cat-file --batch <in &&
2388+
2389+
cat >in <<-\EOF &&
2390+
:deep/a
2391+
:folder1/a
2392+
EOF
2393+
test_all_match git cat-file --batch <in &&
2394+
ensure_expanded cat-file --batch <in
2395+
'
2396+
23572397
test_done

0 commit comments

Comments
 (0)