11/*
2+ * Copyright (C) the libgit2 contributors. All rights reserved.
3+ *
4+ * This file is part of libgit2, distributed under the GNU GPL v2 with
5+ * a Linking Exception. For full terms see the included COPYING file.
6+ */
7+
8+ #include "common.h"
9+
10+ /**
211 * This is a sample program that is similar to "git init". See the
312 * documentation for that (try "git help init") to understand what this
413 * program is emulating.
817 * This also contains a special additional option that regular "git init"
918 * does not support which is "--initial-commit" to make a first empty commit.
1019 * That is demonstrated in the "create_initial_commit" helper function.
11- *
12- * Copyright (C) the libgit2 contributors. All rights reserved.
13- *
14- * This file is part of libgit2, distributed under the GNU GPL v2 with
15- * a Linking Exception. For full terms see the included COPYING file.
1620 */
1721
18- #include "common.h"
19-
20- /* forward declarations of helpers */
22+ /** Forward declarations of helpers */
2123struct opts {
2224 int no_options ;
2325 int quiet ;
@@ -41,17 +43,19 @@ int main(int argc, char *argv[])
4143
4244 parse_opts (& o , argc , argv );
4345
44- /* Initialize repository */
46+ /* Initialize repository. */
4547
4648 if (o .no_options ) {
47- /* No options were specified, so let's demonstrate the default
49+ /**
50+ * No options were specified, so let's demonstrate the default
4851 * simple case of git_repository_init() API usage...
4952 */
5053 check_lg2 (git_repository_init (& repo , o .dir , 0 ),
5154 "Could not initialize repository" , NULL );
5255 }
5356 else {
54- /* Some command line options were specified, so we'll use the
57+ /**
58+ * Some command line options were specified, so we'll use the
5559 * extended init API to handle them
5660 */
5761 git_repository_init_options initopts = GIT_REPOSITORY_INIT_OPTIONS_INIT ;
@@ -66,7 +70,8 @@ int main(int argc, char *argv[])
6670 }
6771
6872 if (o .gitdir ) {
69- /* if you specified a separate git directory, then initialize
73+ /**
74+ * If you specified a separate git directory, then initialize
7075 * the repository at that path and use the second path as the
7176 * working directory of the repository (with a git-link file)
7277 */
@@ -81,7 +86,7 @@ int main(int argc, char *argv[])
8186 "Could not initialize repository" , NULL );
8287 }
8388
84- /* Print a message to stdout like "git init" does */
89+ /** Print a message to stdout like "git init" does. */
8590
8691 if (!o .quiet ) {
8792 if (o .bare || o .gitdir )
@@ -92,7 +97,8 @@ int main(int argc, char *argv[])
9297 printf ("Initialized empty Git repository in %s\n" , o .dir );
9398 }
9499
95- /* As an extension to the basic "git init" command, this example
100+ /**
101+ * As an extension to the basic "git init" command, this example
96102 * gives the option to create an empty initial commit. This is
97103 * mostly to demonstrate what it takes to do that, but also some
98104 * people like to have that empty base commit in their repo.
@@ -108,7 +114,8 @@ int main(int argc, char *argv[])
108114 return 0 ;
109115}
110116
111- /* Unlike regular "git init", this example shows how to create an initial
117+ /**
118+ * Unlike regular "git init", this example shows how to create an initial
112119 * empty commit in the repository. This is the helper function that does
113120 * that.
114121 */
@@ -119,7 +126,7 @@ static void create_initial_commit(git_repository *repo)
119126 git_oid tree_id , commit_id ;
120127 git_tree * tree ;
121128
122- /* First use the config to initialize a commit signature for the user */
129+ /** First use the config to initialize a commit signature for the user. */
123130
124131 if (git_signature_default (& sig , repo ) < 0 )
125132 fatal ("Unable to create a commit signature." ,
@@ -130,7 +137,8 @@ static void create_initial_commit(git_repository *repo)
130137 if (git_repository_index (& index , repo ) < 0 )
131138 fatal ("Could not open repository index" , NULL );
132139
133- /* Outside of this example, you could call git_index_add_bypath()
140+ /**
141+ * Outside of this example, you could call git_index_add_bypath()
134142 * here to put actual files into the index. For our purposes, we'll
135143 * leave it empty for now.
136144 */
@@ -143,7 +151,8 @@ static void create_initial_commit(git_repository *repo)
143151 if (git_tree_lookup (& tree , repo , & tree_id ) < 0 )
144152 fatal ("Could not look up initial tree" , NULL );
145153
146- /* Ready to create the initial commit
154+ /**
155+ * Ready to create the initial commit.
147156 *
148157 * Normally creating a commit would involve looking up the current
149158 * HEAD commit and making that be the parent of the initial commit,
@@ -155,7 +164,7 @@ static void create_initial_commit(git_repository *repo)
155164 NULL , "Initial commit" , tree , 0 ) < 0 )
156165 fatal ("Could not create the initial commit" , NULL );
157166
158- /* Clean up so we don't leak memory */
167+ /** Clean up so we don't leak memory. */
159168
160169 git_tree_free (tree );
161170 git_signature_free (sig );
@@ -171,7 +180,7 @@ static void usage(const char *error, const char *arg)
171180 exit (1 );
172181}
173182
174- /* parse the tail of the --shared= argument */
183+ /** Parse the tail of the --shared= argument. */
175184static uint32_t parse_shared (const char * shared )
176185{
177186 if (!strcmp (shared , "false" ) || !strcmp (shared , "umask" ))
@@ -204,7 +213,7 @@ static void parse_opts(struct opts *o, int argc, char *argv[])
204213 struct args_info args = ARGS_INFO_INIT ;
205214 const char * sharedarg ;
206215
207- /* Process arguments */
216+ /** Process arguments. */
208217
209218 for (args .pos = 1 ; args .pos < argc ; ++ args .pos ) {
210219 char * a = argv [args .pos ];
0 commit comments