15
15
#include "worktree.h"
16
16
#include "quote.h"
17
17
18
- static const char * const worktree_usage [] = {
19
- N_ ("git worktree add [<options>] <path> [<commit-ish>]" ),
20
- N_ ("git worktree list [<options>]" ),
21
- N_ ("git worktree lock [<options>] <path>" ),
22
- N_ ("git worktree move <worktree> <new-path>" ),
23
- N_ ("git worktree prune [<options>]" ),
24
- N_ ("git worktree remove [<options>] <worktree>" ),
25
- N_ ("git worktree repair [<path>...]" ),
26
- N_ ("git worktree unlock <worktree>" ),
18
+ #define BUILTIN_WORKTREE_ADD_USAGE \
19
+ N_("git worktree add [<options>] <path> [<commit-ish>]")
20
+ #define BUILTIN_WORKTREE_LIST_USAGE \
21
+ N_("git worktree list [<options>]")
22
+ #define BUILTIN_WORKTREE_LOCK_USAGE \
23
+ N_("git worktree lock [<options>] <path>")
24
+ #define BUILTIN_WORKTREE_MOVE_USAGE \
25
+ N_("git worktree move <worktree> <new-path>")
26
+ #define BUILTIN_WORKTREE_PRUNE_USAGE \
27
+ N_("git worktree prune [<options>]")
28
+ #define BUILTIN_WORKTREE_REMOVE_USAGE \
29
+ N_("git worktree remove [<options>] <worktree>")
30
+ #define BUILTIN_WORKTREE_REPAIR_USAGE \
31
+ N_("git worktree repair [<path>...]")
32
+ #define BUILTIN_WORKTREE_UNLOCK_USAGE \
33
+ N_("git worktree unlock <worktree>")
34
+
35
+ static const char * const git_worktree_usage [] = {
36
+ BUILTIN_WORKTREE_ADD_USAGE ,
37
+ BUILTIN_WORKTREE_LIST_USAGE ,
38
+ BUILTIN_WORKTREE_LOCK_USAGE ,
39
+ BUILTIN_WORKTREE_MOVE_USAGE ,
40
+ BUILTIN_WORKTREE_PRUNE_USAGE ,
41
+ BUILTIN_WORKTREE_REMOVE_USAGE ,
42
+ BUILTIN_WORKTREE_REPAIR_USAGE ,
43
+ BUILTIN_WORKTREE_UNLOCK_USAGE ,
44
+ NULL
45
+ };
46
+
47
+ static const char * const git_worktree_add_usage [] = {
48
+ BUILTIN_WORKTREE_ADD_USAGE ,
49
+ NULL ,
50
+ };
51
+
52
+ static const char * const git_worktree_list_usage [] = {
53
+ BUILTIN_WORKTREE_LIST_USAGE ,
54
+ NULL
55
+ };
56
+
57
+ static const char * const git_worktree_lock_usage [] = {
58
+ BUILTIN_WORKTREE_LOCK_USAGE ,
59
+ NULL
60
+ };
61
+
62
+ static const char * const git_worktree_move_usage [] = {
63
+ BUILTIN_WORKTREE_MOVE_USAGE ,
64
+ NULL
65
+ };
66
+
67
+ static const char * const git_worktree_prune_usage [] = {
68
+ BUILTIN_WORKTREE_PRUNE_USAGE ,
69
+ NULL
70
+ };
71
+
72
+ static const char * const git_worktree_remove_usage [] = {
73
+ BUILTIN_WORKTREE_REMOVE_USAGE ,
74
+ NULL
75
+ };
76
+
77
+ static const char * const git_worktree_repair_usage [] = {
78
+ BUILTIN_WORKTREE_REPAIR_USAGE ,
79
+ NULL
80
+ };
81
+
82
+ static const char * const git_worktree_unlock_usage [] = {
83
+ BUILTIN_WORKTREE_UNLOCK_USAGE ,
27
84
NULL
28
85
};
29
86
@@ -153,9 +210,10 @@ static int prune(int ac, const char **av, const char *prefix)
153
210
};
154
211
155
212
expire = TIME_MAX ;
156
- ac = parse_options (ac , av , prefix , options , worktree_usage , 0 );
213
+ ac = parse_options (ac , av , prefix , options , git_worktree_prune_usage ,
214
+ 0 );
157
215
if (ac )
158
- usage_with_options (worktree_usage , options );
216
+ usage_with_options (git_worktree_prune_usage , options );
159
217
prune_worktrees ();
160
218
return 0 ;
161
219
}
@@ -573,7 +631,7 @@ static int add(int ac, const char **av, const char *prefix)
573
631
574
632
memset (& opts , 0 , sizeof (opts ));
575
633
opts .checkout = 1 ;
576
- ac = parse_options (ac , av , prefix , options , worktree_usage , 0 );
634
+ ac = parse_options (ac , av , prefix , options , git_worktree_add_usage , 0 );
577
635
if (!!opts .detach + !!new_branch + !!new_branch_force > 1 )
578
636
die (_ ("options '%s', '%s', and '%s' cannot be used together" ), "-b" , "-B" , "--detach" );
579
637
if (lock_reason && !keep_locked )
@@ -584,7 +642,7 @@ static int add(int ac, const char **av, const char *prefix)
584
642
opts .keep_locked = _ ("added with --lock" );
585
643
586
644
if (ac < 1 || ac > 2 )
587
- usage_with_options (worktree_usage , options );
645
+ usage_with_options (git_worktree_add_usage , options );
588
646
589
647
path = prefix_filename (prefix , av [0 ]);
590
648
branch = ac < 2 ? "HEAD" : av [1 ];
@@ -772,9 +830,9 @@ static int list(int ac, const char **av, const char *prefix)
772
830
};
773
831
774
832
expire = TIME_MAX ;
775
- ac = parse_options (ac , av , prefix , options , worktree_usage , 0 );
833
+ ac = parse_options (ac , av , prefix , options , git_worktree_list_usage , 0 );
776
834
if (ac )
777
- usage_with_options (worktree_usage , options );
835
+ usage_with_options (git_worktree_list_usage , options );
778
836
else if (verbose && porcelain )
779
837
die (_ ("options '%s' and '%s' cannot be used together" ), "--verbose" , "--porcelain" );
780
838
else if (!line_terminator && !porcelain )
@@ -811,9 +869,9 @@ static int lock_worktree(int ac, const char **av, const char *prefix)
811
869
};
812
870
struct worktree * * worktrees , * wt ;
813
871
814
- ac = parse_options (ac , av , prefix , options , worktree_usage , 0 );
872
+ ac = parse_options (ac , av , prefix , options , git_worktree_lock_usage , 0 );
815
873
if (ac != 1 )
816
- usage_with_options (worktree_usage , options );
874
+ usage_with_options (git_worktree_lock_usage , options );
817
875
818
876
worktrees = get_worktrees ();
819
877
wt = find_worktree (worktrees , prefix , av [0 ]);
@@ -844,9 +902,9 @@ static int unlock_worktree(int ac, const char **av, const char *prefix)
844
902
struct worktree * * worktrees , * wt ;
845
903
int ret ;
846
904
847
- ac = parse_options (ac , av , prefix , options , worktree_usage , 0 );
905
+ ac = parse_options (ac , av , prefix , options , git_worktree_unlock_usage , 0 );
848
906
if (ac != 1 )
849
- usage_with_options (worktree_usage , options );
907
+ usage_with_options (git_worktree_unlock_usage , options );
850
908
851
909
worktrees = get_worktrees ();
852
910
wt = find_worktree (worktrees , prefix , av [0 ]);
@@ -914,9 +972,10 @@ static int move_worktree(int ac, const char **av, const char *prefix)
914
972
const char * reason = NULL ;
915
973
char * path ;
916
974
917
- ac = parse_options (ac , av , prefix , options , worktree_usage , 0 );
975
+ ac = parse_options (ac , av , prefix , options , git_worktree_move_usage ,
976
+ 0 );
918
977
if (ac != 2 )
919
- usage_with_options (worktree_usage , options );
978
+ usage_with_options (git_worktree_move_usage , options );
920
979
921
980
path = prefix_filename (prefix , av [1 ]);
922
981
strbuf_addstr (& dst , path );
@@ -1042,9 +1101,9 @@ static int remove_worktree(int ac, const char **av, const char *prefix)
1042
1101
const char * reason = NULL ;
1043
1102
int ret = 0 ;
1044
1103
1045
- ac = parse_options (ac , av , prefix , options , worktree_usage , 0 );
1104
+ ac = parse_options (ac , av , prefix , options , git_worktree_remove_usage , 0 );
1046
1105
if (ac != 1 )
1047
- usage_with_options (worktree_usage , options );
1106
+ usage_with_options (git_worktree_remove_usage , options );
1048
1107
1049
1108
worktrees = get_worktrees ();
1050
1109
wt = find_worktree (worktrees , prefix , av [0 ]);
@@ -1102,7 +1161,7 @@ static int repair(int ac, const char **av, const char *prefix)
1102
1161
};
1103
1162
int rc = 0 ;
1104
1163
1105
- ac = parse_options (ac , av , prefix , options , worktree_usage , 0 );
1164
+ ac = parse_options (ac , av , prefix , options , git_worktree_repair_usage , 0 );
1106
1165
p = ac > 0 ? av : self ;
1107
1166
for (; * p ; p ++ )
1108
1167
repair_worktree_at_path (* p , report_repair , & rc );
@@ -1130,6 +1189,6 @@ int cmd_worktree(int ac, const char **av, const char *prefix)
1130
1189
if (!prefix )
1131
1190
prefix = "" ;
1132
1191
1133
- ac = parse_options (ac , av , prefix , options , worktree_usage , 0 );
1192
+ ac = parse_options (ac , av , prefix , options , git_worktree_usage , 0 );
1134
1193
return fn (ac , av , prefix );
1135
1194
}
0 commit comments