diff mbox series

[v2] builtin/remote: quote remote name on error to display empty name

Message ID 20180913131833.32722-1-m.shulhan@gmail.com (mailing list archive)
State New, archived
Headers show
Series [v2] builtin/remote: quote remote name on error to display empty name | expand

Commit Message

Shulhan Sept. 13, 2018, 1:18 p.m. UTC
When adding new remote name with empty string, git will print the
following error message,

  fatal: '' is not a valid remote name\n

But when removing remote name with empty string as input, git shows the
empty string without quote,

  fatal: No such remote: \n

To make these error messages consistent, quote the name of the remote
that we tried and failed to find.

Signed-off-by: Shulhan <m.shulhan@gmail.com>
Reviewed-by: Junio C Hamano <gitster@pobox.com>
---
 builtin/remote.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

Comments

Junio C Hamano Sept. 13, 2018, 9:51 p.m. UTC | #1
Shulhan <m.shulhan@gmail.com> writes:

> When adding new remote name with empty string, git will print the
> following error message,
>
>   fatal: '' is not a valid remote name\n
>
> But when removing remote name with empty string as input, git shows the
> empty string without quote,
>
>   fatal: No such remote: \n
>
> To make these error messages consistent, quote the name of the remote
> that we tried and failed to find.
>
> Signed-off-by: Shulhan <m.shulhan@gmail.com>
> Reviewed-by: Junio C Hamano <gitster@pobox.com>
> ---
>  builtin/remote.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)

Have you run "make test" with this change?  

I expect at least 5505.10 to fail without adjustment.
Junio C Hamano Sept. 13, 2018, 10:01 p.m. UTC | #2
Junio C Hamano <gitster@pobox.com> writes:

> Have you run "make test" with this change?  
>
> I expect at least 5505.10 to fail without adjustment.

For now, I'll queue this on top, and if this turns out to be
sufficient, I will squash it in.

 t/t5505-remote.sh | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/t/t5505-remote.sh b/t/t5505-remote.sh
index 241e6a319d..d2a2cdd453 100755
--- a/t/t5505-remote.sh
+++ b/t/t5505-remote.sh
@@ -145,7 +145,7 @@ test_expect_success 'remove remote protects local branches' '
 test_expect_success 'remove errors out early when deleting non-existent branch' '
 	(
 		cd test &&
-		echo "fatal: No such remote: foo" >expect &&
+		echo "fatal: No such remote: '\''foo'\''" >expect &&
 		test_must_fail git remote rm foo 2>actual &&
 		test_i18ncmp expect actual
 	)
@@ -173,7 +173,7 @@ test_expect_success 'remove remote with a branch without configured merge' '
 test_expect_success 'rename errors out early when deleting non-existent branch' '
 	(
 		cd test &&
-		echo "fatal: No such remote: foo" >expect &&
+		echo "fatal: No such remote: '\''foo'\''" >expect &&
 		test_must_fail git remote rename foo bar 2>actual &&
 		test_i18ncmp expect actual
 	)
Shulhan Sept. 14, 2018, 8:17 a.m. UTC | #3
On Thu, 13 Sep 2018 14:51:56 -0700
Junio C Hamano <gitster@pobox.com> wrote:

> Shulhan <m.shulhan@gmail.com> writes:
> 
> > When adding new remote name with empty string, git will print the
> > following error message,
> >
> >   fatal: '' is not a valid remote name\n
> >
> > But when removing remote name with empty string as input, git shows
> > the empty string without quote,
> >
> >   fatal: No such remote: \n
> >
> > To make these error messages consistent, quote the name of the
> > remote that we tried and failed to find.
> >
> > Signed-off-by: Shulhan <m.shulhan@gmail.com>
> > Reviewed-by: Junio C Hamano <gitster@pobox.com>
> > ---
> >  builtin/remote.c | 6 +++---
> >  1 file changed, 3 insertions(+), 3 deletions(-)  
> 
> Have you run "make test" with this change?  
> 
> I expect at least 5505.10 to fail without adjustment.

I am really sorry about that.  I am pretty sure, I run "make" to check
if source is run successfully before I know the patch was correct, as
the "t/README" said,

  Running Tests
  -------------

  The easiest way to run tests is to say "make".  This runs all
  the tests.

I will look into it later, if there is an error on test, I will send
another version of patch.
Junio C Hamano Sept. 14, 2018, 4:22 p.m. UTC | #4
Shulhan <m.shulhan@gmail.com> writes:

> if source is run successfully before I know the patch was correct, as
> the "t/README" said,
>
>   Running Tests
>   -------------
>
>   The easiest way to run tests is to say "make".  This runs all
>   the tests.

t/README says that it is sufficient to run "make" to perform tests,
but that implicitly assumes that the people who are reading it are
now in the t/ directory.

We probably want to clarify the language there, perhaps like so?

Thanks.

 t/README | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/t/README b/t/README
index 8373a27fea..f95624959f 100644
--- a/t/README
+++ b/t/README
@@ -14,8 +14,8 @@ describes how your test scripts should be organized.
 Running Tests
 -------------
 
-The easiest way to run tests is to say "make".  This runs all
-the tests.
+The easiest way to run tests is to say "make" in this directory (or
+"make test" from the top-level).  This runs all the tests.
 
     *** t0000-basic.sh ***
     ok 1 - .git/objects should be empty after git init in an empty repo.
diff mbox series

Patch

diff --git a/builtin/remote.c b/builtin/remote.c
index 40c6f8a1b..f7edf7f2c 100644
--- a/builtin/remote.c
+++ b/builtin/remote.c
@@ -626,7 +626,7 @@  static int mv(int argc, const char **argv)
 
 	oldremote = remote_get(rename.old_name);
 	if (!remote_is_configured(oldremote, 1))
-		die(_("No such remote: %s"), rename.old_name);
+		die(_("No such remote: '%s'"), rename.old_name);
 
 	if (!strcmp(rename.old_name, rename.new_name) && oldremote->origin != REMOTE_CONFIG)
 		return migrate_file(oldremote);
@@ -762,7 +762,7 @@  static int rm(int argc, const char **argv)
 
 	remote = remote_get(argv[1]);
 	if (!remote_is_configured(remote, 1))
-		die(_("No such remote: %s"), argv[1]);
+		die(_("No such remote: '%s'"), argv[1]);
 
 	known_remotes.to_delete = remote;
 	for_each_remote(add_known_remote, &known_remotes);
@@ -861,7 +861,7 @@  static int get_remote_ref_states(const char *name,
 
 	states->remote = remote_get(name);
 	if (!states->remote)
-		return error(_("No such remote: %s"), name);
+		return error(_("No such remote: '%s'"), name);
 
 	read_branches();