{"thread":{"id":"56373","subject":"[BUG] git-rebase unnecessarily change mtime of files","startedAt":"2021-08-25T09:56:01Z","lastAt":"2021-08-25T12:51:59Z","messageCount":2,"participants":["Konstantin Kharlamov","Ævar Arnfjörð Bjarmason"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"433727","messageId":"7d29b582ef44785015e631251da8499b197ff4bc.camel@yandex.ru","threadId":"56373","inReplyTo":null,"subject":"[BUG] git-rebase unnecessarily change mtime of files","fromName":"Konstantin Kharlamov","fromEmail":"hi-angel@yandex.ru","sentAt":"2021-08-25T09:49:10Z","receivedAt":"2021-08-25T09:56:01Z","isPatch":false,"sender":{"key":"hi-angel@yandex.ru","avatar":null},"body":"Suppose your branch has *one* commit that modified file `myfile`. When you\ninteractively-rebase to that commit, mtime of that file will change even if\nthough you did not change the file (i.e. commit you are on has changed the file,\nbut since you're *at* this commit, not before this, there shouldn't have been\nany change to the file).\n\nThis might be bad for performance; however what concerns me personally the most\nis that my editor keeps asking me \"file was changed on the disk, are you sure\nyou wanna modify the file?\", which is confusing and annoying.\n\nI am also not completely sure, but it might be a regression, because I don't\nseem to remember having that before.\n\n# Steps to reproduce\n\n λ mkdir foo\n λ cd foo\n λ git init\nhint: Using 'master' as the name for the initial branch. This default branch\nname\nhint: is subject to change. To configure the initial branch name to use in all\nhint: of your new repositories, which will suppress this warning, call:\nhint:\nhint:   git config --global init.defaultBranch <name>\nhint:\nhint: Names commonly chosen instead of 'master' are 'main', 'trunk' and\nhint: 'development'. The just-created branch can be renamed via this command:\nhint:\nhint:   git branch -m <name>\nInitialized empty Git repository in /tmp/foo/.git/\n λ echo hello1 > file1 && git add file1 && git commit -m \"1st commit\"\n[master (root-commit) f1cc312] 1st commit\n 1 file changed, 1 insertion(+)\n create mode 100644 file1\n λ echo hello2 > file2 && git add file2 && git commit -m \"2nd commit\"\n[master 8bed9e1] 2nd commit\n 1 file changed, 1 insertion(+)\n create mode 100644 file2\n λ echo hello3 > file3 && git add file3 && git commit -m \"3rd commit\"\n[master e6d5aab] 3rd commit\n 1 file changed, 1 insertion(+)\n create mode 100644 file3\n λ stat -c %y file2\n2021-08-25 12:37:19.008378563 +0300\n λ rebase-at e HEAD~2     # that is `git rebase -i HEAD~2`, then [e]dit the\ncommit\nStopped at 8bed9e1...  2nd commit\nYou can amend the commit now, with\n\n  git commit --amend\n\nOnce you are satisfied with your changes, run\n\n  git rebase --continue\n λ stat -c %y file2\n2021-08-25 12:37:37.375537063 +0300\n\n\n## Expected\n\nThe mtime of the file did not change\n\n## Actual\n\nThe mtime of the file changed by 18 seconds\n\n# Additional information\n\n[System Info]\ngit version:\ngit version 2.33.0\ncpu: x86_64\nno commit associated with this build\nsizeof-long: 8\nsizeof-size_t: 8\nshell-path: /bin/sh\nuname: Linux 5.13.5-zen1-1-zen #1 ZEN SMP PREEMPT Sun, 25 Jul 2021 18:03:00\n+0000 x86_64\ncompiler info: gnuc: 11.1\nlibc info: glibc: 2.33\n$SHELL (typically, interactive shell): /usr/bin/zsh\n\n\n"},{"id":"433732","messageId":"87sfyxd6vo.fsf@evledraar.gmail.com","threadId":"56373","inReplyTo":"7d29b582ef44785015e631251da8499b197ff4bc.camel@yandex.ru","subject":"Re: [BUG] git-rebase unnecessarily change mtime of files","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2021-08-25T12:45:30Z","receivedAt":"2021-08-25T12:51:59Z","isPatch":false,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"\nOn Wed, Aug 25 2021, Konstantin Kharlamov wrote:\n\n> Suppose your branch has *one* commit that modified file `myfile`. When you\n> interactively-rebase to that commit, mtime of that file will change even if\n> though you did not change the file (i.e. commit you are on has changed the file,\n> but since you're *at* this commit, not before this, there shouldn't have been\n> any change to the file).\n>\n> This might be bad for performance; however what concerns me personally the most\n> is that my editor keeps asking me \"file was changed on the disk, are you sure\n> you wanna modify the file?\", which is confusing and annoying.\n>\n> I am also not completely sure, but it might be a regression, because I don't\n> seem to remember having that before.\n>\n> # Steps to reproduce\n>\n>  λ mkdir foo\n>  λ cd foo\n>  λ git init\n> hint: Using 'master' as the name for the initial branch. This default branch\n> name\n> hint: is subject to change. To configure the initial branch name to use in all\n> hint: of your new repositories, which will suppress this warning, call:\n> hint:\n> hint:   git config --global init.defaultBranch <name>\n> hint:\n> hint: Names commonly chosen instead of 'master' are 'main', 'trunk' and\n> hint: 'development'. The just-created branch can be renamed via this command:\n> hint:\n> hint:   git branch -m <name>\n> Initialized empty Git repository in /tmp/foo/.git/\n>  λ echo hello1 > file1 && git add file1 && git commit -m \"1st commit\"\n> [master (root-commit) f1cc312] 1st commit\n>  1 file changed, 1 insertion(+)\n>  create mode 100644 file1\n>  λ echo hello2 > file2 && git add file2 && git commit -m \"2nd commit\"\n> [master 8bed9e1] 2nd commit\n>  1 file changed, 1 insertion(+)\n>  create mode 100644 file2\n>  λ echo hello3 > file3 && git add file3 && git commit -m \"3rd commit\"\n> [master e6d5aab] 3rd commit\n>  1 file changed, 1 insertion(+)\n>  create mode 100644 file3\n>  λ stat -c %y file2\n> 2021-08-25 12:37:19.008378563 +0300\n>  λ rebase-at e HEAD~2     # that is `git rebase -i HEAD~2`, then [e]dit the\n> commit\n> Stopped at 8bed9e1...  2nd commit\n> You can amend the commit now, with\n>\n>   git commit --amend\n>\n> Once you are satisfied with your changes, run\n>\n>   git rebase --continue\n>  λ stat -c %y file2\n> 2021-08-25 12:37:37.375537063 +0300\n>\n>\n> ## Expected\n>\n> The mtime of the file did not change\n>\n> ## Actual\n>\n> The mtime of the file changed by 18 seconds\n\nI don't know if this is a bug or feature, I suspect the latter.\n\nI think you'll find that if you use a TODO list like:\n\n    pick X <commit changes 'foo'>\n    break\n    pick Y <commit changes 'bar'>\n\nYou'll find that if your \"foo\" won't be changed, but it would with:\n\n    edit X <commit changes 'foo'>\n    pick Y <commit changes 'bar'>\n\nThis is because, as you'll see with GIT_TRACE=1 we actually check out X~\nand then apply it with \"edit\", but with \"break\" we'll check out X\nitself.\n\nI didn't dig further than that, maybe it's a bug, maybe not. The code in\nd87d48b2e03 (sequencer: learn about the special \"fake root commit\"\nhandling, 2018-05-04) may or may not be involved, I didn't dig much.\n"}]}