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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



: ' 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.

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@xxxxxxxxxxx" &&
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;




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux