git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 3/5 v2] unpack_trees_options: update porcelain messages

From
DGDiane Gasselin <diane.gasselin@ensimag.imag.fr>
Date
Jun 15, 2010, 12:22 UTC
Message-ID
<1276604576-28092-4-git-send-email-diane.gasselin@ensimag.imag.fr>
In-Reply-To
<1276604576-28092-3-git-send-email-diane.gasselin@ensimag.imag.fr>

Update porcelain messages of unpack_trees_options in order to have a good layout and add an advice for would_lose_untracked errors if advice_commit_before_merge is enabled.

Update t3400 to have an expect_failure for the rebase verbose error message.
Signed-off-by: Diane Gasselin <diane.gasselin@ensimag.imag.fr>
Signed-off-by: Clément Poulain <clement.poulain@ensimag.imag.fr>
Signed-off-by: Axel Bonnet <axel.bonnet@ensimag.imag.fr>
---
 builtin/checkout.c |    2 +-
 merge-recursive.c  |   18 +++++++++---------
 t/t3400-rebase.sh  |    2 +-
 3 files changed, 11 insertions(+), 11 deletions(-)
diff --git a/builtin/checkout.c b/builtin/checkout.c
index 23eae56..b9d056d 100644
--- a/builtin/checkout.c
+++ b/builtin/checkout.c
@@ -373,7 +373,7 @@ static int merge_working_tree(struct checkout_opts *opts,
 		topts.dst_index = &the_index;
 
 		topts.msgs = get_porcelain_error_msgs("checkout");
-		topts.msgs.not_uptodate_file = "You have local changes to '%s'; cannot switch branches.";
+		topts.msgs.not_uptodate_file = "You have local changes to the following files:\n%sCannot switch branches.";
 
 		refresh_cache(REFRESH_QUIET);
 
diff --git a/merge-recursive.c b/merge-recursive.c
index 80c9744..ee80553 100644
--- a/merge-recursive.c
+++ b/merge-recursive.c
@@ -1183,31 +1183,31 @@ struct unpack_trees_error_msgs get_porcelain_error_msgs(const char *cmd)
 	struct unpack_trees_error_msgs msgs;
 
 	/* would_overwrite */
-	msgs.would_overwrite = malloc(sizeof(char) * 72);
+	msgs.would_overwrite = malloc(sizeof(char) * 80);
 	sprintf((char *)msgs.would_overwrite,
-		"Your local changes to '%%s' would be overwritten by %s.  Aborting.",
+		"Your local changes to the following files would be overwritten by %s:\n%%s",
 		cmd);
 	/* not_uptodate_file */
 	msgs.not_uptodate_file = msgs.would_overwrite;
 	/* not_uptodate_dir */
 	msgs.not_uptodate_dir =
-		"Updating '%s' would lose untracked files in it.  Aborting.";
+		"Updating the following directories would lose untracked files in it:\n%s";
 	/* would_lose_untracked */
-	msgs.would_lose_untracked = malloc(sizeof(char) * 72);
+	msgs.would_lose_untracked = malloc(sizeof(char) * 80);
 	sprintf((char *)msgs.would_lose_untracked,
-		"Untracked working tree file '%%s' would be %%s by %s.  Aborting.",
+		"The following untracked working tree files would be %%s by %s:\n%%s",
 		cmd);
 
 	if (advice_commit_before_merge) {
-		msgs.would_overwrite = malloc(sizeof(char) * 140);
+		msgs.would_overwrite = malloc(sizeof(char) * 160);
 		sprintf((char *)msgs.would_overwrite,
-			"Your local changes to '%%s' would be overwritten by %s.  Aborting.\n"
+			"Your local changes to the following files would be overwritten by %s:\n%%s"
 			"Please, commit your changes or stash them before you can %s.",
 			cmd, strcmp(cmd,"checkout") ? cmd : "swicth branches");
 		msgs.not_uptodate_file = msgs.would_overwrite;
-		msgs.would_lose_untracked = malloc (sizeof(char) * 135);
+		msgs.would_lose_untracked = malloc (sizeof(char) * 160);
 		sprintf((char *)msgs.would_lose_untracked,
-			"Untracked working tree file '%%s' would be %%s by %s.  Aborting.\n"
+			"The following untracked working tree files would be %%s by %s:\n%%s"
 			"Please move or remove them before you can %s.",
 			cmd, strcmp(cmd,"checkout") ? cmd : "swicth branches");
 	}
diff --git a/t/t3400-rebase.sh b/t/t3400-rebase.sh
index dbf7dfb..cbf160d 100755
--- a/t/t3400-rebase.sh
+++ b/t/t3400-rebase.sh
@@ -121,7 +121,7 @@ test_expect_success 'rebase a single mode change' '
      GIT_TRACE=1 git rebase master
 '
 
-test_expect_success 'Show verbose error when HEAD could not be detached' '
+test_expect_failure 'Show verbose error when HEAD could not be detached' '
      : > B &&
      test_must_fail git rebase topic 2> output.err > output.out &&
      grep "Untracked working tree file .B. would be overwritten" output.err
-- 
1.6.6.7.ga5fe3
Previous: Diane GasselinNext: Diane Gasselin
Message 4 of 13 in “unpack_trees: nicer error messages”
  1. 0/5 unpack_trees: nicer error messagesDiane Gasselin, Jun 15, 2010
  2. 1/5 merge-recursive: porcelain messages for checkoutDiane Gasselin, Jun 15, 2010
  3. 2/5 unpack_trees: group errors by typeDiane Gasselin, Jun 15, 2010
  4. 3/5 unpack_trees_options: update porcelain messagesDiane Gasselin, Jun 15, 2010
  5. 4/5 tests: update porcelain expected messageDiane Gasselin, Jun 15, 2010
  6. 5/5 t7609: test merge and checkout error messagesDiane Gasselin, Jun 15, 2010
  7. Matthieu MoyJun 15, 2010
  8. Matthieu MoyJun 15, 2010
  9. Matthieu MoyJun 15, 2010
  10. Diane GasselinJun 15, 2010
  11. Matthieu MoyJun 15, 2010
  12. Diane GasselinJun 15, 2010
  13. Matthieu MoyJun 15, 2010

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.