From d7a1b863c0406a124806a7d7fe963543967e9e7e Mon Sep 17 00:00:00 2001 From: David Aguilar Date: Sat, 11 Oct 2008 02:15:01 -0700 Subject: [PATCH] git-difftool: detect and handle renamed files git difftool --start= --end= -- would not show the correct diff for renamed files. With this change it now follows renames and shows the correct diffs. Signed-off-by: David Aguilar --- bin/git-difftool | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/bin/git-difftool b/bin/git-difftool index ab055428..f548c0e3 100755 --- a/bin/git-difftool +++ b/bin/git-difftool @@ -142,11 +142,19 @@ merge_file () { local=start remote=end - if ! git show "$start":"$MERGED" > "$LOCAL" 2>/dev/null; then + # detects renames.. sweet! + oldname=$(git diff --follow "$start".."$end" -- "$MERGED" | + head -n9 | + grep '^rename from' | + sed -e 's/rename from //') + startname="$MERGED" + test -n "$oldname" && startname="$oldname" + + if ! git show "$start":"$startname" > "$LOCAL" 2>/dev/null; then if should_prompt; then echo echo -n "Warning: " - echo -n "'$MERGED' does not exist at $start." + echo -n "'$startname' does not exist at $start." fi touch "$LOCAL" fi -- 2.11.4.GIT