git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: git@vger.kernel.org
Subject: [PATCH 3/8] xdl_merge(): allow passing down marker_size in xmparam_t
Date: Sun, 17 Jan 2010 01:38:59 -0800	[thread overview]
Message-ID: <1263721144-18605-4-git-send-email-gitster@pobox.com> (raw)
In-Reply-To: <1263721144-18605-1-git-send-email-gitster@pobox.com>

This allows the callers of xdl_merge() to pass marker_size (defaults to 7)
in xmparam_t argument, to use conflict markers of non-default length.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
 xdiff/xdiff.h  |    3 +++
 xdiff/xmerge.c |   23 +++++++++++++++--------
 2 files changed, 18 insertions(+), 8 deletions(-)

diff --git a/xdiff/xdiff.h b/xdiff/xdiff.h
index b265909..22f3913 100644
--- a/xdiff/xdiff.h
+++ b/xdiff/xdiff.h
@@ -110,8 +110,11 @@ int xdl_diff(mmfile_t *mf1, mmfile_t *mf2, xpparam_t const *xpp,
 
 typedef struct s_xmparam {
 	xpparam_t xpp;
+	int marker_size;
 } xmparam_t;
 
+#define DEFAULT_CONFLICT_MARKER_SIZE 7
+
 int xdl_merge(mmfile_t *orig, mmfile_t *mf1, const char *name1,
 		mmfile_t *mf2, const char *name2,
 		xmparam_t const *xmp, int level, mmbuffer_t *result);
diff --git a/xdiff/xmerge.c b/xdiff/xmerge.c
index 5c37b4e..68c815f 100644
--- a/xdiff/xmerge.c
+++ b/xdiff/xmerge.c
@@ -145,13 +145,15 @@ static int xdl_orig_copy(xdfenv_t *xe, int i, int count, int add_nl, char *dest)
 static int fill_conflict_hunk(xdfenv_t *xe1, const char *name1,
 			      xdfenv_t *xe2, const char *name2,
 			      int size, int i, int style,
-			      xdmerge_t *m, char *dest)
+			      xdmerge_t *m, char *dest, int marker_size)
 {
-	const int marker_size = 7;
 	int marker1_size = (name1 ? strlen(name1) + 1 : 0);
 	int marker2_size = (name2 ? strlen(name2) + 1 : 0);
 	int j;
 
+	if (marker_size <= 0)
+		marker_size = DEFAULT_CONFLICT_MARKER_SIZE;
+
 	/* Before conflicting part */
 	size += xdl_recs_copy(xe1, i, m->i1 - i, 0,
 			      dest ? dest + size : NULL);
@@ -214,14 +216,16 @@ static int fill_conflict_hunk(xdfenv_t *xe1, const char *name1,
 
 static int xdl_fill_merge_buffer(xdfenv_t *xe1, const char *name1,
 				 xdfenv_t *xe2, const char *name2,
-				 xdmerge_t *m, char *dest, int style)
+				 xdmerge_t *m, char *dest, int style,
+				 int marker_size)
 {
 	int size, i;
 
 	for (size = i = 0; m; m = m->next) {
 		if (m->mode == 0)
 			size = fill_conflict_hunk(xe1, name1, xe2, name2,
-						  size, i, style, m, dest);
+						  size, i, style, m, dest,
+						  marker_size);
 		else if (m->mode == 1)
 			size += xdl_recs_copy(xe1, i, m->i1 + m->chg1 - i, 0,
 					      dest ? dest + size : NULL);
@@ -386,8 +390,9 @@ static int xdl_simplify_non_conflicts(xdfenv_t *xe1, xdmerge_t *m,
  */
 static int xdl_do_merge(xdfenv_t *xe1, xdchange_t *xscr1, const char *name1,
 		xdfenv_t *xe2, xdchange_t *xscr2, const char *name2,
-		int flags, xpparam_t const *xpp, mmbuffer_t *result) {
+		int flags, xmparam_t const *xmp, mmbuffer_t *result) {
 	xdmerge_t *changes, *c;
+	xpparam_t const *xpp = &xmp->xpp;
 	int i0, i1, i2, chg0, chg1, chg2;
 	int level = flags & XDL_MERGE_LEVEL_MASK;
 	int style = flags & XDL_MERGE_STYLE_MASK;
@@ -522,8 +527,10 @@ static int xdl_do_merge(xdfenv_t *xe1, xdchange_t *xscr1, const char *name1,
 	}
 	/* output */
 	if (result) {
+		int marker_size = xmp->marker_size;
 		int size = xdl_fill_merge_buffer(xe1, name1, xe2, name2,
-			changes, NULL, style);
+						 changes, NULL, style,
+						 marker_size);
 		result->ptr = xdl_malloc(size);
 		if (!result->ptr) {
 			xdl_cleanup_merge(changes);
@@ -531,7 +538,7 @@ static int xdl_do_merge(xdfenv_t *xe1, xdchange_t *xscr1, const char *name1,
 		}
 		result->size = size;
 		xdl_fill_merge_buffer(xe1, name1, xe2, name2, changes,
-				      result->ptr, style);
+				      result->ptr, style, marker_size);
 	}
 	return xdl_cleanup_merge(changes);
 }
@@ -575,7 +582,7 @@ int xdl_merge(mmfile_t *orig, mmfile_t *mf1, const char *name1,
 	} else {
 		status = xdl_do_merge(&xe1, xscr1, name1,
 				      &xe2, xscr2, name2,
-				      flags, xpp, result);
+				      flags, xmp, result);
 	}
 	xdl_free_script(xscr1);
 	xdl_free_script(xscr2);
-- 
1.6.6.405.g80ed6.dirty

  parent reply	other threads:[~2010-01-17  9:39 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-01-17  9:38 [PATCH 0/8] Rescuing repeated merge of Documentation/git-merge.txt Junio C Hamano
2010-01-17  9:38 ` [PATCH 1/8] git_attr(): fix function signature Junio C Hamano
2010-01-17  9:38 ` [PATCH 2/8] xdl_merge(): introduce xmparam_t for merge specific parameters Junio C Hamano
2010-01-17  9:38 ` Junio C Hamano [this message]
2010-01-17  9:39 ` [PATCH 4/8] merge-tree: use ll_merge() not xdl_merge() Junio C Hamano
2010-01-17  9:39 ` [PATCH 5/8] rerere: use ll_merge() instead of using xdl_merge() Junio C Hamano
2010-01-17 11:52   ` Johannes Sixt
2010-01-17 19:01     ` Junio C Hamano
2010-01-17 20:40       ` Johannes Sixt
2010-01-17  9:39 ` [PATCH 6/8] conflict-marker-size: new attribute Junio C Hamano
2010-01-17  9:39 ` [PATCH 7/8] rerere: prepare for customizable conflict marker length Junio C Hamano
2010-01-17  9:39 ` [PATCH 8/8] rerere: honor conflict-marker-size attribute Junio C Hamano
2010-01-17 10:07 ` [PATCH 0/8] Rescuing repeated merge of Documentation/git-merge.txt Junio C Hamano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1263721144-18605-4-git-send-email-gitster@pobox.com \
    --to=gitster@pobox.com \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).