diff: move show_interdiff() from its own file to diff-lib
show_interdiff() is a relatively small function and not likely to grow larger or more complicated. Rather than dedicating an entire source file to it, relocate it to diff-lib.c which houses other "take two things and compare them" functions meant to be re-used but not so low-level as to reside in the core diff implementation. Signed-off-by: Eric Sunshine <sunshine@sunshineco.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Eric Sunshine committed
Sep 8, 2020 at 03:16 UTC
cdffbdc217aba8a39d786a642d1376a5a605adec
7 files changed
+26
-39
Makefile
-1
@@ -883,7 +883,6 @@ LIB_OBJS += hashmap.o
883
LIB_OBJS += help.o
884
LIB_OBJS += hex.o
885
LIB_OBJS += ident.o
886
-LIB_OBJS += interdiff.o
886
LIB_OBJS += json-writer.o
887
LIB_OBJS += kwset.o
888
LIB_OBJS += levenshtein.o
builtin/log.c
-1
@@ -33,7 +33,6 @@
33
#include "commit-slab.h"
34
#include "repository.h"
35
#include "commit-reach.h"
36
-#include "interdiff.h"
36
#include "range-diff.h"
37
38
#define MAIL_DEFAULT_WRAP 72
diff-lib.c
+24
@@ -571,3 +571,27 @@ int index_differs_from(struct repository *r,
571
object_array_clear(&rev.pending);
572
return (rev.diffopt.flags.has_changes != 0);
573
}
574
+
575
+static struct strbuf *idiff_prefix_cb(struct diff_options *opt, void *data)
576
+{
577
+ return data;
578
+}
579
+
580
+void show_interdiff(struct rev_info *rev, int indent)
581
+{
582
+ struct diff_options opts;
583
+ struct strbuf prefix = STRBUF_INIT;
584
+
585
+ memcpy(&opts, &rev->diffopt, sizeof(opts));
586
+ opts.output_format = DIFF_FORMAT_PATCH;
587
+ opts.output_prefix = idiff_prefix_cb;
588
+ strbuf_addchars(&prefix, ' ', indent);
589
+ opts.output_prefix_data = &prefix;
590
+ diff_setup_done(&opts);
591
+
592
+ diff_tree_oid(rev->idiff_oid1, rev->idiff_oid2, "", &opts);
593
+ diffcore_std(&opts);
594
+ diff_flush(&opts);
595
+
596
+ strbuf_release(&prefix);
597
+}
diff.h
+2
@@ -600,6 +600,8 @@ int index_differs_from(struct repository *r, const char *def,
600
const struct diff_flags *flags,
601
int ita_invisible_in_index);
602
603
+void show_interdiff(struct rev_info *, int indent);
604
+
605
/*
606
* Fill the contents of the filespec "df", respecting any textconv defined by
607
* its userdiff driver. The "driver" parameter must come from a
interdiff.c
deleted
-28
@@ -1,28 +0,0 @@
1
-#include "cache.h"
2
-#include "commit.h"
3
-#include "revision.h"
4
-#include "interdiff.h"
5
-
6
-static struct strbuf *idiff_prefix_cb(struct diff_options *opt, void *data)
7
-{
8
- return data;
9
-}
10
-
11
-void show_interdiff(struct rev_info *rev, int indent)
12
-{
13
- struct diff_options opts;
14
- struct strbuf prefix = STRBUF_INIT;
15
-
16
- memcpy(&opts, &rev->diffopt, sizeof(opts));
17
- opts.output_format = DIFF_FORMAT_PATCH;
18
- opts.output_prefix = idiff_prefix_cb;
19
- strbuf_addchars(&prefix, ' ', indent);
20
- opts.output_prefix_data = &prefix;
21
- diff_setup_done(&opts);
22
-
23
- diff_tree_oid(rev->idiff_oid1, rev->idiff_oid2, "", &opts);
24
- diffcore_std(&opts);
25
- diff_flush(&opts);
26
-
27
- strbuf_release(&prefix);
28
-}
interdiff.h
deleted
-8
@@ -1,8 +0,0 @@
1
-#ifndef INTERDIFF_H
2
-#define INTERDIFF_H
3
-
4
-struct rev_info;
5
-
6
-void show_interdiff(struct rev_info *, int indent);
7
-
8
-#endif
log-tree.c
-1
@@ -15,7 +15,6 @@
15
#include "sequencer.h"
16
#include "line-log.h"
17
#include "help.h"
18
-#include "interdiff.h"
18
#include "range-diff.h"
19
20
static struct decoration name_decoration = { "object names" };