Commit 6b5ee137 authored by Junio C Hamano's avatar Junio C Hamano

Diff clean-up.

This is a long overdue clean-up to the code for parsing and passing
diff options.  It also tightens some constness issues.
Signed-off-by: default avatarJunio C Hamano <[email protected]>
parent dbc37438
......@@ -143,9 +143,9 @@ extern char *get_graft_file(void);
#define ALTERNATE_DB_ENVIRONMENT "GIT_ALTERNATE_OBJECT_DIRECTORIES"
extern const char **get_pathspec(const char *prefix, char **pathspec);
extern const char **get_pathspec(const char *prefix, const char **pathspec);
extern const char *setup_git_directory(void);
extern char *prefix_path(const char *prefix, int len, char *path);
extern const char *prefix_path(const char *prefix, int len, const char *path);
#define alloc_nr(x) (((x)+16)*3/2)
......@@ -158,7 +158,7 @@ extern int cache_name_pos(const char *name, int namelen);
#define ADD_CACHE_SKIP_DFCHECK 4 /* Ok to skip DF conflict checks */
extern int add_cache_entry(struct cache_entry *ce, int option);
extern int remove_cache_entry_at(int pos);
extern int remove_file_from_cache(char *path);
extern int remove_file_from_cache(const char *path);
extern int ce_same_name(struct cache_entry *a, struct cache_entry *b);
extern int ce_match_stat(struct cache_entry *ce, struct stat *st);
extern int ce_modified(struct cache_entry *ce, struct stat *st);
......
......@@ -11,87 +11,56 @@ static const char diff_files_usage[] =
"[<common diff options>] [<path>...]"
COMMON_DIFF_OPTIONS_HELP;
static int diff_output_format = DIFF_FORMAT_RAW;
static int diff_line_termination = '\n';
static int detect_rename = 0;
static int find_copies_harder = 0;
static int diff_setup_opt = 0;
static int diff_score_opt = 0;
static const char *pickaxe = NULL;
static int pickaxe_opts = 0;
static int diff_break_opt = -1;
static const char *orderfile = NULL;
static const char *diff_filter = NULL;
static struct diff_options diff_options;
static int silent = 0;
static void show_unmerge(const char *path)
{
diff_unmerge(path);
diff_unmerge(&diff_options, path);
}
static void show_file(int pfx, struct cache_entry *ce)
{
diff_addremove(pfx, ntohl(ce->ce_mode), ce->sha1, ce->name, NULL);
diff_addremove(&diff_options, pfx, ntohl(ce->ce_mode),
ce->sha1, ce->name, NULL);
}
static void show_modified(int oldmode, int mode,
const unsigned char *old_sha1, const unsigned char *sha1,
char *path)
{
diff_change(oldmode, mode, old_sha1, sha1, path, NULL);
diff_change(&diff_options, oldmode, mode, old_sha1, sha1, path, NULL);
}
int main(int argc, char **argv)
int main(int argc, const char **argv)
{
static const unsigned char null_sha1[20] = { 0, };
const char **pathspec;
const char *prefix = setup_git_directory();
int entries, i;
diff_setup(&diff_options);
while (1 < argc && argv[1][0] == '-') {
if (!strcmp(argv[1], "-p") || !strcmp(argv[1], "-u"))
diff_output_format = DIFF_FORMAT_PATCH;
else if (!strcmp(argv[1], "-q"))
if (!strcmp(argv[1], "-q"))
silent = 1;
else if (!strcmp(argv[1], "-r"))
; /* no-op */
else if (!strcmp(argv[1], "-s"))
; /* no-op */
else if (!strcmp(argv[1], "-z"))
diff_line_termination = 0;
else if (!strcmp(argv[1], "--name-only"))
diff_output_format = DIFF_FORMAT_NAME;
else if (!strcmp(argv[1], "-R"))
diff_setup_opt |= DIFF_SETUP_REVERSE;
else if (!strncmp(argv[1], "-S", 2))
pickaxe = argv[1] + 2;
else if (!strncmp(argv[1], "-O", 2))
orderfile = argv[1] + 2;
else if (!strncmp(argv[1], "--diff-filter=", 14))
diff_filter = argv[1] + 14;
else if (!strcmp(argv[1], "--pickaxe-all"))
pickaxe_opts = DIFF_PICKAXE_ALL;
else if (!strncmp(argv[1], "-B", 2)) {
if ((diff_break_opt =
diff_scoreopt_parse(argv[1])) == -1)
else {
int diff_opt_cnt;
diff_opt_cnt = diff_opt_parse(&diff_options,
argv+1, argc-1);
if (diff_opt_cnt < 0)
usage(diff_files_usage);
}
else if (!strncmp(argv[1], "-M", 2)) {
if ((diff_score_opt =
diff_scoreopt_parse(argv[1])) == -1)
usage(diff_files_usage);
detect_rename = DIFF_DETECT_RENAME;
}
else if (!strncmp(argv[1], "-C", 2)) {
if ((diff_score_opt =
diff_scoreopt_parse(argv[1])) == -1)
else if (diff_opt_cnt) {
argv += diff_opt_cnt;
argc -= diff_opt_cnt;
continue;
}
else
usage(diff_files_usage);
detect_rename = DIFF_DETECT_COPY;
}
else if (!strcmp(argv[1], "--find-copies-harder"))
find_copies_harder = 1;
else
usage(diff_files_usage);
argv++; argc--;
}
......@@ -99,7 +68,7 @@ int main(int argc, char **argv)
pathspec = get_pathspec(prefix, argv + 1);
entries = read_cache();
if (find_copies_harder && detect_rename != DIFF_DETECT_COPY)
if (diff_setup_done(&diff_options) < 0)
usage(diff_files_usage);
/* At this point, if argc == 1, then we are doing everything.
......@@ -110,8 +79,6 @@ int main(int argc, char **argv)
exit(1);
}
diff_setup(diff_setup_opt);
for (i = 0; i < entries; i++) {
struct stat st;
unsigned int oldmode;
......@@ -141,18 +108,14 @@ int main(int argc, char **argv)
continue;
}
changed = ce_match_stat(ce, &st);
if (!changed && !find_copies_harder)
if (!changed && !diff_options.find_copies_harder)
continue;
oldmode = ntohl(ce->ce_mode);
show_modified(oldmode, DIFF_FILE_CANON_MODE(st.st_mode),
ce->sha1, (changed ? null_sha1 : ce->sha1),
ce->name);
}
diffcore_std(pathspec,
detect_rename, diff_score_opt,
pickaxe, pickaxe_opts,
diff_break_opt,
orderfile, diff_filter);
diff_flush(diff_output_format, diff_line_termination);
diffcore_std(&diff_options);
diff_flush(&diff_options);
return 0;
}
......@@ -2,26 +2,20 @@
#include "diff.h"
static int cached_only = 0;
static int diff_output_format = DIFF_FORMAT_RAW;
static int diff_line_termination = '\n';
static int match_nonexisting = 0;
static int detect_rename = 0;
static int find_copies_harder = 0;
static int diff_setup_opt = 0;
static int diff_score_opt = 0;
static const char *pickaxe = NULL;
static int pickaxe_opts = 0;
static int diff_break_opt = -1;
static const char *orderfile = NULL;
static const char *diff_filter = NULL;
static struct diff_options diff_options;
/* A file entry went away or appeared */
static void show_file(const char *prefix, struct cache_entry *ce, unsigned char *sha1, unsigned int mode)
static void show_file(const char *prefix,
struct cache_entry *ce,
unsigned char *sha1, unsigned int mode)
{
diff_addremove(prefix[0], ntohl(mode), sha1, ce->name, NULL);
diff_addremove(&diff_options, prefix[0], ntohl(mode),
sha1, ce->name, NULL);
}
static int get_stat_data(struct cache_entry *ce, unsigned char **sha1p, unsigned int *modep)
static int get_stat_data(struct cache_entry *ce,
unsigned char **sha1p, unsigned int *modep)
{
unsigned char *sha1 = ce->sha1;
unsigned int mode = ce->ce_mode;
......@@ -77,13 +71,13 @@ static int show_modified(struct cache_entry *old,
oldmode = old->ce_mode;
if (mode == oldmode && !memcmp(sha1, old->sha1, 20) &&
!find_copies_harder)
!diff_options.find_copies_harder)
return 0;
mode = ntohl(mode);
oldmode = ntohl(oldmode);
diff_change(oldmode, mode,
diff_change(&diff_options, oldmode, mode,
old->sha1, sha1, old->name, NULL);
return 0;
}
......@@ -127,7 +121,7 @@ static int diff_cache(struct cache_entry **ac, int entries, const char **pathspe
break;
/* fallthru */
case 3:
diff_unmerge(ce->name);
diff_unmerge(&diff_options, ce->name);
break;
default:
......@@ -168,7 +162,7 @@ static const char diff_cache_usage[] =
"[<common diff options>] <tree-ish> [<path>...]"
COMMON_DIFF_OPTIONS_HELP;
int main(int argc, char **argv)
int main(int argc, const char **argv)
{
const char *tree_name = NULL;
unsigned char sha1[20];
......@@ -180,8 +174,10 @@ int main(int argc, char **argv)
int allow_options = 1;
int i;
diff_setup(&diff_options);
for (i = 1; i < argc; i++) {
const char *arg = argv[i];
int diff_opt_cnt;
if (!allow_options || *arg != '-') {
if (tree_name)
......@@ -198,60 +194,15 @@ int main(int argc, char **argv)
/* We accept the -r flag just to look like git-diff-tree */
continue;
}
/* We accept the -u flag as a synonym for "-p" */
if (!strcmp(arg, "-p") || !strcmp(arg, "-u")) {
diff_output_format = DIFF_FORMAT_PATCH;
continue;
}
if (!strncmp(arg, "-B", 2)) {
if ((diff_break_opt = diff_scoreopt_parse(arg)) == -1)
usage(diff_cache_usage);
continue;
}
if (!strncmp(arg, "-M", 2)) {
detect_rename = DIFF_DETECT_RENAME;
if ((diff_score_opt = diff_scoreopt_parse(arg)) == -1)
usage(diff_cache_usage);
continue;
}
if (!strncmp(arg, "-C", 2)) {
detect_rename = DIFF_DETECT_COPY;
if ((diff_score_opt = diff_scoreopt_parse(arg)) == -1)
usage(diff_cache_usage);
continue;
}
if (!strcmp(arg, "--find-copies-harder")) {
find_copies_harder = 1;
continue;
}
if (!strcmp(arg, "-z")) {
diff_line_termination = 0;
continue;
}
if (!strcmp(arg, "--name-only")) {
diff_output_format = DIFF_FORMAT_NAME;
continue;
}
if (!strcmp(arg, "-R")) {
diff_setup_opt |= DIFF_SETUP_REVERSE;
continue;
}
if (!strncmp(arg, "-S", 2)) {
pickaxe = arg + 2;
continue;
}
if (!strncmp(arg, "--diff-filter=", 14)) {
diff_filter = arg + 14;
continue;
}
if (!strncmp(arg, "-O", 2)) {
orderfile = arg + 2;
continue;
}
if (!strcmp(arg, "--pickaxe-all")) {
pickaxe_opts = DIFF_PICKAXE_ALL;
diff_opt_cnt = diff_opt_parse(&diff_options, argv + i,
argc - i);
if (diff_opt_cnt < 0)
usage(diff_cache_usage);
else if (diff_opt_cnt) {
i += diff_opt_cnt - 1;
continue;
}
if (!strcmp(arg, "-m")) {
match_nonexisting = 1;
continue;
......@@ -265,7 +216,7 @@ int main(int argc, char **argv)
pathspec = get_pathspec(prefix, argv + i);
if (find_copies_harder && detect_rename != DIFF_DETECT_COPY)
if (diff_setup_done(&diff_options) < 0)
usage(diff_cache_usage);
if (!tree_name || get_sha1(tree_name, sha1))
......@@ -273,9 +224,6 @@ int main(int argc, char **argv)
read_cache();
/* The rest is for paths restriction. */
diff_setup(diff_setup_opt);
mark_merge_entries();
tree = read_object_with_reference(sha1, "tree", &size, NULL);
......@@ -286,11 +234,7 @@ int main(int argc, char **argv)
ret = diff_cache(active_cache, active_nr, pathspec);
diffcore_std(pathspec,
detect_rename, diff_score_opt,
pickaxe, pickaxe_opts,
diff_break_opt,
orderfile, diff_filter);
diff_flush(diff_output_format, diff_line_termination);
diffcore_std(&diff_options);
diff_flush(&diff_options);
return ret;
}
......@@ -5,17 +5,7 @@
#include "cache.h"
#include "diff.h"
static int diff_output_format = DIFF_FORMAT_RAW;
static int diff_line_termination = '\n';
static int detect_rename = 0;
static int find_copies_harder = 0;
static int diff_setup_opt = 0;
static int diff_score_opt = 0;
static const char *pickaxe = NULL;
static int pickaxe_opts = 0;
static int diff_break_opt = -1;
static const char *orderfile = NULL;
static const char *diff_filter = NULL;
static struct diff_options diff_options;
static const char diff_stages_usage[] =
"git-diff-stages [<common diff options>] <stage1> <stage2> [<path>...]"
......@@ -47,15 +37,16 @@ static void diff_stages(int stage1, int stage2)
if (!one && !two)
continue;
if (!one)
diff_addremove('+', ntohl(two->ce_mode),
diff_addremove(&diff_options, '+', ntohl(two->ce_mode),
two->sha1, name, NULL);
else if (!two)
diff_addremove('-', ntohl(one->ce_mode),
diff_addremove(&diff_options, '-', ntohl(one->ce_mode),
one->sha1, name, NULL);
else if (memcmp(one->sha1, two->sha1, 20) ||
(one->ce_mode != two->ce_mode) ||
find_copies_harder)
diff_change(ntohl(one->ce_mode), ntohl(two->ce_mode),
diff_options.find_copies_harder)
diff_change(&diff_options,
ntohl(one->ce_mode), ntohl(two->ce_mode),
one->sha1, two->sha1, name, NULL);
}
}
......@@ -65,44 +56,25 @@ int main(int ac, const char **av)
int stage1, stage2;
read_cache();
diff_setup(&diff_options);
while (1 < ac && av[1][0] == '-') {
const char *arg = av[1];
if (!strcmp(arg, "-r"))
; /* as usual */
else if (!strcmp(arg, "-p") || !strcmp(arg, "-u"))
diff_output_format = DIFF_FORMAT_PATCH;
else if (!strncmp(arg, "-B", 2)) {
if ((diff_break_opt = diff_scoreopt_parse(arg)) == -1)
else {
int diff_opt_cnt;
diff_opt_cnt = diff_opt_parse(&diff_options,
av+1, ac-1);
if (diff_opt_cnt < 0)
usage(diff_stages_usage);
}
else if (!strncmp(arg, "-M", 2)) {
detect_rename = DIFF_DETECT_RENAME;
if ((diff_score_opt = diff_scoreopt_parse(arg)) == -1)
usage(diff_stages_usage);
}
else if (!strncmp(arg, "-C", 2)) {
detect_rename = DIFF_DETECT_COPY;
if ((diff_score_opt = diff_scoreopt_parse(arg)) == -1)
else if (diff_opt_cnt) {
av += diff_opt_cnt;
ac -= diff_opt_cnt;
continue;
}
else
usage(diff_stages_usage);
}
else if (!strcmp(arg, "--find-copies-harder"))
find_copies_harder = 1;
else if (!strcmp(arg, "-z"))
diff_line_termination = 0;
else if (!strcmp(arg, "--name-only"))
diff_output_format = DIFF_FORMAT_NAME;
else if (!strcmp(arg, "-R"))
diff_setup_opt |= DIFF_SETUP_REVERSE;
else if (!strncmp(arg, "-S", 2))
pickaxe = arg + 2;
else if (!strncmp(arg, "-O", 2))
orderfile = arg + 2;
else if (!strncmp(arg, "--diff-filter=", 14))
diff_filter = arg + 14;
else if (!strcmp(arg, "--pickaxe-all"))
pickaxe_opts = DIFF_PICKAXE_ALL;
else
usage(diff_stages_usage);
ac--; av++;
}
......@@ -110,21 +82,17 @@ int main(int ac, const char **av)
sscanf(av[1], "%d", &stage1) != 1 ||
! (0 <= stage1 && stage1 <= 3) ||
sscanf(av[2], "%d", &stage2) != 1 ||
! (0 <= stage2 && stage2 <= 3) ||
(find_copies_harder && detect_rename != DIFF_DETECT_COPY))
! (0 <= stage2 && stage2 <= 3))
usage(diff_stages_usage);
av += 3; /* The rest from av[0] are for paths restriction. */
diff_setup(diff_setup_opt);
diff_options.paths = av;
diff_stages(stage1, stage2);
if (diff_setup_done(&diff_options) < 0)
usage(diff_stages_usage);
diffcore_std(av,
detect_rename, diff_score_opt,
pickaxe, pickaxe_opts,
diff_break_opt,
orderfile,
diff_filter);
diff_flush(diff_output_format, diff_line_termination);
diff_stages(stage1, stage2);
diffcore_std(&diff_options);
diff_flush(&diff_options);
return 0;
}
......@@ -9,17 +9,9 @@ static int ignore_merges = 1;
static int recursive = 0;
static int show_tree_entry_in_recursive = 0;
static int read_stdin = 0;
static int diff_output_format = DIFF_FORMAT_RAW;
static int diff_line_termination = '\n';
static int detect_rename = 0;
static int find_copies_harder = 0;
static int diff_setup_opt = 0;
static int diff_score_opt = 0;
static const char *pickaxe = NULL;
static int pickaxe_opts = 0;
static int diff_break_opt = -1;
static const char *orderfile = NULL;
static const char *diff_filter = NULL;
static struct diff_options diff_options;
static const char *header = NULL;
static const char *header_prefix = "";
static enum cmit_fmt commit_format = CMIT_FMT_RAW;
......@@ -94,7 +86,7 @@ static void show_file(const char *prefix, void *tree, unsigned long size, const
return;
}
diff_addremove(prefix[0], mode, sha1, base, path);
diff_addremove(&diff_options, prefix[0], mode, sha1, base, path);
}
static int compare_tree_entry(void *tree1, unsigned long size1, void *tree2, unsigned long size2, const char *base)
......@@ -118,7 +110,8 @@ static int compare_tree_entry(void *tree1, unsigned long size1, void *tree2, uns
show_file("+", tree2, size2, base);
return 1;
}
if (!find_copies_harder && !memcmp(sha1, sha2, 20) && mode1 == mode2)
if (!diff_options.find_copies_harder &&
!memcmp(sha1, sha2, 20) && mode1 == mode2)
return 0;
/*
......@@ -135,13 +128,14 @@ static int compare_tree_entry(void *tree1, unsigned long size1, void *tree2, uns
int retval;
char *newbase = malloc_base(base, path1, pathlen1);
if (show_tree_entry_in_recursive)
diff_change(mode1, mode2, sha1, sha2, base, path1);
diff_change(&diff_options, mode1, mode2,
sha1, sha2, base, path1);
retval = diff_tree_sha1(sha1, sha2, newbase);
free(newbase);
return retval;
}
diff_change(mode1, mode2, sha1, sha2, base, path1);
diff_change(&diff_options, mode1, mode2, sha1, sha2, base, path1);
return 0;
}
......@@ -263,28 +257,26 @@ static int diff_tree_sha1(const unsigned char *old, const unsigned char *new, co
return retval;
}
static void call_diff_setup(void)
static void call_diff_setup_done(void)
{
diff_setup(diff_setup_opt);
diff_setup_done(&diff_options);
}
static int call_diff_flush(void)
{
diffcore_std(NULL,
detect_rename, diff_score_opt,
pickaxe, pickaxe_opts,
diff_break_opt,
orderfile,
diff_filter);
diffcore_std(&diff_options);
if (diff_queue_is_empty()) {
diff_flush(DIFF_FORMAT_NO_OUTPUT, diff_line_termination);
int saved_fmt = diff_options.output_format;
diff_options.output_format = DIFF_FORMAT_NO_OUTPUT;
diff_flush(&diff_options);
diff_options.output_format = saved_fmt;
return 0;
}
if (header) {
printf("%s%c", header, diff_line_termination);
printf("%s%c", header, diff_options.line_termination);
header = NULL;
}
diff_flush(diff_output_format, diff_line_termination);
diff_flush(&diff_options);
return 1;
}
......@@ -293,7 +285,7 @@ static int diff_tree_sha1_top(const unsigned char *old,
{
int ret;
call_diff_setup();
call_diff_setup_done();
ret = diff_tree_sha1(old, new, base);
call_diff_flush();
return ret;
......@@ -305,7 +297,7 @@ static int diff_root_tree(const unsigned char *new, const char *base)
void *tree;
unsigned long size;
call_diff_setup();
call_diff_setup_done();
tree = read_object_with_reference(new, "tree", &size, NULL);
if (!tree)
die("unable to read root tree (%s)", sha1_to_hex(new));
......@@ -409,7 +401,7 @@ static const char diff_tree_usage[] =
"[<common diff options>] <tree-ish> <tree-ish>"
COMMON_DIFF_OPTIONS_HELP;
int main(int argc, char **argv)
int main(int argc, const char **argv)
{
int nr_sha1;
char line[1000];
......@@ -417,7 +409,10 @@ int main(int argc, char **argv)
const char *prefix = setup_git_directory();
nr_sha1 = 0;
diff_setup(&diff_options);
for (;;) {
int diff_opt_cnt;
const char *arg;
argv++;
......@@ -434,6 +429,16 @@ int main(int argc, char **argv)
break;
}
diff_opt_cnt = diff_opt_parse(&diff_options, argv, argc);
if (diff_opt_cnt < 0)
usage(diff_tree_usage);
else if (diff_opt_cnt) {
argv += diff_opt_cnt - 1;
argc -= diff_opt_cnt - 1;
continue;
}
if (!strcmp(arg, "--")) {
argv++;
argc--;
......@@ -447,68 +452,10 @@ int main(int argc, char **argv)
recursive = show_tree_entry_in_recursive = 1;
continue;
}
if (!strcmp(arg, "-R")) {
diff_setup_opt |= DIFF_SETUP_REVERSE;
continue;
}
if (!strcmp(arg, "-p") || !strcmp(arg, "-u")) {
diff_output_format = DIFF_FORMAT_PATCH;
recursive = 1;
continue;
}
if (!strncmp(arg, "-S", 2)) {
pickaxe = arg + 2;
continue;
}
if (!strncmp(arg, "-O", 2)) {
orderfile = arg + 2;
continue;
}
if (!strncmp(arg, "--diff-filter=", 14)) {
diff_filter = arg + 14;
continue;
}
if (!strcmp(arg, "--pickaxe-all")) {
pickaxe_opts = DIFF_PICKAXE_ALL;
continue;
}
if (!strncmp(arg, "-M", 2)) {
detect_rename = DIFF_DETECT_RENAME;
if ((diff_score_opt = diff_scoreopt_parse(arg)) == -1)
usage(diff_tree_usage);
continue;
}
if (!strncmp(arg, "-C", 2)) {
detect_rename = DIFF_DETECT_COPY;
if ((diff_score_opt = diff_scoreopt_parse(arg)) == -1)
usage(diff_tree_usage);
continue;
}
if (!strncmp(arg, "-B", 2)) {
if ((diff_break_opt = diff_scoreopt_parse(arg)) == -1)
usage(diff_tree_usage);
continue;
}
if (!strcmp(arg, "--find-copies-harder")) {
find_copies_harder = 1;
continue;
}
if (!strcmp(arg, "--name-only")) {
diff_output_format = DIFF_FORMAT_NAME;
continue;
}
if (!strcmp(arg, "-z")) {
diff_line_termination = 0;
continue;
}
if (!strcmp(arg, "-m")) {
ignore_merges = 0;
continue;
}
if (!strcmp(arg, "-s")) {
diff_output_format = DIFF_FORMAT_NO_OUTPUT;
continue;
}
if (!strcmp(arg, "-v")) {
verbose_header = 1;
header_prefix = "diff-tree ";
......@@ -530,8 +477,8 @@ int main(int argc, char **argv)
}
usage(diff_tree_usage);
}
if (find_copies_harder && detect_rename != DIFF_DETECT_COPY)
usage(diff_tree_usage);
if (diff_options.output_format == DIFF_FORMAT_PATCH)
recursive = 1;
paths = get_pathspec(prefix, argv);
if (paths) {
......@@ -559,9 +506,9 @@ int main(int argc, char **argv)
if (!read_stdin)
return 0;
if (detect_rename)
diff_setup_opt |= (DIFF_SETUP_USE_SIZE_CACHE |
DIFF_SETUP_USE_CACHE);
if (diff_options.detect_rename)
diff_options.setup |= (DIFF_SETUP_USE_SIZE_CACHE |
DIFF_SETUP_USE_CACHE);
while (fgets(line, sizeof(line), stdin))
diff_tree_stdin(line);
......
......@@ -12,7 +12,6 @@
static const char *diff_opts = "-pu";
static unsigned char null_sha1[20] = { 0, };
static int reverse_diff;
static int use_size_cache;
static const char *external_diff(void)
......@@ -669,11 +668,20 @@ static void run_diff(struct diff_filepair *p)
complete_rewrite);
}
void diff_setup(int flags)
void diff_setup(struct diff_options *options)
{
if (flags & DIFF_SETUP_REVERSE)
reverse_diff = 1;
if (flags & DIFF_SETUP_USE_CACHE) {
memset(options, 0, sizeof(*options));
options->output_format = DIFF_FORMAT_RAW;
options->line_termination = '\n';
options->break_opt = -1;
}
int diff_setup_done(struct diff_options *options)
{
if (options->find_copies_harder &&
options->detect_rename != DIFF_DETECT_COPY)
return -1;
if (options->setup & DIFF_SETUP_USE_CACHE) {
if (!active_cache)