@matheusbsbs / matheus-bagliano / commits / 9cba13ca5d
Fork 0

standardize brace placement in struct definitions

In a struct definitions, unlike functions, the prevailing style is for the opening brace to go on the same line as the struct name, like so: struct foo { int bar; char *baz; }; Indeed, grepping for 'struct [a-z_]* {$' yields about 5 times as many matches as 'struct [a-z_]*$'. Linus sayeth: Heretic people all over the world have claimed that this inconsistency is ... well ... inconsistent, but all right-thinking people know that (a) K&R are _right_ and (b) K&R are right. Signed-off-by: Jonathan Nieder <jrnieder@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Jonathan Nieder committed Mar 16, 2011 at 02:08 UTC 9cba13ca5d233a4e1a7068f3f5ed5836a081dcc0
17 files changed +44 -88
builtin/add.c
+1 -2
@@ -21,8 +21,7 @@ static const char * const builtin_add_usage[] = {
21 static int patch_interactive, add_interactive, edit_interactive;
22 static int take_worktree_changes;
23
24 -struct update_callback_data
25 -{
24 +struct update_callback_data {
25 int flags;
26 int add_errors;
27 };
builtin/blame.c
+1 -2
@@ -1312,8 +1312,7 @@ static void pass_blame(struct scoreboard *sb, struct origin *origin, int opt)
1312 /*
1313 * Information on commits, used for output.
1314 */
1315 -struct commit_info
1316 -{
1315 +struct commit_info {
1316 const char *author;
1317 const char *author_mail;
1318 unsigned long author_time;
builtin/grep.c
+1 -2
@@ -40,8 +40,7 @@ enum work_type {WORK_SHA1, WORK_FILE};
40 * threads. The producer adds struct work_items to 'todo' and the
41 * consumers pick work items from the same array.
42 */
43 -struct work_item
44 -{
43 +struct work_item {
44 enum work_type type;
45 char *name;
46
builtin/index-pack.c
+2 -4
@@ -13,8 +13,7 @@
13 static const char index_pack_usage[] =
14 "git index-pack [-v] [-o <index-file>] [ --keep | --keep=<msg> ] [--strict] (<pack-file> | --stdin [--fix-thin] [<pack-file>])";
15
16 -struct object_entry
17 -{
16 +struct object_entry {
17 struct pack_idx_entry idx;
18 unsigned long size;
19 unsigned int hdr_size;
@@ -44,8 +43,7 @@ struct base_data {
43 #define FLAG_LINK (1u<<20)
44 #define FLAG_CHECKED (1u<<21)
45
47 -struct delta_entry
48 -{
46 +struct delta_entry {
47 union delta_base base;
48 int obj_no;
49 };
commit.h
+1 -2
@@ -68,8 +68,7 @@ enum cmit_fmt {
68 CMIT_FMT_UNSPECIFIED
69 };
70
71 -struct pretty_print_context
72 -{
71 +struct pretty_print_context {
72 int abbrev;
73 const char *subject;
74 const char *after_subject;
config.c
+1 -2
@@ -20,8 +20,7 @@ static int zlib_compression_seen;
20
21 const char *config_exclusive_filename = NULL;
22
23 -struct config_item
24 -{
23 +struct config_item {
24 struct config_item *next;
25 char *name;
26 char *value;
diff.c
+2 -4
@@ -606,16 +606,14 @@ static void diff_words_append(char *line, unsigned long len,
606 buffer->text.ptr[buffer->text.size] = '\0';
607 }
608
609 -struct diff_words_style_elem
610 -{
609 +struct diff_words_style_elem {
610 const char *prefix;
611 const char *suffix;
612 const char *color; /* NULL; filled in by the setup code if
613 * color is enabled */
614 };
615
617 -struct diff_words_style
618 -{
616 +struct diff_words_style {
617 enum diff_words_type type;
618 struct diff_words_style_elem new, old, ctx;
619 const char *newline;
fast-import.c
+14 -28
@@ -166,8 +166,7 @@ Format of STDIN stream:
166 #define DEPTH_BITS 13
167 #define MAX_DEPTH ((1<<DEPTH_BITS)-1)
168
169 -struct object_entry
170 -{
169 +struct object_entry {
170 struct pack_idx_entry idx;
171 struct object_entry *next;
172 uint32_t type : TYPE_BITS,
@@ -175,16 +174,14 @@ struct object_entry
174 depth : DEPTH_BITS;
175 };
176
178 -struct object_entry_pool
179 -{
177 +struct object_entry_pool {
178 struct object_entry_pool *next_pool;
179 struct object_entry *next_free;
180 struct object_entry *end;
181 struct object_entry entries[FLEX_ARRAY]; /* more */
182 };
183
186 -struct mark_set
187 -{
184 +struct mark_set {
185 union {
186 struct object_entry *marked[1024];
187 struct mark_set *sets[1024];
@@ -192,57 +189,49 @@ struct mark_set
189 unsigned int shift;
190 };
191
195 -struct last_object
196 -{
192 +struct last_object {
193 struct strbuf data;
194 off_t offset;
195 unsigned int depth;
196 unsigned no_swap : 1;
197 };
198
203 -struct mem_pool
204 -{
199 +struct mem_pool {
200 struct mem_pool *next_pool;
201 char *next_free;
202 char *end;
203 uintmax_t space[FLEX_ARRAY]; /* more */
204 };
205
211 -struct atom_str
212 -{
206 +struct atom_str {
207 struct atom_str *next_atom;
208 unsigned short str_len;
209 char str_dat[FLEX_ARRAY]; /* more */
210 };
211
212 struct tree_content;
219 -struct tree_entry
220 -{
213 +struct tree_entry {
214 struct tree_content *tree;
215 struct atom_str *name;
223 - struct tree_entry_ms
224 - {
216 + struct tree_entry_ms {
217 uint16_t mode;
218 unsigned char sha1[20];
219 } versions[2];
220 };
221
230 -struct tree_content
231 -{
222 +struct tree_content {
223 unsigned int entry_capacity; /* must match avail_tree_content */
224 unsigned int entry_count;
225 unsigned int delta_depth;
226 struct tree_entry *entries[FLEX_ARRAY]; /* more */
227 };
228
238 -struct avail_tree_content
239 -{
229 +struct avail_tree_content {
230 unsigned int entry_capacity; /* must match tree_content */
231 struct avail_tree_content *next_avail;
232 };
233
244 -struct branch
245 -{
234 +struct branch {
235 struct branch *table_next_branch;
236 struct branch *active_next_branch;
237 const char *name;
@@ -254,16 +243,14 @@ struct branch
243 unsigned char sha1[20];
244 };
245
257 -struct tag
258 -{
246 +struct tag {
247 struct tag *next_tag;
248 const char *name;
249 unsigned int pack_id;
250 unsigned char sha1[20];
251 };
252
265 -struct hash_list
266 -{
253 +struct hash_list {
254 struct hash_list *next;
255 unsigned char sha1[20];
256 };
@@ -274,8 +261,7 @@ typedef enum {
261 WHENSPEC_NOW
262 } whenspec_type;
263
277 -struct recent_command
278 -{
264 +struct recent_command {
265 struct recent_command *prev;
266 struct recent_command *next;
267 char *buf;
fetch-pack.h
+1 -2
@@ -1,8 +1,7 @@
1 #ifndef FETCH_PACK_H
2 #define FETCH_PACK_H
3
4 -struct fetch_pack_args
5 -{
4 +struct fetch_pack_args {
5 const char *uploadpack;
6 int unpacklimit;
7 int depth;
generate-cmdlist.sh
+1 -2
@@ -1,8 +1,7 @@
1 #!/bin/sh
2
3 echo "/* Automatically generated by $0 */
4 -struct cmdname_help
5 -{
4 +struct cmdname_help {
5 char name[16];
6 char help[80];
7 };
http-push.c
+5 -10
@@ -82,8 +82,7 @@ static int helper_status;
82
83 static struct object_list *objects;
84
85 -struct repo
86 -{
85 +struct repo {
86 char *url;
87 char *path;
88 int path_len;
@@ -108,8 +107,7 @@ enum transfer_state {
107 COMPLETE
108 };
109
111 -struct transfer_request
112 -{
110 +struct transfer_request {
111 struct object *obj;
112 char *url;
113 char *dest;
@@ -127,8 +125,7 @@ struct transfer_request
125
126 static struct transfer_request *request_queue_head;
127
130 -struct xml_ctx
131 -{
128 +struct xml_ctx {
129 char *name;
130 int len;
131 char *cdata;
@@ -136,8 +133,7 @@ struct xml_ctx
133 void *userData;
134 };
135
139 -struct remote_lock
140 -{
136 +struct remote_lock {
137 char *url;
138 char *owner;
139 char *token;
@@ -156,8 +152,7 @@ struct remote_lock
152 /* Flags that remote_ls passes to callback functions */
153 #define IS_DIR (1u << 0)
154
159 -struct remote_ls_ctx
160 -{
155 +struct remote_ls_ctx {
156 char *path;
157 void (*userFunc)(struct remote_ls_ctx *ls);
158 void *userData;
http-walker.c
+2 -4
@@ -3,8 +3,7 @@
3 #include "walker.h"
4 #include "http.h"
5
6 -struct alt_base
7 -{
6 +struct alt_base {
7 char *base;
8 int got_indices;
9 struct packed_git *packs;
@@ -18,8 +17,7 @@ enum object_request_state {
17 COMPLETE
18 };
19
21 -struct object_request
22 -{
20 +struct object_request {
21 struct walker *walker;
22 unsigned char sha1[20];
23 struct alt_base *repo;
http.h
+5 -10
@@ -42,14 +42,12 @@
42 #define NO_CURL_IOCTL
43 #endif
44
45 -struct slot_results
46 -{
45 +struct slot_results {
46 CURLcode curl_result;
47 long http_code;
48 };
49
51 -struct active_request_slot
52 -{
50 +struct active_request_slot {
51 CURL *curl;
52 FILE *local;
53 int in_use;
@@ -62,8 +60,7 @@ struct active_request_slot
60 struct active_request_slot *next;
61 };
62
65 -struct buffer
66 -{
63 +struct buffer {
64 struct strbuf buf;
65 size_t posn;
66 };
@@ -149,8 +146,7 @@ extern int http_fetch_ref(const char *base, struct ref *ref);
146 extern int http_get_info_packs(const char *base_url,
147 struct packed_git **packs_head);
148
152 -struct http_pack_request
153 -{
149 +struct http_pack_request {
150 char *url;
151 struct packed_git *target;
152 struct packed_git **lst;
@@ -166,8 +162,7 @@ extern int finish_http_pack_request(struct http_pack_request *preq);
162 extern void release_http_pack_request(struct http_pack_request *preq);
163
164 /* Helpers for fetching object */
169 -struct http_object_request
170 -{
165 +struct http_object_request {
166 char *url;
167 char tmpfile[PATH_MAX];
168 int localfile;
merge-recursive.c
+4 -8
@@ -83,10 +83,8 @@ struct rename_df_conflict_info {
83 * Since we want to write the index eventually, we cannot reuse the index
84 * for these (temporary) data.
85 */
86 -struct stage_data
87 -{
88 - struct
89 - {
86 +struct stage_data {
87 + struct {
88 unsigned mode;
89 unsigned char sha[20];
90 } stages[4];
@@ -403,8 +401,7 @@ static void make_room_for_directories_of_df_conflicts(struct merge_options *o,
401 }
402 }
403
406 -struct rename
407 -{
404 +struct rename {
405 struct diff_filepair *pair;
406 struct stage_data *src_entry;
407 struct stage_data *dst_entry;
@@ -717,8 +714,7 @@ static void update_file(struct merge_options *o,
714
715 /* Low level file merging, update and removal */
716
720 -struct merge_file_info
721 -{
717 +struct merge_file_info {
718 unsigned char sha[20];
719 unsigned mode;
720 unsigned clean:1,
pack-check.c
+1 -2
@@ -2,8 +2,7 @@
2 #include "pack.h"
3 #include "pack-revindex.h"
4
5 -struct idx_entry
6 -{
5 +struct idx_entry {
6 off_t offset;
7 const unsigned char *sha1;
8 unsigned int nr;
string-list.h
+1 -2
@@ -5,8 +5,7 @@ struct string_list_item {
5 char *string;
6 void *util;
7 };
8 -struct string_list
9 -{
8 +struct string_list {
9 struct string_list_item *items;
10 unsigned int nr, alloc;
11 unsigned int strdup_strings:1;
transport-helper.c
+1 -2
@@ -12,8 +12,7 @@
12
13 static int debug;
14
15 -struct helper_data
16 -{
15 +struct helper_data {
16 const char *name;
17 struct child_process *helper;
18 FILE *out;