@@ -191,8 +191,10 @@ static int add(int argc, const char **argv)
191
191
url = argv [1 ];
192
192
193
193
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
+ }
196
198
197
199
if (!valid_remote_name (name ))
198
200
die (_ ("'%s' is not a valid remote name" ), name );
@@ -685,15 +687,19 @@ static int mv(int argc, const char **argv)
685
687
rename .remote_branches = & remote_branches ;
686
688
687
689
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
+ }
690
694
691
695
if (!strcmp (rename .old_name , rename .new_name ) && oldremote -> origin != REMOTE_CONFIG )
692
696
return migrate_file (oldremote );
693
697
694
698
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
+ }
697
703
698
704
if (!valid_remote_name (rename .new_name ))
699
705
die (_ ("'%s' is not a valid remote name" ), rename .new_name );
@@ -826,8 +832,10 @@ static int rm(int argc, const char **argv)
826
832
usage_with_options (builtin_remote_rm_usage , options );
827
833
828
834
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
+ }
831
839
832
840
known_remotes .to_delete = remote ;
833
841
for_each_remote (add_known_remote , & known_remotes );
@@ -1508,8 +1516,10 @@ static int set_remote_branches(const char *remotename, const char **branches,
1508
1516
strbuf_addf (& key , "remote.%s.fetch" , remotename );
1509
1517
1510
1518
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
+ }
1513
1523
1514
1524
if (!add_mode && remove_all_fetch_refspecs (key .buf )) {
1515
1525
strbuf_release (& key );
@@ -1562,8 +1572,10 @@ static int get_url(int argc, const char **argv)
1562
1572
remotename = argv [0 ];
1563
1573
1564
1574
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
+ }
1567
1579
1568
1580
url_nr = 0 ;
1569
1581
if (push_mode ) {
@@ -1630,8 +1642,10 @@ static int set_url(int argc, const char **argv)
1630
1642
oldurl = newurl ;
1631
1643
1632
1644
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
+ }
1635
1649
1636
1650
if (push_mode ) {
1637
1651
strbuf_addf (& name_buf , "remote.%s.pushurl" , remotename );
0 commit comments