{"thread":{"id":"62333","subject":"Bug: diff --color-moved={zebra,blocks,dimmed-zebra} fails to identify some individual moved line","startedAt":"2024-10-14T14:01:03Z","lastAt":"2024-10-14T16:23:24Z","messageCount":3,"participants":["lolligerhans@gmx.de","Phillip Wood"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"505022","messageId":"trinity-1a7c1cfa-3f79-4430-bf3d-776c526c242b-1728914461526@msvc-mesg-gmx102","threadId":"62333","inReplyTo":null,"subject":"Bug: diff --color-moved={zebra,blocks,dimmed-zebra} fails to identify some individual moved line","fromName":"","fromEmail":"lolligerhans@gmx.de","sentAt":"2024-10-14T14:01:01Z","receivedAt":"2024-10-14T14:01:03Z","isPatch":false,"sender":{"key":"lolligerhans@gmx.de","avatar":null},"body":": ' What did you do before the bug happened? (Steps to reproduce your issue)\n    I diff-d after moving lines.\n    Reproduce:\n        This entire report can be run verbatim as a bash script. The executed\n        code is at the end.\n            - 1. Execute: Copy-paste the suggested command to hide ~/.gitconfig\n            - 2. Execute: Produces example diff\n            - 3. Execute: Copy-paste the suggested command(s) to unhide and\n                          clean up.\n\nWhat did you expect to happen? (Expected behavior)\n    All (!) moved-only lines are colour coded cyan-purple.\n\nWhat happened instead? (Actual behavior)\n    Some (the first?) individual moved lines are colour coded (treated?) as if\n    the line changed (red-green).\n    In a commit with only one moved line, it is coloured as changed.\n\nWhats different between what you expected and what actually happened?\n    The distinct colouration for moved lines is lacking in the actual\n    behaviour.\n\nAnything else you want to add:\n    Running \"script.sh show\" will use \"git show\" instead of \"git diff\". Same\n    problem.\n\n    Moved mode \"plain\" behaves as expected.\n\n    Skimming \"git log -p next\" suggests that \"--color-moved\" did not change on\n    \"next\" nor recently.\n\n[System Info]\n    git version 2.47.0\n    shell-path: /bin/sh\n    libc info: glibc: 2.39\n\n[Enabled Hooks]\n    None\n\n----------------------------------------------------------------\nScript to reproduce\n----------------------------------------------------------------';\n\n#!/usr/bin/env bash\n\ntrap 'echo 1>&2 \"Error: $BASH_SOURCE:$LINENO $BASH_COMMAND\";' ERR\n\nfunction diff_now() {\n  declare mode\n  echo -e \"==================== [${1:-\"\"}] ====================\"\n  for mode in plain blocks zebra dimmed-zebra; do\n  echo -e \"\\t----- (${mode}) -----\";\n    git \"${2:-\"diff\"}\" --color-moved=\"${mode}\";\n  done\n  echo\n}\n\nclear || true;\nif [[ -f ~/.gitconfig ]]; then\n  echo 'mv -v ~/.gitconfig ~/.gitconfig.save';\n  exit 0;\nelse\n  echo 'mv -v ~/.gitconfig.save ~/.gitconfig';\nfi\nmkdir color_moved || { echo 'rm -rf color_moved'; exit 0; };\ncd color_moved &&\ngit --version &&\ngit init &&\ngit config --local user.email \"you@example.com\" &&\ngit config --local user.name \"Your Name\" &&\ncat <<-EOF >file.txt &&\n\tIs this even a line?\n\tThe first line number 1\n\tThe second line number 2\n\tThe third line number 3\n\tThe fourth line number 4\n\tThe fifth line number 5\n\tThe sixth line number 6\n\tThe seventh line number 7\n\tThe eighth line number 8\n\tThe ninth line number 9\n\tThe tenth line number 10\n\tThe eleventh line number 11\n\tThe twelfth line number 12\n\tThe thirteenth line number 13\n\tThe fourteenth line number 14\n\tThe fifteenth line number 15\nEOF\ngit add . &&\ngit commit -m \"Initial commit\" &&\n\ncat <<-EOF >file.txt &&\n\tThe first line number 1\n\tThe second line number 2\n\tThe ninth line number 9\n\tThe tenth line number 10\n\tThe eleventh line number 11\n\tThe sixth line number 6\n\tThe seventh line number 7\n\tThe eighth line number 8\n\tThe third line number 3\n\tThe fourth line number 4\n\tThe fifth line number 5\n\tIs this even a line?\n\tThe twelfth line number 12\n\tThe thirteenth line number 13\n\tThe fourteenth line number 14\n\tThe fifteenth line number 15\nEOF\ndiff_now \"Can identify moved lines in blocks (but not the single line)\" \"${1}\" &&\ngit add . &&\ngit commit -m \"Moved multiple blocks and a single line\" &&\n\ncat <<-EOF >file.txt &&\n\tThe first line number 1\n\tThe second line number 2\n\tThe ninth line number 9\n\tThe tenth line number 10\n\tIs this even a line?\n\tThe eleventh line number 11\n\tThe sixth line number 6\n\tThe seventh line number 7\n\tThe fourteenth line number 14\n\tThe eighth line number 8\n\tThe third line number 3\n\tThe fourth line number 4\n\tThe fifth line number 5\n\tThe twelfth line number 12\n\tThe thirteenth line number 13\n\tThe fifteenth line number 15\nEOF\ndiff_now \"Cannot identify a single moved line\" \"${1}\" &&\ngit add . &&\ngit commit -m \"Moved only a single line\" &&\n\necho;\necho \"[OK]\";\necho;\necho 'mv -v ~/.gitconfig.save ~/.gitconfig';\nexit 0;\n"},{"id":"505029","messageId":"6f6d6518-fa01-457f-a482-5e6ffbba3f2b@gmail.com","threadId":"62333","inReplyTo":"trinity-1a7c1cfa-3f79-4430-bf3d-776c526c242b-1728914461526@msvc-mesg-gmx102","subject":"Re: Bug: diff --color-moved={zebra,blocks,dimmed-zebra} fails to identify some individual moved line","fromName":"Phillip Wood","fromEmail":"phillip.wood123@gmail.com","sentAt":"2024-10-14T15:00:28Z","receivedAt":"2024-10-14T15:00:37Z","isPatch":false,"sender":{"key":"phillip.wood@dunelm.org.uk","avatar":null},"body":"On 14/10/2024 15:01, lolligerhans@gmx.de wrote:\n> : ' What did you do before the bug happened? (Steps to reproduce your issue)\n>      I diff-d after moving lines.\n>      Reproduce:\n>          This entire report can be run verbatim as a bash script. The executed\n>          code is at the end.\n>              - 1. Execute: Copy-paste the suggested command to hide ~/.gitconfig\n>              - 2. Execute: Produces example diff\n>              - 3. Execute: Copy-paste the suggested command(s) to unhide and\n>                            clean up.\n\nThank you for taking the time to report this. Are you able to show a \ndiff and point to the lines which you think should be marked as moved \nbut aren't? With the block modes a block must contain 20 alphanumeric \nascii characters for it to be considered moved so you maybe running up \nagainst that.\n\nBest Wishes\n\nPhillip\n\n> What did you expect to happen? (Expected behavior)\n>      All (!) moved-only lines are colour coded cyan-purple.\n> \n> What happened instead? (Actual behavior)\n>      Some (the first?) individual moved lines are colour coded (treated?) as if\n>      the line changed (red-green).\n>      In a commit with only one moved line, it is coloured as changed.\n> \n> Whats different between what you expected and what actually happened?\n>      The distinct colouration for moved lines is lacking in the actual\n>      behaviour.\n> \n> Anything else you want to add:\n>      Running \"script.sh show\" will use \"git show\" instead of \"git diff\". Same\n>      problem.\n> \n>      Moved mode \"plain\" behaves as expected.\n> \n>      Skimming \"git log -p next\" suggests that \"--color-moved\" did not change on\n>      \"next\" nor recently.\n> \n> [System Info]\n>      git version 2.47.0\n>      shell-path: /bin/sh\n>      libc info: glibc: 2.39\n> \n> [Enabled Hooks]\n>      None\n> \n> ----------------------------------------------------------------\n> Script to reproduce\n> ----------------------------------------------------------------';\n> \n> #!/usr/bin/env bash\n> \n> trap 'echo 1>&2 \"Error: $BASH_SOURCE:$LINENO $BASH_COMMAND\";' ERR\n> \n> function diff_now() {\n>    declare mode\n>    echo -e \"==================== [${1:-\"\"}] ====================\"\n>    for mode in plain blocks zebra dimmed-zebra; do\n>    echo -e \"\\t----- (${mode}) -----\";\n>      git \"${2:-\"diff\"}\" --color-moved=\"${mode}\";\n>    done\n>    echo\n> }\n> \n> clear || true;\n> if [[ -f ~/.gitconfig ]]; then\n>    echo 'mv -v ~/.gitconfig ~/.gitconfig.save';\n>    exit 0;\n> else\n>    echo 'mv -v ~/.gitconfig.save ~/.gitconfig';\n> fi\n> mkdir color_moved || { echo 'rm -rf color_moved'; exit 0; };\n> cd color_moved &&\n> git --version &&\n> git init &&\n> git config --local user.email \"you@example.com\" &&\n> git config --local user.name \"Your Name\" &&\n> cat <<-EOF >file.txt &&\n> \tIs this even a line?\n> \tThe first line number 1\n> \tThe second line number 2\n> \tThe third line number 3\n> \tThe fourth line number 4\n> \tThe fifth line number 5\n> \tThe sixth line number 6\n> \tThe seventh line number 7\n> \tThe eighth line number 8\n> \tThe ninth line number 9\n> \tThe tenth line number 10\n> \tThe eleventh line number 11\n> \tThe twelfth line number 12\n> \tThe thirteenth line number 13\n> \tThe fourteenth line number 14\n> \tThe fifteenth line number 15\n> EOF\n> git add . &&\n> git commit -m \"Initial commit\" &&\n> \n> cat <<-EOF >file.txt &&\n> \tThe first line number 1\n> \tThe second line number 2\n> \tThe ninth line number 9\n> \tThe tenth line number 10\n> \tThe eleventh line number 11\n> \tThe sixth line number 6\n> \tThe seventh line number 7\n> \tThe eighth line number 8\n> \tThe third line number 3\n> \tThe fourth line number 4\n> \tThe fifth line number 5\n> \tIs this even a line?\n> \tThe twelfth line number 12\n> \tThe thirteenth line number 13\n> \tThe fourteenth line number 14\n> \tThe fifteenth line number 15\n> EOF\n> diff_now \"Can identify moved lines in blocks (but not the single line)\" \"${1}\" &&\n> git add . &&\n> git commit -m \"Moved multiple blocks and a single line\" &&\n> \n> cat <<-EOF >file.txt &&\n> \tThe first line number 1\n> \tThe second line number 2\n> \tThe ninth line number 9\n> \tThe tenth line number 10\n> \tIs this even a line?\n> \tThe eleventh line number 11\n> \tThe sixth line number 6\n> \tThe seventh line number 7\n> \tThe fourteenth line number 14\n> \tThe eighth line number 8\n> \tThe third line number 3\n> \tThe fourth line number 4\n> \tThe fifth line number 5\n> \tThe twelfth line number 12\n> \tThe thirteenth line number 13\n> \tThe fifteenth line number 15\n> EOF\n> diff_now \"Cannot identify a single moved line\" \"${1}\" &&\n> git add . &&\n> git commit -m \"Moved only a single line\" &&\n> \n> echo;\n> echo \"[OK]\";\n> echo;\n> echo 'mv -v ~/.gitconfig.save ~/.gitconfig';\n> exit 0;\n> \n\n"},{"id":"505037","messageId":"trinity-4806cd90-2a2b-4be8-a202-bb9f4f6b1732-1728922999672@msvc-mesg-gmx104","threadId":"62333","inReplyTo":"6f6d6518-fa01-457f-a482-5e6ffbba3f2b@gmail.com","subject":"[Resolved] Bug: diff --color-moved={zebra,blocks,dimmed-zebra} fails to identify some individual moved line","fromName":"","fromEmail":"lolligerhans@gmx.de","sentAt":"2024-10-14T16:23:19Z","receivedAt":"2024-10-14T16:23:24Z","isPatch":false,"sender":{"key":"lolligerhans@gmx.de","avatar":null},"body":"My apologies, it appears the behaviour is as intended.\n\nI confused the wording in the documentation, and proceeded to accidentally dance right around the 20 character limit trying it out.\n"}]}