summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 8588567)
raw | patch | inline | side by side (parent: 8588567)
author | Junio C Hamano <gitster@pobox.com> | |
Thu, 25 Mar 2010 02:21:32 +0000 (19:21 -0700) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Thu, 25 Mar 2010 02:35:34 +0000 (19:35 -0700) |
Signed-off-by: Junio C Hamano <gitster@pobox.com>
diff.c | patch | blob | history | |
t/t4017-diff-retval.sh | patch | blob | history |
index 08bbd3e9070996b38f4d34cedf7640d93aa5808d..a09c97fa71cb6f057b892af1965ea9ed3cbcc58f 100644 (file)
--- a/diff.c
+++ b/diff.c
#include "userdiff.h"
#include "sigchain.h"
#include "submodule.h"
+#include "ll-merge.h"
#ifdef NO_FAST_WORKING_DIRECTORY
#define FAST_WORKING_DIRECTORY 0
struct checkdiff_t {
const char *filename;
int lineno;
+ int conflict_marker_size;
struct diff_options *o;
unsigned ws_rule;
unsigned status;
};
-static int is_conflict_marker(const char *line, unsigned long len)
+static int is_conflict_marker(const char *line, int marker_size, unsigned long len)
{
char firstchar;
int cnt;
- if (len < 8)
+ if (len < marker_size + 1)
return 0;
firstchar = line[0];
switch (firstchar) {
- case '=': case '>': case '<':
+ case '=': case '>': case '<': case '|':
break;
default:
return 0;
}
- for (cnt = 1; cnt < 7; cnt++)
+ for (cnt = 1; cnt < marker_size; cnt++)
if (line[cnt] != firstchar)
return 0;
- /* line[0] thru line[6] are same as firstchar */
- if (firstchar == '=') {
- /* divider between ours and theirs? */
- if (len != 8 || line[7] != '\n')
- return 0;
- } else if (len < 8 || !isspace(line[7])) {
- /* not divider before ours nor after theirs */
+ /* line[1] thru line[marker_size-1] are same as firstchar */
+ if (len < marker_size + 1 || !isspace(line[marker_size]))
return 0;
- }
return 1;
}
{
struct checkdiff_t *data = priv;
int color_diff = DIFF_OPT_TST(data->o, COLOR_DIFF);
+ int marker_size = data->conflict_marker_size;
const char *ws = diff_get_color(color_diff, DIFF_WHITESPACE);
const char *reset = diff_get_color(color_diff, DIFF_RESET);
const char *set = diff_get_color(color_diff, DIFF_FILE_NEW);
if (line[0] == '+') {
unsigned bad;
data->lineno++;
- if (is_conflict_marker(line + 1, len - 1)) {
+ if (is_conflict_marker(line + 1, marker_size, len - 1)) {
data->status |= 1;
fprintf(data->o->file,
"%s:%d: leftover conflict marker\n",
data.lineno = 0;
data.o = o;
data.ws_rule = whitespace_rule(attr_path);
+ data.conflict_marker_size = ll_merge_marker_size(attr_path);
if (fill_mmfile(&mf1, one) < 0 || fill_mmfile(&mf2, two) < 0)
die("unable to read files to diff");
diff --git a/t/t4017-diff-retval.sh b/t/t4017-diff-retval.sh
index 60dd2014d5ae5d5e9e168b8b60278d90ef93cc53..92e9137d1c9549300cba2fab9549cc84981bd1b4 100755 (executable)
--- a/t/t4017-diff-retval.sh
+++ b/t/t4017-diff-retval.sh
'
-
test_expect_success 'check should test not just the last line' '
echo "" >>a &&
git --no-pager diff --check
git reset --hard
'
+test_expect_success 'check honors conflict marker length' '
+ git reset --hard &&
+ echo ">>>>>>> boo" >>b &&
+ echo "======" >>a &&
+ git diff --check a &&
+ (
+ git diff --check b
+ test $? = 2
+ ) &&
+ git reset --hard &&
+ echo ">>>>>>>> boo" >>b &&
+ echo "========" >>a &&
+ git diff --check &&
+ echo "b conflict-marker-size=8" >.gitattributes &&
+ (
+ git diff --check b
+ test $? = 2
+ ) &&
+ git diff --check a &&
+ git reset --hard
+'
+
test_done