git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH] rebase: display an error if --root and --fork-point are both provided

From
Elijah Newren via GitGitGadget <gitgitgadget@gmail.com>
Date
Apr 27, 2020, 16:21 UTC
Message-ID
<pull.771.git.git.1588004500766.gitgitgadget@gmail.com>
From: Elijah Newren <newren@gmail.com>

--root implies we want to rebase all commits since the beginning of history. --fork-point means we want to use the reflog of the specified upstream to find the best common ancestor between <upstream> and <branch> and only rebase commits since that common ancestor. These options are clearly contradictory, so throw an error (instead of segfaulting on a NULL pointer) if both are specified.

Reported-by: Alexander Berg <alexander.berg@atos.net>
Signed-off-by: Elijah Newren <newren@gmail.com>
---
    rebase: display an error if --root and --fork-point are both provided
    
    --root implies we want to rebase all commits since the beginning of
    history. --fork-point means we want to use the reflog of the specified
    upstream to find the best common ancestor between and and only rebase
    commits since that common ancestor. These options are clearly
    contradictory, so throw an error (instead of segfaulting on a NULL
    pointer) if both are specified.
    
    Reported-by: Alexander Berg alexander.berg@atos.net
    [alexander.berg@atos.net]Signed-off-by: Elijah Newren newren@gmail.com
    [newren@gmail.com]
Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-771%2Fnewren%2Frebase-fork-point-root-error-v1
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-771/newren/rebase-fork-point-root-error-v1
Pull-Request: https://github.com/git/git/pull/771
 builtin/rebase.c | 3 +++
 1 file changed, 3 insertions(+)
diff --git a/builtin/rebase.c b/builtin/rebase.c
index bff53d5d167..287ac1aa21b 100644
--- a/builtin/rebase.c
+++ b/builtin/rebase.c
@@ -1652,6 +1652,9 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
 			die(_("cannot combine '--keep-base' with '--root'"));
 	}
 
+	if (options.root && fork_point > 0)
+		die(_("cannot combine '--root' with '--fork-point'"));
+
 	if (action != ACTION_NONE && !in_progress)
 		die(_("No rebase in progress?"));
 	setenv(GIT_REFLOG_ACTION_ENVIRONMENT, "rebase", 0);

base-commit: af6b65d45ef179ed52087e80cb089f6b2349f4ec
-- 
gitgitgadget
Next: Alban Gruin
Message 1 of 3 in “rebase: display an error if --root and --fork-point are both provided”
  1. rebase: display an error if --root and --fork-point are both providedElijah Newren via GitGitGadget, Apr 27, 2020
  2. Alban GruinApr 27, 2020
  3. rebase: display an error if --root and --fork-point are both providedElijah Newren via GitGitGadget, Apr 27, 2020

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.