summaryrefslogtreecommitdiff
path: root/diff.h
diff options
context:
space:
mode:
authorDaniel Ferreira <bnmvco@gmail.com>2019-11-13 12:40:58 +0000
committerJunio C Hamano <gitster@pobox.com>2019-11-14 11:10:04 +0900
commite4cb659ebdd7c21976f9088226cbcc96acaa1dff (patch)
treea32386e21485a6ced3c2475748eabb6f207d4cc7 /diff.h
parentf83dff60a7880f1abfc3dc3c6b8e2972c4889da5 (diff)
downloadgit-e4cb659ebdd7c21976f9088226cbcc96acaa1dff.tar.gz
diff: export diffstat interface
Make the diffstat interface (namely, the diffstat_t struct and compute_diffstat) no longer be internal to diff.c and allow it to be used by other parts of git. This is helpful for code that may want to easily extract information from files using the diff machinery, while flushing it differently from how the show_* functions used by diff_flush() do it. One example is the builtin implementation of git-add--interactive's status. Signed-off-by: Daniel Ferreira <bnmvco@gmail.com> Signed-off-by: Slavica Đukić <slawica92@hotmail.com> Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'diff.h')
-rw-r--r--diff.h20
1 files changed, 20 insertions, 0 deletions
diff --git a/diff.h b/diff.h
index 7f8f024feb..d986ddc3b5 100644
--- a/diff.h
+++ b/diff.h
@@ -245,6 +245,22 @@ void diff_emit_submodule_error(struct diff_options *o, const char *err);
void diff_emit_submodule_pipethrough(struct diff_options *o,
const char *line, int len);
+struct diffstat_t {
+ int nr;
+ int alloc;
+ struct diffstat_file {
+ char *from_name;
+ char *name;
+ char *print_name;
+ const char *comments;
+ unsigned is_unmerged:1;
+ unsigned is_binary:1;
+ unsigned is_renamed:1;
+ unsigned is_interesting:1;
+ uintmax_t added, deleted;
+ } **files;
+};
+
enum color_diff {
DIFF_RESET = 0,
DIFF_CONTEXT = 1,
@@ -334,6 +350,10 @@ void diff_change(struct diff_options *,
struct diff_filepair *diff_unmerge(struct diff_options *, const char *path);
+void compute_diffstat(struct diff_options *options, struct diffstat_t *diffstat,
+ struct diff_queue_struct *q);
+void free_diffstat_info(struct diffstat_t *diffstat);
+
#define DIFF_SETUP_REVERSE 1
#define DIFF_SETUP_USE_SIZE_CACHE 4