summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorDamien PROFETA <damien.profeta@amadeus.com>2015-02-05 11:40:16 +0100
committerDamien PROFETA <damien.profeta@amadeus.com>2015-02-25 10:24:13 +0100
commita275fbc0f7773e6c5888ae7ce766e7a9eb3a5e65 (patch)
tree34fced6b3b392f03f12cadc625fc4fd74f941043 /include
parent366e53d3da72805a3db1a1e77d4666416fcb5a93 (diff)
downloadlibgit2-a275fbc0f7773e6c5888ae7ce766e7a9eb3a5e65.tar.gz
Add API to add a memory buffer to an index
git_index_add_frombuffer enables now to store a memory buffer in the odb and to store an entry in the index directly if the index is attached to a repository.
Diffstat (limited to 'include')
-rw-r--r--include/git2/index.h32
1 files changed, 32 insertions, 0 deletions
diff --git a/include/git2/index.h b/include/git2/index.h
index 4382c2f9e..1feeb6fb1 100644
--- a/include/git2/index.h
+++ b/include/git2/index.h
@@ -457,6 +457,38 @@ GIT_EXTERN(int) git_index_entry_stage(const git_index_entry *entry);
GIT_EXTERN(int) git_index_add_bypath(git_index *index, const char *path);
/**
+ * Add or update an index entry from a buffer in memory
+ *
+ * This method will create a blob in the repository that owns the
+ * index and then add the index entry to the index. The `path` of the
+ * entry represents the position of the blob relative to the
+ * repository's root folder.
+ *
+ * If a previous index entry exists that has the same path as the
+ * given 'entry', it will be replaced. Otherwise, the 'entry' will be
+ * added. The `id` and the `file_size` of the 'entry' are updated with the
+ * real value of the blob.
+ *
+ * This forces the file to be added to the index, not looking
+ * at gitignore rules. Those rules can be evaluated through
+ * the git_status APIs (in status.h) before calling this.
+ *
+ * If this file currently is the result of a merge conflict, this
+ * file will no longer be marked as conflicting. The data about
+ * the conflict will be moved to the "resolve undo" (REUC) section.
+ *
+ * @param index an existing index object
+ * @param entry filename to add
+ * @param buffer data to be written into the blob
+ * @param len length of the data
+ * @return 0 or an error code
+ */
+GIT_EXTERN(int) git_index_add_frombuffer(
+ git_index *index,
+ git_index_entry *entry,
+ const void *buffer, size_t len);
+
+/**
* Remove an index entry corresponding to a file on disk
*
* The file `path` must be relative to the repository's