Skip to content

Commit

Permalink
Update bundled libgit2 source code (da8138b)
Browse files Browse the repository at this point in the history
* Update libgit2 source code to commit
  da8138b01217824cf211fa491608a7b067cf8e43

Signed-off-by: Stefan Widgren <stefan.widgren@gmail.com>
  • Loading branch information
stewid committed Dec 18, 2018
1 parent 2b96b17 commit 786ac10
Show file tree
Hide file tree
Showing 60 changed files with 531 additions and 466 deletions.
6 changes: 3 additions & 3 deletions src/libgit2/include/git2/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -243,13 +243,13 @@ typedef enum {
* > `GIT_CONFIG_LEVEL_GLOBAL`, `GIT_CONFIG_LEVEL_XDG`, or
* > `GIT_CONFIG_LEVEL_PROGRAMDATA`.
*
* * opts(GIT_OPT_SET_CACHE_OBJECT_LIMIT, git_otype type, size_t size)
* * opts(GIT_OPT_SET_CACHE_OBJECT_LIMIT, git_object_t type, size_t size)
*
* > Set the maximum data size for the given type of object to be
* > considered eligible for caching in memory. Setting to value to
* > zero means that that type of object will not be cached.
* > Defaults to 0 for GIT_OBJ_BLOB (i.e. won't cache blobs) and 4k
* > for GIT_OBJ_COMMIT, GIT_OBJ_TREE, and GIT_OBJ_TAG.
* > Defaults to 0 for GIT_OBJECT_BLOB (i.e. won't cache blobs) and 4k
* > for GIT_OBJECT_COMMIT, GIT_OBJECT_TREE, and GIT_OBJECT_TAG.
*
* * opts(GIT_OPT_SET_CACHE_MAX_SIZE, ssize_t max_storage_bytes)
*
Expand Down
116 changes: 74 additions & 42 deletions src/libgit2/include/git2/index.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,11 @@ typedef struct {
* "Documentation/technical/index-format.txt").
*
* The `flags` field consists of a number of bit fields which can be
* accessed via the first set of `GIT_IDXENTRY_...` bitmasks below. These
* flags are all read from and persisted to disk.
* accessed via the first set of `GIT_INDEX_ENTRY_...` bitmasks below.
* These flags are all read from and persisted to disk.
*
* The `flags_extended` field also has a number of bit fields which can be
* accessed via the later `GIT_IDXENTRY_...` bitmasks below. Some of
* accessed via the later `GIT_INDEX_ENTRY_...` bitmasks below. Some of
* these flags are read from and written to disk, but some are set aside
* for in-memory only reference.
*
Expand Down Expand Up @@ -76,32 +76,33 @@ typedef struct git_index_entry {
* value both in memory and on disk. You can use them to interpret the
* data in the `flags`.
*/
#define GIT_IDXENTRY_NAMEMASK (0x0fff)
#define GIT_IDXENTRY_STAGEMASK (0x3000)
#define GIT_IDXENTRY_STAGESHIFT 12

#define GIT_INDEX_ENTRY_NAMEMASK (0x0fff)
#define GIT_INDEX_ENTRY_STAGEMASK (0x3000)
#define GIT_INDEX_ENTRY_STAGESHIFT 12

/**
* Flags for index entries
*/
typedef enum {
GIT_IDXENTRY_EXTENDED = (0x4000),
GIT_IDXENTRY_VALID = (0x8000),
} git_indxentry_flag_t;
GIT_INDEX_ENTRY_EXTENDED = (0x4000),
GIT_INDEX_ENTRY_VALID = (0x8000),
} git_index_entry_flag_t;

#define GIT_IDXENTRY_STAGE(E) \
(((E)->flags & GIT_IDXENTRY_STAGEMASK) >> GIT_IDXENTRY_STAGESHIFT)
#define GIT_INDEX_ENTRY_STAGE(E) \
(((E)->flags & GIT_INDEX_ENTRY_STAGEMASK) >> GIT_INDEX_ENTRY_STAGESHIFT)

#define GIT_IDXENTRY_STAGE_SET(E,S) do { \
(E)->flags = ((E)->flags & ~GIT_IDXENTRY_STAGEMASK) | \
(((S) & 0x03) << GIT_IDXENTRY_STAGESHIFT); } while (0)
#define GIT_INDEX_ENTRY_STAGE_SET(E,S) do { \
(E)->flags = ((E)->flags & ~GIT_INDEX_ENTRY_STAGEMASK) | \
(((S) & 0x03) << GIT_INDEX_ENTRY_STAGESHIFT); } while (0)

/**
* Bitmasks for on-disk fields of `git_index_entry`'s `flags_extended`
*
* In memory, the `flags_extended` fields are divided into two parts: the
* fields that are read from and written to disk, and other fields that
* in-memory only and used by libgit2. Only the flags in
* `GIT_IDXENTRY_EXTENDED_FLAGS` will get saved on-disk.
* `GIT_INDEX_ENTRY_EXTENDED_FLAGS` will get saved on-disk.
*
* Thee first three bitmasks match the three fields in the
* `git_index_entry` `flags_extended` value that belong on disk. You
Expand All @@ -113,34 +114,22 @@ typedef enum {
*
*/
typedef enum {
GIT_INDEX_ENTRY_INTENT_TO_ADD = (1 << 13),
GIT_INDEX_ENTRY_SKIP_WORKTREE = (1 << 14),

GIT_IDXENTRY_INTENT_TO_ADD = (1 << 13),
GIT_IDXENTRY_SKIP_WORKTREE = (1 << 14),
/** Reserved for future extension */
GIT_IDXENTRY_EXTENDED2 = (1 << 15),

GIT_IDXENTRY_EXTENDED_FLAGS = (GIT_IDXENTRY_INTENT_TO_ADD | GIT_IDXENTRY_SKIP_WORKTREE),
GIT_IDXENTRY_UPDATE = (1 << 0),
GIT_IDXENTRY_REMOVE = (1 << 1),
GIT_IDXENTRY_UPTODATE = (1 << 2),
GIT_IDXENTRY_ADDED = (1 << 3),

GIT_IDXENTRY_HASHED = (1 << 4),
GIT_IDXENTRY_UNHASHED = (1 << 5),
GIT_IDXENTRY_WT_REMOVE = (1 << 6), /**< remove in work directory */
GIT_IDXENTRY_CONFLICTED = (1 << 7),
GIT_INDEX_ENTRY_EXTENDED_FLAGS = (GIT_INDEX_ENTRY_INTENT_TO_ADD | GIT_INDEX_ENTRY_SKIP_WORKTREE),

GIT_IDXENTRY_UNPACKED = (1 << 8),
GIT_IDXENTRY_NEW_SKIP_WORKTREE = (1 << 9),
} git_idxentry_extended_flag_t;
GIT_INDEX_ENTRY_UPTODATE = (1 << 2),
} git_index_entry_extended_flag_t;

/** Capabilities of system that affect index actions. */
typedef enum {
GIT_INDEXCAP_IGNORE_CASE = 1,
GIT_INDEXCAP_NO_FILEMODE = 2,
GIT_INDEXCAP_NO_SYMLINKS = 4,
GIT_INDEXCAP_FROM_OWNER = -1,
} git_indexcap_t;
GIT_INDEX_CAPABILITY_IGNORE_CASE = 1,
GIT_INDEX_CAPABILITY_NO_FILEMODE = 2,
GIT_INDEX_CAPABILITY_NO_SYMLINKS = 4,
GIT_INDEX_CAPABILITY_FROM_OWNER = -1,
} git_index_capability_t;


/** Callback for APIs that add/remove/update files matching pathspec */
typedef int (*git_index_matched_path_cb)(
Expand Down Expand Up @@ -234,19 +223,19 @@ GIT_EXTERN(git_repository *) git_index_owner(const git_index *index);
* Read index capabilities flags.
*
* @param index An existing index object
* @return A combination of GIT_INDEXCAP values
* @return A combination of GIT_INDEX_CAPABILITY values
*/
GIT_EXTERN(int) git_index_caps(const git_index *index);

/**
* Set index capabilities flags.
*
* If you pass `GIT_INDEXCAP_FROM_OWNER` for the caps, then the
* If you pass `GIT_INDEX_CAPABILITY_FROM_OWNER` for the caps, then
* capabilities will be read from the config of the owner object,
* looking at `core.ignorecase`, `core.filemode`, `core.symlinks`.
*
* @param index An existing index object
* @param caps A combination of GIT_INDEXCAP values
* @param caps A combination of GIT_INDEX_CAPABILITY values
* @return 0 on success, -1 on failure
*/
GIT_EXTERN(int) git_index_set_caps(git_index *index, int caps);
Expand Down Expand Up @@ -474,7 +463,7 @@ GIT_EXTERN(int) git_index_add(git_index *index, const git_index_entry *source_en
*
* This entry is calculated from the entry's flag attribute like this:
*
* (entry->flags & GIT_IDXENTRY_STAGEMASK) >> GIT_IDXENTRY_STAGESHIFT
* (entry->flags & GIT_INDEX_ENTRY_STAGEMASK) >> GIT_INDEX_ENTRY_STAGESHIFT
*
* @param entry The entry
* @return the stage number
Expand Down Expand Up @@ -847,6 +836,49 @@ GIT_EXTERN(void) git_index_conflict_iterator_free(

/**@}*/

/** @name Deprecated Index Structures
*
* These macros, structures and enumerations are retained for backward
* compatibility. The newer versions of these functions and structures
* should be preferred in all new code.
*/
/**@{*/

#define GIT_IDXENTRY_NAMEMASK GIT_INDEX_ENTRY_NAMEMASK
#define GIT_IDXENTRY_STAGEMASK GIT_INDEX_ENTRY_STAGEMASK
#define GIT_IDXENTRY_STAGESHIFT GIT_INDEX_ENTRY_STAGESHIFT

/* The git_indxentry_flag_t enum */
#define GIT_IDXENTRY_EXTENDED GIT_INDEX_ENTRY_EXTENDED
#define GIT_IDXENTRY_VALID GIT_INDEX_ENTRY_VALID

#define GIT_IDXENTRY_STAGE(E) GIT_INDEX_ENTRY_STAGE(E)
#define GIT_IDXENTRY_STAGE_SET(E,S) GIT_INDEX_ENTRY_STAGE_SET(E,S)

/* The git_idxentry_extended_flag_t enum */
#define GIT_IDXENTRY_INTENT_TO_ADD GIT_INDEX_ENTRY_INTENT_TO_ADD
#define GIT_IDXENTRY_SKIP_WORKTREE GIT_INDEX_ENTRY_SKIP_WORKTREE
#define GIT_IDXENTRY_EXTENDED_FLAGS (GIT_INDEX_ENTRY_INTENT_TO_ADD | GIT_INDEX_ENTRY_SKIP_WORKTREE)
#define GIT_IDXENTRY_EXTENDED2 (1 << 15)
#define GIT_IDXENTRY_UPDATE (1 << 0)
#define GIT_IDXENTRY_REMOVE (1 << 1)
#define GIT_IDXENTRY_UPTODATE (1 << 2)
#define GIT_IDXENTRY_ADDED (1 << 3)
#define GIT_IDXENTRY_HASHED (1 << 4)
#define GIT_IDXENTRY_UNHASHED (1 << 5)
#define GIT_IDXENTRY_WT_REMOVE (1 << 6)
#define GIT_IDXENTRY_CONFLICTED (1 << 7)
#define GIT_IDXENTRY_UNPACKED (1 << 8)
#define GIT_IDXENTRY_NEW_SKIP_WORKTREE (1 << 9)

/* The git_index_capability_t enum */
#define GIT_INDEXCAP_IGNORE_CASE GIT_INDEX_CAPABILITY_IGNORE_CASE
#define GIT_INDEXCAP_NO_FILEMODE GIT_INDEX_CAPABILITY_NO_FILEMODE
#define GIT_INDEXCAP_NO_SYMLINKS GIT_INDEX_CAPABILITY_NO_SYMLINKS
#define GIT_INDEXCAP_FROM_OWNER GIT_INDEX_CAPABILITY_FROM_OWNER

/**@}*/

/** @} */
GIT_END_DECL
#endif
32 changes: 16 additions & 16 deletions src/libgit2/include/git2/object.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ GIT_BEGIN_DECL
*
* The 'type' parameter must match the type of the object
* in the odb; the method will fail otherwise.
* The special value 'GIT_OBJ_ANY' may be passed to let
* The special value 'GIT_OBJECT_ANY' may be passed to let
* the method guess the object's type.
*
* @param object pointer to the looked-up object
Expand All @@ -43,7 +43,7 @@ GIT_EXTERN(int) git_object_lookup(
git_object **object,
git_repository *repo,
const git_oid *id,
git_otype type);
git_object_t type);

/**
* Lookup a reference to one of the objects in a repository,
Expand All @@ -62,7 +62,7 @@ GIT_EXTERN(int) git_object_lookup(
*
* The 'type' parameter must match the type of the object
* in the odb; the method will fail otherwise.
* The special value 'GIT_OBJ_ANY' may be passed to let
* The special value 'GIT_OBJECT_ANY' may be passed to let
* the method guess the object's type.
*
* @param object_out pointer where to store the looked-up object
Expand All @@ -77,7 +77,7 @@ GIT_EXTERN(int) git_object_lookup_prefix(
git_repository *repo,
const git_oid *id,
size_t len,
git_otype type);
git_object_t type);


/**
Expand All @@ -94,7 +94,7 @@ GIT_EXTERN(int) git_object_lookup_bypath(
git_object **out,
const git_object *treeish,
const char *path,
git_otype type);
git_object_t type);

/**
* Get the id (SHA1) of a repository object
Expand Down Expand Up @@ -124,7 +124,7 @@ GIT_EXTERN(int) git_object_short_id(git_buf *out, const git_object *obj);
* @param obj the repository object
* @return the object's type
*/
GIT_EXTERN(git_otype) git_object_type(const git_object *obj);
GIT_EXTERN(git_object_t) git_object_type(const git_object *obj);

/**
* Get the repository that owns this object
Expand Down Expand Up @@ -166,24 +166,24 @@ GIT_EXTERN(void) git_object_free(git_object *object);
* @param type object type to convert.
* @return the corresponding string representation.
*/
GIT_EXTERN(const char *) git_object_type2string(git_otype type);
GIT_EXTERN(const char *) git_object_type2string(git_object_t type);

/**
* Convert a string object type representation to it's git_otype.
* Convert a string object type representation to it's git_object_t.
*
* @param str the string to convert.
* @return the corresponding git_otype.
* @return the corresponding git_object_t.
*/
GIT_EXTERN(git_otype) git_object_string2type(const char *str);
GIT_EXTERN(git_object_t) git_object_string2type(const char *str);

/**
* Determine if the given git_otype is a valid loose object type.
* Determine if the given git_object_t is a valid loose object type.
*
* @param type object type to test.
* @return true if the type represents a valid loose object type,
* false otherwise.
*/
GIT_EXTERN(int) git_object_typeisloose(git_otype type);
GIT_EXTERN(int) git_object_typeisloose(git_object_t type);

/**
* Get the size in bytes for the structure which
Expand All @@ -197,7 +197,7 @@ GIT_EXTERN(int) git_object_typeisloose(git_otype type);
* @param type object type to get its size
* @return size in bytes of the object
*/
GIT_EXTERN(size_t) git_object__size(git_otype type);
GIT_EXTERN(size_t) git_object__size(git_object_t type);

/**
* Recursively peel an object until an object of the specified type is met.
Expand All @@ -206,7 +206,7 @@ GIT_EXTERN(size_t) git_object__size(git_otype type);
* GIT_EINVALIDSPEC will be returned (e.g. trying to peel a blob to a
* tree).
*
* If you pass `GIT_OBJ_ANY` as the target type, then the object will
* If you pass `GIT_OBJECT_ANY` as the target type, then the object will
* be peeled until the type changes. A tag will be peeled until the
* referenced object is no longer a tag, and a commit will be peeled
* to a tree. Any other object type will return GIT_EINVALIDSPEC.
Expand All @@ -219,13 +219,13 @@ GIT_EXTERN(size_t) git_object__size(git_otype type);
*
* @param peeled Pointer to the peeled git_object
* @param object The object to be processed
* @param target_type The type of the requested object (a GIT_OBJ_ value)
* @param target_type The type of the requested object (a GIT_OBJECT_ value)
* @return 0 on success, GIT_EINVALIDSPEC, GIT_EPEEL, or an error code
*/
GIT_EXTERN(int) git_object_peel(
git_object **peeled,
const git_object *object,
git_otype target_type);
git_object_t target_type);

/**
* Create an in-memory copy of a Git object. The copy must be
Expand Down
18 changes: 9 additions & 9 deletions src/libgit2/include/git2/odb.h
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ GIT_EXTERN(int) git_odb_read_prefix(git_odb_object **out, git_odb *db, const git
* - 0 if the object was read;
* - GIT_ENOTFOUND if the object is not in the database.
*/
GIT_EXTERN(int) git_odb_read_header(size_t *len_out, git_otype *type_out, git_odb *db, const git_oid *id);
GIT_EXTERN(int) git_odb_read_header(size_t *len_out, git_object_t *type_out, git_odb *db, const git_oid *id);

/**
* Determine if the given object can be found in the object database.
Expand Down Expand Up @@ -189,9 +189,9 @@ typedef struct git_odb_expand_id {

/**
* The (optional) type of the object to search for; leave as `0` or set
* to `GIT_OBJ_ANY` to query for any object matching the ID.
* to `GIT_OBJECT_ANY` to query for any object matching the ID.
*/
git_otype type;
git_object_t type;
} git_odb_expand_id;

/**
Expand Down Expand Up @@ -270,7 +270,7 @@ GIT_EXTERN(int) git_odb_foreach(git_odb *db, git_odb_foreach_cb cb, void *payloa
* @param type type of the data to store
* @return 0 or an error code
*/
GIT_EXTERN(int) git_odb_write(git_oid *out, git_odb *odb, const void *data, size_t len, git_otype type);
GIT_EXTERN(int) git_odb_write(git_oid *out, git_odb *odb, const void *data, size_t len, git_object_t type);

/**
* Open a stream to write an object into the ODB
Expand All @@ -293,7 +293,7 @@ GIT_EXTERN(int) git_odb_write(git_oid *out, git_odb *odb, const void *data, size
* @param type type of the object that will be written
* @return 0 if the stream was created; error code otherwise
*/
GIT_EXTERN(int) git_odb_open_wstream(git_odb_stream **out, git_odb *db, git_off_t size, git_otype type);
GIT_EXTERN(int) git_odb_open_wstream(git_odb_stream **out, git_odb *db, git_off_t size, git_object_t type);

/**
* Write to an odb stream
Expand Down Expand Up @@ -366,7 +366,7 @@ GIT_EXTERN(void) git_odb_stream_free(git_odb_stream *stream);
GIT_EXTERN(int) git_odb_open_rstream(
git_odb_stream **out,
size_t *len,
git_otype *type,
git_object_t *type,
git_odb *db,
const git_oid *oid);

Expand Down Expand Up @@ -406,7 +406,7 @@ GIT_EXTERN(int) git_odb_write_pack(
* @param type of the data to hash
* @return 0 or an error code
*/
GIT_EXTERN(int) git_odb_hash(git_oid *out, const void *data, size_t len, git_otype type);
GIT_EXTERN(int) git_odb_hash(git_oid *out, const void *data, size_t len, git_object_t type);

/**
* Read a file from disk and fill a git_oid with the object id
Expand All @@ -421,7 +421,7 @@ GIT_EXTERN(int) git_odb_hash(git_oid *out, const void *data, size_t len, git_oty
* @param type the type of the object that will be hashed
* @return 0 or an error code
*/
GIT_EXTERN(int) git_odb_hashfile(git_oid *out, const char *path, git_otype type);
GIT_EXTERN(int) git_odb_hashfile(git_oid *out, const char *path, git_object_t type);

/**
* Create a copy of an odb_object
Expand Down Expand Up @@ -487,7 +487,7 @@ GIT_EXTERN(size_t) git_odb_object_size(git_odb_object *object);
* @param object the object
* @return the type
*/
GIT_EXTERN(git_otype) git_odb_object_type(git_odb_object *object);
GIT_EXTERN(git_object_t) git_odb_object_type(git_odb_object *object);

/**
* Add a custom backend to an existing Object DB
Expand Down
Loading

0 comments on commit 786ac10

Please sign in to comment.