Commit 313908f9f5322f623ef1924f859726b39cb9740c

Etienne Samson 2019-11-06T11:08:49

examples: normalize decls and usage of options structs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
diff --git a/examples/add.c b/examples/add.c
index b835172..6e3c239 100644
--- a/examples/add.c
+++ b/examples/add.c
@@ -40,7 +40,7 @@ struct index_options {
 };
 
 /* Forward declarations for helpers */
-static void parse_opts(const char **repo_path, struct index_options *options, struct args_info *args);
+static void parse_opts(const char **repo_path, struct index_options *opts, struct args_info *args);
 int print_matched_cb(const char *path, const char *matched_pathspec, void *payload);
 
 int lg2_add(git_repository *repo, int argc, char **argv)
@@ -86,13 +86,13 @@ int lg2_add(git_repository *repo, int argc, char **argv)
  */
 int print_matched_cb(const char *path, const char *matched_pathspec, void *payload)
 {
-	struct index_options options = *(struct index_options *)(payload);
+	struct index_options *opts = (struct index_options *)(payload);
 	int ret;
 	unsigned status;
 	(void)matched_pathspec;
 
 	/* Get the file status */
-	if (git_status_file(&status, options.repo, path) < 0)
+	if (git_status_file(&status, opts->repo, path) < 0)
 		return -1;
 
 	if ((status & GIT_STATUS_WT_MODIFIED) || (status & GIT_STATUS_WT_NEW)) {
@@ -102,7 +102,7 @@ int print_matched_cb(const char *path, const char *matched_pathspec, void *paylo
 		ret = 1;
 	}
 
-	if (options.dry_run)
+	if (opts->dry_run)
 		ret = 1;
 
 	return ret;
@@ -132,7 +132,7 @@ void print_usage(void)
 	exit(1);
 }
 
-static void parse_opts(const char **repo_path, struct index_options *options, struct args_info *args)
+static void parse_opts(const char **repo_path, struct index_options *opts, struct args_info *args)
 {
 	if (args->argc <= 1)
 		print_usage();
@@ -142,9 +142,9 @@ static void parse_opts(const char **repo_path, struct index_options *options, st
 
 		if (curr[0] != '-') {
 			if (!strcmp("add", curr)) {
-				options->mode = INDEX_ADD;
+				opts->mode = INDEX_ADD;
 				continue;
-			} else if (options->mode == INDEX_NONE) {
+			} else if (opts->mode == INDEX_NONE) {
 				fprintf(stderr, "missing command: %s", curr);
 				print_usage();
 				break;
@@ -152,10 +152,10 @@ static void parse_opts(const char **repo_path, struct index_options *options, st
 				/* We might be looking at a filename */
 				break;
 			}
-		} else if (match_bool_arg(&options->verbose, args, "--verbose") ||
-				   match_bool_arg(&options->dry_run, args, "--dry-run") ||
+		} else if (match_bool_arg(&opts->verbose, args, "--verbose") ||
+				   match_bool_arg(&opts->dry_run, args, "--dry-run") ||
 				   match_str_arg(repo_path, args, "--git-dir") ||
-				   (options->mode == INDEX_ADD && match_bool_arg(&options->add_update, args, "--update"))) {
+				   (opts->mode == INDEX_ADD && match_bool_arg(&opts->add_update, args, "--update"))) {
 			continue;
 		} else if (match_bool_arg(NULL, args, "--help")) {
 			print_usage();
diff --git a/examples/blame.c b/examples/blame.c
index 76f5ed2..1b78d1c 100644
--- a/examples/blame.c
+++ b/examples/blame.c
@@ -19,7 +19,7 @@
  * simulate the output of `git blame` and a few of its command line arguments.
  */
 
-struct opts {
+struct blame_opts {
 	char *path;
 	char *commitspec;
 	int C;
@@ -28,14 +28,14 @@ struct opts {
 	int end_line;
 	int F;
 };
-static void parse_opts(struct opts *o, int argc, char *argv[]);
+static void parse_opts(struct blame_opts *o, int argc, char *argv[]);
 
 int lg2_blame(git_repository *repo, int argc, char *argv[])
 {
 	int line, break_on_null_hunk;
 	git_off_t i, rawsize;
 	char spec[1024] = {0};
-	struct opts o = {0};
+	struct blame_opts o = {0};
 	const char *rawdata;
 	git_revspec revspec = {0};
 	git_blame_options blameopts = GIT_BLAME_OPTIONS_INIT;
@@ -143,7 +143,7 @@ static void usage(const char *msg, const char *arg)
 }
 
 /** Parse the arguments. */
-static void parse_opts(struct opts *o, int argc, char *argv[])
+static void parse_opts(struct blame_opts *o, int argc, char *argv[])
 {
 	int i;
 	char *bare_args[3] = {0};
diff --git a/examples/cat-file.c b/examples/cat-file.c
index 9b14a70..b81e9a8 100644
--- a/examples/cat-file.c
+++ b/examples/cat-file.c
@@ -102,27 +102,28 @@ static void show_tag(const git_tag *tag)
 		printf("\n%s\n", git_tag_message(tag));
 }
 
-enum {
+typedef enum {
 	SHOW_TYPE = 1,
 	SHOW_SIZE = 2,
 	SHOW_NONE = 3,
 	SHOW_PRETTY = 4
-};
+} catfile_mode;
 
 /* Forward declarations for option-parsing helper */
-struct opts {
+struct catfile_options {
 	const char *dir;
 	const char *rev;
-	int action;
+	catfile_mode action;
 	int verbose;
 };
-static void parse_opts(struct opts *o, int argc, char *argv[]);
+
+static void parse_opts(struct catfile_options *o, int argc, char *argv[]);
 
 
 /** Entry point for this command */
 int lg2_cat_file(git_repository *repo, int argc, char *argv[])
 {
-	struct opts o = { ".", NULL, 0, 0 };
+	struct catfile_options o = { ".", NULL, 0, 0 };
 	git_object *obj = NULL;
 	char oidstr[GIT_OID_HEXSZ + 1];
 
@@ -201,7 +202,7 @@ static void usage(const char *message, const char *arg)
 }
 
 /** Parse the command-line options taken from git */
-static void parse_opts(struct opts *o, int argc, char *argv[])
+static void parse_opts(struct catfile_options *o, int argc, char *argv[])
 {
 	struct args_info args = ARGS_INFO_INIT;
 
diff --git a/examples/describe.c b/examples/describe.c
index 181e499..1236272 100644
--- a/examples/describe.c
+++ b/examples/describe.c
@@ -37,16 +37,14 @@
  */
 
 /** describe_options represents the parsed command line options */
-typedef struct {
+struct describe_options {
 	const char **commits;
 	size_t commit_count;
 	git_describe_options describe_options;
 	git_describe_format_options format_options;
-} describe_options;
+};
 
-typedef struct args_info args_info;
-
-static void opts_add_commit(describe_options *opts, const char *commit)
+static void opts_add_commit(struct describe_options *opts, const char *commit)
 {
 	size_t sz;
 
@@ -57,7 +55,7 @@ static void opts_add_commit(describe_options *opts, const char *commit)
 	opts->commits[opts->commit_count - 1] = commit;
 }
 
-static void do_describe_single(git_repository *repo, describe_options *opts, const char *rev)
+static void do_describe_single(git_repository *repo, struct describe_options *opts, const char *rev)
 {
 	git_object *commit;
 	git_describe_result *describe_result;
@@ -80,7 +78,7 @@ static void do_describe_single(git_repository *repo, describe_options *opts, con
 	printf("%s\n", buf.ptr);
 }
 
-static void do_describe(git_repository *repo, describe_options *opts)
+static void do_describe(git_repository *repo, struct describe_options *opts)
 {
 	if (opts->commit_count == 0)
 		do_describe_single(repo, opts, NULL);
@@ -99,9 +97,9 @@ static void print_usage(void)
 }
 
 /** Parse command line arguments */
-static void parse_options(describe_options *opts, int argc, char **argv)
+static void parse_options(struct describe_options *opts, int argc, char **argv)
 {
-	args_info args = ARGS_INFO_INIT;
+	struct args_info args = ARGS_INFO_INIT;
 
 	for (args.pos = 1; args.pos < argc; ++args.pos) {
 		const char *curr = argv[args.pos];
@@ -141,7 +139,7 @@ static void parse_options(describe_options *opts, int argc, char **argv)
 }
 
 /** Initialize describe_options struct */
-static void describe_options_init(describe_options *opts)
+static void describe_options_init(struct describe_options *opts)
 {
 	memset(opts, 0, sizeof(*opts));
 
@@ -153,7 +151,7 @@ static void describe_options_init(describe_options *opts)
 
 int lg2_describe(git_repository *repo, int argc, char **argv)
 {
-	describe_options opts;
+	struct describe_options opts;
 
 	describe_options_init(&opts);
 	parse_options(&opts, argc, argv);
diff --git a/examples/diff.c b/examples/diff.c
index 9e2aa9c..2305c86 100644
--- a/examples/diff.c
+++ b/examples/diff.c
@@ -47,8 +47,8 @@ enum {
 	CACHE_NONE = 2
 };
 
-/** The 'opts' struct captures all the various parsed command line options. */
-struct opts {
+/** The 'diff_options' struct captures all the various parsed command line options. */
+struct diff_options {
 	git_diff_options diffopts;
 	git_diff_find_options findopts;
 	int color;
@@ -63,18 +63,17 @@ struct opts {
 
 /** These functions are implemented at the end */
 static void usage(const char *message, const char *arg);
-static void parse_opts(struct opts *o, int argc, char *argv[]);
+static void parse_opts(struct diff_options *o, int argc, char *argv[]);
 static int color_printer(
 	const git_diff_delta*, const git_diff_hunk*, const git_diff_line*, void*);
-static void diff_print_stats(git_diff *diff, struct opts *o);
-static void compute_diff_no_index(git_diff **diff, struct opts *o);
+static void diff_print_stats(git_diff *diff, struct diff_options *o);
+static void compute_diff_no_index(git_diff **diff, struct diff_options *o);
 
 int lg2_diff(git_repository *repo, int argc, char *argv[])
 {
 	git_tree *t1 = NULL, *t2 = NULL;
 	git_diff *diff;
-
-	struct opts o = {
+	struct diff_options o = {
 		GIT_DIFF_OPTIONS_INIT, GIT_DIFF_FIND_OPTIONS_INIT,
 		-1, -1, 0, 0, GIT_DIFF_FORMAT_PATCH, NULL, NULL, "."
 	};
@@ -166,7 +165,7 @@ int lg2_diff(git_repository *repo, int argc, char *argv[])
 	return 0;
 }
 
-static void compute_diff_no_index(git_diff **diff, struct opts *o) {
+static void compute_diff_no_index(git_diff **diff, struct diff_options *o) {
 	git_patch *patch = NULL;
 	char *file1_str = NULL;
 	char *file2_str = NULL;
@@ -242,11 +241,10 @@ static int color_printer(
 }
 
 /** Parse arguments as copied from git-diff. */
-static void parse_opts(struct opts *o, int argc, char *argv[])
+static void parse_opts(struct diff_options *o, int argc, char *argv[])
 {
 	struct args_info args = ARGS_INFO_INIT;
 
-
 	for (args.pos = 1; args.pos < argc; ++args.pos) {
 		const char *a = argv[args.pos];
 
@@ -343,7 +341,7 @@ static void parse_opts(struct opts *o, int argc, char *argv[])
 }
 
 /** Display diff output with "--stat", "--numstat", or "--shortstat" */
-static void diff_print_stats(git_diff *diff, struct opts *o)
+static void diff_print_stats(git_diff *diff, struct diff_options *o)
 {
 	git_diff_stats *stats;
 	git_buf b = GIT_BUF_INIT_CONST(NULL, 0);
diff --git a/examples/init.c b/examples/init.c
index e9841bc..2f681c5 100644
--- a/examples/init.c
+++ b/examples/init.c
@@ -27,7 +27,7 @@
  */
 
 /** Forward declarations of helpers */
-struct opts {
+struct init_opts {
 	int no_options;
 	int quiet;
 	int bare;
@@ -38,11 +38,11 @@ struct opts {
 	const char *dir;
 };
 static void create_initial_commit(git_repository *repo);
-static void parse_opts(struct opts *o, int argc, char *argv[]);
+static void parse_opts(struct init_opts *o, int argc, char *argv[]);
 
 int lg2_init(git_repository *repo, int argc, char *argv[])
 {
-	struct opts o = { 1, 0, 0, 0, GIT_REPOSITORY_INIT_SHARED_UMASK, 0, 0, 0 };
+	struct init_opts o = { 1, 0, 0, 0, GIT_REPOSITORY_INIT_SHARED_UMASK, 0, 0, 0 };
 
 	parse_opts(&o, argc, argv);
 
@@ -210,7 +210,7 @@ static uint32_t parse_shared(const char *shared)
 	return 0;
 }
 
-static void parse_opts(struct opts *o, int argc, char *argv[])
+static void parse_opts(struct init_opts *o, int argc, char *argv[])
 {
 	struct args_info args = ARGS_INFO_INIT;
 	const char *sharedarg;
diff --git a/examples/ls-files.c b/examples/ls-files.c
index b82af01..a235069 100644
--- a/examples/ls-files.c
+++ b/examples/ls-files.c
@@ -25,11 +25,11 @@
  * This currently supports the default behavior and the `--error-unmatch` option.
  */
 
-typedef struct {
+struct ls_options {
 	int error_unmatch;
 	char *files[1024];
 	size_t file_count;
-} ls_options;
+};
 
 static void usage(const char *message, const char *arg)
 {
@@ -41,12 +41,12 @@ static void usage(const char *message, const char *arg)
 	exit(1);
 }
 
-static int parse_options(ls_options *opts, int argc, char *argv[])
+static int parse_options(struct ls_options *opts, int argc, char *argv[])
 {
 	int parsing_files = 0;
 	int i;
 
-	memset(opts, 0, sizeof(ls_options));
+	memset(opts, 0, sizeof(struct ls_options));
 
 	if (argc < 2)
 		return 0;
@@ -78,7 +78,7 @@ static int parse_options(ls_options *opts, int argc, char *argv[])
 	return 0;
 }
 
-static int print_paths(ls_options *opts, git_index *index)
+static int print_paths(struct ls_options *opts, git_index *index)
 {
 	size_t i;
 	const git_index_entry *entry;
@@ -113,7 +113,7 @@ static int print_paths(ls_options *opts, git_index *index)
 int lg2_ls_files(git_repository *repo, int argc, char *argv[])
 {
 	git_index *index = NULL;
-	ls_options opts;
+	struct ls_options opts;
 	int error;
 
 	if ((error = parse_options(&opts, argc, argv)) < 0)
diff --git a/examples/merge.c b/examples/merge.c
index 0cdeeea..460c06a 100644
--- a/examples/merge.c
+++ b/examples/merge.c
@@ -23,7 +23,7 @@
  *
  */
 
-typedef struct {
+struct merge_options {
 	const char **heads;
 	size_t heads_count;
 
@@ -31,7 +31,7 @@ typedef struct {
 	size_t annotated_count;
 
 	int no_commit : 1;
-} merge_options;
+};
 
 static void print_usage(void)
 {
@@ -39,7 +39,7 @@ static void print_usage(void)
 	exit(1);
 }
 
-static void merge_options_init(merge_options *opts)
+static void merge_options_init(struct merge_options *opts)
 {
 	memset(opts, 0, sizeof(*opts));
 
@@ -49,7 +49,7 @@ static void merge_options_init(merge_options *opts)
 	opts->annotated_count = 0;
 }
 
-static void opts_add_refish(merge_options *opts, const char *refish)
+static void opts_add_refish(struct merge_options *opts, const char *refish)
 {
 	size_t sz;
 
@@ -60,7 +60,7 @@ static void opts_add_refish(merge_options *opts, const char *refish)
 	opts->heads[opts->heads_count - 1] = refish;
 }
 
-static void parse_options(const char **repo_path, merge_options *opts, int argc, char **argv)
+static void parse_options(const char **repo_path, struct merge_options *opts, int argc, char **argv)
 {
 	struct args_info args = ARGS_INFO_INIT;
 
@@ -82,7 +82,7 @@ static void parse_options(const char **repo_path, merge_options *opts, int argc,
 	}
 }
 
-static int resolve_heads(git_repository *repo, merge_options *opts)
+static int resolve_heads(git_repository *repo, struct merge_options *opts)
 {
 	git_annotated_commit **annotated = calloc(opts->heads_count, sizeof(git_annotated_commit *));
 	size_t annotated_count = 0, i;
@@ -200,7 +200,7 @@ static void output_conflicts(git_index *index)
 	git_index_conflict_iterator_free(conflicts);
 }
 
-static int create_merge_commit(git_repository *repo, git_index *index, merge_options *opts)
+static int create_merge_commit(git_repository *repo, git_index *index, struct merge_options *opts)
 {
 	git_oid tree_oid, commit_oid;
 	git_tree *tree;
@@ -276,7 +276,7 @@ cleanup:
 
 int lg2_merge(git_repository *repo, int argc, char **argv)
 {
-	merge_options opts;
+	struct merge_options opts;
 	git_index *index;
 	git_repository_state_t state;
 	git_merge_analysis_t analysis;
diff --git a/examples/remote.c b/examples/remote.c
index 7345f82..34d8865 100644
--- a/examples/remote.c
+++ b/examples/remote.c
@@ -30,7 +30,7 @@ enum subcmd {
 	subcmd_show,
 };
 
-struct opts {
+struct remote_opts {
 	enum subcmd cmd;
 
 	/* for command-specific args */
@@ -38,20 +38,20 @@ struct opts {
 	char **argv;
 };
 
-static int cmd_add(git_repository *repo, struct opts *o);
-static int cmd_remove(git_repository *repo, struct opts *o);
-static int cmd_rename(git_repository *repo, struct opts *o);
-static int cmd_seturl(git_repository *repo, struct opts *o);
-static int cmd_show(git_repository *repo, struct opts *o);
+static int cmd_add(git_repository *repo, struct remote_opts *o);
+static int cmd_remove(git_repository *repo, struct remote_opts *o);
+static int cmd_rename(git_repository *repo, struct remote_opts *o);
+static int cmd_seturl(git_repository *repo, struct remote_opts *o);
+static int cmd_show(git_repository *repo, struct remote_opts *o);
 
 static void parse_subcmd(
-	struct opts *opt, int argc, char **argv);
+	struct remote_opts *opt, int argc, char **argv);
 static void usage(const char *msg, const char *arg);
 
 int lg2_remote(git_repository *repo, int argc, char *argv[])
 {
 	int retval = 0;
-	struct opts opt = {0};
+	struct remote_opts opt = {0};
 
 	parse_subcmd(&opt, argc, argv);
 
@@ -77,7 +77,7 @@ int lg2_remote(git_repository *repo, int argc, char *argv[])
 	return retval;
 }
 
-static int cmd_add(git_repository *repo, struct opts *o)
+static int cmd_add(git_repository *repo, struct remote_opts *o)
 {
 	char *name, *url;
 	git_remote *remote = {0};
@@ -94,7 +94,7 @@ static int cmd_add(git_repository *repo, struct opts *o)
 	return 0;
 }
 
-static int cmd_remove(git_repository *repo, struct opts *o)
+static int cmd_remove(git_repository *repo, struct remote_opts *o)
 {
 	char *name;
 
@@ -109,7 +109,7 @@ static int cmd_remove(git_repository *repo, struct opts *o)
 	return 0;
 }
 
-static int cmd_rename(git_repository *repo, struct opts *o)
+static int cmd_rename(git_repository *repo, struct remote_opts *o)
 {
 	int i, retval;
 	char *old, *new;
@@ -134,7 +134,7 @@ static int cmd_rename(git_repository *repo, struct opts *o)
 	return retval;
 }
 
-static int cmd_seturl(git_repository *repo, struct opts *o)
+static int cmd_seturl(git_repository *repo, struct remote_opts *o)
 {
 	int i, retval, push = 0;
 	char *name = NULL, *url = NULL;
@@ -166,7 +166,7 @@ static int cmd_seturl(git_repository *repo, struct opts *o)
 	return 0;
 }
 
-static int cmd_show(git_repository *repo, struct opts *o)
+static int cmd_show(git_repository *repo, struct remote_opts *o)
 {
 	int i;
 	const char *arg, *name, *fetch, *push;
@@ -213,7 +213,7 @@ static int cmd_show(git_repository *repo, struct opts *o)
 }
 
 static void parse_subcmd(
-	struct opts *opt, int argc, char **argv)
+	struct remote_opts *opt, int argc, char **argv)
 {
 	char *arg = argv[1];
 	enum subcmd cmd = 0;
diff --git a/examples/show-index.c b/examples/show-index.c
index 34eb41c..7aaa45e 100644
--- a/examples/show-index.c
+++ b/examples/show-index.c
@@ -14,7 +14,7 @@
 
 #include "common.h"
 
-int lg2_show_index(git_repository *repo, int argc, char** argv)
+int lg2_show_index(git_repository *repo, int argc, char **argv)
 {
 	git_index *index;
 	size_t i, ecount;
diff --git a/examples/status.c b/examples/status.c
index 979ab7c..8cf9221 100644
--- a/examples/status.c
+++ b/examples/status.c
@@ -43,7 +43,7 @@ enum {
 
 #define MAX_PATHSPEC 8
 
-struct opts {
+struct status_opts {
 	git_status_options statusopt;
 	char *repodir;
 	char *pathspec[MAX_PATHSPEC];
@@ -55,7 +55,7 @@ struct opts {
 	int repeat;
 };
 
-static void parse_opts(struct opts *o, int argc, char *argv[]);
+static void parse_opts(struct status_opts *o, int argc, char *argv[]);
 static void show_branch(git_repository *repo, int format);
 static void print_long(git_status_list *status);
 static void print_short(git_repository *repo, git_status_list *status);
@@ -64,7 +64,7 @@ static int print_submod(git_submodule *sm, const char *name, void *payload);
 int lg2_status(git_repository *repo, int argc, char *argv[])
 {
 	git_status_list *status;
-	struct opts o = { GIT_STATUS_OPTIONS_INIT, "." };
+	struct status_opts o = { GIT_STATUS_OPTIONS_INIT, "." };
 
 	o.statusopt.show  = GIT_STATUS_SHOW_INDEX_AND_WORKDIR;
 	o.statusopt.flags = GIT_STATUS_OPT_INCLUDE_UNTRACKED |
@@ -435,7 +435,7 @@ static int print_submod(git_submodule *sm, const char *name, void *payload)
 /**
  * Parse options that git's status command supports.
  */
-static void parse_opts(struct opts *o, int argc, char *argv[])
+static void parse_opts(struct status_opts *o, int argc, char *argv[])
 {
 	struct args_info args = ARGS_INFO_INIT;
 
diff --git a/examples/tag.c b/examples/tag.c
index 7bfb92a..4408294 100644
--- a/examples/tag.c
+++ b/examples/tag.c
@@ -31,19 +31,19 @@
  */
 
 /** tag_options represents the parsed command line options */
-typedef struct {
+struct tag_options {
 	const char *message;
 	const char *pattern;
 	const char *tag_name;
 	const char *target;
 	int num_lines;
 	int force;
-} tag_options;
+};
 
 /** tag_state represents the current program state for dragging around */
 typedef struct {
 	git_repository *repo;
-	tag_options *opts;
+	struct tag_options *opts;
 } tag_state;
 
 /** An action to execute based on the command line arguments */
@@ -167,7 +167,7 @@ static void action_list_tags(tag_state *state)
 
 static void action_delete_tag(tag_state *state)
 {
-	tag_options *opts = state->opts;
+	struct tag_options *opts = state->opts;
 	git_object *obj;
 	git_buf abbrev_oid = {0};
 
@@ -191,7 +191,7 @@ static void action_delete_tag(tag_state *state)
 static void action_create_lighweight_tag(tag_state *state)
 {
 	git_repository *repo = state->repo;
-	tag_options *opts = state->opts;
+	struct tag_options *opts = state->opts;
 	git_oid oid;
 	git_object *target;
 
@@ -213,7 +213,7 @@ static void action_create_lighweight_tag(tag_state *state)
 static void action_create_tag(tag_state *state)
 {
 	git_repository *repo = state->repo;
-	tag_options *opts = state->opts;
+	struct tag_options *opts = state->opts;
 	git_signature *tagger;
 	git_oid oid;
 	git_object *target;
@@ -243,7 +243,7 @@ static void print_usage(void)
 }
 
 /** Parse command line arguments and choose action to run when done */
-static void parse_options(tag_action *action, tag_options *opts, int argc, char **argv)
+static void parse_options(tag_action *action, struct tag_options *opts, int argc, char **argv)
 {
 	args_info args = ARGS_INFO_INIT;
 	*action = &action_list_tags;
@@ -281,7 +281,7 @@ static void parse_options(tag_action *action, tag_options *opts, int argc, char 
 }
 
 /** Initialize tag_options struct */
-static void tag_options_init(tag_options *opts)
+static void tag_options_init(struct tag_options *opts)
 {
 	memset(opts, 0, sizeof(*opts));
 
@@ -295,7 +295,7 @@ static void tag_options_init(tag_options *opts)
 
 int lg2_tag(git_repository *repo, int argc, char **argv)
 {
-	tag_options opts;
+	struct tag_options opts;
 	tag_action action;
 	tag_state state;