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

[BUG?] 'git rebase --update-refs --whitespace=fix' incompatible, but not enforced

From
Philippe Blain <levraiphilippeblain@gmail.com>
Date
Jan 17, 2023, 22:02 UTC
Message-ID
<b322c536-5a75-bb0c-8eac-1a99d3ba3230@gmail.com>
Hi Elijah and Stolee,

First, Stolee, thanks a lot for adding '--update-refs', it is very useful (I've added it to my config so I don't forget to use it).

I recently learned that 'git rebase --whitespace=fix' exists, which is also great but since it uses the apply backend, it can't be used with --update-refs. I understand this, and the fact that adding '--whitespace=fix' to the merge backend would be a big task; this is not what this email is about.

I think there is a bug in that the code does not enforce the fact that both options can't be used together. Whenever '--whitespace' or '-C' are used, the code defaults to the apply backend:

```builtin/rebase +1502
        if (options.git_am_opts.nr || options.type == REBASE_APPLY) {
                /* all am options except -q are compatible only with --apply */
                for (i = options.git_am_opts.nr - 1; i >= 0; i--)
                        if (strcmp(options.git_am_opts.v[i], "-q"))
                                break;
                if (i >= 0) {
                        if (is_merge(&options))
                                die(_("apply options and merge options "
                                          "cannot be used together"));
                        else
                                options.type = REBASE_APPLY;
                }
```

but 'is_merge' only checks if 'opts->type == REBASE_MERGE', so the check only works if --merge was given explicitely, but not when none of '--merge' or '--apply' were given (and so the default "merge" backend is used).

I would have expected the code to die telling me --update-refs and --whitespace are incompatible. But instead it defaulted to --apply, and (of course) did not update the refs in my history (which I found out later).

Thanks,
Philippe.
Next: Derrick Stolee
Message 1 of 6 in “[BUG?] 'git rebase --update-refs --whitespace=fix' incompatible, but not enforced”
  1. Philippe BlainJan 17, 2023
  2. Derrick StoleeJan 18, 2023
  3. Phillip WoodJan 18, 2023
  4. Elijah NewrenJan 18, 2023
  5. Derrick StoleeJan 18, 2023
  6. Philippe BlainJan 18, 2023

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.