]> git.proxmox.com Git - libgit2.git/blobdiff - include/git2/repository.h
New upstream version 1.3.0+dfsg.1
[libgit2.git] / include / git2 / repository.h
index 9ddcd340420f008ff3c8229e12e0609b13206e61..8d1cffc9bf62fe7ee733a8707b8ccb2a68015a7b 100644 (file)
@@ -219,36 +219,54 @@ GIT_EXTERN(int) git_repository_init(
  *
  * These flags configure extra behaviors to `git_repository_init_ext`.
  * In every case, the default behavior is the zero value (i.e. flag is
- * not set).  Just OR the flag values together for the `flags` parameter
- * when initializing a new repo.  Details of individual values are:
- *
- * * BARE   - Create a bare repository with no working directory.
- * * NO_REINIT - Return an GIT_EEXISTS error if the repo_path appears to
- *        already be an git repository.
- * * NO_DOTGIT_DIR - Normally a "/.git/" will be appended to the repo
- *        path for non-bare repos (if it is not already there), but
- *        passing this flag prevents that behavior.
- * * MKDIR  - Make the repo_path (and workdir_path) as needed.  Init is
- *        always willing to create the ".git" directory even without this
- *        flag.  This flag tells init to create the trailing component of
- *        the repo and workdir paths as needed.
- * * MKPATH - Recursively make all components of the repo and workdir
- *        paths as necessary.
- * * EXTERNAL_TEMPLATE - libgit2 normally uses internal templates to
- *        initialize a new repo.  This flags enables external templates,
- *        looking the "template_path" from the options if set, or the
- *        `init.templatedir` global config if not, or falling back on
- *        "/usr/share/git-core/templates" if it exists.
- * * GIT_REPOSITORY_INIT_RELATIVE_GITLINK - If an alternate workdir is
- *        specified, use relative paths for the gitdir and core.worktree.
+ * not set). Just OR the flag values together for the `flags` parameter
+ * when initializing a new repo.
  */
 typedef enum {
+       /**
+        * Create a bare repository with no working directory.
+        */
        GIT_REPOSITORY_INIT_BARE              = (1u << 0),
+
+       /**
+        * Return an GIT_EEXISTS error if the repo_path appears to already be
+        * an git repository.
+        */
        GIT_REPOSITORY_INIT_NO_REINIT         = (1u << 1),
+
+       /**
+        * Normally a "/.git/" will be appended to the repo path for
+        * non-bare repos (if it is not already there), but passing this flag
+        * prevents that behavior.
+        */
        GIT_REPOSITORY_INIT_NO_DOTGIT_DIR     = (1u << 2),
+
+       /**
+        * Make the repo_path (and workdir_path) as needed. Init is always willing
+        * to create the ".git" directory even without this flag. This flag tells
+        * init to create the trailing component of the repo and workdir paths
+        * as needed.
+        */
        GIT_REPOSITORY_INIT_MKDIR             = (1u << 3),
+
+       /**
+        * Recursively make all components of the repo and workdir paths as
+        * necessary.
+        */
        GIT_REPOSITORY_INIT_MKPATH            = (1u << 4),
+
+       /**
+        * libgit2 normally uses internal templates to initialize a new repo.
+        * This flags enables external templates, looking the "template_path" from
+        * the options if set, or the `init.templatedir` global config if not,
+        * or falling back on "/usr/share/git-core/templates" if it exists.
+        */
        GIT_REPOSITORY_INIT_EXTERNAL_TEMPLATE = (1u << 5),
+
+       /**
+        * If an alternate workdir is specified, use relative paths for the gitdir
+        * and core.worktree.
+        */
        GIT_REPOSITORY_INIT_RELATIVE_GITLINK  = (1u << 6),
 } git_repository_init_flag_t;
 
@@ -257,17 +275,23 @@ typedef enum {
  *
  * Set the mode field of the `git_repository_init_options` structure
  * either to the custom mode that you would like, or to one of the
- * following modes:
- *
- * * SHARED_UMASK - Use permissions configured by umask - the default.
- * * SHARED_GROUP - Use "--shared=group" behavior, chmod'ing the new repo
- *        to be group writable and "g+sx" for sticky group assignment.
- * * SHARED_ALL - Use "--shared=all" behavior, adding world readability.
- * * Anything else - Set to custom value.
+ * defined modes.
  */
 typedef enum {
+       /**
+        * Use permissions configured by umask - the default.
+        */
        GIT_REPOSITORY_INIT_SHARED_UMASK = 0,
+
+       /**
+        * Use "--shared=group" behavior, chmod'ing the new repo to be group
+        * writable and "g+sx" for sticky group assignment.
+        */
        GIT_REPOSITORY_INIT_SHARED_GROUP = 0002775,
+
+       /**
+        * Use "--shared=all" behavior, adding world readability.
+        */
        GIT_REPOSITORY_INIT_SHARED_ALL   = 0002777,
 } git_repository_init_mode_t;
 
@@ -275,38 +299,57 @@ typedef enum {
  * Extended options structure for `git_repository_init_ext`.
  *
  * This contains extra options for `git_repository_init_ext` that enable
- * additional initialization features.  The fields are:
- *
- * * flags - Combination of GIT_REPOSITORY_INIT flags above.
- * * mode  - Set to one of the standard GIT_REPOSITORY_INIT_SHARED_...
- *        constants above, or to a custom value that you would like.
- * * workdir_path - The path to the working dir or NULL for default (i.e.
- *        repo_path parent on non-bare repos).  IF THIS IS RELATIVE PATH,
- *        IT WILL BE EVALUATED RELATIVE TO THE REPO_PATH.  If this is not
- *        the "natural" working directory, a .git gitlink file will be
- *        created here linking to the repo_path.
- * * description - If set, this will be used to initialize the "description"
- *        file in the repository, instead of using the template content.
- * * template_path - When GIT_REPOSITORY_INIT_EXTERNAL_TEMPLATE is set,
- *        this contains the path to use for the template directory.  If
- *        this is NULL, the config or default directory options will be
- *        used instead.
- * * initial_head - The name of the head to point HEAD at.  If NULL, then
- *        this will be treated as "master" and the HEAD ref will be set
- *        to "refs/heads/master".  If this begins with "refs/" it will be
- *        used verbatim; otherwise "refs/heads/" will be prefixed.
- * * origin_url - If this is non-NULL, then after the rest of the
- *        repository initialization is completed, an "origin" remote
- *        will be added pointing to this URL.
+ * additional initialization features.
  */
 typedef struct {
        unsigned int version;
+
+       /**
+        * Combination of GIT_REPOSITORY_INIT flags above.
+        */
        uint32_t    flags;
+
+       /**
+        * Set to one of the standard GIT_REPOSITORY_INIT_SHARED_... constants
+        * above, or to a custom value that you would like.
+        */
        uint32_t    mode;
+
+       /**
+        * The path to the working dir or NULL for default (i.e. repo_path parent
+        * on non-bare repos). IF THIS IS RELATIVE PATH, IT WILL BE EVALUATED
+        * RELATIVE TO THE REPO_PATH. If this is not the "natural" working
+        * directory, a .git gitlink file will be created here linking to the
+        * repo_path.
+        */
        const char *workdir_path;
+
+       /**
+        * If set, this will be used to initialize the "description" file in the
+        * repository, instead of using the template content.
+        */
        const char *description;
+
+       /**
+        * When GIT_REPOSITORY_INIT_EXTERNAL_TEMPLATE is set, this contains
+        * the path to use for the template directory. If this is NULL, the config
+        * or default directory options will be used instead.
+        */
        const char *template_path;
+
+       /**
+        * The name of the head to point HEAD at. If NULL, then this will be
+        * treated as "master" and the HEAD ref will be set to "refs/heads/master".
+        * If this begins with "refs/" it will be used verbatim;
+        * otherwise "refs/heads/" will be prefixed.
+        */
        const char *initial_head;
+
+       /**
+        * If this is non-NULL, then after the rest of the repository
+        * initialization is completed, an "origin" remote will be added
+        * pointing to this URL.
+        */
        const char *origin_url;
 } git_repository_init_options;
 
@@ -719,13 +762,15 @@ GIT_EXTERN(int) git_repository_mergehead_foreach(
  *
  * @param out Output value of calculated SHA
  * @param repo Repository pointer
- * @param path Path to file on disk whose contents should be hashed. If the
- *             repository is not NULL, this can be a relative path.
+ * @param path Path to file on disk whose contents should be hashed.  This
+ *             may be an absolute path or a relative path, in which case it
+ *             will be treated as a path within the working directory.
  * @param type The object type to hash as (e.g. GIT_OBJECT_BLOB)
  * @param as_path The path to use to look up filtering rules. If this is
- *             NULL, then the `path` parameter will be used instead. If
- *             this is passed as the empty string, then no filters will be
- *             applied when calculating the hash.
+ *             an empty string then no filters will be applied when
+ *             calculating the hash. If this is `NULL` and the `path`
+ *             parameter is a file within the repository's working
+ *             directory, then the `path` will be used.
  * @return 0 on success, or an error code
  */
 GIT_EXTERN(int) git_repository_hashfile(
@@ -754,8 +799,8 @@ GIT_EXTERN(int) git_repository_hashfile(
  * @return 0 on success, or an error code
  */
 GIT_EXTERN(int) git_repository_set_head(
-       git_repositoryrepo,
-       const charrefname);
+       git_repository *repo,
+       const char *refname);
 
 /**
  * Make the repository HEAD directly point to the Commit.
@@ -774,8 +819,8 @@ GIT_EXTERN(int) git_repository_set_head(
  * @return 0 on success, or an error code
  */
 GIT_EXTERN(int) git_repository_set_head_detached(
-       git_repositoryrepo,
-       const git_oidcommitish);
+       git_repository *repo,
+       const git_oid *commitish);
 
 /**
  * Make the repository HEAD directly point to the Commit.
@@ -811,7 +856,7 @@ GIT_EXTERN(int) git_repository_set_head_detached_from_annotated(
  * branch or an error code
  */
 GIT_EXTERN(int) git_repository_detach_head(
-       git_repositoryrepo);
+       git_repository *repo);
 
 /**
  * Repository state