@@ -12,13 +12,48 @@ static const char * const builtin_remote_usage[] = {
12
12
"git remote add [-t <branch>] [-m <master>] [-f] [--mirror] <name> <url>" ,
13
13
"git remote rename <old> <new>" ,
14
14
"git remote rm <name>" ,
15
- "git remote set-head <name> [ -a | -d | <branch>] " ,
16
- "git remote show [-n] <name>" ,
15
+ "git remote set-head <name> ( -a | -d | <branch>) " ,
16
+ "git remote [-v | --verbose] show [-n] <name>" ,
17
17
"git remote prune [-n | --dry-run] <name>" ,
18
18
"git remote [-v | --verbose] update [-p | --prune] [group]" ,
19
19
NULL
20
20
};
21
21
22
+ static const char * const builtin_remote_add_usage [] = {
23
+ "git remote add [<options>] <name> <url>" ,
24
+ NULL
25
+ };
26
+
27
+ static const char * const builtin_remote_rename_usage [] = {
28
+ "git remote rename <old> <new>" ,
29
+ NULL
30
+ };
31
+
32
+ static const char * const builtin_remote_rm_usage [] = {
33
+ "git remote rm <name>" ,
34
+ NULL
35
+ };
36
+
37
+ static const char * const builtin_remote_sethead_usage [] = {
38
+ "git remote set-head <name> (-a | -d | <branch>])" ,
39
+ NULL
40
+ };
41
+
42
+ static const char * const builtin_remote_show_usage [] = {
43
+ "git remote show [<options>] <name>" ,
44
+ NULL
45
+ };
46
+
47
+ static const char * const builtin_remote_prune_usage [] = {
48
+ "git remote prune [<options>] <name>" ,
49
+ NULL
50
+ };
51
+
52
+ static const char * const builtin_remote_update_usage [] = {
53
+ "git remote update [<options>] [<group> | <remote>]..." ,
54
+ NULL
55
+ };
56
+
22
57
#define GET_REF_STATES (1<<0)
23
58
#define GET_HEAD_NAMES (1<<1)
24
59
#define GET_PUSH_REF_STATES (1<<2)
@@ -70,7 +105,6 @@ static int add(int argc, const char **argv)
70
105
int i ;
71
106
72
107
struct option options [] = {
73
- OPT_GROUP ("add specific options" ),
74
108
OPT_BOOLEAN ('f' , "fetch" , & fetch , "fetch the remote branches" ),
75
109
OPT_CALLBACK ('t' , "track" , & track , "branch" ,
76
110
"branch(es) to track" , opt_parse_track ),
@@ -79,11 +113,11 @@ static int add(int argc, const char **argv)
79
113
OPT_END ()
80
114
};
81
115
82
- argc = parse_options (argc , argv , NULL , options , builtin_remote_usage ,
116
+ argc = parse_options (argc , argv , NULL , options , builtin_remote_add_usage ,
83
117
0 );
84
118
85
119
if (argc < 2 )
86
- usage_with_options (builtin_remote_usage , options );
120
+ usage_with_options (builtin_remote_add_usage , options );
87
121
88
122
name = argv [0 ];
89
123
url = argv [1 ];
@@ -540,7 +574,7 @@ static int mv(int argc, const char **argv)
540
574
int i ;
541
575
542
576
if (argc != 3 )
543
- usage_with_options (builtin_remote_usage , options );
577
+ usage_with_options (builtin_remote_rename_usage , options );
544
578
545
579
rename .old = argv [1 ];
546
580
rename .new = argv [2 ];
@@ -681,7 +715,7 @@ static int rm(int argc, const char **argv)
681
715
int i , result ;
682
716
683
717
if (argc != 2 )
684
- usage_with_options (builtin_remote_usage , options );
718
+ usage_with_options (builtin_remote_rm_usage , options );
685
719
686
720
remote = remote_get (argv [1 ]);
687
721
if (!remote )
@@ -976,15 +1010,14 @@ static int show(int argc, const char **argv)
976
1010
{
977
1011
int no_query = 0 , result = 0 , query_flag = 0 ;
978
1012
struct option options [] = {
979
- OPT_GROUP ("show specific options" ),
980
1013
OPT_BOOLEAN ('n' , NULL , & no_query , "do not query remotes" ),
981
1014
OPT_END ()
982
1015
};
983
1016
struct ref_states states ;
984
1017
struct string_list info_list = { NULL , 0 , 0 , 0 };
985
1018
struct show_info info ;
986
1019
987
- argc = parse_options (argc , argv , NULL , options , builtin_remote_usage ,
1020
+ argc = parse_options (argc , argv , NULL , options , builtin_remote_show_usage ,
988
1021
0 );
989
1022
990
1023
if (argc < 1 )
@@ -1081,14 +1114,13 @@ static int set_head(int argc, const char **argv)
1081
1114
char * head_name = NULL ;
1082
1115
1083
1116
struct option options [] = {
1084
- OPT_GROUP ("set-head specific options" ),
1085
1117
OPT_BOOLEAN ('a' , "auto" , & opt_a ,
1086
1118
"set refs/remotes/<name>/HEAD according to remote" ),
1087
1119
OPT_BOOLEAN ('d' , "delete" , & opt_d ,
1088
1120
"delete refs/remotes/<name>/HEAD" ),
1089
1121
OPT_END ()
1090
1122
};
1091
- argc = parse_options (argc , argv , NULL , options , builtin_remote_usage ,
1123
+ argc = parse_options (argc , argv , NULL , options , builtin_remote_sethead_usage ,
1092
1124
0 );
1093
1125
if (argc )
1094
1126
strbuf_addf (& buf , "refs/remotes/%s/HEAD" , argv [0 ]);
@@ -1114,7 +1146,7 @@ static int set_head(int argc, const char **argv)
1114
1146
if (delete_ref (buf .buf , NULL , REF_NODEREF ))
1115
1147
result |= error ("Could not delete %s" , buf .buf );
1116
1148
} else
1117
- usage_with_options (builtin_remote_usage , options );
1149
+ usage_with_options (builtin_remote_sethead_usage , options );
1118
1150
1119
1151
if (head_name ) {
1120
1152
unsigned char sha1 [20 ];
@@ -1138,16 +1170,15 @@ static int prune(int argc, const char **argv)
1138
1170
{
1139
1171
int dry_run = 0 , result = 0 ;
1140
1172
struct option options [] = {
1141
- OPT_GROUP ("prune specific options" ),
1142
1173
OPT__DRY_RUN (& dry_run ),
1143
1174
OPT_END ()
1144
1175
};
1145
1176
1146
- argc = parse_options (argc , argv , NULL , options , builtin_remote_usage ,
1177
+ argc = parse_options (argc , argv , NULL , options , builtin_remote_prune_usage ,
1147
1178
0 );
1148
1179
1149
1180
if (argc < 1 )
1150
- usage_with_options (builtin_remote_usage , options );
1181
+ usage_with_options (builtin_remote_prune_usage , options );
1151
1182
1152
1183
for (; argc ; argc -- , argv ++ )
1153
1184
result |= prune_remote (* argv , dry_run );
@@ -1228,13 +1259,12 @@ static int update(int argc, const char **argv)
1228
1259
struct string_list list = { NULL , 0 , 0 , 0 };
1229
1260
static const char * default_argv [] = { NULL , "default" , NULL };
1230
1261
struct option options [] = {
1231
- OPT_GROUP ("update specific options" ),
1232
1262
OPT_BOOLEAN ('p' , "prune" , & prune ,
1233
1263
"prune remotes after fetching" ),
1234
1264
OPT_END ()
1235
1265
};
1236
1266
1237
- argc = parse_options (argc , argv , NULL , options , builtin_remote_usage ,
1267
+ argc = parse_options (argc , argv , NULL , options , builtin_remote_update_usage ,
1238
1268
PARSE_OPT_KEEP_ARGV0 );
1239
1269
if (argc < 2 ) {
1240
1270
argc = 2 ;
@@ -1334,7 +1364,7 @@ static int show_all(void)
1334
1364
int cmd_remote (int argc , const char * * argv , const char * prefix )
1335
1365
{
1336
1366
struct option options [] = {
1337
- OPT__VERBOSE ( & verbose ),
1367
+ OPT_BOOLEAN ( 'v' , "verbose" , & verbose , "be verbose; must be placed before a subcommand" ),
1338
1368
OPT_END ()
1339
1369
};
1340
1370
int result ;
0 commit comments