@matheusbsbs / matheus-bagliano / commits / 4ee5d50fc3
Fork 0

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 <dstolee@microsoft.com> Signed-off-by: Elijah Newren <newren@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Elijah Newren committed Mar 27, 2020 at 00:48 UTC 4ee5d50fc39f8d41f67c3c9a936084fb914c9a50
2 files changed +4 -4
builtin/sparse-checkout.c
+2
@@ -112,7 +112,9 @@ static int update_working_directory(struct pattern_list *pl)
112
113 repo_hold_locked_index(r, &lock_file, LOCK_DIE_ON_ERROR);
114
115 + setup_unpack_trees_porcelain(&o, "sparse-checkout");
116 result = update_sparsity(&o);
117 + clear_unpack_trees_porcelain(&o);
118
119 if (result == UPDATE_SPARSITY_WARNINGS)
120 /*
t/t1091-sparse-checkout-builtin.sh
+2 -4
@@ -328,12 +328,10 @@ test_expect_success 'sparse-checkout (init|set|disable) warns with dirty status'
328 echo dirty >dirty/folder1/a &&
329
330 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 &&
332
333 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 &&
335 test_path_is_file dirty/folder1/a &&
336
337 git -C dirty sparse-checkout disable 2>err &&