From: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
To: git@vger.kernel.org
Cc: Junio C Hamano <gitster@pobox.com>
Subject: [PATCH v4] sequencer: rectify empty hint in call of require_clean_work_tree()
Date: Thu, 24 Aug 2023 17:00:46 +0200 [thread overview]
Message-ID: <20230824150046.802008-1-oswald.buddenhagen@gmx.de> (raw)
In-Reply-To: <ZNTI6xpXIRaoFlxx@ugly>
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 the worktree
is dirtied while editing the initial rebase todo file. 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>
---
yeah, so i _did_ miss something.
v4:
- fixed reproduction instructions
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
next prev parent reply other threads:[~2023-08-24 15:01 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-23 16:22 [PATCH] sequencer: rectify empty hint in call of require_clean_work_tree() Oswald Buddenhagen
2023-04-27 7:58 ` Oswald Buddenhagen
2023-04-27 21:13 ` Junio C Hamano
2023-04-27 22:33 ` Oswald Buddenhagen
2023-05-02 18:57 ` Felipe Contreras
2023-05-03 7:15 ` Oswald Buddenhagen
2023-08-07 17:09 ` [PATCH v2] " Oswald Buddenhagen
2023-08-07 20:19 ` Junio C Hamano
2023-08-09 17:15 ` [PATCH v3] " Oswald Buddenhagen
2023-08-09 21:44 ` Junio C Hamano
2023-08-10 11:24 ` Oswald Buddenhagen
2023-08-10 16:04 ` Junio C Hamano
2023-08-24 15:00 ` Oswald Buddenhagen [this message]
2023-08-24 15:59 ` [PATCH v4] " Junio C Hamano
2023-08-09 1:24 ` [PATCH v2] " Junio C Hamano
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230824150046.802008-1-oswald.buddenhagen@gmx.de \
--to=oswald.buddenhagen@gmx.de \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).