[v2,11/18] sparse-checkout: use improved unpack_trees porcelain messages
diff mbox series

Message ID 79b9cc1df55c7fab9b3c0e8dcc88ca19f23e771c.1584813609.git.gitgitgadget@gmail.com
State New
Headers show
Series
  • Sparse checkout improvements -- improved sparsity updating
Related show

Commit Message

SZEDER Gábor via GitGitGadget March 21, 2020, 6 p.m. UTC
From: Elijah Newren <newren@gmail.com>

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.

Signed-off-by: Elijah Newren <newren@gmail.com>
---
 builtin/sparse-checkout.c          | 2 ++
 t/t1091-sparse-checkout-builtin.sh | 9 +++------
 2 files changed, 5 insertions(+), 6 deletions(-)

Patch
diff mbox series

diff --git a/builtin/sparse-checkout.c b/builtin/sparse-checkout.c
index a55c60d7594..aa81199f85d 100644
--- a/builtin/sparse-checkout.c
+++ b/builtin/sparse-checkout.c
@@ -112,7 +112,9 @@  static int update_working_directory(struct pattern_list *pl)
 
 	repo_hold_locked_index(r, &lock_file, LOCK_DIE_ON_ERROR);
 
+	setup_unpack_trees_porcelain(&o, "sparse-checkout");
 	result = update_sparsity(&o);
+	clear_unpack_trees_porcelain(&o);
 
 	if (result == UPDATE_SPARSITY_WARNINGS)
 		/*
diff --git a/t/t1091-sparse-checkout-builtin.sh b/t/t1091-sparse-checkout-builtin.sh
index 86ae422ff5c..93c650ac038 100755
--- a/t/t1091-sparse-checkout-builtin.sh
+++ b/t/t1091-sparse-checkout-builtin.sh
@@ -328,16 +328,13 @@  test_expect_success 'sparse-checkout (init|set|disable) warns with dirty status'
 	echo dirty >dirty/folder1/a &&
 
 	git -C dirty sparse-checkout init 2>err &&
-	test_i18ngrep "error" err &&
-	test_i18ngrep "Cannot update sparse checkout" err &&
+	test_i18ngrep "error.*Cannot update sparse checkout" err &&
 
 	git -C dirty sparse-checkout set /folder2/* /deep/deeper1/* &&
-	test_i18ngrep "error" err &&
-	test_i18ngrep "Cannot update sparse checkout" err &&
+	test_i18ngrep "error.*Cannot update sparse checkout" err &&
 
 	git -C dirty sparse-checkout disable &&
-	test_i18ngrep "error" err &&
-	test_i18ngrep "Cannot update sparse checkout" err &&
+	test_i18ngrep "error.*Cannot update sparse checkout" err &&
 
 	git -C dirty reset --hard &&
 	git -C dirty sparse-checkout init &&