summaryrefslogtreecommitdiff
path: root/include/git2
diff options
context:
space:
mode:
authorRussell Belfer <rb@github.com>2012-10-17 14:14:51 -0700
committerRussell Belfer <rb@github.com>2012-10-17 14:14:51 -0700
commit4c47a8bcfe03c42096b74d4af06ab95fb95fd211 (patch)
treec79eb8290ef110faff68ae2d5746455095508e1e /include/git2
parent6012e86839bbdfc98085662c22f8e34b6f6abefb (diff)
parent52a61bb8047f431bf363bd9327d0f34884437c83 (diff)
downloadlibgit2-4c47a8bcfe03c42096b74d4af06ab95fb95fd211.tar.gz
Merge pull request #968 from arrbee/diff-support-typechange
Support TYPECHANGE records in status and adjust checkout accordingly
Diffstat (limited to 'include/git2')
-rw-r--r--include/git2/checkout.h45
-rw-r--r--include/git2/diff.h64
-rw-r--r--include/git2/status.h23
-rw-r--r--include/git2/tree.h4
4 files changed, 93 insertions, 43 deletions
diff --git a/include/git2/checkout.h b/include/git2/checkout.h
index a4d0a0cef..0bac5690a 100644
--- a/include/git2/checkout.h
+++ b/include/git2/checkout.h
@@ -21,22 +21,39 @@
*/
GIT_BEGIN_DECL
-enum {
- GIT_CHECKOUT_DEFAULT = (1 << 0),
- GIT_CHECKOUT_OVERWRITE_MODIFIED = (1 << 1),
- GIT_CHECKOUT_CREATE_MISSING = (1 << 2),
- GIT_CHECKOUT_REMOVE_UNTRACKED = (1 << 3),
-};
+/**
+ * Checkout behavior flags
+ *
+ * These flags control what checkout does with files. Pass in a
+ * combination of these values OR'ed together.
+ */
+typedef enum {
+ /** Checkout does not update any files in the working directory. */
+ GIT_CHECKOUT_DEFAULT = (1 << 0),
+
+ /** When a file exists and is modified, replace it with new version. */
+ GIT_CHECKOUT_OVERWRITE_MODIFIED = (1 << 1),
+
+ /** When a file does not exist in the working directory, create it. */
+ GIT_CHECKOUT_CREATE_MISSING = (1 << 2),
-/* Use zeros to indicate default settings */
+ /** If an untracked file in found in the working dir, delete it. */
+ GIT_CHECKOUT_REMOVE_UNTRACKED = (1 << 3),
+} git_checkout_strategy_t;
+
+/**
+ * Checkout options structure
+ *
+ * Use zeros to indicate default settings.
+ */
typedef struct git_checkout_opts {
- unsigned int checkout_strategy; /* default: GIT_CHECKOUT_DEFAULT */
- int disable_filters;
- int dir_mode; /* default is 0755 */
- int file_mode; /* default is 0644 */
- int file_open_flags; /* default is O_CREAT | O_TRUNC | O_WRONLY */
+ unsigned int checkout_strategy; /** default: GIT_CHECKOUT_DEFAULT */
+ int disable_filters; /** don't apply filters like CRLF conversion */
+ int dir_mode; /** default is 0755 */
+ int file_mode; /** default is 0644 or 0755 as dictated by blob */
+ int file_open_flags; /** default is O_CREAT | O_TRUNC | O_WRONLY */
- /* Optional callback to notify the consumer of files that
+ /** Optional callback to notify the consumer of files that
* haven't be checked out because a modified version of them
* exist in the working directory.
*
@@ -51,7 +68,7 @@ typedef struct git_checkout_opts {
void *notify_payload;
- /* when not NULL, arrays of fnmatch pattern specifying
+ /** When not NULL, array of fnmatch patterns specifying
* which paths should be taken into account
*/
git_strarray paths;
diff --git a/include/git2/diff.h b/include/git2/diff.h
index 121c40307..1932db029 100644
--- a/include/git2/diff.h
+++ b/include/git2/diff.h
@@ -34,21 +34,58 @@ GIT_BEGIN_DECL
* in via the `flags` value in the `git_diff_options`.
*/
enum {
+ /** Normal diff, the default */
GIT_DIFF_NORMAL = 0,
+ /** Reverse the sides of the diff */
GIT_DIFF_REVERSE = (1 << 0),
+ /** Treat all files as text, disabling binary attributes & detection */
GIT_DIFF_FORCE_TEXT = (1 << 1),
+ /** Ignore all whitespace */
GIT_DIFF_IGNORE_WHITESPACE = (1 << 2),
+ /** Ignore changes in amount of whitespace */
GIT_DIFF_IGNORE_WHITESPACE_CHANGE = (1 << 3),
+ /** Ignore whitespace at end of line */
GIT_DIFF_IGNORE_WHITESPACE_EOL = (1 << 4),
+ /** Exclude submodules from the diff completely */
GIT_DIFF_IGNORE_SUBMODULES = (1 << 5),
+ /** Use the "patience diff" algorithm (currently unimplemented) */
GIT_DIFF_PATIENCE = (1 << 6),
+ /** Include ignored files in the diff list */
GIT_DIFF_INCLUDE_IGNORED = (1 << 7),
+ /** Include untracked files in the diff list */
GIT_DIFF_INCLUDE_UNTRACKED = (1 << 8),
+ /** Include unmodified files in the diff list */
GIT_DIFF_INCLUDE_UNMODIFIED = (1 << 9),
+ /** Even with the GIT_DIFF_INCLUDE_UNTRACKED flag, when an untracked
+ * directory is found, only a single entry for the directory is added
+ * to the diff list; with this flag, all files under the directory will
+ * be included, too.
+ */
GIT_DIFF_RECURSE_UNTRACKED_DIRS = (1 << 10),
+ /** If the pathspec is set in the diff options, this flags means to
+ * apply it as an exact match instead of as an fnmatch pattern.
+ */
GIT_DIFF_DISABLE_PATHSPEC_MATCH = (1 << 11),
+ /** Use case insensitive filename comparisons */
GIT_DIFF_DELTAS_ARE_ICASE = (1 << 12),
+ /** When generating patch text, include the content of untracked files */
GIT_DIFF_INCLUDE_UNTRACKED_CONTENT = (1 << 13),
+ /** Disable updating of the `binary` flag in delta records. This is
+ * useful when iterating over a diff if you don't need hunk and data
+ * callbacks and want to avoid having to load file completely.
+ */
+ GIT_DIFF_SKIP_BINARY_CHECK = (1 << 14),
+ /** Normally, a type change between files will be converted into a
+ * DELETED record for the old and an ADDED record for the new; this
+ * options enabled the generation of TYPECHANGE delta records.
+ */
+ GIT_DIFF_INCLUDE_TYPECHANGE = (1 << 15),
+ /** Even with GIT_DIFF_INCLUDE_TYPECHANGE, blob->tree changes still
+ * generally show as a DELETED blob. This flag tries to correctly
+ * label blob->tree transitions as TYPECHANGE records with new_file's
+ * mode set to tree. Note: the tree SHA will not be available.
+ */
+ GIT_DIFF_INCLUDE_TYPECHANGE_TREES = (1 << 16),
};
/**
@@ -85,24 +122,16 @@ typedef struct git_diff_list git_diff_list;
* Flags that can be set for the file on side of a diff.
*
* Most of the flags are just for internal consumption by libgit2,
- * but some of them may be interesting to external users. They are:
- *
- * - VALID_OID - the `oid` value is computed and correct
- * - FREE_PATH - the `path` string is separated allocated memory
- * - BINARY - this file should be considered binary data
- * - NOT_BINARY - this file should be considered text data
- * - FREE_DATA - the internal file data is kept in allocated memory
- * - UNMAP_DATA - the internal file data is kept in mmap'ed memory
- * - NO_DATA - this side of the diff should not be loaded
+ * but some of them may be interesting to external users.
*/
enum {
- GIT_DIFF_FILE_VALID_OID = (1 << 0),
- GIT_DIFF_FILE_FREE_PATH = (1 << 1),
- GIT_DIFF_FILE_BINARY = (1 << 2),
- GIT_DIFF_FILE_NOT_BINARY = (1 << 3),
- GIT_DIFF_FILE_FREE_DATA = (1 << 4),
- GIT_DIFF_FILE_UNMAP_DATA = (1 << 5),
- GIT_DIFF_FILE_NO_DATA = (1 << 6),
+ GIT_DIFF_FILE_VALID_OID = (1 << 0), /** `oid` value is known correct */
+ GIT_DIFF_FILE_FREE_PATH = (1 << 1), /** `path` is allocated memory */
+ GIT_DIFF_FILE_BINARY = (1 << 2), /** should be considered binary data */
+ GIT_DIFF_FILE_NOT_BINARY = (1 << 3), /** should be considered text data */
+ GIT_DIFF_FILE_FREE_DATA = (1 << 4), /** internal file data is allocated */
+ GIT_DIFF_FILE_UNMAP_DATA = (1 << 5), /** internal file data is mmap'ed */
+ GIT_DIFF_FILE_NO_DATA = (1 << 6), /** file data should not be loaded */
};
/**
@@ -116,7 +145,8 @@ typedef enum {
GIT_DELTA_RENAMED = 4,
GIT_DELTA_COPIED = 5,
GIT_DELTA_IGNORED = 6,
- GIT_DELTA_UNTRACKED = 7
+ GIT_DELTA_UNTRACKED = 7,
+ GIT_DELTA_TYPECHANGE = 8,
} git_delta_t;
/**
diff --git a/include/git2/status.h b/include/git2/status.h
index 0dd98596e..979e6e4ff 100644
--- a/include/git2/status.h
+++ b/include/git2/status.h
@@ -19,19 +19,22 @@
*/
GIT_BEGIN_DECL
-enum {
- GIT_STATUS_CURRENT = 0,
+typedef enum {
+ GIT_STATUS_CURRENT = 0,
- GIT_STATUS_INDEX_NEW = (1 << 0),
- GIT_STATUS_INDEX_MODIFIED = (1 << 1),
- GIT_STATUS_INDEX_DELETED = (1 << 2),
+ GIT_STATUS_INDEX_NEW = (1u << 0),
+ GIT_STATUS_INDEX_MODIFIED = (1u << 1),
+ GIT_STATUS_INDEX_DELETED = (1u << 2),
+ GIT_STATUS_INDEX_RENAMED = (1u << 3),
+ GIT_STATUS_INDEX_TYPECHANGE = (1u << 4),
- GIT_STATUS_WT_NEW = (1 << 3),
- GIT_STATUS_WT_MODIFIED = (1 << 4),
- GIT_STATUS_WT_DELETED = (1 << 5),
+ GIT_STATUS_WT_NEW = (1u << 7),
+ GIT_STATUS_WT_MODIFIED = (1u << 8),
+ GIT_STATUS_WT_DELETED = (1u << 9),
+ GIT_STATUS_WT_TYPECHANGE = (1u << 10),
- GIT_STATUS_IGNORED = (1 << 6),
-};
+ GIT_STATUS_IGNORED = (1u << 14),
+} git_status_t;
/**
* Gather file statuses and run a callback for each one.
diff --git a/include/git2/tree.h b/include/git2/tree.h
index e5261417c..2ee1f4afa 100644
--- a/include/git2/tree.h
+++ b/include/git2/tree.h
@@ -100,7 +100,7 @@ GIT_EXTERN(git_tree_entry *) git_tree_entry_dup(const git_tree_entry *entry);
* @param tree a previously loaded tree.
* @return object identity for the tree.
*/
-GIT_EXTERN(const git_oid *) git_tree_id(git_tree *tree);
+GIT_EXTERN(const git_oid *) git_tree_id(const git_tree *tree);
/**
* Get the number of entries listed in a tree
@@ -108,7 +108,7 @@ GIT_EXTERN(const git_oid *) git_tree_id(git_tree *tree);
* @param tree a previously loaded tree.
* @return the number of entries in the tree
*/
-GIT_EXTERN(unsigned int) git_tree_entrycount(git_tree *tree);
+GIT_EXTERN(unsigned int) git_tree_entrycount(const git_tree *tree);
/**
* Lookup a tree entry by its filename