From patchwork Fri Mar 8 14:14:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Phillip Wood X-Patchwork-Id: 13586865 Received: from mail-wm1-f53.google.com (mail-wm1-f53.google.com [209.85.128.53]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E52743FE22 for ; Fri, 8 Mar 2024 14:14:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.53 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709907277; cv=none; b=NDkpLnO6s6meftm0vwHUNNJRDbyzfj/tkdO/sZP7TAXCUShu2XMSHj4moVhl3s91DSUwZYSLNfYgnL85MibOkVeyR+BhPshrEPPJHA9c8mWFLPpRoJGk3ieMitJTa+ydLbtZep18t2Xln5rHzApB0dKjIndUluOia18/3UaklGM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709907277; c=relaxed/simple; bh=lc1c2r7Q/Bkn7lW9a+G1YNYIlzgAmtV/zp22qGVEG/M=; h=Message-ID:In-Reply-To:References:From:Date:Subject:Content-Type: MIME-Version:To:Cc; b=g3P+ZMaAZj/719IQVYsgYtxaN7qZFWJ6WdXseWZ87oCc2zhuCR/Vg//H98UJjXTyMQaXEJPGaZIr0b8gAr1GEcDqtAEPXrqSlY3HI+Aa6xIWbgKuAbGuq/FKDTegG9CZY1ZDs6ln3untuo9LALqlvdrNMtEyLHPZ/NAJsvwoQyA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=gBGCEu+u; arc=none smtp.client-ip=209.85.128.53 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="gBGCEu+u" Received: by mail-wm1-f53.google.com with SMTP id 5b1f17b1804b1-4130ff11782so6369435e9.2 for ; Fri, 08 Mar 2024 06:14:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1709907272; x=1710512072; darn=vger.kernel.org; h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date:from :references:in-reply-to:message-id:from:to:cc:subject:date :message-id:reply-to; bh=/5aJUaGJH5A51169aETUrWdf0IHIrzsjkj4k8uK3oWc=; b=gBGCEu+uQjJvUwdyiOUtF984m4GSKNNlH5LWzAXcbUr55xG59f4ZsyNWkTDodWuIAS Ct4YhAjM9TG9x3xsfY7YI1VoVUEX2jngpEyjKnNHCloC1dZSjtlUAQR8by7Qn70R8pYn Uhk5be/Iv4TivMrWOJzwir1hIcx5akub7bm34FXJMuwM4gnbe6PSnG79gUOu6UJjmkfY Oh8ncbi6Q5126VL9BI+ye8uIwzxWKWjsNOLZ0Ay/uepla57f1tyG7jPvkbY//rcdecOS qh2TIf1K3a0mHG2qAbH7H09QOJb7gdEQ86bOXa+h5CMNC3GZGpWWlLLfM6Wfy2LzHVzC BEDA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709907272; x=1710512072; h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date:from :references:in-reply-to:message-id:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=/5aJUaGJH5A51169aETUrWdf0IHIrzsjkj4k8uK3oWc=; b=HlTf0f5eS0NqiU6Pck4Y9A8/XAfinJPdCY4Qp9EjGeJzuJQxqjo2wPLtxh6Bvu7T/c /MY9Am5BrTuY/CkQsQXT7tOAcfoX31azt/h+4+7n6w1Dog6tTpJ6MucJjP4y1sXr678f d7/trJALMlIX4bJtsUZ27Ur53IEWsOLa9lM561mh9F73D0NWw3nzINKyoU1CiO2eAti5 rlIiksvyWqoWDXYoK0TsLW60f0Och5bnraVLP6cPG9f9ELwVBPdKHVPALVoZITDv8ELd n4aLvsXjcnig/oLCmPXA9WUU+nVON6sb7wCQVjXG8nOiHbE1N7U8FILlx9eS+RJaNv/b 517w== X-Gm-Message-State: AOJu0YwLifh7h7JKEplvJ+fjoSrjQpMzO/ariVA2E5dQAfyi8mPZXjeK rlkUdQiJnv9iiZYyfEF6uPHyZeOYhDEqkC+vM6x0mcW1tsaaB9tGWMOhcWN9 X-Google-Smtp-Source: AGHT+IGuD0x740SAFX+af2dynPSjRlvUvKD1OHQew3TfkzpWigdgPjH15Bd6zuTL9RtkhdEzby+4Kg== X-Received: by 2002:a05:600c:310e:b0:413:1375:871b with SMTP id g14-20020a05600c310e00b004131375871bmr3000357wmo.26.1709907272580; Fri, 08 Mar 2024 06:14:32 -0800 (PST) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id bv28-20020a0560001f1c00b0033d70dd0e04sm23377282wrb.8.2024.03.08.06.14.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Mar 2024 06:14:32 -0800 (PST) Message-ID: <0263d001634bd29970390be96a1df9b2251ef10c.1709907270.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Fri, 08 Mar 2024 14:14:27 +0000 Subject: [PATCH 1/4] xdiff-interface: refactor parsing of merge.conflictstyle Fcc: Sent Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 To: git@vger.kernel.org Cc: Phillip Wood , Phillip Wood From: Phillip Wood From: Phillip Wood Factor out the code that parses of conflict style name so it can be reused in a later commit that wants to parse the name given on the command line. Signed-off-by: Phillip Wood --- xdiff-interface.c | 29 ++++++++++++++++++----------- xdiff-interface.h | 1 + 2 files changed, 19 insertions(+), 11 deletions(-) diff --git a/xdiff-interface.c b/xdiff-interface.c index 3162f517434..daee3c584e1 100644 --- a/xdiff-interface.c +++ b/xdiff-interface.c @@ -305,6 +305,22 @@ int xdiff_compare_lines(const char *l1, long s1, return xdl_recmatch(l1, s1, l2, s2, flags); } +int parse_conflict_style(const char *value) +{ + if (!strcmp(value, "diff3")) + return XDL_MERGE_DIFF3; + else if (!strcmp(value, "zdiff3")) + return XDL_MERGE_ZEALOUS_DIFF3; + else if (!strcmp(value, "merge")) + return 0; + /* + * Please update _git_checkout() in git-completion.bash when + * you add new merge config + */ + else + return -1; +} + int git_xmerge_style = -1; int git_xmerge_config(const char *var, const char *value, @@ -313,17 +329,8 @@ int git_xmerge_config(const char *var, const char *value, if (!strcmp(var, "merge.conflictstyle")) { if (!value) return config_error_nonbool(var); - if (!strcmp(value, "diff3")) - git_xmerge_style = XDL_MERGE_DIFF3; - else if (!strcmp(value, "zdiff3")) - git_xmerge_style = XDL_MERGE_ZEALOUS_DIFF3; - else if (!strcmp(value, "merge")) - git_xmerge_style = 0; - /* - * Please update _git_checkout() in - * git-completion.bash when you add new merge config - */ - else + git_xmerge_style = parse_conflict_style(value); + if (git_xmerge_style == -1) return error(_("unknown style '%s' given for '%s'"), value, var); return 0; diff --git a/xdiff-interface.h b/xdiff-interface.h index e6f80df0462..c569b7c5203 100644 --- a/xdiff-interface.h +++ b/xdiff-interface.h @@ -51,6 +51,7 @@ int buffer_is_binary(const char *ptr, unsigned long size); void xdiff_set_find_func(xdemitconf_t *xecfg, const char *line, int cflags); void xdiff_clear_find_func(xdemitconf_t *xecfg); struct config_context; +int parse_conflict_style(const char *value); int git_xmerge_config(const char *var, const char *value, const struct config_context *ctx, void *cb); extern int git_xmerge_style; From patchwork Fri Mar 8 14:14:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Phillip Wood X-Patchwork-Id: 13586866 Received: from mail-lf1-f49.google.com (mail-lf1-f49.google.com [209.85.167.49]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id ADEF148CE0 for ; Fri, 8 Mar 2024 14:14:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.49 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709907278; cv=none; b=ghiPDYNJByCWiLd7tPydUIfhQ56+ANV518zUHjg46z/yiHqAT0lWNIvccZF1D2k6XluwwgR/DyymzR0HgsDQVZ0TBpazXSAMJuLOxewgcEcaDkjBo8iX0uM2sAKFRtxFGsvwFoLU5Xc++VgqjKBoFW/G7KuY1dOqskO2yO7jmXw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709907278; c=relaxed/simple; bh=A0YrVTjRnqL1mcqVGqhcC1XMkZymD6gkzV4SF1wYBX8=; h=Message-ID:In-Reply-To:References:From:Date:Subject:Content-Type: MIME-Version:To:Cc; b=AwyphwhM9qqSeZH80QO4N//Z/dUZWUCDEjmE42Jz4BKpYUu6XB/sn05+R4z7wK+iSH940sBcU8MueMZWudRgE3yOI7NGKcrJFnn3ZC9fs/JOaJno7g3V1GPLR3YhdxcwMYmDpOHXPqZUwsjD8kCRObUnY5BMTFZN8gl+B37w9NU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=XSdyKdzA; arc=none smtp.client-ip=209.85.167.49 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="XSdyKdzA" Received: by mail-lf1-f49.google.com with SMTP id 2adb3069b0e04-512ed314881so2030584e87.2 for ; Fri, 08 Mar 2024 06:14:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1709907274; x=1710512074; darn=vger.kernel.org; h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date:from :references:in-reply-to:message-id:from:to:cc:subject:date :message-id:reply-to; bh=C3igKwnp4fvuAKJOi8YTwLUw7jLZUiI8LUC+1noZy9w=; b=XSdyKdzA99GJagtY+K+xSMaH52Wr8LMwGQE9wuuIuXVjyyFs+ympmxbr97YxbSLETo ow6YvBPvIBOxlYLq2YXlWFa6out2+UKSUaS/tYo0G26gbuOz+4xywUjKIJu9wZ6i2gqP sH3zysHdE0W/dzfXn3nAS8pP79fdPDyj2WnCYs72TxCvhzBD9vu7uZ376H+0i6QURNxr Ir07ZaPN2uUdBbYcI1sCS6prphZnjKuQtWW8UHy7tuDhduDcpaSlg3L/oMlM010GtG8r VtiuR309Beca56M23BrWPqQTJ6aXp+Vy4TM7llZJ+My6cQ2idLH0M2r8xzv2yOhhhdfI eArA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709907274; x=1710512074; h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date:from :references:in-reply-to:message-id:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=C3igKwnp4fvuAKJOi8YTwLUw7jLZUiI8LUC+1noZy9w=; b=e8aIaSz30dhwPTtlNVUy6UJ4cKqcOymsQsRqSXTvqCqbWmZQweCIiplRaaqrXxdGr6 9a6ffR7/Z8S3GtT9Dn2iwUkFNpL9vRqz8BRurb5HvFyBEiYoyT40jMhxEpVo/5FBL27L 6iiSEKMovdma0NlPf3DCjibMzKeO7RoRAXJp1cSfdZw6swt5rH7AD6IdXxAi5aN8uLFl 5E8b8cf2PuAxn/yNSPj8gWSywwyKhtXr+7MoRnRNGbDeMW3Clzu2Zq8P4GKCJgCVoGBl l8DHFYoq98MtSjYQ7T243HE6i9WswDIY2Xmcfb5+8jtUwfHurbP0qvCj/yYZImYh+5O1 eEyQ== X-Gm-Message-State: AOJu0Yw1wACdoQr4vjkSAhDNIvVnLdIbXHRCvoXKcw2TwBA//1AIpdxB QD1lq+XKcJEzMbiYRIdpwRYQ914QBEkg14e0bhYNmh4SWfPSjgYb44JfkoJy X-Google-Smtp-Source: AGHT+IHuWa7o96CF1sYJ9m8ugTOb3X27h9L9s9wPoHwqj59OeiOCGyd5bluwP39mvl+IwRGJi0X3jA== X-Received: by 2002:ac2:55a6:0:b0:513:3f81:224f with SMTP id y6-20020ac255a6000000b005133f81224fmr3701117lfg.37.1709907273946; Fri, 08 Mar 2024 06:14:33 -0800 (PST) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id fc20-20020a05600c525400b00412ae4b45b3sm5976969wmb.30.2024.03.08.06.14.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Mar 2024 06:14:32 -0800 (PST) Message-ID: <4e05bc156bc93e86f3f2ac878c39596bec722a56.1709907270.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Fri, 08 Mar 2024 14:14:28 +0000 Subject: [PATCH 2/4] merge-ll: introduce LL_MERGE_OPTIONS_INIT Fcc: Sent Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 To: git@vger.kernel.org Cc: Phillip Wood , Phillip Wood From: Phillip Wood From: Phillip Wood Introduce a macro to initialize `struct ll_merge_options` in preparation for the next commit that will add a new member that needs to be initialized to a non-zero value. Signed-off-by: Phillip Wood --- builtin/checkout.c | 3 +-- merge-ll.c | 2 +- merge-ll.h | 2 ++ merge-ort.c | 2 +- merge-recursive.c | 2 +- 5 files changed, 6 insertions(+), 5 deletions(-) diff --git a/builtin/checkout.c b/builtin/checkout.c index 067c2519334..6ded58bd95c 100644 --- a/builtin/checkout.c +++ b/builtin/checkout.c @@ -262,7 +262,7 @@ static int checkout_merged(int pos, const struct checkout *state, mmbuffer_t result_buf; struct object_id threeway[3]; unsigned mode = 0; - struct ll_merge_options ll_opts; + struct ll_merge_options ll_opts = LL_MERGE_OPTIONS_INIT; int renormalize = 0; memset(threeway, 0, sizeof(threeway)); @@ -284,7 +284,6 @@ static int checkout_merged(int pos, const struct checkout *state, read_mmblob(&ours, &threeway[1]); read_mmblob(&theirs, &threeway[2]); - memset(&ll_opts, 0, sizeof(ll_opts)); git_config_get_bool("merge.renormalize", &renormalize); ll_opts.renormalize = renormalize; merge_status = ll_merge(&result_buf, path, &ancestor, "base", diff --git a/merge-ll.c b/merge-ll.c index 61e0ae53981..6570707297d 100644 --- a/merge-ll.c +++ b/merge-ll.c @@ -401,7 +401,7 @@ enum ll_merge_result ll_merge(mmbuffer_t *result_buf, const struct ll_merge_options *opts) { struct attr_check *check = load_merge_attributes(); - static const struct ll_merge_options default_opts; + static const struct ll_merge_options default_opts = LL_MERGE_OPTIONS_INIT; const char *ll_driver_name = NULL; int marker_size = DEFAULT_CONFLICT_MARKER_SIZE; const struct ll_merge_driver *driver; diff --git a/merge-ll.h b/merge-ll.h index e4a20e81a3a..af1ee36abdb 100644 --- a/merge-ll.h +++ b/merge-ll.h @@ -82,6 +82,8 @@ struct ll_merge_options { long xdl_opts; }; +#define LL_MERGE_OPTIONS_INIT {0} + enum ll_merge_result { LL_MERGE_ERROR = -1, LL_MERGE_OK = 0, diff --git a/merge-ort.c b/merge-ort.c index 8617babee41..4a02c3ecd99 100644 --- a/merge-ort.c +++ b/merge-ort.c @@ -1956,7 +1956,7 @@ static int merge_3way(struct merge_options *opt, mmbuffer_t *result_buf) { mmfile_t orig, src1, src2; - struct ll_merge_options ll_opts = {0}; + struct ll_merge_options ll_opts = LL_MERGE_OPTIONS_INIT; char *base, *name1, *name2; enum ll_merge_result merge_status; diff --git a/merge-recursive.c b/merge-recursive.c index a0c3e7a2d91..02b7b584f95 100644 --- a/merge-recursive.c +++ b/merge-recursive.c @@ -1047,7 +1047,7 @@ static int merge_3way(struct merge_options *opt, const int extra_marker_size) { mmfile_t orig, src1, src2; - struct ll_merge_options ll_opts = {0}; + struct ll_merge_options ll_opts = LL_MERGE_OPTIONS_INIT; char *base, *name1, *name2; enum ll_merge_result merge_status; From patchwork Fri Mar 8 14:14:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Phillip Wood X-Patchwork-Id: 13586867 Received: from mail-wr1-f47.google.com (mail-wr1-f47.google.com [209.85.221.47]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1DD2D4CE05 for ; Fri, 8 Mar 2024 14:14:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.47 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709907278; cv=none; b=GWt7oSvMt1wYVbbqBce7N8r07WghT9Jt+PVeCDZRuReJmObNOrw9qHJbvOxRQYO8g+3MYKY5gfp3rWB7zxUN6hQ2ITeOU4DKK0gyZ853OHqU0e3dRw8ZcqfCfAyWjT6FG+uKyxpK0JtVMA+i65Sa17ZlAH9XfEAD62sV6mzBwHU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709907278; c=relaxed/simple; bh=T5XxBEBaYuACA2GrzRCBSpRuI9t7YZuvFVR64MSqJ+E=; h=Message-ID:In-Reply-To:References:From:Date:Subject:Content-Type: MIME-Version:To:Cc; b=ZZTJKbdvqZAySzYZHW3B/7Xr5zrQWSSqh6OHsBzp5R/T3lc61IuNOCtuLVUJcdkIiXStYtv2JK6GYOA/0nnWeXbChpm5BqhsuZ+X4dZqzR2jx3ZE7+Pe8Ij2ewMiJZboWremaWfW5wzByjzvKjFidvGYIA3LiKIYbpqIeQdmIkU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=Y1RX7Zwj; arc=none smtp.client-ip=209.85.221.47 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Y1RX7Zwj" Received: by mail-wr1-f47.google.com with SMTP id ffacd0b85a97d-33e383546c1so1272843f8f.2 for ; Fri, 08 Mar 2024 06:14:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1709907275; x=1710512075; darn=vger.kernel.org; h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date:from :references:in-reply-to:message-id:from:to:cc:subject:date :message-id:reply-to; bh=0IQe7fFSBIOKmZgTGj08sFRGzDizk0S4zIjA9PLPARo=; b=Y1RX7ZwjKKGTOtmoRJqxylAM8tQqTEu8gdqwMbAy3vSruWWZTPlWXSwX06OizVrC1o bp8uyLoSX0lH8tu/jiul/0XmvPxg9aYhhR/uPp8Fpbs8uwvHFJouallkvn3RUPChZtLx Y1GJ7iPALLCwSGo5xhjICf3nuOqF0Oj4JiVoSMBYqNRpLzImzOxidhHxHLTeS5P8mRct Vnfa9JUsF3UkaA6k84q/4KOvsQeuGVS+wXqAMPg50JmHqzB0LIDPBOocvnUNtQOnXCLX mPPOciDrum15BDvlBL+tiGss862uozGyFRCucO+W/0YS8nQynghGttT/xnePa7J3UH/x BSZQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709907275; x=1710512075; h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date:from :references:in-reply-to:message-id:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=0IQe7fFSBIOKmZgTGj08sFRGzDizk0S4zIjA9PLPARo=; b=OI23W6eq74tOZ8CJL6GE57TpXHzpBkn4/gt8gDuG+UyOHp34M8WExCRiRMyxzo59Ri xRI/kpYiTuxXkP55YEIIzDgzDPLGVgYdAoYJvm2T4/puVIewePGeuYezRd30ZvKwdVA2 CTQanXQzuAoJ9hqMMaj5lPIbiv1W7yRYRxDAtV2FSbnvnVZSTziTavjWEfPDsZGcXJMU t/4Wln/XX7ExAuwAeQcIFZwkHs65uB9ieccGAze107tVP2m0+CEd6LgbN+s4AW0x9xRC EJyJHZBSfAiyHDF5IxmazVqmzXP8fAxxwyVKJrnf2Ths51Ct3Vt1yLla702OZPVhs6Wt wItw== X-Gm-Message-State: AOJu0YxJRbgjtI7hC8s+5EpRXV7klbRFuW6T1MCRGdL1O9aqJZ5ikMaf 9w3avVyAeorMlm4bDj+X5GrPx2z9y6+S7HkpmkCJoyvZvTOjepq0yLiZTVxf X-Google-Smtp-Source: AGHT+IEA/BkbTnFb169cumJxTfE7VsC8kQxX9IyHrvZc2+OoxogsAl0vug9h5zBOVPFwWb1UvIpfow== X-Received: by 2002:a5d:6d8b:0:b0:33d:354a:99b2 with SMTP id l11-20020a5d6d8b000000b0033d354a99b2mr19163765wrs.3.1709907274616; Fri, 08 Mar 2024 06:14:34 -0800 (PST) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id bv28-20020a0560001f1c00b0033d70dd0e04sm23377341wrb.8.2024.03.08.06.14.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Mar 2024 06:14:34 -0800 (PST) Message-ID: In-Reply-To: References: Date: Fri, 08 Mar 2024 14:14:29 +0000 Subject: [PATCH 3/4] merge options: add a conflict style member Fcc: Sent Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 To: git@vger.kernel.org Cc: Phillip Wood , Phillip Wood From: Phillip Wood From: Phillip Wood Add a conflict_style member to `struct merge_options` and `struct ll_merge_options` to allow callers to override the default conflict style. This will be used in the next commit. Signed-off-by: Phillip Wood --- merge-ll.c | 4 +++- merge-ll.h | 5 ++++- merge-ort.c | 1 + merge-recursive.c | 3 +++ merge-recursive.h | 1 + 5 files changed, 12 insertions(+), 2 deletions(-) diff --git a/merge-ll.c b/merge-ll.c index 6570707297d..bf1077ae092 100644 --- a/merge-ll.c +++ b/merge-ll.c @@ -128,7 +128,9 @@ static enum ll_merge_result ll_xdl_merge(const struct ll_merge_driver *drv_unuse xmp.level = XDL_MERGE_ZEALOUS; xmp.favor = opts->variant; xmp.xpp.flags = opts->xdl_opts; - if (git_xmerge_style >= 0) + if (opts->conflict_style >= 0) + xmp.style = opts->conflict_style; + else if (git_xmerge_style >= 0) xmp.style = git_xmerge_style; if (marker_size > 0) xmp.marker_size = marker_size; diff --git a/merge-ll.h b/merge-ll.h index af1ee36abdb..d038ee0c1e8 100644 --- a/merge-ll.h +++ b/merge-ll.h @@ -78,11 +78,14 @@ struct ll_merge_options { */ unsigned extra_marker_size; + /* Override the global conflict style. */ + int conflict_style; + /* Extra xpparam_t flags as defined in xdiff/xdiff.h. */ long xdl_opts; }; -#define LL_MERGE_OPTIONS_INIT {0} +#define LL_MERGE_OPTIONS_INIT { .conflict_style = -1 } enum ll_merge_result { LL_MERGE_ERROR = -1, diff --git a/merge-ort.c b/merge-ort.c index 4a02c3ecd99..a9ab4031451 100644 --- a/merge-ort.c +++ b/merge-ort.c @@ -1966,6 +1966,7 @@ static int merge_3way(struct merge_options *opt, ll_opts.renormalize = opt->renormalize; ll_opts.extra_marker_size = extra_marker_size; ll_opts.xdl_opts = opt->xdl_opts; + ll_opts.conflict_style = opt->conflict_style; if (opt->priv->call_depth) { ll_opts.virtual_ancestor = 1; diff --git a/merge-recursive.c b/merge-recursive.c index 02b7b584f95..33b5f9384e8 100644 --- a/merge-recursive.c +++ b/merge-recursive.c @@ -1054,6 +1054,7 @@ static int merge_3way(struct merge_options *opt, ll_opts.renormalize = opt->renormalize; ll_opts.extra_marker_size = extra_marker_size; ll_opts.xdl_opts = opt->xdl_opts; + ll_opts.conflict_style = opt->conflict_style; if (opt->priv->call_depth) { ll_opts.virtual_ancestor = 1; @@ -3899,6 +3900,8 @@ void init_merge_options(struct merge_options *opt, opt->renormalize = 0; + opt->conflict_style = -1; + merge_recursive_config(opt); merge_verbosity = getenv("GIT_MERGE_VERBOSITY"); if (merge_verbosity) diff --git a/merge-recursive.h b/merge-recursive.h index 3d3b3e3c295..e67d38c3030 100644 --- a/merge-recursive.h +++ b/merge-recursive.h @@ -31,6 +31,7 @@ struct merge_options { /* xdiff-related options (patience, ignore whitespace, ours/theirs) */ long xdl_opts; + int conflict_style; enum { MERGE_VARIANT_NORMAL = 0, MERGE_VARIANT_OURS, From patchwork Fri Mar 8 14:14:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Phillip Wood X-Patchwork-Id: 13586868 Received: from mail-wr1-f53.google.com (mail-wr1-f53.google.com [209.85.221.53]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C32735339B for ; Fri, 8 Mar 2024 14:14:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.53 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709907280; cv=none; b=EzKrNcFAherD6n3ROvzlZCra7a+C/OFLoX0yq4jY6gQS5iEaJo9TyOYRpAAGgOxdaPAPn9pMOrgavg6V5vsHq/S9fczQ3L1dD7v9z+rHKMnEC/qoyj+T+Mdoq1LM8fO0UOtXMJ1SVFLnUzM4XY4euAHn/+sWT/QQyuN8UzbbaC0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709907280; c=relaxed/simple; bh=mCqkT0G2EZrIymJHIXn/7kkAfgMDhI/Vvzd5mT+8+bg=; h=Message-ID:In-Reply-To:References:From:Date:Subject:Content-Type: MIME-Version:To:Cc; b=YV28F7V6nZ6CuE9ndO2SiCWeN3S7TEqSFGrJuKNZ/AUcDmhuGkv0BhhJxZFqjESXnxTaaPf5JoYVZYl851EGnV50O1RB8WNYwJWeNeXCWPusmAIyaJDaTTzO7rPVcqPSLEYPGBxhn1MFk+bNMfA8F8BXDoSHmZRcs+fBRsj2DbQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=SF/+pi14; arc=none smtp.client-ip=209.85.221.53 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="SF/+pi14" Received: by mail-wr1-f53.google.com with SMTP id ffacd0b85a97d-33e383546c1so1272854f8f.2 for ; Fri, 08 Mar 2024 06:14:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1709907276; x=1710512076; darn=vger.kernel.org; h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date:from :references:in-reply-to:message-id:from:to:cc:subject:date :message-id:reply-to; bh=LtPk7SV/A8XooDvCNOOiFWmXHz1TF1ummXpO+MFiZSQ=; b=SF/+pi14SpUxCQ9mxfh/5hZhv7+q9goaflIGNPAN9o45Q5eTHCrSaUOGkdIOqtb1H3 bOIs48LH/YnHV+q19kqRzwsqTOd4lxDrpeafTnLMgAF6OkMsdQ6hNDdW/G3qfE97OmA7 34o5KMBG70tKEHIniEkxbPNfVkB1Y5rQgGK57cuNtcwKuc9wm5nhSAAIHLDG4YG1onpV 3MJkoBfW0zNalVsHgEQa3CKeWQYprZYGs/pUCsCd2YF9FwlbdS/eV7E/JjevVbbGZyYM Xlho/nn5+rXCKvR3TAk2RpDAA/X2dm9juIsySk9yjEmh4eHKQLE2ymtudphcO0cskKOI GwOA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709907276; x=1710512076; h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date:from :references:in-reply-to:message-id:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=LtPk7SV/A8XooDvCNOOiFWmXHz1TF1ummXpO+MFiZSQ=; b=o79ySKQUBf5GIc2y8XOVl5fT3MsNBsgi72PM47BGBfZGjTyxyNoVIa64O8DaN5/5U0 DfpGDmT9Sjk+pSTOM4TYFTHYO7mgD12xZFc5cJavCSaPsWRjOetrZGacNUUszlKRKWC7 2KhRToAT39PJFwthjTmStm7cU9LNf5oZLsPhO5xILNvzPNo1cieSvxkwC15YWuVcNFuM Ei/IfjKtKioy/DLOmYHeJ/9yIbpxfp8AJdhIYiq7gHYn4eM/2WGxJlYa5kiULe8/xkGs grhO6Mam+DzsocLrU8G75AFXF73KXFvDsy4oyqbtpHn3whnVFdD09cGXP4MsYht7NKT5 Fhuw== X-Gm-Message-State: AOJu0YwdeQyyAHlLegclD0QgHl2KPggWfLnPhB2MFHKXgI3QPqM8Xk1P f9bKUKmN96tr3cORTqc+/xlv8XY1nmfstKYACCHfos2hBhI1SOE/xJrv7sxT X-Google-Smtp-Source: AGHT+IGynynVGuE58kTkSnMNFxJc2dtIdZvkXGM73Ibb7IAU96Iz6sm6pQ+oG/uOtR2c4UBA3XyksA== X-Received: by 2002:adf:cc84:0:b0:33e:798f:6d1e with SMTP id p4-20020adfcc84000000b0033e798f6d1emr819157wrj.37.1709907276020; Fri, 08 Mar 2024 06:14:36 -0800 (PST) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id n12-20020adfe78c000000b0033e745176f5sm2367572wrm.110.2024.03.08.06.14.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Mar 2024 06:14:34 -0800 (PST) Message-ID: <317bb7a70d023278087f4370b843d7f28f9ee2f6.1709907271.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Fri, 08 Mar 2024 14:14:30 +0000 Subject: [PATCH 4/4] checkout: cleanup --conflict=