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

[PATCH v3] sequencer: rectify empty hint in call of require_clean_work_tree()

From
Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
Date
Aug 9, 2023, 17:15 UTC
Message-ID
<20230809171531.2564829-1-oswald.buddenhagen@gmx.de>
In-Reply-To
<xmqqa5v2ehba.fsf@gitster.g>

The canonical way to represent "no error hint" is making it NULL, which shortcuts the error() call altogether. This fixes the output by removing the line which said just "error:", which would appear when starting a rebase whose initial checkout worked fine despite a dirty worktree. This was introduced by 97e1873 (rebase -i: rewrite complete_action() in C, 2018-08-28), which did a somewhat inaccurate conversion from shell.

To avoid that such bugs re-appear, test for the condition in require_clean_work_tree().

Signed-off-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
---
v3:
- added BUG()
- rewrote commit message again
v2:
- expanded commit message
Cc: Junio C Hamano <gitster@pobox.com>
---
 sequencer.c | 2 +-
 wt-status.c | 6 +++++-
 2 files changed, 6 insertions(+), 2 deletions(-)
diff --git a/sequencer.c b/sequencer.c
index cc9821ece2..d15a7409d8 100644
--- a/sequencer.c
+++ b/sequencer.c
@@ -6182,7 +6182,7 @@ int complete_action(struct repository *r, struct replay_opts *opts, unsigned fla
 	if (checkout_onto(r, opts, onto_name, &oid, orig_head))
 		goto cleanup;
 
-	if (require_clean_work_tree(r, "rebase", "", 1, 1))
+	if (require_clean_work_tree(r, "rebase", NULL, 1, 1))
 		goto cleanup;
 
 	todo_list_write_total_nr(&new_todo);
diff --git a/wt-status.c b/wt-status.c
index 8a1a4fb1f0..c8c1780566 100644
--- a/wt-status.c
+++ b/wt-status.c
@@ -2654,8 +2654,12 @@ int require_clean_work_tree(struct repository *r,
 	}
 
 	if (err) {
-		if (hint)
+		if (hint) {
+			if (!*hint)
+				BUG("empty hint passed to require_clean_work_tree();"
+				    " use NULL instead");
 			error("%s", hint);
+		}
 		if (!gently)
 			exit(128);
 	}
-- 
2.40.0.152.g15d061e6df
Previous: Junio C HamanoNext: Junio C Hamano
Message 9 of 15 in “sequencer: rectify empty hint in call of require_clean_work_tree()”
  1. sequencer: rectify empty hint in call of require_clean_work_tree()Oswald Buddenhagen, Mar 23, 2023
  2. Oswald BuddenhagenApr 27, 2023
  3. Junio C HamanoApr 27, 2023
  4. Oswald BuddenhagenApr 27, 2023
  5. Felipe ContrerasMay 2, 2023
  6. Oswald BuddenhagenMay 3, 2023
  7. sequencer: rectify empty hint in call of require_clean_work_tree()Oswald Buddenhagen, Aug 7, 2023
  8. Junio C HamanoAug 7, 2023
  9. sequencer: rectify empty hint in call of require_clean_work_tree()Oswald Buddenhagen, Aug 9, 2023
  10. Junio C HamanoAug 9, 2023
  11. Oswald BuddenhagenAug 10, 2023
  12. Junio C HamanoAug 10, 2023
  13. sequencer: rectify empty hint in call of require_clean_work_tree()Oswald Buddenhagen, Aug 24, 2023
  14. Junio C HamanoAug 24, 2023
  15. Junio C HamanoAug 9, 2023

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.