Skip to content

Commit 8588567

Browse files
committed
rerere: honor conflict-marker-size attribute
Signed-off-by: Junio C Hamano <[email protected]>
1 parent 191f241 commit 8588567

File tree

3 files changed

+20
-2
lines changed

3 files changed

+20
-2
lines changed

ll-merge.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -380,3 +380,18 @@ int ll_merge(mmbuffer_t *result_buf,
380380
ours, our_label, theirs, their_label,
381381
virtual_ancestor, marker_size);
382382
}
383+
384+
int ll_merge_marker_size(const char *path)
385+
{
386+
static struct git_attr_check check;
387+
int marker_size = DEFAULT_CONFLICT_MARKER_SIZE;
388+
389+
if (!check.attr)
390+
check.attr = git_attr("conflict-marker-size");
391+
if (!git_checkattr(path, 1, &check) && check.value) {
392+
marker_size = atoi(check.value);
393+
if (marker_size <= 0)
394+
marker_size = DEFAULT_CONFLICT_MARKER_SIZE;
395+
}
396+
return marker_size;
397+
}

ll-merge.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,6 @@ int ll_merge(mmbuffer_t *result_buf,
1212
mmfile_t *theirs, const char *their_label,
1313
int virtual_ancestor);
1414

15+
int ll_merge_marker_size(const char *path);
16+
1517
#endif

rerere.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
#include "dir.h"
66
#include "resolve-undo.h"
77
#include "ll-merge.h"
8+
#include "attr.h"
89

910
/* if rerere_enabled == -1, fall back to detection of .git/rr-cache */
1011
static int rerere_enabled = -1;
@@ -221,7 +222,7 @@ static int handle_file(const char *path, unsigned char *sha1, const char *output
221222
{
222223
int hunk_no = 0;
223224
struct rerere_io_file io;
224-
int marker_size = 7;
225+
int marker_size = ll_merge_marker_size(path);
225226

226227
memset(&io, 0, sizeof(io));
227228
io.io.getline = rerere_file_getline;
@@ -288,7 +289,7 @@ static int handle_cache(const char *path, unsigned char *sha1, const char *outpu
288289
struct cache_entry *ce;
289290
int pos, len, i, hunk_no;
290291
struct rerere_io_mem io;
291-
int marker_size = 7;
292+
int marker_size = ll_merge_marker_size(path);
292293

293294
/*
294295
* Reproduce the conflicted merge in-core

0 commit comments

Comments
 (0)