1
+ #define USE_THE_REPOSITORY_VARIABLE
2
+
1
3
#include "builtin.h"
4
+ #include "environment.h"
5
+ #include "hash.h"
2
6
#include "json-writer.h"
3
7
#include "parse-options.h"
4
8
#include "quote.h"
@@ -10,17 +14,23 @@ enum output_format {
10
14
};
11
15
12
16
enum repo_info_category {
13
- CATEGORY_REFERENCES = 1 << 0
17
+ CATEGORY_REFERENCES = 1 << 0 ,
18
+ CATEGORY_LAYOUT = 1 << 1
14
19
};
15
20
16
21
enum repo_info_references_field {
17
22
FIELD_REFERENCES_FORMAT = 1 << 0
18
23
};
19
24
25
+ enum repo_info_layout_field {
26
+ FIELD_LAYOUT_BARE = 1 << 0
27
+ };
28
+
20
29
struct repo_info_field {
21
30
enum repo_info_category category ;
22
31
union {
23
32
enum repo_info_references_field references ;
33
+ enum repo_info_layout_field layout ;
24
34
} field ;
25
35
};
26
36
@@ -35,6 +45,10 @@ static struct repo_info_field default_fields[] = {
35
45
{
36
46
.category = CATEGORY_REFERENCES ,
37
47
.field .references = FIELD_REFERENCES_FORMAT
48
+ },
49
+ {
50
+ .category = CATEGORY_LAYOUT ,
51
+ .field .layout = FIELD_LAYOUT_BARE
38
52
}
39
53
};
40
54
@@ -74,6 +88,9 @@ static void repo_info_init(struct repo_info *repo_info,
74
88
if (!strcmp (arg , "references.format" )) {
75
89
field -> category = CATEGORY_REFERENCES ;
76
90
field -> field .references = FIELD_REFERENCES_FORMAT ;
91
+ } else if (!strcmp (arg , "layout.bare" )) {
92
+ field -> category = CATEGORY_LAYOUT ;
93
+ field -> field .layout = FIELD_LAYOUT_BARE ;
77
94
} else {
78
95
die ("invalid field '%s'" , arg );
79
96
}
@@ -101,6 +118,15 @@ static void repo_info_print_plaintext(struct repo_info *repo_info) {
101
118
break ;
102
119
}
103
120
break ;
121
+ case CATEGORY_LAYOUT :
122
+ switch (field -> field .layout ) {
123
+ case FIELD_LAYOUT_BARE :
124
+ print_key_value ("layout.bare" ,
125
+ is_bare_repository () ?
126
+ "true" : "false" );
127
+ break ;
128
+ }
129
+ break ;
104
130
}
105
131
}
106
132
}
@@ -111,6 +137,7 @@ static void repo_info_print_json(struct repo_info *repo_info)
111
137
int i ;
112
138
unsigned int categories = 0 ;
113
139
unsigned int references_fields = 0 ;
140
+ unsigned int layout_fields = 0 ;
114
141
struct repository * repo = repo_info -> repo ;
115
142
116
143
for (i = 0 ; i < repo_info -> n_fields ; i ++ ) {
@@ -120,6 +147,9 @@ static void repo_info_print_json(struct repo_info *repo_info)
120
147
case CATEGORY_REFERENCES :
121
148
references_fields |= field -> field .references ;
122
149
break ;
150
+ case CATEGORY_LAYOUT :
151
+ layout_fields |= field -> field .layout ;
152
+ break ;
123
153
}
124
154
}
125
155
@@ -136,6 +166,15 @@ static void repo_info_print_json(struct repo_info *repo_info)
136
166
}
137
167
jw_end (& jw );
138
168
}
169
+
170
+ if (categories & CATEGORY_LAYOUT ) {
171
+ jw_object_inline_begin_object (& jw , "layout" );
172
+ if (layout_fields & FIELD_LAYOUT_BARE ) {
173
+ jw_object_bool (& jw , "bare" ,
174
+ is_bare_repository ());
175
+ }
176
+ jw_end (& jw );
177
+ }
139
178
jw_end (& jw );
140
179
141
180
puts (jw .json .buf );
0 commit comments