Skip to content

Commit 5025425

Browse files
shuLhangitster
authored andcommitted
builtin/remote: quote remote name on error to display empty name
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 1d4361b commit 5025425

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

builtin/remote.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -625,7 +625,7 @@ static int mv(int argc, const char **argv)
625625

626626
oldremote = remote_get(rename.old_name);
627627
if (!remote_is_configured(oldremote, 1))
628-
die(_("No such remote: %s"), rename.old_name);
628+
die(_("No such remote: '%s'"), rename.old_name);
629629

630630
if (!strcmp(rename.old_name, rename.new_name) && oldremote->origin != REMOTE_CONFIG)
631631
return migrate_file(oldremote);
@@ -761,7 +761,7 @@ static int rm(int argc, const char **argv)
761761

762762
remote = remote_get(argv[1]);
763763
if (!remote_is_configured(remote, 1))
764-
die(_("No such remote: %s"), argv[1]);
764+
die(_("No such remote: '%s'"), argv[1]);
765765

766766
known_remotes.to_delete = remote;
767767
for_each_remote(add_known_remote, &known_remotes);
@@ -860,7 +860,7 @@ static int get_remote_ref_states(const char *name,
860860

861861
states->remote = remote_get(name);
862862
if (!states->remote)
863-
return error(_("No such remote: %s"), name);
863+
return error(_("No such remote: '%s'"), name);
864864

865865
read_branches();
866866

t/t5505-remote.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ test_expect_success 'remove remote protects local branches' '
145145
test_expect_success 'remove errors out early when deleting non-existent branch' '
146146
(
147147
cd test &&
148-
echo "fatal: No such remote: foo" >expect &&
148+
echo "fatal: No such remote: '\''foo'\''" >expect &&
149149
test_must_fail git remote rm foo 2>actual &&
150150
test_i18ncmp expect actual
151151
)
@@ -173,7 +173,7 @@ test_expect_success 'remove remote with a branch without configured merge' '
173173
test_expect_success 'rename errors out early when deleting non-existent branch' '
174174
(
175175
cd test &&
176-
echo "fatal: No such remote: foo" >expect &&
176+
echo "fatal: No such remote: '\''foo'\''" >expect &&
177177
test_must_fail git remote rename foo bar 2>actual &&
178178
test_i18ncmp expect actual
179179
)

0 commit comments

Comments
 (0)