rerere: honor conflict-marker-size attribute
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Junio C Hamano committed
Jan 16, 2010 at 23:28 UTC
8588567c96490b8d236b1bc13f9bcb0dfa118efe
3 files changed
+20
-2
ll-merge.c
+15
@@ -380,3 +380,18 @@ int ll_merge(mmbuffer_t *result_buf,
380
ours, our_label, theirs, their_label,
381
virtual_ancestor, marker_size);
382
}
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
+2
@@ -12,4 +12,6 @@ int ll_merge(mmbuffer_t *result_buf,
12
mmfile_t *theirs, const char *their_label,
13
int virtual_ancestor);
14
15
+int ll_merge_marker_size(const char *path);
16
+
17
#endif
rerere.c
+3
-2
@@ -5,6 +5,7 @@
5
#include "dir.h"
6
#include "resolve-undo.h"
7
#include "ll-merge.h"
8
+#include "attr.h"
9
10
/* if rerere_enabled == -1, fall back to detection of .git/rr-cache */
11
static int rerere_enabled = -1;
@@ -221,7 +222,7 @@ static int handle_file(const char *path, unsigned char *sha1, const char *output
222
{
223
int hunk_no = 0;
224
struct rerere_io_file io;
224
- int marker_size = 7;
225
+ int marker_size = ll_merge_marker_size(path);
226
227
memset(&io, 0, sizeof(io));
228
io.io.getline = rerere_file_getline;
@@ -288,7 +289,7 @@ static int handle_cache(const char *path, unsigned char *sha1, const char *outpu
289
struct cache_entry *ce;
290
int pos, len, i, hunk_no;
291
struct rerere_io_mem io;
291
- int marker_size = 7;
292
+ int marker_size = ll_merge_marker_size(path);
293
294
/*
295
* Reproduce the conflicted merge in-core