summaryrefslogtreecommitdiff
path: root/ll-merge.c
diff options
context:
space:
mode:
authorJonathan Nieder <jrnieder@gmail.com>2010-08-05 06:17:38 -0500
committerJunio C Hamano <gitster@pobox.com>2010-08-06 09:20:01 -0700
commit73cf7f713da4fc797e2393a9e490ad4ec9466c53 (patch)
tree8d9c9fed8bfb98d0041ec9b4e8c125b5d4f26678 /ll-merge.c
parent24d113ec11d9948cedee4ba4687d0775e36b65f9 (diff)
downloadgit-73cf7f713da4fc797e2393a9e490ad4ec9466c53.tar.gz
ll-merge: make flag easier to populate
ll_merge() takes its options in a flag word, which has a few advantages: - options flags can be cheaply passed around in registers, while an option struct passed by pointer cannot; - callers can easily pass 0 without trouble for no options, while an option struct passed by value would not allow that. The downside is that code to populate and access the flag word can be somewhat opaque. Mitigate that with a few macros. Cc: Avery Pennarun <apenwarr@gmail.com> Cc: Bert Wesarg <bert.wesarg@googlemail.com> Signed-off-by: Jonathan Nieder <jrnieder@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'll-merge.c')
-rw-r--r--ll-merge.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/ll-merge.c b/ll-merge.c
index 5068fe069f..290f764f56 100644
--- a/ll-merge.c
+++ b/ll-merge.c
@@ -46,7 +46,7 @@ static int ll_binary_merge(const struct ll_merge_driver *drv_unused,
* or common ancestor for an internal merge. Still return
* "conflicted merge" status.
*/
- mmfile_t *stolen = (flag & 01) ? orig : src1;
+ mmfile_t *stolen = (flag & LL_OPT_VIRTUAL_ANCESTOR) ? orig : src1;
result->ptr = stolen->ptr;
result->size = stolen->size;
@@ -79,7 +79,7 @@ static int ll_xdl_merge(const struct ll_merge_driver *drv_unused,
memset(&xmp, 0, sizeof(xmp));
xmp.level = XDL_MERGE_ZEALOUS;
- xmp.favor= (flag >> 1) & 03;
+ xmp.favor = ll_opt_favor(flag);
if (git_xmerge_style >= 0)
xmp.style = git_xmerge_style;
if (marker_size > 0)
@@ -99,7 +99,8 @@ static int ll_union_merge(const struct ll_merge_driver *drv_unused,
int flag, int marker_size)
{
/* Use union favor */
- flag = (flag & 1) | (XDL_MERGE_FAVOR_UNION << 1);
+ flag = (flag & LL_OPT_VIRTUAL_ANCESTOR) |
+ create_ll_flag(XDL_MERGE_FAVOR_UNION);
return ll_xdl_merge(drv_unused, result, path_unused,
orig, NULL, src1, NULL, src2, NULL,
flag, marker_size);
@@ -342,7 +343,7 @@ int ll_merge(mmbuffer_t *result_buf,
const char *ll_driver_name = NULL;
int marker_size = DEFAULT_CONFLICT_MARKER_SIZE;
const struct ll_merge_driver *driver;
- int virtual_ancestor = flag & 01;
+ int virtual_ancestor = flag & LL_OPT_VIRTUAL_ANCESTOR;
if (merge_renormalize) {
normalize_file(ancestor, path);