diff mbox series

[07/13] bisect--helper: pretend we're real bisect when report error

Message ID f212e6428855f0b0839bf6befd7c4703c505cc66.1667667460.git.congdanhqx@gmail.com (mailing list archive)
State Superseded
Headers show
Series Turn git-bisect to be builtin | expand

Commit Message

Đoàn Trần Công Danh Nov. 5, 2022, 5:07 p.m. UTC
In a later change, we will convert the bisect--helper to be builtin
bisect. Let's start by pretending it's the real bisect when reporting
error.

Signed-off-by: Đoàn Trần Công Danh <congdanhqx@gmail.com>
---
 builtin/bisect--helper.c | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

Comments

Ævar Arnfjörð Bjarmason Nov. 7, 2022, 9:29 p.m. UTC | #1
On Sun, Nov 06 2022, Đoàn Trần Công Danh wrote:

> In a later change, we will convert the bisect--helper to be builtin
> bisect. Let's start by pretending it's the real bisect when reporting
> error.

It's good to have this in here, FWIW I left this out of my version
reasoning that it was broken before, so we could leave it with the
psot-cleanups.

I'm fine with having it in while we're at it, but just FWIW:

I don't think we're "pretending". We *are* the bisect command, the fact
that we're implementing it via a "helper" is really quite irrelevant,
just like we're not "pretending" if we say we're "git bisect" instead of
"git-bisect.sh" or whatever.

The only cases where we should have these helpers report that they are
the helper is for messages that aren't user-visible, e.g. the "-h"
output emitted when you invoke a helper-specific command that no user
should be invoking (although arguably, we should just BUG() out
there...).
diff mbox series

Patch

diff --git a/builtin/bisect--helper.c b/builtin/bisect--helper.c
index b99cbb0dbe..6be4d8861e 100644
--- a/builtin/bisect--helper.c
+++ b/builtin/bisect--helper.c
@@ -1284,7 +1284,8 @@  static int bisect_run(struct bisect_terms *terms, const char **argv, int argc)
 static int cmd_bisect__reset(int argc, const char **argv, const char *prefix UNUSED)
 {
 	if (argc > 1)
-		return error(_("--bisect-reset requires either no argument or a commit"));
+		return error(_("'%s' requires either no argument or a commit"),
+			     "git bisect reset");
 	return bisect_reset(argc ? argv[0] : NULL);
 }
 
@@ -1294,7 +1295,8 @@  static int cmd_bisect__terms(int argc, const char **argv, const char *prefix UNU
 	struct bisect_terms terms = { .term_good = NULL, .term_bad = NULL };
 
 	if (argc > 1)
-		return error(_("--bisect-terms requires 0 or 1 argument"));
+		return error(_("'%s' requires 0 or 1 argument"),
+			     "git bisect terms");
 	res = bisect_terms(&terms, argc == 1 ? argv[0] : NULL);
 	free_terms(&terms);
 	return res;
@@ -1317,7 +1319,8 @@  static int cmd_bisect__next(int argc, const char **argv UNUSED, const char *pref
 	struct bisect_terms terms = { .term_good = NULL, .term_bad = NULL };
 
 	if (argc)
-		return error(_("--bisect-next requires 0 arguments"));
+		return error(_("'%s' requires 0 arguments"),
+			     "git bisect next");
 	get_terms(&terms);
 	res = bisect_next(&terms, prefix);
 	free_terms(&terms);
@@ -1339,7 +1342,7 @@  static int cmd_bisect__state(int argc, const char **argv, const char *prefix UNU
 static int cmd_bisect__log(int argc, const char **argv UNUSED, const char *prefix UNUSED)
 {
 	if (argc)
-		return error(_("--bisect-log requires 0 arguments"));
+		return error(_("'%s' requires 0 arguments"), "git bisect log");
 	return bisect_log();
 }
 
@@ -1385,7 +1388,7 @@  static int cmd_bisect__run(int argc, const char **argv, const char *prefix UNUSE
 	struct bisect_terms terms = { .term_good = NULL, .term_bad = NULL };
 
 	if (!argc)
-		return error(_("bisect run failed: no command provided."));
+		return error(_("'%s' failed: no command provided."), "git bisect run");
 	get_terms(&terms);
 	res = bisect_run(&terms, argv, argc);
 	free_terms(&terms);