git-external-diff-scripton commit (revert local fix) (200e7fb)
   1#!/bin/sh
   2# Copyright (C) 2005 Junio C Hamano
   3#
   4# This script is designed to emulate what the built-in diff driver
   5# does when set as GIT_EXTERNAL_SCRIPT.
   6
   7case "$#" in
   81)
   9    echo "* Unmerged path $1"
  10    exit 0 ;;
  11*)
  12    name1="$1" tmp1="$2" hex1="$3" mode1="$4" tmp2="$5" hex2="$6" mode2="$7"
  13    case "$#" in
  14    7)
  15        name2="$name1" ;;
  16    9)
  17        name2="$8" xfrm_msg="$9" ;;
  18    esac ;;     
  19esac
  20
  21show_create () {
  22    name_="$1" tmp_="$2" hex_="$3" mode_="$4"
  23    echo "diff --git a/$name_ b/$name_"
  24    echo "new file mode $mode_"
  25    diff ${GIT_DIFF_OPTS-'-pu'} -L /dev/null -L "b/$name_" /dev/null "$tmp_"
  26}
  27
  28show_delete () {
  29    name_="$1" tmp_="$2" hex_="$3" mode_="$4"
  30    echo "diff --git a/$name_ b/$name_"
  31    echo "deleted file mode $mode_"
  32    diff ${GIT_DIFF_OPTS-'-pu'} -L "a/$name_" -L /dev/null "$tmp_" /dev/null
  33}
  34
  35case "$mode1" in
  36120*) type1=l ;;
  37100*) type1=f ;;
  38.)    show_create "$name2" "$tmp2" "$hex2" "$mode2"
  39      exit 0 ;;
  40esac
  41case "$mode2" in
  42120*) type2=l ;;
  43100*) type2=f ;;
  44.)    show_delete "$name1" "$tmp1" "$hex1" "$mode1"
  45      exit 0 ;;
  46esac
  47
  48if test "$type1" != "$type2"
  49then
  50        show_delete "$name1" "$tmp1" "$hex1" "$mode1"
  51        show_create "$name2" "$tmp2" "$hex2" "$mode2"
  52        exit 0
  53fi
  54
  55echo diff --git "a/$name1" "b/$name2"
  56if test "$mode1" != "$mode2"
  57then
  58    echo "old mode $mode1"
  59    echo "new mode $mode2"
  60    if test "$xfrm_msg" != ""
  61    then
  62        echo "$xfrm_msg"
  63    fi
  64fi
  65diff ${GIT_DIFF_OPTS-'-pu'} -L "a/$name1" -L "b/$name2" "$tmp1" "$tmp2"
  66exit 0
  67