summaryrefslogtreecommitdiff
path: root/diff.c
diff options
context:
space:
mode:
Diffstat (limited to 'diff.c')
-rw-r--r--diff.c103
1 files changed, 70 insertions, 33 deletions
diff --git a/diff.c b/diff.c
index c89c15d98e..90e8003dd1 100644
--- a/diff.c
+++ b/diff.c
@@ -23,7 +23,7 @@
#include "color.h"
#include "run-command.h"
#include "utf8.h"
-#include "object-store-ll.h"
+#include "object-store.h"
#include "userdiff.h"
#include "submodule.h"
#include "hashmap.h"
@@ -892,7 +892,7 @@ static void fill_es_indent_data(struct emitted_diff_symbol *es)
/* skip any \v \f \r at start of indentation */
while (s[off] == '\f' || s[off] == '\v' ||
- (s[off] == '\r' && off < len - 1))
+ (off < len - 1 && s[off] == '\r'))
off++;
/* calculate the visual width of indentation */
@@ -4193,7 +4193,8 @@ int diff_populate_filespec(struct repository *r,
* is probably fine.
*/
if (check_binary &&
- s->size > big_file_threshold && s->is_binary == -1) {
+ s->size > repo_settings_get_big_file_threshold(the_repository) &&
+ s->is_binary == -1) {
s->is_binary = 1;
return 0;
}
@@ -4243,7 +4244,8 @@ object_read:
if (size_only || check_binary) {
if (size_only)
return 0;
- if (s->size > big_file_threshold && s->is_binary == -1) {
+ if (s->size > repo_settings_get_big_file_threshold(the_repository) &&
+ s->is_binary == -1) {
s->is_binary = 1;
return 0;
}
@@ -4344,7 +4346,7 @@ static struct diff_tempfile *prepare_temp_file(struct repository *r,
die_errno("readlink(%s)", one->path);
prep_temp_blob(r->index, one->path, temp, sb.buf, sb.len,
(one->oid_valid ?
- &one->oid : null_oid()),
+ &one->oid : null_oid(the_hash_algo)),
(one->oid_valid ?
one->mode : S_IFLNK));
strbuf_release(&sb);
@@ -4353,7 +4355,7 @@ static struct diff_tempfile *prepare_temp_file(struct repository *r,
/* we can borrow from the file in the work tree */
temp->name = one->path;
if (!one->oid_valid)
- oid_to_hex_r(temp->hex, null_oid());
+ oid_to_hex_r(temp->hex, null_oid(the_hash_algo));
else
oid_to_hex_r(temp->hex, &one->oid);
/* Even though we may sometimes borrow the
@@ -5892,10 +5894,15 @@ struct option *add_diff_options(const struct option *opts,
OPT_CALLBACK_F(0, "diff-filter", options, N_("[(A|C|D|M|R|T|U|X|B)...[*]]"),
N_("select files by diff type"),
PARSE_OPT_NONEG, diff_opt_diff_filter),
- { OPTION_CALLBACK, 0, "output", options, N_("<file>"),
- N_("output to a specific file"),
- PARSE_OPT_NONEG, NULL, 0, diff_opt_output },
-
+ {
+ .type = OPTION_CALLBACK,
+ .long_name = "output",
+ .value = options,
+ .argh = N_("<file>"),
+ .help = N_("output to a specific file"),
+ .flags = PARSE_OPT_NONEG,
+ .ll_callback = diff_opt_output,
+ },
OPT_END()
};
@@ -6647,8 +6654,8 @@ static void create_filepairs_for_header_only_notifications(struct diff_options *
one = alloc_filespec(e->key);
two = alloc_filespec(e->key);
- fill_filespec(one, null_oid(), 0, 0);
- fill_filespec(two, null_oid(), 0, 0);
+ fill_filespec(one, null_oid(the_hash_algo), 0, 0);
+ fill_filespec(two, null_oid(the_hash_algo), 0, 0);
p = diff_queue(q, one, two);
p->status = DIFF_STATUS_MODIFIED;
}
@@ -7085,7 +7092,7 @@ void diffcore_std(struct diff_options *options)
diffcore_order(options->orderfile);
if (options->rotate_to)
diffcore_rotate(options);
- if (!options->found_follow)
+ if (!options->found_follow && !options->skip_resolving_statuses)
/* See try_to_follow_renames() in tree-diff.c */
diff_resolve_rename_copy();
diffcore_apply_filter(options);
@@ -7161,16 +7168,19 @@ void compute_diffstat(struct diff_options *options,
options->found_changes = !!diffstat->nr;
}
-void diff_addremove(struct diff_options *options,
- int addremove, unsigned mode,
- const struct object_id *oid,
- int oid_valid,
- const char *concatpath, unsigned dirty_submodule)
+struct diff_filepair *diff_queue_addremove(struct diff_queue_struct *queue,
+ struct diff_options *options,
+ int addremove, unsigned mode,
+ const struct object_id *oid,
+ int oid_valid,
+ const char *concatpath,
+ unsigned dirty_submodule)
{
struct diff_filespec *one, *two;
+ struct diff_filepair *pair;
if (S_ISGITLINK(mode) && is_submodule_ignored(concatpath, options))
- return;
+ return NULL;
/* This may look odd, but it is a preparation for
* feeding "there are unchanged files which should
@@ -7190,7 +7200,7 @@ void diff_addremove(struct diff_options *options,
if (options->prefix &&
strncmp(concatpath, options->prefix, options->prefix_length))
- return;
+ return NULL;
one = alloc_filespec(concatpath);
two = alloc_filespec(concatpath);
@@ -7202,25 +7212,29 @@ void diff_addremove(struct diff_options *options,
two->dirty_submodule = dirty_submodule;
}
- diff_queue(&diff_queued_diff, one, two);
+ pair = diff_queue(queue, one, two);
if (!options->flags.diff_from_contents)
options->flags.has_changes = 1;
+
+ return pair;
}
-void diff_change(struct diff_options *options,
- unsigned old_mode, unsigned new_mode,
- const struct object_id *old_oid,
- const struct object_id *new_oid,
- int old_oid_valid, int new_oid_valid,
- const char *concatpath,
- unsigned old_dirty_submodule, unsigned new_dirty_submodule)
+struct diff_filepair *diff_queue_change(struct diff_queue_struct *queue,
+ struct diff_options *options,
+ unsigned old_mode, unsigned new_mode,
+ const struct object_id *old_oid,
+ const struct object_id *new_oid,
+ int old_oid_valid, int new_oid_valid,
+ const char *concatpath,
+ unsigned old_dirty_submodule,
+ unsigned new_dirty_submodule)
{
struct diff_filespec *one, *two;
struct diff_filepair *p;
if (S_ISGITLINK(old_mode) && S_ISGITLINK(new_mode) &&
is_submodule_ignored(concatpath, options))
- return;
+ return NULL;
if (options->flags.reverse_diff) {
SWAP(old_mode, new_mode);
@@ -7231,7 +7245,7 @@ void diff_change(struct diff_options *options,
if (options->prefix &&
strncmp(concatpath, options->prefix, options->prefix_length))
- return;
+ return NULL;
one = alloc_filespec(concatpath);
two = alloc_filespec(concatpath);
@@ -7239,19 +7253,42 @@ void diff_change(struct diff_options *options,
fill_filespec(two, new_oid, new_oid_valid, new_mode);
one->dirty_submodule = old_dirty_submodule;
two->dirty_submodule = new_dirty_submodule;
- p = diff_queue(&diff_queued_diff, one, two);
+ p = diff_queue(queue, one, two);
if (options->flags.diff_from_contents)
- return;
+ return p;
if (options->flags.quick && options->skip_stat_unmatch &&
!diff_filespec_check_stat_unmatch(options->repo, p)) {
diff_free_filespec_data(p->one);
diff_free_filespec_data(p->two);
- return;
+ return p;
}
options->flags.has_changes = 1;
+
+ return p;
+}
+
+void diff_addremove(struct diff_options *options, int addremove, unsigned mode,
+ const struct object_id *oid, int oid_valid,
+ const char *concatpath, unsigned dirty_submodule)
+{
+ diff_queue_addremove(&diff_queued_diff, options, addremove, mode, oid,
+ oid_valid, concatpath, dirty_submodule);
+}
+
+void diff_change(struct diff_options *options,
+ unsigned old_mode, unsigned new_mode,
+ const struct object_id *old_oid,
+ const struct object_id *new_oid,
+ int old_oid_valid, int new_oid_valid,
+ const char *concatpath,
+ unsigned old_dirty_submodule, unsigned new_dirty_submodule)
+{
+ diff_queue_change(&diff_queued_diff, options, old_mode, new_mode,
+ old_oid, new_oid, old_oid_valid, new_oid_valid,
+ concatpath, old_dirty_submodule, new_dirty_submodule);
}
struct diff_filepair *diff_unmerge(struct diff_options *options, const char *path)