git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
To: git@vger.kernel.org
Cc: Junio C Hamano <gitster@pobox.com>
Subject: [PATCH v3] advice: handle "rebase" in error_resolve_conflict()
Date: Mon,  7 Aug 2023 19:09:35 +0200	[thread overview]
Message-ID: <20230807170935.2336715-1-oswald.buddenhagen@gmx.de> (raw)
In-Reply-To: <20230428125649.1719796-1-oswald.buddenhagen@gmx.de>

This makes sure that we get a properly translated message rather than
inserting the command (which we failed to translate) into a generic
fallback message.

The function is called indirectly via die_resolve_conflict() with fixed
strings, and directly with the string obtained via action_name(), which
in turn returns a string from a fixed set. Hence we know that the now
covered set of strings is exhausitive, and will therefore BUG() out when
encountering an unexpected string. We also know that all covered strings
are actually used.

Arguably, the above suggests that it would be cleaner to pass the
command as an enum in the first place, but that's left for another time.

Signed-off-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
---
v2:
- more verbose description

Cc: Junio C Hamano <gitster@pobox.com>
---
 advice.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/advice.c b/advice.c
index e5a9bb9b44..50c79443ba 100644
--- a/advice.c
+++ b/advice.c
@@ -191,9 +191,10 @@ int error_resolve_conflict(const char *me)
 		error(_("Pulling is not possible because you have unmerged files."));
 	else if (!strcmp(me, "revert"))
 		error(_("Reverting is not possible because you have unmerged files."));
+	else if (!strcmp(me, "rebase"))
+		error(_("Rebasing is not possible because you have unmerged files."));
 	else
-		error(_("It is not possible to %s because you have unmerged files."),
-			me);
+		BUG("Unhandled conflict reason '%s'", me);
 
 	if (advice_enabled(ADVICE_RESOLVE_CONFLICT))
 		/*
-- 
2.40.0.152.g15d061e6df


  parent reply	other threads:[~2023-08-07 17:09 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-23 16:22 [PATCH 1/3] Capitalization and punctuation fixes to some user visible messages Oswald Buddenhagen
2023-03-23 16:22 ` [PATCH 2/3] sequencer: actually translate report in do_exec() Oswald Buddenhagen
2023-03-23 20:43   ` Junio C Hamano
2023-03-23 21:20     ` Oswald Buddenhagen
2023-03-23 21:25       ` Junio C Hamano
2023-03-23 21:53         ` Oswald Buddenhagen
2023-03-23 16:22 ` [PATCH 3/3] advice: translate all actions in error_resolve_conflict() Oswald Buddenhagen
2023-03-24 14:44   ` Junio C Hamano
2023-03-23 20:39 ` [PATCH 1/3] Capitalization and punctuation fixes to some user visible messages Junio C Hamano
2023-03-23 21:10   ` Oswald Buddenhagen
2023-04-28 12:56 ` [PATCH v2 1/3] advice: handle "rebase" in error_resolve_conflict() Oswald Buddenhagen
2023-04-28 12:56   ` [PATCH v2 2/3] sequencer: actually translate report in do_exec() Oswald Buddenhagen
2023-04-28 19:02     ` Junio C Hamano
2023-04-28 12:56   ` [PATCH v2 3/3] Capitalization and punctuation fixes to some user visible messages Oswald Buddenhagen
2023-04-28 18:57     ` Junio C Hamano
2023-04-28 19:09       ` Junio C Hamano
2023-04-28 19:01   ` [PATCH v2 1/3] advice: handle "rebase" in error_resolve_conflict() Junio C Hamano
2023-04-29  7:18     ` Oswald Buddenhagen
2023-04-30  5:06       ` Junio C Hamano
2023-08-07 17:09   ` Oswald Buddenhagen [this message]
2023-08-07 20:20     ` [PATCH v3] " 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

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230807170935.2336715-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.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

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).