{"thread":{"id":"62094","subject":"`git diff --break-rewrites` does not work (otherwise it should break rewrite into delete and create, for `--find-renames` to work)","startedAt":"2024-09-10T11:07:32Z","lastAt":"2024-09-11T10:30:25Z","messageCount":3,"participants":["Han Jiang","Jeff King"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"502557","messageId":"CANrWfmTz6x0qmTDaTOF_USR+fDcVdwfpUJDhjozb_VzBAnUJsA@mail.gmail.com","threadId":"62094","inReplyTo":null,"subject":"`git diff --break-rewrites` does not work (otherwise it should break rewrite into delete and create, for `--find-renames` to work)","fromName":"Han Jiang","fromEmail":"jhcarl0814@gmail.com","sentAt":"2024-09-10T11:07:19Z","receivedAt":"2024-09-10T11:07:32Z","isPatch":false,"sender":{"key":"jhcarl0814@gmail.com","avatar":"https://avatars.githubusercontent.com/u/5171262?v=4"},"body":"Thank you for filling out a Git bug report!\nPlease answer the following questions to help us understand your issue.\n\nWhat did you do before the bug happened? (Steps to reproduce your issue)\n\ncd '/'; cd '/'; rm --force --recursive -- './test_git2'; mkdir \"$_\"; cd \"$_\";\nmkdir --parents -- './repo';\ngit init './repo'\necho -e 'a\\nb\\nc\\nd\\ne\\nf\\ng\\nh\\ni\\nj' >'./repo/file1'\necho -e '0\\n1\\n2\\n3\\n4\\n5\\n6\\n7\\n8\\n9' >'./repo/file2'\ngit -C './repo' add './file1' './file2'\nmv './repo/file2' './repo/file3'\nmv './repo/file1' './repo/file2'\ngit -C './repo' add --intent-to-add './file3'\ngit -C './repo' diff --break-rewrites='50%/50%' --find-renames='50%'\n\nWhat did you expect to happen? (Expected behavior)\n\n`git diff` outputs: file1 rename to file2, file2 rename to file3\n\nWhat happened instead? (Actual behavior)\n\n`git diff` outputs: file1 remove all content, file2 complete rewrite,\nfile3 add all content\n\nWhat's different between what you expected and what actually happened?\n\nAnything else you want to add:\n\nPlease review the rest of the bug report below.\nYou can delete any lines you don't wish to share.\n\n\n[System Info]\ngit version:\ngit version 2.46.0.windows.1\ncpu: x86_64\nbuilt from commit: 2e6a859ffc0471f60f79c1256f766042b0d5d17d\nsizeof-long: 4\nsizeof-size_t: 8\nshell-path: D:/git-sdk-64-build-installers/usr/bin/sh\nfeature: fsmonitor--daemon\nlibcurl: 8.9.0\nOpenSSL: OpenSSL 3.2.2 4 Jun 2024\nzlib: 1.3.1\nuname: Windows 10.0 22631\ncompiler info: gnuc: 14.1\nlibc info: no libc information available\n$SHELL (typically, interactive shell): C:\\Program Files\\Git\\usr\\bin\\bash.exe\n\n\n[Enabled Hooks]\nnot run from a git repository - no hooks to show\n"},{"id":"502608","messageId":"20240911064836.GB1538586@coredump.intra.peff.net","threadId":"62094","inReplyTo":"CANrWfmTz6x0qmTDaTOF_USR+fDcVdwfpUJDhjozb_VzBAnUJsA@mail.gmail.com","subject":"Re: `git diff --break-rewrites` does not work (otherwise it should break rewrite into delete and create, for `--find-renames` to work)","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2024-09-11T06:48:36Z","receivedAt":"2024-09-11T06:48:37Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Tue, Sep 10, 2024 at 11:07:19PM +1200, Han Jiang wrote:\n\n> Thank you for filling out a Git bug report!\n> Please answer the following questions to help us understand your issue.\n> \n> What did you do before the bug happened? (Steps to reproduce your issue)\n> \n> cd '/'; cd '/'; rm --force --recursive -- './test_git2'; mkdir \"$_\"; cd \"$_\";\n> mkdir --parents -- './repo';\n> git init './repo'\n> echo -e 'a\\nb\\nc\\nd\\ne\\nf\\ng\\nh\\ni\\nj' >'./repo/file1'\n> echo -e '0\\n1\\n2\\n3\\n4\\n5\\n6\\n7\\n8\\n9' >'./repo/file2'\n> git -C './repo' add './file1' './file2'\n> mv './repo/file2' './repo/file3'\n> mv './repo/file1' './repo/file2'\n> git -C './repo' add --intent-to-add './file3'\n> git -C './repo' diff --break-rewrites='50%/50%' --find-renames='50%'\n> \n> What did you expect to happen? (Expected behavior)\n> \n> `git diff` outputs: file1 rename to file2, file2 rename to file3\n> \n> What happened instead? (Actual behavior)\n> \n> `git diff` outputs: file1 remove all content, file2 complete rewrite,\n> file3 add all content\n\nIt's because your toy example is too small. Try:\n\n  seq 400 >repo/file2\n\ninstead of the 0-9 input, which will then do what you expect.\n\nThere is a hard-coded MINIMUM_BREAK_SIZE limit which requires that one\nof the files must be at least 400 bytes, presumably to avoid awkward\ncorner cases in the heuristics for very small files. That comes from\neeaa460314 ([PATCH] diff: Update -B heuristics., 2005-06-03), so quite\nlong ago. But I'm not sure if any science went into determining it.\n\nDo you have a real (non-toy) case where it should be triggering but\nisn't? I wonder if we should consider making that hard-coded limit\nconfigurable somehow.\n\n-Peff\n"},{"id":"502611","messageId":"CANrWfmQt_krw6pR1W+nXWheUg_wbcJmoC1K8sStu-Ou36=vD4g@mail.gmail.com","threadId":"62094","inReplyTo":"20240911064836.GB1538586@coredump.intra.peff.net","subject":"Re: `git diff --break-rewrites` does not work (otherwise it should break rewrite into delete and create, for `--find-renames` to work)","fromName":"Han Jiang","fromEmail":"jhcarl0814@gmail.com","sentAt":"2024-09-11T10:30:12Z","receivedAt":"2024-09-11T10:30:25Z","isPatch":false,"sender":{"key":"jhcarl0814@gmail.com","avatar":"https://avatars.githubusercontent.com/u/5171262?v=4"},"body":"Thank you for the explanation!\nThe bug report comes from an attempt to write examples to demonstrate\nwhat those command line options do and how they interact, so currently\nthere is no real-world case where the limit needs to be loosen.\nIt would be good to make the limit configurable if many people want\nit. For me I just hope the documentation and the actual behavior can\nbe consistent.\n\nOn Wed, Sep 11, 2024 at 6:48 PM Jeff King <peff@peff.net> wrote:\n>\n> On Tue, Sep 10, 2024 at 11:07:19PM +1200, Han Jiang wrote:\n>\n> > Thank you for filling out a Git bug report!\n> > Please answer the following questions to help us understand your issue.\n> >\n> > What did you do before the bug happened? (Steps to reproduce your issue)\n> >\n> > cd '/'; cd '/'; rm --force --recursive -- './test_git2'; mkdir \"$_\"; cd \"$_\";\n> > mkdir --parents -- './repo';\n> > git init './repo'\n> > echo -e 'a\\nb\\nc\\nd\\ne\\nf\\ng\\nh\\ni\\nj' >'./repo/file1'\n> > echo -e '0\\n1\\n2\\n3\\n4\\n5\\n6\\n7\\n8\\n9' >'./repo/file2'\n> > git -C './repo' add './file1' './file2'\n> > mv './repo/file2' './repo/file3'\n> > mv './repo/file1' './repo/file2'\n> > git -C './repo' add --intent-to-add './file3'\n> > git -C './repo' diff --break-rewrites='50%/50%' --find-renames='50%'\n> >\n> > What did you expect to happen? (Expected behavior)\n> >\n> > `git diff` outputs: file1 rename to file2, file2 rename to file3\n> >\n> > What happened instead? (Actual behavior)\n> >\n> > `git diff` outputs: file1 remove all content, file2 complete rewrite,\n> > file3 add all content\n>\n> It's because your toy example is too small. Try:\n>\n>   seq 400 >repo/file2\n>\n> instead of the 0-9 input, which will then do what you expect.\n>\n> There is a hard-coded MINIMUM_BREAK_SIZE limit which requires that one\n> of the files must be at least 400 bytes, presumably to avoid awkward\n> corner cases in the heuristics for very small files. That comes from\n> eeaa460314 ([PATCH] diff: Update -B heuristics., 2005-06-03), so quite\n> long ago. But I'm not sure if any science went into determining it.\n>\n> Do you have a real (non-toy) case where it should be triggering but\n> isn't? I wonder if we should consider making that hard-coded limit\n> configurable somehow.\n>\n> -Peff\n"}]}