diff options
author | Carlos Martín Nieto <cmn@dwim.me> | 2015-01-20 20:13:34 +0100 |
---|---|---|
committer | Carlos Martín Nieto <cmn@dwim.me> | 2015-01-20 20:13:34 +0100 |
commit | 2136240dbd35cf2b4308f92008a24c0c36665811 (patch) | |
tree | d605b760265da0dad8a6acd818ea1592cbc62dbd | |
parent | d5712ed2b33a18a4f9417d112bda7813c0570caa (diff) | |
parent | 147d86fc697d6c88be329c2ce4845a2b135dcf61 (diff) | |
download | libgit2-2136240dbd35cf2b4308f92008a24c0c36665811.tar.gz |
Merge pull request #2828 from ethomson/treediff_dont_patch
diff: only compute patches when requested
-rw-r--r-- | src/diff_patch.c | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/src/diff_patch.c b/src/diff_patch.c index 317dbeabb..3129d06e1 100644 --- a/src/diff_patch.c +++ b/src/diff_patch.c @@ -284,11 +284,12 @@ int git_diff_foreach( if (git_diff_delta__should_skip(&diff->opts, patch.delta)) continue; - if ((error = diff_patch_init_from_diff(&patch, diff, idx)) < 0) - break; - - if (!(error = diff_patch_invoke_file_callback(&patch, &xo.output))) - error = diff_patch_generate(&patch, &xo.output); + if ((error = diff_patch_invoke_file_callback(&patch, &xo.output)) == 0) { + if (hunk_cb || data_cb) { + if ((error = diff_patch_init_from_diff(&patch, diff, idx)) == 0) + error = diff_patch_generate(&patch, &xo.output); + } + } git_patch_free(&patch); |