@@ -191,8 +191,10 @@ static int add(int argc, const char **argv)
191191 url = argv [1 ];
192192
193193 remote = remote_get (name );
194- if (remote_is_configured (remote , 1 ))
195- die (_ ("remote %s already exists." ), name );
194+ if (remote_is_configured (remote , 1 )) {
195+ error (_ ("remote %s already exists." ), name );
196+ exit (3 );
197+ }
196198
197199 if (!valid_remote_name (name ))
198200 die (_ ("'%s' is not a valid remote name" ), name );
@@ -685,15 +687,19 @@ static int mv(int argc, const char **argv)
685687 rename .remote_branches = & remote_branches ;
686688
687689 oldremote = remote_get (rename .old_name );
688- if (!remote_is_configured (oldremote , 1 ))
689- die (_ ("No such remote: '%s'" ), rename .old_name );
690+ if (!remote_is_configured (oldremote , 1 )) {
691+ error (_ ("No such remote: '%s'" ), rename .old_name );
692+ exit (2 );
693+ }
690694
691695 if (!strcmp (rename .old_name , rename .new_name ) && oldremote -> origin != REMOTE_CONFIG )
692696 return migrate_file (oldremote );
693697
694698 newremote = remote_get (rename .new_name );
695- if (remote_is_configured (newremote , 1 ))
696- die (_ ("remote %s already exists." ), rename .new_name );
699+ if (remote_is_configured (newremote , 1 )) {
700+ error (_ ("remote %s already exists." ), rename .new_name );
701+ exit (3 );
702+ }
697703
698704 if (!valid_remote_name (rename .new_name ))
699705 die (_ ("'%s' is not a valid remote name" ), rename .new_name );
@@ -826,8 +832,10 @@ static int rm(int argc, const char **argv)
826832 usage_with_options (builtin_remote_rm_usage , options );
827833
828834 remote = remote_get (argv [1 ]);
829- if (!remote_is_configured (remote , 1 ))
830- die (_ ("No such remote: '%s'" ), argv [1 ]);
835+ if (!remote_is_configured (remote , 1 )) {
836+ error (_ ("No such remote: '%s'" ), argv [1 ]);
837+ exit (2 );
838+ }
831839
832840 known_remotes .to_delete = remote ;
833841 for_each_remote (add_known_remote , & known_remotes );
@@ -1508,8 +1516,10 @@ static int set_remote_branches(const char *remotename, const char **branches,
15081516 strbuf_addf (& key , "remote.%s.fetch" , remotename );
15091517
15101518 remote = remote_get (remotename );
1511- if (!remote_is_configured (remote , 1 ))
1512- die (_ ("No such remote '%s'" ), remotename );
1519+ if (!remote_is_configured (remote , 1 )) {
1520+ error (_ ("No such remote '%s'" ), remotename );
1521+ exit (2 );
1522+ }
15131523
15141524 if (!add_mode && remove_all_fetch_refspecs (key .buf )) {
15151525 strbuf_release (& key );
@@ -1562,8 +1572,10 @@ static int get_url(int argc, const char **argv)
15621572 remotename = argv [0 ];
15631573
15641574 remote = remote_get (remotename );
1565- if (!remote_is_configured (remote , 1 ))
1566- die (_ ("No such remote '%s'" ), remotename );
1575+ if (!remote_is_configured (remote , 1 )) {
1576+ error (_ ("No such remote '%s'" ), remotename );
1577+ exit (2 );
1578+ }
15671579
15681580 url_nr = 0 ;
15691581 if (push_mode ) {
@@ -1630,8 +1642,10 @@ static int set_url(int argc, const char **argv)
16301642 oldurl = newurl ;
16311643
16321644 remote = remote_get (remotename );
1633- if (!remote_is_configured (remote , 1 ))
1634- die (_ ("No such remote '%s'" ), remotename );
1645+ if (!remote_is_configured (remote , 1 )) {
1646+ error (_ ("No such remote '%s'" ), remotename );
1647+ exit (2 );
1648+ }
16351649
16361650 if (push_mode ) {
16371651 strbuf_addf (& name_buf , "remote.%s.pushurl" , remotename );
0 commit comments