#endif
static int diff_detect_rename_default;
-static int diff_rename_limit_default = -1;
+static int diff_rename_limit_default = 100;
static int diff_use_color_default;
+int diff_auto_refresh_index = 1;
static char diff_colors[][COLOR_MAXLEN] = {
"\033[m", /* reset */
diff_detect_rename_default = DIFF_DETECT_RENAME;
return 0;
}
+ if (!strcmp(var, "diff.autorefreshindex")) {
+ diff_auto_refresh_index = git_config_bool(var, value);
+ return 0;
+ }
if (!prefixcmp(var, "diff.")) {
const char *ep = strrchr(var, '.');
fill_mmfile(&mf2, p->two) < 0)
return error("unable to read files to diff");
- /* Maybe hash p->two? into the patch id? */
- if (diff_filespec_is_binary(p->two))
- continue;
-
len1 = remove_space(p->one->path, strlen(p->one->path));
len2 = remove_space(p->two->path, strlen(p->two->path));
if (p->one->mode == 0)
*q = outq;
}
+/* Check whether two filespecs with the same mode and size are identical */
+static int diff_filespec_is_identical(struct diff_filespec *one,
+ struct diff_filespec *two)
+{
+ if (S_ISGITLINK(one->mode)) {
+ diff_fill_sha1_info(one);
+ diff_fill_sha1_info(two);
+ return !hashcmp(one->sha1, two->sha1);
+ }
+ if (diff_populate_filespec(one, 0))
+ return 0;
+ if (diff_populate_filespec(two, 0))
+ return 0;
+ return !memcmp(one->data, two->data, one->size);
+}
+
static void diffcore_skip_stat_unmatch(struct diff_options *diffopt)
{
int i;
diff_populate_filespec(p->one, 1) ||
diff_populate_filespec(p->two, 1) ||
(p->one->size != p->two->size) ||
-
- diff_populate_filespec(p->one, 0) || /* (2) */
- diff_populate_filespec(p->two, 0) ||
- memcmp(p->one->data, p->two->data, p->one->size))
+ !diff_filespec_is_identical(p->one, p->two)) /* (2) */
diff_q(&outq, p);
else {
/*
* to determine how many paths were dirty only
* due to stat info mismatch.
*/
- diffopt->skip_stat_unmatch++;
+ if (!diffopt->no_index)
+ diffopt->skip_stat_unmatch++;
diff_free_filepair(p);
}
}