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

Re: [PATCH 09/11] builtin rebase: start a new rebase only if none is in progress

From
Stefan Beller <sbeller@google.com>
Date
Aug 8, 2018, 18:59 UTC
Message-ID
<CAGZ79kafP=dVrwWopXW0WCWf199sU6uFSphjxtMTXDSix4Y81Q@mail.gmail.com>
In-Reply-To
<20180808134830.19949-10-predatoramigo@gmail.com>
On Wed, Aug 8, 2018 at 6:51 AM Pratik Karki <predatoramigo@gmail.com> wrote:
Show 71 quoted lines
>
> To run a new rebase, there needs to be a check to assure that no other
> rebase is in progress. New rebase operation cannot start until an
> ongoing rebase operation completes or is terminated.
>
> Signed-off-by: Pratik Karki <predatoramigo@gmail.com>
> ---
>  builtin/rebase.c | 48 +++++++++++++++++++++++++++++++++++++++++++++++-
>  1 file changed, 47 insertions(+), 1 deletion(-)
>
> diff --git a/builtin/rebase.c b/builtin/rebase.c
> index 8a7bf3d468..a261f552f1 100644
> --- a/builtin/rebase.c
> +++ b/builtin/rebase.c
> @@ -87,6 +87,7 @@ struct rebase_options {
>                 REBASE_VERBOSE = 1<<1,
>                 REBASE_DIFFSTAT = 1<<2,
>                 REBASE_FORCE = 1<<3,
> +               REBASE_INTERACTIVE_EXPLICIT = 1<<4,
>         } flags;
>         struct strbuf git_am_opt;
>  };
> @@ -392,10 +393,11 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
>                 .git_am_opt = STRBUF_INIT,
>         };
>         const char *branch_name;
> -       int ret, flags;
> +       int ret, flags, in_progress = 0;
>         int ok_to_skip_pre_rebase = 0;
>         struct strbuf msg = STRBUF_INIT;
>         struct strbuf revisions = STRBUF_INIT;
> +       struct strbuf buf = STRBUF_INIT;
>         struct object_id merge_base;
>         struct option builtin_rebase_options[] = {
>                 OPT_STRING(0, "onto", &options.onto_name,
> @@ -447,6 +449,30 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
>
>         git_config(rebase_config, &options);
>
> +       if (is_directory(apply_dir())) {
> +               options.type = REBASE_AM;
> +               options.state_dir = apply_dir();
> +       } else if (is_directory(merge_dir())) {
> +               strbuf_reset(&buf);
> +               strbuf_addf(&buf, "%s/rewritten", merge_dir());
> +               if (is_directory(buf.buf)) {
> +                       options.type = REBASE_PRESERVE_MERGES;
> +                       options.flags |= REBASE_INTERACTIVE_EXPLICIT;
> +               } else {
> +                       strbuf_reset(&buf);
> +                       strbuf_addf(&buf, "%s/interactive", merge_dir());
> +                       if(file_exists(buf.buf)) {
> +                               options.type = REBASE_INTERACTIVE;
> +                               options.flags |= REBASE_INTERACTIVE_EXPLICIT;
> +                       } else
> +                               options.type = REBASE_MERGE;
> +               }
> +               options.state_dir = merge_dir();
> +       }
> +
> +       if (options.type != REBASE_UNSPECIFIED)
> +               in_progress = 1;
> +
>         argc = parse_options(argc, argv, prefix,
>                              builtin_rebase_options,
>                              builtin_rebase_usage, 0);
> @@ -455,6 +481,26 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
>                 usage_with_options(builtin_rebase_usage,
>                                    builtin_rebase_options);
>
> +       /* Make sure no rebase is in progress */

The faithful conversion doesn't even stop at the comments. ;-) I shortly wondered if this is the best place for this comment, but let's just keep it here to have the 1:1 rewrite.

> +       if (in_progress) {
[...]
> +                   state_dir_base, cmd_live_rebase,buf.buf);

In case a resend is needed, add a whitespace after the comma and buf.buf, please.

So far I have not seen anything major that would warrant a resend.

Thanks, Stefan

Previous: Pratik KarkiNext: Johannes Schindelin
Message 22 of 42 in “A minimal builtin rebase”
  1. Pratik KarkiAug 8, 2018
  2. 01/11 builtin rebase: support --ontoPratik Karki, Aug 8, 2018
  3. Junio C HamanoAug 8, 2018
  4. Johannes SchindelinAug 24, 2018
  5. 02/11 builtin rebase: support `git rebase --onto A...B`Pratik Karki, Aug 8, 2018
  6. Junio C HamanoAug 8, 2018
  7. Johannes SchindelinAug 26, 2018
  8. 03/11 builtin rebase: handle the pre-rebase hook (and add --no-verify)Pratik Karki, Aug 8, 2018
  9. Junio C HamanoAug 8, 2018
  10. Johannes SchindelinAug 27, 2018
  11. 04/11 builtin rebase: support --quietPratik Karki, Aug 8, 2018
  12. Stefan BellerAug 8, 2018
  13. Junio C HamanoAug 8, 2018
  14. Johannes SchindelinAug 27, 2018
  15. 05/11 builtin rebase: support the `verbose` and `diffstat` optionsPratik Karki, Aug 8, 2018
  16. 06/11 builtin rebase: require a clean worktreePratik Karki, Aug 8, 2018
  17. 07/11 builtin rebase: try to fast forward when possiblePratik Karki, Aug 8, 2018
  18. 08/11 builtin rebase: support --force-rebasePratik Karki, Aug 8, 2018
  19. Stefan BellerAug 8, 2018
  20. Johannes SchindelinAug 24, 2018
  21. 09/11 builtin rebase: start a new rebase only if none is in progressPratik Karki, Aug 8, 2018
  22. Stefan BellerAug 8, 2018
  23. Johannes SchindelinAug 24, 2018
  24. 10/11 builtin rebase: only store fully-qualified refs in `options.head_name`Pratik Karki, Aug 8, 2018
  25. 11/11 builtin rebase: support `git rebase <upstream> <switch-to>`Pratik Karki, Aug 8, 2018
  26. Duy NguyenAug 8, 2018
  27. Johannes SchindelinAug 8, 2018
  28. 00/11 A minimal builtin rebaseJohannes Schindelin via GitGitGadget, Sep 4, 2018
  29. 01/11 builtin rebase: support --ontoPratik Karki via GitGitGadget, Sep 4, 2018
  30. 02/11 builtin rebase: support `git rebase --onto A...B`Pratik Karki via GitGitGadget, Sep 4, 2018
  31. 03/11 builtin rebase: handle the pre-rebase hook and --no-verifyPratik Karki via GitGitGadget, Sep 4, 2018
  32. 04/11 builtin rebase: support --quietPratik Karki via GitGitGadget, Sep 4, 2018
  33. 05/11 builtin rebase: support the `verbose` and `diffstat` optionsPratik Karki via GitGitGadget, Sep 4, 2018
  34. 06/11 builtin rebase: require a clean worktreePratik Karki via GitGitGadget, Sep 4, 2018
  35. 07/11 builtin rebase: try to fast forward when possiblePratik Karki via GitGitGadget, Sep 4, 2018
  36. 08/11 builtin rebase: support --force-rebasePratik Karki via GitGitGadget, Sep 4, 2018
  37. 09/11 builtin rebase: start a new rebase only if none is in progressPratik Karki via GitGitGadget, Sep 4, 2018
  38. 10/11 builtin rebase: only store fully-qualified refs in `options.head_name`Pratik Karki via GitGitGadget, Sep 4, 2018
  39. SZEDER GáborSep 8, 2018
  40. Junio C HamanoSep 10, 2018
  41. SZEDER GáborSep 10, 2018
  42. 11/11 builtin rebase: support `git rebase <upstream> <switch-to>`Pratik Karki via GitGitGadget, Sep 4, 2018

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.