{"thread":{"id":"53332","subject":"[PATCH] rebase: display an error if --root and --fork-point are both provided","startedAt":"2020-04-27T16:21:46Z","lastAt":"2020-04-27T17:59:55Z","messageCount":3,"participants":["Elijah Newren via GitGitGadget","Alban Gruin"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"396342","messageId":"pull.771.git.git.1588004500766.gitgitgadget@gmail.com","threadId":"53332","inReplyTo":null,"subject":"[PATCH] rebase: display an error if --root and --fork-point are both provided","fromName":"Elijah Newren via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2020-04-27T16:21:39Z","receivedAt":"2020-04-27T16:21:46Z","isPatch":true,"sender":{"key":"newren@gmail.com","avatar":"https://avatars.githubusercontent.com/u/5455730?v=4"},"body":"From: Elijah Newren <newren@gmail.com>\n\n--root implies we want to rebase all commits since the beginning of\nhistory.  --fork-point means we want to use the reflog of the specified\nupstream to find the best common ancestor between <upstream> and\n<branch> and only rebase commits since that common ancestor.  These\noptions are clearly contradictory, so throw an error (instead of\nsegfaulting on a NULL pointer) if both are specified.\n\nReported-by: Alexander Berg <alexander.berg@atos.net>\nSigned-off-by: Elijah Newren <newren@gmail.com>\n---\n    rebase: display an error if --root and --fork-point are both provided\n    \n    --root implies we want to rebase all commits since the beginning of\n    history. --fork-point means we want to use the reflog of the specified\n    upstream to find the best common ancestor between and and only rebase\n    commits since that common ancestor. These options are clearly\n    contradictory, so throw an error (instead of segfaulting on a NULL\n    pointer) if both are specified.\n    \n    Reported-by: Alexander Berg alexander.berg@atos.net\n    [alexander.berg@atos.net]Signed-off-by: Elijah Newren newren@gmail.com\n    [newren@gmail.com]\n\nPublished-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-771%2Fnewren%2Frebase-fork-point-root-error-v1\nFetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-771/newren/rebase-fork-point-root-error-v1\nPull-Request: https://github.com/git/git/pull/771\n\n builtin/rebase.c | 3 +++\n 1 file changed, 3 insertions(+)\n\ndiff --git a/builtin/rebase.c b/builtin/rebase.c\nindex bff53d5d167..287ac1aa21b 100644\n--- a/builtin/rebase.c\n+++ b/builtin/rebase.c\n@@ -1652,6 +1652,9 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)\n \t\t\tdie(_(\"cannot combine '--keep-base' with '--root'\"));\n \t}\n \n+\tif (options.root && fork_point > 0)\n+\t\tdie(_(\"cannot combine '--root' with '--fork-point'\"));\n+\n \tif (action != ACTION_NONE && !in_progress)\n \t\tdie(_(\"No rebase in progress?\"));\n \tsetenv(GIT_REFLOG_ACTION_ENVIRONMENT, \"rebase\", 0);\n\nbase-commit: af6b65d45ef179ed52087e80cb089f6b2349f4ec\n-- \ngitgitgadget\n"},{"id":"396351","messageId":"7f8b3ab5-9632-637d-27db-7e35330ff31d@gmail.com","threadId":"53332","inReplyTo":"pull.771.git.git.1588004500766.gitgitgadget@gmail.com","subject":"Re: [PATCH] rebase: display an error if --root and --fork-point are both provided","fromName":"Alban Gruin","fromEmail":"alban.gruin@gmail.com","sentAt":"2020-04-27T16:46:33Z","receivedAt":"2020-04-27T16:46:47Z","isPatch":true,"sender":{"key":"alban.gruin@gmail.com","avatar":"https://avatars.githubusercontent.com/u/6310153?v=4"},"body":"Hi Elijah,\n\nLe 27/04/2020 à 18:21, Elijah Newren via GitGitGadget a écrit :\n> From: Elijah Newren <newren@gmail.com>\n> \n> --root implies we want to rebase all commits since the beginning of\n> history.  --fork-point means we want to use the reflog of the specified\n> upstream to find the best common ancestor between <upstream> and\n> <branch> and only rebase commits since that common ancestor.  These\n> options are clearly contradictory, so throw an error (instead of\n> segfaulting on a NULL pointer) if both are specified.\n> \n> Reported-by: Alexander Berg <alexander.berg@atos.net>\n> Signed-off-by: Elijah Newren <newren@gmail.com>\n> ---\n>     rebase: display an error if --root and --fork-point are both provided\n>     \n>     --root implies we want to rebase all commits since the beginning of\n>     history. --fork-point means we want to use the reflog of the specified\n>     upstream to find the best common ancestor between and and only rebase\n>     commits since that common ancestor. These options are clearly\n>     contradictory, so throw an error (instead of segfaulting on a NULL\n>     pointer) if both are specified.\n>     \n>     Reported-by: Alexander Berg alexander.berg@atos.net\n>     [alexander.berg@atos.net]Signed-off-by: Elijah Newren newren@gmail.com\n>     [newren@gmail.com]\n> \n> Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-771%2Fnewren%2Frebase-fork-point-root-error-v1\n> Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-771/newren/rebase-fork-point-root-error-v1\n> Pull-Request: https://github.com/git/git/pull/771\n> \n>  builtin/rebase.c | 3 +++\n>  1 file changed, 3 insertions(+)\n> \n> diff --git a/builtin/rebase.c b/builtin/rebase.c\n> index bff53d5d167..287ac1aa21b 100644\n> --- a/builtin/rebase.c\n> +++ b/builtin/rebase.c\n> @@ -1652,6 +1652,9 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)\n>  \t\t\tdie(_(\"cannot combine '--keep-base' with '--root'\"));\n>  \t}\n>  \n> +\tif (options.root && fork_point > 0)\n> +\t\tdie(_(\"cannot combine '--root' with '--fork-point'\"));\n> +\n>  \tif (action != ACTION_NONE && !in_progress)\n>  \t\tdie(_(\"No rebase in progress?\"));\n>  \tsetenv(GIT_REFLOG_ACTION_ENVIRONMENT, \"rebase\", 0);\n> \n> base-commit: af6b65d45ef179ed52087e80cb089f6b2349f4ec\n> \n\nThe patch is fairly obvious and looks good to me.\n\nThe documentation must be updated, too, since it does not mention the\nincompatibility between the two switches:\n\n-- snip --\ndiff --git a/Documentation/git-rebase.txt b/Documentation/git-rebase.txt\nindex bed500f151..a30de5aa20 100644\n--- a/Documentation/git-rebase.txt\n+++ b/Documentation/git-rebase.txt\n@@ -448,12 +448,14 @@ When --fork-point is active, 'fork_point' will be\nused instead of\n <branch>` command (see linkgit:git-merge-base[1]).  If 'fork_point'\n ends up being empty, the <upstream> will be used as a fallback.\n +\n-If either <upstream> or --root is given on the command line, then the\n-default is `--no-fork-point`, otherwise the default is `--fork-point`.\n+If <upstream> is given on the command line, then the default is\n+`--no-fork-point`, otherwise the default is `--fork-point`.\n +\n If your branch was based on <upstream> but <upstream> was rewound and\n your branch contains commits which were dropped, this option can be used\n with `--keep-base` in order to drop those commits from your branch.\n++\n+See also INCOMPATIBLE OPTIONS below.\n\n --ignore-whitespace::\n --whitespace=<option>::\n@@ -635,6 +637,7 @@ In addition, the following pairs of options are\nincompatible:\n  * --preserve-merges and --empty=\n  * --keep-base and --onto\n  * --keep-base and --root\n+ * --fork-point and --root\n\n BEHAVIORAL DIFFERENCES\n -----------------------\n-- snap --\n\nCheers,\nAlban\n\n"},{"id":"396361","messageId":"pull.771.v2.git.git.1588010390778.gitgitgadget@gmail.com","threadId":"53332","inReplyTo":"pull.771.git.git.1588004500766.gitgitgadget@gmail.com","subject":"[PATCH v2] rebase: display an error if --root and --fork-point are both provided","fromName":"Elijah Newren via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2020-04-27T17:59:49Z","receivedAt":"2020-04-27T17:59:55Z","isPatch":true,"sender":{"key":"newren@gmail.com","avatar":"https://avatars.githubusercontent.com/u/5455730?v=4"},"body":"From: Elijah Newren <newren@gmail.com>\n\n--root implies we want to rebase all commits since the beginning of\nhistory.  --fork-point means we want to use the reflog of the specified\nupstream to find the best common ancestor between <upstream> and\n<branch> and only rebase commits since that common ancestor.  These\noptions are clearly contradictory, so throw an error (instead of\nsegfaulting on a NULL pointer) if both are specified.\n\nReported-by: Alexander Berg <alexander.berg@atos.net>\nDocumentation-by: Alban Gruin <alban.gruin@gmail.com>\nSigned-off-by: Elijah Newren <newren@gmail.com>\n---\n    rebase: display an error if --root and --fork-point are both provided\n\nPublished-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-771%2Fnewren%2Frebase-fork-point-root-error-v2\nFetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-771/newren/rebase-fork-point-root-error-v2\nPull-Request: https://github.com/git/git/pull/771\n\nRange-diff vs v1:\n\n 1:  c4508c7ddae ! 1:  307124b00d4 rebase: display an error if --root and --fork-point are both provided\n     @@ Commit message\n          segfaulting on a NULL pointer) if both are specified.\n      \n          Reported-by: Alexander Berg <alexander.berg@atos.net>\n     +    Documentation-by: Alban Gruin <alban.gruin@gmail.com>\n          Signed-off-by: Elijah Newren <newren@gmail.com>\n      \n     + ## Documentation/git-rebase.txt ##\n     +@@ Documentation/git-rebase.txt: When --fork-point is active, 'fork_point' will be used instead of\n     + <branch>` command (see linkgit:git-merge-base[1]).  If 'fork_point'\n     + ends up being empty, the <upstream> will be used as a fallback.\n     + +\n     +-If either <upstream> or --root is given on the command line, then the\n     +-default is `--no-fork-point`, otherwise the default is `--fork-point`.\n     ++If <upstream> is given on the command line, then the default is\n     ++`--no-fork-point`, otherwise the default is `--fork-point`.\n     + +\n     + If your branch was based on <upstream> but <upstream> was rewound and\n     + your branch contains commits which were dropped, this option can be used\n     + with `--keep-base` in order to drop those commits from your branch.\n     +++\n     ++See also INCOMPATIBLE OPTIONS below.\n     + \n     + --ignore-whitespace::\n     + --whitespace=<option>::\n     +@@ Documentation/git-rebase.txt: In addition, the following pairs of options are incompatible:\n     +  * --preserve-merges and --empty=\n     +  * --keep-base and --onto\n     +  * --keep-base and --root\n     ++ * --fork-point and --root\n     + \n     + BEHAVIORAL DIFFERENCES\n     + -----------------------\n     +\n       ## builtin/rebase.c ##\n      @@ builtin/rebase.c: int cmd_rebase(int argc, const char **argv, const char *prefix)\n       \t\t\tdie(_(\"cannot combine '--keep-base' with '--root'\"));\n\n\n Documentation/git-rebase.txt | 7 +++++--\n builtin/rebase.c             | 3 +++\n 2 files changed, 8 insertions(+), 2 deletions(-)\n\ndiff --git a/Documentation/git-rebase.txt b/Documentation/git-rebase.txt\nindex f7a6033607f..fbad356c68e 100644\n--- a/Documentation/git-rebase.txt\n+++ b/Documentation/git-rebase.txt\n@@ -414,12 +414,14 @@ When --fork-point is active, 'fork_point' will be used instead of\n <branch>` command (see linkgit:git-merge-base[1]).  If 'fork_point'\n ends up being empty, the <upstream> will be used as a fallback.\n +\n-If either <upstream> or --root is given on the command line, then the\n-default is `--no-fork-point`, otherwise the default is `--fork-point`.\n+If <upstream> is given on the command line, then the default is\n+`--no-fork-point`, otherwise the default is `--fork-point`.\n +\n If your branch was based on <upstream> but <upstream> was rewound and\n your branch contains commits which were dropped, this option can be used\n with `--keep-base` in order to drop those commits from your branch.\n++\n+See also INCOMPATIBLE OPTIONS below.\n \n --ignore-whitespace::\n --whitespace=<option>::\n@@ -600,6 +602,7 @@ In addition, the following pairs of options are incompatible:\n  * --preserve-merges and --empty=\n  * --keep-base and --onto\n  * --keep-base and --root\n+ * --fork-point and --root\n \n BEHAVIORAL DIFFERENCES\n -----------------------\ndiff --git a/builtin/rebase.c b/builtin/rebase.c\nindex bff53d5d167..287ac1aa21b 100644\n--- a/builtin/rebase.c\n+++ b/builtin/rebase.c\n@@ -1652,6 +1652,9 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)\n \t\t\tdie(_(\"cannot combine '--keep-base' with '--root'\"));\n \t}\n \n+\tif (options.root && fork_point > 0)\n+\t\tdie(_(\"cannot combine '--root' with '--fork-point'\"));\n+\n \tif (action != ACTION_NONE && !in_progress)\n \t\tdie(_(\"No rebase in progress?\"));\n \tsetenv(GIT_REFLOG_ACTION_ENVIRONMENT, \"rebase\", 0);\n\nbase-commit: af6b65d45ef179ed52087e80cb089f6b2349f4ec\n-- \ngitgitgadget\n"}]}