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

Re: git-rebase produces incorrect output

From
Junio C Hamano <gitster@pobox.com>
Date
Nov 30, 2019, 17:58 UTC
Message-ID
<xmqqa78d2qmk.fsf@gitster-ct.c.googlers.com>
In-Reply-To
<CABPp-BGiu2nVMQY_t-rnFR5GQUz_ipyEE8oDocKeO+h+t4Mn4A@mail.gmail.com>
Elijah Newren <newren@gmail.com> writes:
Show 6 quoted lines
> Sadly, I tried to force this with git rebase, but -C5 only affected
> the apply side and there's no option to pass to rebase to pass through
> -U5 to the diff logic.  Also, although there is a diff.context config
> option, git-am ignores it (Note that git_am_config() does not directly
> check that value and it calls git_default_config(), not
> git_diff_ui_config() or even git_diff_basic_config()).

Not essential but puzzled. The context applies to the generation side, not acceptance side, no? IOW, I suspect that you are talking about "git format-patch" that sits on the upstream side of the pipe that feeds "git am".

Show 6 quoted lines
> So, to summarize here:
>   * you have a case where the default 3 lines of context mess stuff
> up; but rebase --merge works great
>   * am doesn't have a -U option, and ignores the diff.context setting,
> making it impossible to force the am backend to work on your case
> and also:

I do not think it is super hard to teach "git rebase" to pass backend specific options so that "git rebase--am" can be told to work with wider context (which will reduce the risk of ambiguous patch like this example, trading the increased risk of unnecessary conflicts; it is a good trade-off most of the time for added safety, as nobody wants a system that produces a wrong result silently and quickly).

Having said that,
>   * rebase doesn't have an option to use the merge/interactive backend
> by default (nor an --am option to override it)

I think addition of rebase.backend would be a good first step for eventually flipping the default, which by the way I have no trouble with.

> Maybe we should just switch the default, for everyone?  (And provide
> an --am option to override it and a config setting to get the old
> default?)

Yes, that would be a sensible second step. I actually think a longer term goal is to deprecate the am backend. It was invented first and then kept to be the default backend for a long time because the merge based backend historically has been noticeably slow (it was expected to be---it was essentially a shell script that run cherry-pick repeatedly in a loop). In some future, it would outlive its usefulness, and that I think that that future is just around the corner.

Previous: Elijah Newren
Message 6 of 6 in “git-rebase produces incorrect output”
  1. Pavel RoskinNov 29, 2019
  2. Philip OakleyNov 29, 2019
  3. Pavel RoskinNov 29, 2019
  4. Elijah NewrenNov 30, 2019
  5. Elijah NewrenNov 30, 2019
  6. Junio C HamanoNov 30, 2019

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.