diff options
Diffstat (limited to 'include')
| -rw-r--r-- | include/git2/commit.h | 20 | ||||
| -rw-r--r-- | include/git2/common.h | 6 | ||||
| -rw-r--r-- | include/git2/index.h | 40 | ||||
| -rw-r--r-- | include/git2/repository.h | 30 | ||||
| -rw-r--r-- | include/git2/signature.h | 23 |
5 files changed, 113 insertions, 6 deletions
diff --git a/include/git2/commit.h b/include/git2/commit.h index c09b34843..3687d9460 100644 --- a/include/git2/commit.h +++ b/include/git2/commit.h @@ -136,6 +136,16 @@ GIT_EXTERN(const git_signature *) git_commit_author(git_commit *commit); GIT_EXTERN(int) git_commit_tree(git_tree **tree_out, git_commit *commit); /** + * Get the id of the tree pointed to by a commit. This differs from + * `git_commit_tree` in that no attempts are made to fetch an object + * from the ODB. + * + * @param commit a previously loaded commit. + * @return the id of tree pointed to by commit. + */ +GIT_EXTERN(const git_oid *) git_commit_tree_oid(git_commit *commit); + +/** * Get the number of parents of this commit * * @param commit a previously loaded commit. @@ -153,6 +163,16 @@ GIT_EXTERN(unsigned int) git_commit_parentcount(git_commit *commit); */ GIT_EXTERN(int) git_commit_parent(git_commit **parent, git_commit *commit, unsigned int n); +/** + * Get the oid of a specified parent for a commit. This is different from + * `git_commit_parent`, which will attempt to load the parent commit from + * the ODB. + * + * @param commit a previously loaded commit. + * @param n the position of the parent (from 0 to `parentcount`) + * @return the id of the parent, NULL on error. + */ +GIT_EXTERN(const git_oid *) git_commit_parent_oid(git_commit *commit, unsigned int n); /** * Create a new commit in the repository diff --git a/include/git2/common.h b/include/git2/common.h index 7cb98b824..ab267e620 100644 --- a/include/git2/common.h +++ b/include/git2/common.h @@ -164,6 +164,12 @@ /** A reference with this name already exists */ #define GIT_EEXISTS (GIT_ERROR - 23) +/** The given integer literal is too large to be parsed */ +#define GIT_EOVERFLOW (GIT_ERROR - 24) + +/** The given literal is not a valid number */ +#define GIT_ENOTNUM (GIT_ERROR - 25) + GIT_BEGIN_DECL typedef struct { diff --git a/include/git2/index.h b/include/git2/index.h index 599512f8a..8a84f507b 100644 --- a/include/git2/index.h +++ b/include/git2/index.h @@ -44,6 +44,46 @@ GIT_BEGIN_DECL #define GIT_IDXENTRY_VALID (0x8000) #define GIT_IDXENTRY_STAGESHIFT 12 +/* + * Flags are divided into two parts: in-memory flags and + * on-disk ones. Flags in GIT_IDXENTRY_EXTENDED_FLAGS + * will get saved on-disk. + * + * In-memory only flags: + */ +#define GIT_IDXENTRY_UPDATE (1 << 16) +#define GIT_IDXENTRY_REMOVE (1 << 17) +#define GIT_IDXENTRY_UPTODATE (1 << 18) +#define GIT_IDXENTRY_ADDED (1 << 19) + +#define GIT_IDXENTRY_HASHED (1 << 20) +#define GIT_IDXENTRY_UNHASHED (1 << 21) +#define GIT_IDXENTRY_WT_REMOVE (1 << 22) /* remove in work directory */ +#define GIT_IDXENTRY_CONFLICTED (1 << 23) + +#define GIT_IDXENTRY_UNPACKED (1 << 24) +#define GIT_IDXENTRY_NEW_SKIP_WORKTREE (1 << 25) + +/* + * Extended on-disk flags: + */ +#define GIT_IDXENTRY_INTENT_TO_ADD (1 << 29) +#define GIT_IDXENTRY_SKIP_WORKTREE (1 << 30) +/* GIT_IDXENTRY_EXTENDED2 is for future extension */ +#define GIT_IDXENTRY_EXTENDED2 (1 << 31) + +#define GIT_IDXENTRY_EXTENDED_FLAGS (GIT_IDXENTRY_INTENT_TO_ADD | GIT_IDXENTRY_SKIP_WORKTREE) + +/* + * Safeguard to avoid saving wrong flags: + * - GIT_IDXENTRY_EXTENDED2 won't get saved until its semantic is known + * - Bits in 0x0000FFFF have been saved in flags already + * - Bits in 0x003F0000 are currently in-memory flags + */ +#if GIT_IDXENTRY_EXTENDED_FLAGS & 0x803FFFFF +#error "GIT_IDXENTRY_EXTENDED_FLAGS out of range" +#endif + /** Time used in a git index entry */ typedef struct { git_time_t seconds; diff --git a/include/git2/repository.h b/include/git2/repository.h index 00c1f20d0..c47fcfc9a 100644 --- a/include/git2/repository.h +++ b/include/git2/repository.h @@ -182,6 +182,36 @@ GIT_EXTERN(void) git_repository_free(git_repository *repo); */ GIT_EXTERN(int) git_repository_init(git_repository **repo_out, const char *path, unsigned is_bare); +/** + * Check if a repository is empty + * + * An empty repository has just been initialized and contains + * no commits. + * + * @param repo Repo to test + * @return 1 if the repository is empty, 0 if it isn't, error code + * if the repository is corrupted + */ +GIT_EXTERN(int) git_repository_is_empty(git_repository *repo); + +/** + * Get the normalized path to the git repository. + * + * @param repo a repository object + * @return absolute path to the git directory + */ +GIT_EXTERN(const char *) git_repository_path(git_repository *repo); + +/** + * Get the normalized path to the working directory of the repository. + * + * If the repository is bare, there is no working directory and NULL we be returned. + * + * @param repo a repository object + * @return NULL if the repository is bare; absolute path to the working directory otherwise. + */ +GIT_EXTERN(const char *) git_repository_workdir(git_repository *repo); + /** @} */ GIT_END_DECL #endif diff --git a/include/git2/signature.h b/include/git2/signature.h index 40412a45f..44d1f285e 100644 --- a/include/git2/signature.h +++ b/include/git2/signature.h @@ -41,19 +41,30 @@ GIT_BEGIN_DECL * Create a new action signature. The signature must be freed * manually or using git_signature_free * - * @name name of the person - * @email email of the person - * @time time when the action happened - * @offset timezone offset in minutes for the time + * @param name name of the person + * @param mail email of the person + * @param time time when the action happened + * @param offset timezone offset in minutes for the time * @return the new sig, NULL on out of memory */ GIT_EXTERN(git_signature *) git_signature_new(const char *name, const char *email, git_time_t time, int offset); /** + * Create a new action signature with a timestamp of 'now'. The + * signature must be freed manually or using git_signature_free + * + * @param name name of the person + * @param email email of the person + * @return the new sig, NULL on out of memory + */ +GIT_EXTERN(git_signature *) git_signature_now(const char *name, const char *email); + + +/** * Create a copy of an existing signature. * * All internal strings are also duplicated. - * @sig signature to duplicated + * @param sig signature to duplicated * @return a copy of sig, NULL on out of memory */ GIT_EXTERN(git_signature *) git_signature_dup(const git_signature *sig); @@ -61,7 +72,7 @@ GIT_EXTERN(git_signature *) git_signature_dup(const git_signature *sig); /** * Free an existing signature * - * @sig signature to free + * @param sig signature to free */ GIT_EXTERN(void) git_signature_free(git_signature *sig); |
