Skip to content

Files

Latest commit

3654409 · Feb 19, 2025

History

History

git-diff-chunk

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
May 21, 2022
Feb 19, 2025

README.md

git diff-chunk

Show the diff of one chunk

Git alias:

diff-chunk = "!f() { \
    git show \"\$1:\$3\" | sed -n \"/^[^ \t].*\$4(/,/^}/p\" > .tmp1 ; \
    git show \"\$2:\$3\" | sed -n \"/^[^ \t].*\$4(/,/^}/p\" > .tmp2 ; \
    git diff --no-index .tmp1 .tmp2 ; \
}; f"

Example:

git diff-chunk

Suppose we want to see just the differences of one chunk, such as one function, in one file, in two different commits.

This alias creates two temp files which contain only the chunk, then does a typical git diff.

Syntax:

git diff-chunk <old-rev> <new-rev> <path> <chunk pattern>