@@ -219,36 +219,54 @@ GIT_EXTERN(int) git_repository_init(
219219 *
220220 * These flags configure extra behaviors to `git_repository_init_ext`.
221221 * In every case, the default behavior is the zero value (i.e. flag is
222- * not set). Just OR the flag values together for the `flags` parameter
223- * when initializing a new repo. Details of individual values are:
224- *
225- * * BARE - Create a bare repository with no working directory.
226- * * NO_REINIT - Return an GIT_EEXISTS error if the repo_path appears to
227- * already be an git repository.
228- * * NO_DOTGIT_DIR - Normally a "/.git/" will be appended to the repo
229- * path for non-bare repos (if it is not already there), but
230- * passing this flag prevents that behavior.
231- * * MKDIR - Make the repo_path (and workdir_path) as needed. Init is
232- * always willing to create the ".git" directory even without this
233- * flag. This flag tells init to create the trailing component of
234- * the repo and workdir paths as needed.
235- * * MKPATH - Recursively make all components of the repo and workdir
236- * paths as necessary.
237- * * EXTERNAL_TEMPLATE - libgit2 normally uses internal templates to
238- * initialize a new repo. This flags enables external templates,
239- * looking the "template_path" from the options if set, or the
240- * `init.templatedir` global config if not, or falling back on
241- * "/usr/share/git-core/templates" if it exists.
242- * * GIT_REPOSITORY_INIT_RELATIVE_GITLINK - If an alternate workdir is
243- * specified, use relative paths for the gitdir and core.worktree.
222+ * not set). Just OR the flag values together for the `flags` parameter
223+ * when initializing a new repo.
244224 */
245225typedef enum {
226+ /**
227+ * Create a bare repository with no working directory.
228+ */
246229 GIT_REPOSITORY_INIT_BARE = (1u << 0 ),
230+
231+ /**
232+ * Return an GIT_EEXISTS error if the repo_path appears to already be
233+ * an git repository.
234+ */
247235 GIT_REPOSITORY_INIT_NO_REINIT = (1u << 1 ),
236+
237+ /**
238+ * Normally a "/.git/" will be appended to the repo path for
239+ * non-bare repos (if it is not already there), but passing this flag
240+ * prevents that behavior.
241+ */
248242 GIT_REPOSITORY_INIT_NO_DOTGIT_DIR = (1u << 2 ),
243+
244+ /**
245+ * Make the repo_path (and workdir_path) as needed. Init is always willing
246+ * to create the ".git" directory even without this flag. This flag tells
247+ * init to create the trailing component of the repo and workdir paths
248+ * as needed.
249+ */
249250 GIT_REPOSITORY_INIT_MKDIR = (1u << 3 ),
251+
252+ /**
253+ * Recursively make all components of the repo and workdir paths as
254+ * necessary.
255+ */
250256 GIT_REPOSITORY_INIT_MKPATH = (1u << 4 ),
257+
258+ /**
259+ * libgit2 normally uses internal templates to initialize a new repo.
260+ * This flags enables external templates, looking the "template_path" from
261+ * the options if set, or the `init.templatedir` global config if not,
262+ * or falling back on "/usr/share/git-core/templates" if it exists.
263+ */
251264 GIT_REPOSITORY_INIT_EXTERNAL_TEMPLATE = (1u << 5 ),
265+
266+ /**
267+ * If an alternate workdir is specified, use relative paths for the gitdir
268+ * and core.worktree.
269+ */
252270 GIT_REPOSITORY_INIT_RELATIVE_GITLINK = (1u << 6 ),
253271} git_repository_init_flag_t ;
254272
@@ -257,56 +275,81 @@ typedef enum {
257275 *
258276 * Set the mode field of the `git_repository_init_options` structure
259277 * either to the custom mode that you would like, or to one of the
260- * following modes:
261- *
262- * * SHARED_UMASK - Use permissions configured by umask - the default.
263- * * SHARED_GROUP - Use "--shared=group" behavior, chmod'ing the new repo
264- * to be group writable and "g+sx" for sticky group assignment.
265- * * SHARED_ALL - Use "--shared=all" behavior, adding world readability.
266- * * Anything else - Set to custom value.
278+ * defined modes.
267279 */
268280typedef enum {
281+ /**
282+ * Use permissions configured by umask - the default.
283+ */
269284 GIT_REPOSITORY_INIT_SHARED_UMASK = 0 ,
285+
286+ /**
287+ * Use "--shared=group" behavior, chmod'ing the new repo to be group
288+ * writable and "g+sx" for sticky group assignment.
289+ */
270290 GIT_REPOSITORY_INIT_SHARED_GROUP = 0002775 ,
291+
292+ /**
293+ * Use "--shared=all" behavior, adding world readability.
294+ */
271295 GIT_REPOSITORY_INIT_SHARED_ALL = 0002777 ,
272296} git_repository_init_mode_t ;
273297
274298/**
275299 * Extended options structure for `git_repository_init_ext`.
276300 *
277301 * This contains extra options for `git_repository_init_ext` that enable
278- * additional initialization features. The fields are:
279- *
280- * * flags - Combination of GIT_REPOSITORY_INIT flags above.
281- * * mode - Set to one of the standard GIT_REPOSITORY_INIT_SHARED_...
282- * constants above, or to a custom value that you would like.
283- * * workdir_path - The path to the working dir or NULL for default (i.e.
284- * repo_path parent on non-bare repos). IF THIS IS RELATIVE PATH,
285- * IT WILL BE EVALUATED RELATIVE TO THE REPO_PATH. If this is not
286- * the "natural" working directory, a .git gitlink file will be
287- * created here linking to the repo_path.
288- * * description - If set, this will be used to initialize the "description"
289- * file in the repository, instead of using the template content.
290- * * template_path - When GIT_REPOSITORY_INIT_EXTERNAL_TEMPLATE is set,
291- * this contains the path to use for the template directory. If
292- * this is NULL, the config or default directory options will be
293- * used instead.
294- * * initial_head - The name of the head to point HEAD at. If NULL, then
295- * this will be treated as "master" and the HEAD ref will be set
296- * to "refs/heads/master". If this begins with "refs/" it will be
297- * used verbatim; otherwise "refs/heads/" will be prefixed.
298- * * origin_url - If this is non-NULL, then after the rest of the
299- * repository initialization is completed, an "origin" remote
300- * will be added pointing to this URL.
302+ * additional initialization features.
301303 */
302304typedef struct {
303305 unsigned int version ;
306+
307+ /**
308+ * Combination of GIT_REPOSITORY_INIT flags above.
309+ */
304310 uint32_t flags ;
311+
312+ /**
313+ * Set to one of the standard GIT_REPOSITORY_INIT_SHARED_... constants
314+ * above, or to a custom value that you would like.
315+ */
305316 uint32_t mode ;
317+
318+ /**
319+ * The path to the working dir or NULL for default (i.e. repo_path parent
320+ * on non-bare repos). IF THIS IS RELATIVE PATH, IT WILL BE EVALUATED
321+ * RELATIVE TO THE REPO_PATH. If this is not the "natural" working
322+ * directory, a .git gitlink file will be created here linking to the
323+ * repo_path.
324+ */
306325 const char * workdir_path ;
326+
327+ /**
328+ * If set, this will be used to initialize the "description" file in the
329+ * repository, instead of using the template content.
330+ */
307331 const char * description ;
332+
333+ /**
334+ * When GIT_REPOSITORY_INIT_EXTERNAL_TEMPLATE is set, this contains
335+ * the path to use for the template directory. If this is NULL, the config
336+ * or default directory options will be used instead.
337+ */
308338 const char * template_path ;
339+
340+ /**
341+ * The name of the head to point HEAD at. If NULL, then this will be
342+ * treated as "master" and the HEAD ref will be set to "refs/heads/master".
343+ * If this begins with "refs/" it will be used verbatim;
344+ * otherwise "refs/heads/" will be prefixed.
345+ */
309346 const char * initial_head ;
347+
348+ /**
349+ * If this is non-NULL, then after the rest of the repository
350+ * initialization is completed, an "origin" remote will be added
351+ * pointing to this URL.
352+ */
310353 const char * origin_url ;
311354} git_repository_init_options ;
312355
0 commit comments