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

Re: Git rebasing attribute the change to the wrong file [bug]

From
Elijah Newren <newren@gmail.com>
Date
Feb 21, 2024, 02:18 UTC
Message-ID
<CABPp-BGi6m3SLce8TbZJOMuu610o0PEf+NgaqqfTzZHrqcYzFA@mail.gmail.com>
In-Reply-To
<CALPZ9FGr8K=AdqOzX2P7A3T8+_V25SOjcHA5kY-Fg5TUFEvh7w@mail.gmail.com>
On Tue, Feb 20, 2024 at 12:02 PM John Gabo <charleforalia@gmail.com> wrote:
Show 43 quoted lines
>
> Hello,
> I think I found a bug in git, where a change get attributed to the
> wrong file when doing a rebasing.
>
> # Short summary
> Assume `master_branch`
> ```
> .
> └── parent_folder
>     ├── project_a
>     │   └── file.txt
>     └── project_b
>         └── file.txt # the 2 file.txt have the same content on master
> ```
> Assume `feature_branch` from master
> ```
> .
> └── parent_folder
>     ├── project_a
>     │   └── file.txt
>     └── project_b
>         └── file.txt # this file got modified with a feature
> ```
> Assume `refactor_branch` from master
> ```
> .
> └── refactored_parent_folder # got renamed
>     ├── project_a
>     │   └── file.txt
>     └── project_b
>         └── file.txt
> ```
> then rebase `feature_branch` on `refactor_branch`,
>
> ```
> .
> └── refactored_parent_folder
>     ├── project_a
>     │   └── file.txt # the feature got moved here !
>     └── project_b
>         └── file.txt # instead of here, where it should be !
> ```

You may want to read through the Support section of https://git.github.io/rev_news/2024/01/31/edition-107/. You are dealing with inexact renames rather than exact, but it's still the same basic issue: git is detecting renames based on file similarity and you have multiple equally valid targets for it to choose, so it simply picks one. As such, it might be considered a limitation of rename detection that you can't manually enforce which files are paired, but it's not what we'd classify as a bug since it did correctly pick one of the files with the most similar contents.

Previous: John Gabo
Message 2 of 2 in “Git rebasing attribute the change to the wrong file [bug]”
  1. John GaboFeb 20, 2024
  2. Elijah NewrenFeb 21, 2024

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.