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

Re: Bug: diff --color-moved={zebra,blocks,dimmed-zebra} fails to identify some individual moved line

From
PWPhillip Wood <phillip.wood123@gmail.com>
Date
Oct 14, 2024, 15:00 UTC
Message-ID
<6f6d6518-fa01-457f-a482-5e6ffbba3f2b@gmail.com>
In-Reply-To
<trinity-1a7c1cfa-3f79-4430-bf3d-776c526c242b-1728914461526@msvc-mesg-gmx102>
On 14/10/2024 15:01, lolligerhans@gmx.de wrote:
Show 9 quoted lines
> : ' What did you do before the bug happened? (Steps to reproduce your issue)
>      I diff-d after moving lines.
>      Reproduce:
>          This entire report can be run verbatim as a bash script. The executed
>          code is at the end.
>              - 1. Execute: Copy-paste the suggested command to hide ~/.gitconfig
>              - 2. Execute: Produces example diff
>              - 3. Execute: Copy-paste the suggested command(s) to unhide and
>                            clean up.

Thank you for taking the time to report this. Are you able to show a diff and point to the lines which you think should be marked as moved but aren't? With the block modes a block must contain 20 alphanumeric ascii characters for it to be considered moved so you maybe running up against that.

Best Wishes
Phillip
Show 131 quoted lines
> What did you expect to happen? (Expected behavior)
>      All (!) moved-only lines are colour coded cyan-purple.
> 
> What happened instead? (Actual behavior)
>      Some (the first?) individual moved lines are colour coded (treated?) as if
>      the line changed (red-green).
>      In a commit with only one moved line, it is coloured as changed.
> 
> Whats different between what you expected and what actually happened?
>      The distinct colouration for moved lines is lacking in the actual
>      behaviour.
> 
> Anything else you want to add:
>      Running "script.sh show" will use "git show" instead of "git diff". Same
>      problem.
> 
>      Moved mode "plain" behaves as expected.
> 
>      Skimming "git log -p next" suggests that "--color-moved" did not change on
>      "next" nor recently.
> 
> [System Info]
>      git version 2.47.0
>      shell-path: /bin/sh
>      libc info: glibc: 2.39
> 
> [Enabled Hooks]
>      None
> 
> ----------------------------------------------------------------
> Script to reproduce
> ----------------------------------------------------------------';
> 
> #!/usr/bin/env bash
> 
> trap 'echo 1>&2 "Error: $BASH_SOURCE:$LINENO $BASH_COMMAND";' ERR
> 
> function diff_now() {
>    declare mode
>    echo -e "==================== [${1:-""}] ===================="
>    for mode in plain blocks zebra dimmed-zebra; do
>    echo -e "\t----- (${mode}) -----";
>      git "${2:-"diff"}" --color-moved="${mode}";
>    done
>    echo
> }
> 
> clear || true;
> if [[ -f ~/.gitconfig ]]; then
>    echo 'mv -v ~/.gitconfig ~/.gitconfig.save';
>    exit 0;
> else
>    echo 'mv -v ~/.gitconfig.save ~/.gitconfig';
> fi
> mkdir color_moved || { echo 'rm -rf color_moved'; exit 0; };
> cd color_moved &&
> git --version &&
> git init &&
> git config --local user.email "you@example.com" &&
> git config --local user.name "Your Name" &&
> cat <<-EOF >file.txt &&
> 	Is this even a line?
> 	The first line number 1
> 	The second line number 2
> 	The third line number 3
> 	The fourth line number 4
> 	The fifth line number 5
> 	The sixth line number 6
> 	The seventh line number 7
> 	The eighth line number 8
> 	The ninth line number 9
> 	The tenth line number 10
> 	The eleventh line number 11
> 	The twelfth line number 12
> 	The thirteenth line number 13
> 	The fourteenth line number 14
> 	The fifteenth line number 15
> EOF
> git add . &&
> git commit -m "Initial commit" &&
> 
> cat <<-EOF >file.txt &&
> 	The first line number 1
> 	The second line number 2
> 	The ninth line number 9
> 	The tenth line number 10
> 	The eleventh line number 11
> 	The sixth line number 6
> 	The seventh line number 7
> 	The eighth line number 8
> 	The third line number 3
> 	The fourth line number 4
> 	The fifth line number 5
> 	Is this even a line?
> 	The twelfth line number 12
> 	The thirteenth line number 13
> 	The fourteenth line number 14
> 	The fifteenth line number 15
> EOF
> diff_now "Can identify moved lines in blocks (but not the single line)" "${1}" &&
> git add . &&
> git commit -m "Moved multiple blocks and a single line" &&
> 
> cat <<-EOF >file.txt &&
> 	The first line number 1
> 	The second line number 2
> 	The ninth line number 9
> 	The tenth line number 10
> 	Is this even a line?
> 	The eleventh line number 11
> 	The sixth line number 6
> 	The seventh line number 7
> 	The fourteenth line number 14
> 	The eighth line number 8
> 	The third line number 3
> 	The fourth line number 4
> 	The fifth line number 5
> 	The twelfth line number 12
> 	The thirteenth line number 13
> 	The fifteenth line number 15
> EOF
> diff_now "Cannot identify a single moved line" "${1}" &&
> git add . &&
> git commit -m "Moved only a single line" &&
> 
> echo;
> echo "[OK]";
> echo;
> echo 'mv -v ~/.gitconfig.save ~/.gitconfig';
> exit 0;
> 
Previous: lolligerhans@gmx.deNext: lolligerhans@gmx.de
Message 2 of 3 in “Bug: diff --color-moved={zebra,blocks,dimmed-zebra} fails to identify some individual moved line”
  1. lolligerhans@gmx.deOct 14, 2024
  2. Phillip WoodOct 14, 2024
  3. [Resolved] Bug: diff --color-moved={zebra,blocks,dimmed-zebra} fails to identify some individual moved linelolligerhans@gmx.de, Oct 14, 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.