Skip to content

Commit 4ee5d50

Browse files
newrengitster
authored andcommitted
sparse-checkout: use improved unpack_trees porcelain messages
setup_unpack_trees_porcelain() provides much improved error/warning messages; instead of a message that assumes that there is only one path with a given problem despite being used by code that intentionally is grouping and showing errors together, it uses a message designed to be used with groups of paths. For example, this transforms error: Entry ' folder1/a folder2/a ' not uptodate. Cannot update sparse checkout. into error: Cannot update sparse checkout: the following entries are not up to date: folder1/a folder2/a In the past the suboptimal messages were never actually triggered because we would error out if the working directory wasn't clean before we even called unpack_trees(). The previous commit changed that, though, so let's use the better error messages. Reviewed-by: Derrick Stolee <[email protected]> Signed-off-by: Elijah Newren <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent f56f31a commit 4ee5d50

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

builtin/sparse-checkout.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,9 @@ static int update_working_directory(struct pattern_list *pl)
112112

113113
repo_hold_locked_index(r, &lock_file, LOCK_DIE_ON_ERROR);
114114

115+
setup_unpack_trees_porcelain(&o, "sparse-checkout");
115116
result = update_sparsity(&o);
117+
clear_unpack_trees_porcelain(&o);
116118

117119
if (result == UPDATE_SPARSITY_WARNINGS)
118120
/*

t/t1091-sparse-checkout-builtin.sh

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -328,12 +328,10 @@ test_expect_success 'sparse-checkout (init|set|disable) warns with dirty status'
328328
echo dirty >dirty/folder1/a &&
329329
330330
git -C dirty sparse-checkout init 2>err &&
331-
test_i18ngrep "error" err &&
332-
test_i18ngrep "Cannot update sparse checkout" err &&
331+
test_i18ngrep "error.*Cannot update sparse checkout" err &&
333332
334333
git -C dirty sparse-checkout set /folder2/* /deep/deeper1/* 2>err &&
335-
test_i18ngrep "error" err &&
336-
test_i18ngrep "Cannot update sparse checkout" err &&
334+
test_i18ngrep "error.*Cannot update sparse checkout" err &&
337335
test_path_is_file dirty/folder1/a &&
338336
339337
git -C dirty sparse-checkout disable 2>err &&

0 commit comments

Comments
 (0)