git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* [BUG?] 'git rebase --update-refs --whitespace=fix' incompatible, but not enforced
@ 2023-01-17 22:02 Philippe Blain
  2023-01-18 15:51 ` Derrick Stolee
  0 siblings, 1 reply; 6+ messages in thread
From: Philippe Blain @ 2023-01-17 22:02 UTC (permalink / raw)
  To: Git mailing list, Derrick Stolee, Elijah Newren

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.

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2023-01-18 18:08 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-01-17 22:02 [BUG?] 'git rebase --update-refs --whitespace=fix' incompatible, but not enforced Philippe Blain
2023-01-18 15:51 ` Derrick Stolee
2023-01-18 16:16   ` Phillip Wood
2023-01-18 16:24   ` Elijah Newren
2023-01-18 17:03     ` Derrick Stolee
2023-01-18 18:07       ` Philippe Blain

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).