mirror of
https://git.proxmox.com/git/libgit2
synced 2025-06-19 22:44:42 +00:00
Introduce git_diff_to_buf
Like `git_patch_to_buf`, provide a simple helper method that can print an entire diff directory to a `git_buf`.
This commit is contained in:
parent
7166bb1665
commit
728274904f
@ -1054,6 +1054,21 @@ GIT_EXTERN(int) git_diff_print(
|
|||||||
git_diff_line_cb print_cb,
|
git_diff_line_cb print_cb,
|
||||||
void *payload);
|
void *payload);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Produce the complete formatted text output from a diff into a
|
||||||
|
* buffer.
|
||||||
|
*
|
||||||
|
* @param out A pointer to a user-allocated git_buf that will
|
||||||
|
* contain the diff text
|
||||||
|
* @param diff A git_diff generated by one of the above functions.
|
||||||
|
* @param format A git_diff_format_t value to pick the text format.
|
||||||
|
* @return 0 on success or error code
|
||||||
|
*/
|
||||||
|
GIT_EXTERN(int) git_diff_to_buf(
|
||||||
|
git_buf *out,
|
||||||
|
git_diff *diff,
|
||||||
|
git_diff_format_t format);
|
||||||
|
|
||||||
/**@}*/
|
/**@}*/
|
||||||
|
|
||||||
|
|
||||||
|
@ -714,6 +714,15 @@ int git_diff_print_callback__to_file_handle(
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* print a git_diff to a git_buf */
|
||||||
|
int git_diff_to_buf(git_buf *out, git_diff *diff, git_diff_format_t format)
|
||||||
|
{
|
||||||
|
assert(out && diff);
|
||||||
|
git_buf_sanitize(out);
|
||||||
|
return git_diff_print(
|
||||||
|
diff, format, git_diff_print_callback__to_buf, out);
|
||||||
|
}
|
||||||
|
|
||||||
/* print a git_patch to an output callback */
|
/* print a git_patch to an output callback */
|
||||||
int git_patch_print(
|
int git_patch_print(
|
||||||
git_patch *patch,
|
git_patch *patch,
|
||||||
|
Loading…
Reference in New Issue
Block a user