summaryrefslogtreecommitdiff
path: root/include/git2
diff options
context:
space:
mode:
authorRussell Belfer <rb@github.com>2013-11-15 14:02:54 -0800
committerRussell Belfer <rb@github.com>2014-04-21 10:34:33 -0700
commit044afa4172ee46acf55f943eb9ea1210017b76d3 (patch)
tree1d48802e25f5ea148640ba746a2e230ef551a1ea /include/git2
parent28750a7d98ce5e23bac5c1d119109ded8e8aab73 (diff)
downloadlibgit2-rb/commit-modified-file.tar.gz
Add git_diff_commit and last-changed examplerb/commit-modified-file
This adds a new diff API `git_diff_commit` which makes it easy to generate a `git_diff` object that represents the changes in a given commit. It follows the core Git rules for considering changes in a merge commit - i.e. if a file has an exact match in any parent of the commit, then the file is considered unmodified by the merge. This also adds a new example program "last-changed" which takes a list of filenames and for each one displays the SHA of the last commit that changed that file.
Diffstat (limited to 'include/git2')
-rw-r--r--include/git2/diff.h19
1 files changed, 19 insertions, 0 deletions
diff --git a/include/git2/diff.h b/include/git2/diff.h
index a0cfbc918..450fc3c79 100644
--- a/include/git2/diff.h
+++ b/include/git2/diff.h
@@ -775,6 +775,25 @@ GIT_EXTERN(int) git_diff_tree_to_workdir_with_index(
const git_diff_options *opts); /**< can be NULL for defaults */
/**
+ * Create a diff of the changes between a commit and its parent(s).
+ *
+ * This generates a diff list between a commit and its parents. For a
+ * non-merge commit, this is simply a shortcut for `git_diff_tree_to_tree`
+ * between the commit tree and the parent tree. For a parent-less commit,
+ * this will generate a diff with the content of the commit tree. For a
+ * merge commit, this generates a diff that contains only files that do
+ * not match any of the parents' trees.
+ *
+ * @param diff A pointer to a git_diff pointer that will be allocated.
+ * @param commit A git_commit object to diff from
+ * @param opts Structure with options to influence diff or NULL for defaults.
+ */
+GIT_EXTERN(int) git_diff_commit(
+ git_diff **diff,
+ git_commit *commit,
+ const git_diff_options *opts); /**< can be NULL for defaults */
+
+/**
* Merge one diff into another.
*
* This merges items from the "from" list into the "onto" list. The