diff options
| author | lye <lye@> | 2014-02-20 00:25:30 -0600 |
|---|---|---|
| committer | lye <lye@> | 2014-02-20 00:29:03 -0600 |
| commit | bc80beb8432091bdf1190ad6b803060324802685 (patch) | |
| tree | 85b6032da7874910ef10981e9fb2e87430169f00 /wrapper.c | |
| parent | 66e1c476199ebcd3e304659992233132c5a52c6c (diff) | |
Add partial diff/patch functionality.
This commit adds barebones capacity to generate diffs from two trees and
to emit those as git-style diffs (via `Patch.String`), or to enumerate
the files/hunks/lines in the diff to emit the data yourself.
The walk functions have been implemented in the same manner as the Odb
walking methods.
Note that not all of the functionality is implemented for either the
`git_diff_*` nor the `git_patch_*` functions, and there are unexposed
constants which would likely be useful to add.
Diffstat (limited to 'wrapper.c')
| -rw-r--r-- | wrapper.c | 21 |
1 files changed, 21 insertions, 0 deletions
@@ -24,4 +24,25 @@ int _go_git_odb_foreach(git_odb *db, void *payload) { return git_odb_foreach(db, (git_odb_foreach_cb)&odbForEachCb, payload); } + +int _go_git_diff_foreach(git_diff *diff, int eachFile, int eachHunk, int eachLine, void *payload) +{ + git_diff_file_cb fcb = NULL; + git_diff_hunk_cb hcb = NULL; + git_diff_line_cb lcb = NULL; + + if (eachFile) { + fcb = (git_diff_file_cb)&diffForEachFileCb; + } + + if (eachHunk) { + hcb = (git_diff_hunk_cb)&diffForEachHunkCb; + } + + if (eachLine) { + lcb = (git_diff_line_cb)&diffForEachLineCb; + } + + return git_diff_foreach(diff, fcb, hcb, lcb, payload); +} /* EOF */ |
