git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Phillip Wood <phillip.wood123@gmail.com>
To: lolligerhans@gmx.de, git@vger.kernel.org
Subject: Re: Bug: diff --color-moved={zebra,blocks,dimmed-zebra} fails to identify some individual moved line
Date: Mon, 14 Oct 2024 16:00:28 +0100	[thread overview]
Message-ID: <6f6d6518-fa01-457f-a482-5e6ffbba3f2b@gmail.com> (raw)
In-Reply-To: <trinity-1a7c1cfa-3f79-4430-bf3d-776c526c242b-1728914461526@msvc-mesg-gmx102>

On 14/10/2024 15:01, lolligerhans@gmx.de wrote:
> : ' 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

> 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;
> 


  reply	other threads:[~2024-10-14 15:00 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-10-14 14:01 Bug: diff --color-moved={zebra,blocks,dimmed-zebra} fails to identify some individual moved line lolligerhans
2024-10-14 15:00 ` Phillip Wood [this message]
2024-10-14 16:23   ` [Resolved] " lolligerhans

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=6f6d6518-fa01-457f-a482-5e6ffbba3f2b@gmail.com \
    --to=phillip.wood123@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=lolligerhans@gmx.de \
    --cc=phillip.wood@dunelm.org.uk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).