Skip to content

Commit cdffbdc

Browse files
sunshinecogitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 3a238e5 commit cdffbdc

File tree

7 files changed

+26
-39
lines changed

7 files changed

+26
-39
lines changed

Makefile

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -883,7 +883,6 @@ LIB_OBJS += hashmap.o
883883
LIB_OBJS += help.o
884884
LIB_OBJS += hex.o
885885
LIB_OBJS += ident.o
886-
LIB_OBJS += interdiff.o
887886
LIB_OBJS += json-writer.o
888887
LIB_OBJS += kwset.o
889888
LIB_OBJS += levenshtein.o

builtin/log.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@
3333
#include "commit-slab.h"
3434
#include "repository.h"
3535
#include "commit-reach.h"
36-
#include "interdiff.h"
3736
#include "range-diff.h"
3837

3938
#define MAIL_DEFAULT_WRAP 72

diff-lib.c

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -571,3 +571,27 @@ int index_differs_from(struct repository *r,
571571
object_array_clear(&rev.pending);
572572
return (rev.diffopt.flags.has_changes != 0);
573573
}
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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -600,6 +600,8 @@ int index_differs_from(struct repository *r, const char *def,
600600
const struct diff_flags *flags,
601601
int ita_invisible_in_index);
602602

603+
void show_interdiff(struct rev_info *, int indent);
604+
603605
/*
604606
* Fill the contents of the filespec "df", respecting any textconv defined by
605607
* its userdiff driver. The "driver" parameter must come from a

interdiff.c

Lines changed: 0 additions & 28 deletions
This file was deleted.

interdiff.h

Lines changed: 0 additions & 8 deletions
This file was deleted.

log-tree.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
#include "sequencer.h"
1616
#include "line-log.h"
1717
#include "help.h"
18-
#include "interdiff.h"
1918
#include "range-diff.h"
2019

2120
static struct decoration name_decoration = { "object names" };

0 commit comments

Comments
 (0)