From: Mr Bill <billc56196@gmail.com>
To: git@vger.kernel.org
Subject: [PATCH] Handle rebase fork-point options in pull --rebase
Date: Wed, 14 May 2025 12:37:26 -0500 [thread overview]
Message-ID: <06beff46-cdaf-91c8-e6a3-6557694af618@gmail.com> (raw)
This is a patch to handle --fork-point and --no-fork-point in pull --rebase.
I had a recent bug report about pull --rebase not working correctly...
but it was working correctly, but not doing what I expected due to always
using "merge-base --fork-point"
This patch implements handling the --fork-point and --no-fork-point options,
and also checks the config rebase.forkpoint value...
and it works to resolve my prior bug report issue.
If there are any questions or comments, let me know!
Thanks to all for the help and comments on my prior bug report!
-Bill
diff --git a/builtin/pull.c b/builtin/pull.c
index a1ebc6a..f2d405f 100644
--- a/builtin/pull.c
+++ b/builtin/pull.c
@@ -117,6 +117,10 @@ static int opt_show_forced_updates = -1;
static const char *set_upstream;
static struct strvec opt_fetch = STRVEC_INIT;
+/* options to include rebase fork-point preference */
+static int config_fork_point = -1;
+static int opt_fork_point = -1;
+
static struct option pull_options[] = {
/* Shared options */
OPT__VERBOSITY(&opt_verbosity),
@@ -253,6 +257,10 @@ static struct option pull_options[] = {
N_("set upstream for git pull/fetch"),
PARSE_OPT_NOARG),
+ /* rebase option to use/not use merge-base --fork-point */
+ OPT_BOOL(0, "fork-point", &opt_fork_point,
+ N_("rebase with 'merge-base --fork-point' to refine upstream")),
+
OPT_END()
};
@@ -366,6 +374,9 @@ static int git_pull_config(const char *var, const
char *value,
if (!strcmp(var, "rebase.autostash")) {
config_autostash = git_config_bool(var, value);
return 0;
+ } else if (!strcmp(var, "rebase.forkpoint")) {
+ config_fork_point = git_config_bool(var, value) ? -1 : 0;
+ return 0;
} else if (!strcmp(var, "submodule.recurse")) {
recurse_submodules = git_config_bool(var, value) ?
RECURSE_SUBMODULES_ON : RECURSE_SUBMODULES_OFF;
@@ -1059,7 +1070,17 @@ int cmd_pull(int argc,
N_("pull with rebase"),
_("Please commit or stash them."), 1, 0);
- if (get_rebase_fork_point(&rebase_fork_point, repo, *refspecs))
+ if (opt_fork_point == -1)
+ opt_fork_point = config_fork_point;
+ if (opt_fork_point < 0)
+ opt_fork_point = 1;
+ fprintf_ln(stderr, _("rebasing %s fork-point"), (opt_fork_point
? "with" : "without"));
+
+ /*
+ * If we're *not* using fork-point, or we don't find one in
get_rebase_fork_point(),
+ * clear the rebase_fork_point info.
+ */
+ if (!opt_fork_point || get_rebase_fork_point(&rebase_fork_point,
repo, *refspecs))
oidclr(&rebase_fork_point, the_repository->hash_algo);
}
next reply other threads:[~2025-05-14 17:37 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-05-14 17:37 Mr Bill [this message]
2025-05-15 13:57 ` [PATCH] Handle rebase fork-point options in pull --rebase Junio C Hamano
2025-05-16 20:20 ` Mr Bill
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=06beff46-cdaf-91c8-e6a3-6557694af618@gmail.com \
--to=billc56196@gmail.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).