Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
git2
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
lvzhengyang
git2
Commits
54e489c2
Commit
54e489c2
authored
May 15, 2013
by
Vicent Martí
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1579 from arrbee/index-entry-dup-and-free
Index entry dup and free
parents
71596200
89251b28
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
87 additions
and
56 deletions
+87
-56
include/git2/index.h
+87
-56
No files found.
include/git2/index.h
View file @
54e489c2
...
...
@@ -21,52 +21,29 @@
*/
GIT_BEGIN_DECL
#define GIT_IDXENTRY_NAMEMASK (0x0fff)
#define GIT_IDXENTRY_STAGEMASK (0x3000)
#define GIT_IDXENTRY_EXTENDED (0x4000)
#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 << 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)
/* remove in work directory */
#define GIT_IDXENTRY_CONFLICTED (1 << 7)
#define GIT_IDXENTRY_UNPACKED (1 << 8)
#define GIT_IDXENTRY_NEW_SKIP_WORKTREE (1 << 9)
/*
* Extended on-disk flags:
*/
#define GIT_IDXENTRY_INTENT_TO_ADD (1 << 13)
#define GIT_IDXENTRY_SKIP_WORKTREE (1 << 14)
/* GIT_IDXENTRY_EXTENDED2 is for future extension */
#define GIT_IDXENTRY_EXTENDED2 (1 << 15)
#define GIT_IDXENTRY_EXTENDED_FLAGS (GIT_IDXENTRY_INTENT_TO_ADD | GIT_IDXENTRY_SKIP_WORKTREE)
#define GIT_IDXENTRY_STAGE(E) (((E)->flags & GIT_IDXENTRY_STAGEMASK) >> GIT_IDXENTRY_STAGESHIFT)
/** Time used in a git index entry */
/** Time structure used in a git index entry */
typedef
struct
{
git_time_t
seconds
;
/* nsec should not be stored as time_t compatible */
unsigned
int
nanoseconds
;
}
git_index_time
;
/** Memory representation of a file entry in the index. */
/**
* In-memory representation of a file entry in the index.
*
* This is a public structure that represents a file entry in the index.
* The meaning of the fields corresponds to core Git's documentation (in
* "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.
*
* The `flags_extended` field also has a number of bit fields which can be
* accessed via the later `GIT_IDXENTRY_...` bitmasks below. Some of
* these flags are read from and written to disk, but some are set aside
* for in-memory only reference.
*/
typedef
struct
git_index_entry
{
git_index_time
ctime
;
git_index_time
mtime
;
...
...
@@ -86,13 +63,67 @@ typedef struct git_index_entry {
char
*
path
;
}
git_index_entry
;
/**
* Bitmasks for on-disk fields of `git_index_entry`'s `flags`
*
* These bitmasks match the four fields in the `git_index_entry` `flags`
* 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_EXTENDED (0x4000)
#define GIT_IDXENTRY_VALID (0x8000)
#define GIT_IDXENTRY_STAGESHIFT 12
#define GIT_IDXENTRY_STAGE(E) (((E)->flags & GIT_IDXENTRY_STAGEMASK) >> GIT_IDXENTRY_STAGESHIFT)
/**
* 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.
*
* These bitmasks match the three fields in the `git_index_entry`
* `flags_extended` value that belong on disk. You can use them to
* interpret the data in the `flags_extended`.
*/
#define GIT_IDXENTRY_INTENT_TO_ADD (1 << 13)
#define GIT_IDXENTRY_SKIP_WORKTREE (1 << 14)
/* GIT_IDXENTRY_EXTENDED2 is reserved for future extension */
#define GIT_IDXENTRY_EXTENDED2 (1 << 15)
#define GIT_IDXENTRY_EXTENDED_FLAGS (GIT_IDXENTRY_INTENT_TO_ADD | GIT_IDXENTRY_SKIP_WORKTREE)
/**
* Bitmasks for in-memory only fields of `git_index_entry`'s `flags_extended`
*
* These bitmasks match the other fields in the `git_index_entry`
* `flags_extended` value that are only used in-memory by libgit2. You
* can use them to interpret the data in the `flags_extended`.
*/
#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)
/* remove in work directory */
#define GIT_IDXENTRY_CONFLICTED (1 << 7)
#define GIT_IDXENTRY_UNPACKED (1 << 8)
#define GIT_IDXENTRY_NEW_SKIP_WORKTREE (1 << 9)
/** Capabilities of system that affect index actions. */
enum
{
typedef
enum
{
GIT_INDEXCAP_IGNORE_CASE
=
1
,
GIT_INDEXCAP_NO_FILEMODE
=
2
,
GIT_INDEXCAP_NO_SYMLINKS
=
4
,
GIT_INDEXCAP_FROM_OWNER
=
~
0u
};
}
git_indexcap_t
;
/** @name Index File Functions
*
...
...
@@ -267,11 +298,9 @@ GIT_EXTERN(void) git_index_clear(git_index *index);
/**
* Get a pointer to one of the entries in the index
*
* The values of this entry can be modified (except the path)
* and the changes will be written back to disk on the next
* write() call.
*
* The entry should not be freed by the caller.
* The entry is not modifiable and should not be freed. Because the
* `git_index_entry` struct is a publicly defined struct, you should
* be able to make your own permanent copy of the data if necessary.
*
* @param index an existing index object
* @param n the position of the entry
...
...
@@ -283,11 +312,9 @@ GIT_EXTERN(const git_index_entry *) git_index_get_byindex(
/**
* Get a pointer to one of the entries in the index
*
* The values of this entry can be modified (except the path)
* and the changes will be written back to disk on the next
* write() call.
*
* The entry should not be freed by the caller.
* The entry is not modifiable and should not be freed. Because the
* `git_index_entry` struct is a publicly defined struct, you should
* be able to make your own permanent copy of the data if necessary.
*
* @param index an existing index object
* @param path path to search
...
...
@@ -337,8 +364,7 @@ GIT_EXTERN(int) git_index_add(git_index *index, const git_index_entry *source_en
/**
* Return the stage number from a git index entry
*
* This entry is calculated from the entry's flag
* attribute like this:
* This entry is calculated from the entry's flag attribute like this:
*
* (entry->flags & GIT_IDXENTRY_STAGEMASK) >> GIT_IDXENTRY_STAGESHIFT
*
...
...
@@ -429,7 +455,7 @@ GIT_EXTERN(int) git_index_find(size_t *at_pos, git_index *index, const char *pat
* @return 0 or an error code
*/
GIT_EXTERN
(
int
)
git_index_conflict_add
(
git_index
*
index
,
git_index
*
index
,
const
git_index_entry
*
ancestor_entry
,
const
git_index_entry
*
our_entry
,
const
git_index_entry
*
their_entry
);
...
...
@@ -447,7 +473,12 @@ GIT_EXTERN(int) git_index_conflict_add(
* @param index an existing index object
* @param path path to search
*/
GIT_EXTERN
(
int
)
git_index_conflict_get
(
git_index_entry
**
ancestor_out
,
git_index_entry
**
our_out
,
git_index_entry
**
their_out
,
git_index
*
index
,
const
char
*
path
);
GIT_EXTERN
(
int
)
git_index_conflict_get
(
git_index_entry
**
ancestor_out
,
git_index_entry
**
our_out
,
git_index_entry
**
their_out
,
git_index
*
index
,
const
char
*
path
);
/**
* Removes the index entries that represent a conflict of a single file.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment