1#!/bin/sh 2# Copyright (C) 2005 Junio C Hamano 3# 4# Applying diff between two trees to the work tree can be 5# done with the following single command: 6# 7# GIT_EXTERNAL_DIFF=git-apply-patch-script git-diff-tree -p $tree1 $tree2 8# 9 10case"$#"in 112)exit1;;# do not feed unmerged diff to me! 12esac 13name="$1" tmp1="$2" hex1="$3" mode1="$4" tmp2="$5" hex2="$6" mode2="$7" 14case"$mode1"in*7??) mode1=+x ;; *6??) mode1=-x;;esac 15case"$mode2"in*7??) mode2=+x ;; *6??) mode2=-x;;esac 16 17iftest -f"$name.orig"||test -f"$name.rej" 18then 19echo>&2"Unresolved patch conflicts in the previous run found." 20exit1 21fi 22# This will say "patching ..." so we do not say anything outselves. 23 24diff-u -L"a/$name"-L"b/$name""$tmp1""$tmp2"|patch-p1 25test -f"$name.rej"|| { 26case"$mode1,$mode2"in 27 .,?x) 28# newly created 29case"$mode2"in 30+x) 31echo>&2"created$namewith mode +x." 32chmod"$mode2""$name" 33;; 34-) 35echo>&2"created$name." 36;; 37esac 38 git-update-cache --add --"$name" 39;; 40 ?x,.) 41# deleted 42echo>&2"deleted$name." 43rm-f"$name" 44 git-update-cache --remove --"$name" 45;; 46*) 47# changed 48case"$mode1,$mode2"in 49"$mode2,$mode1") ;; 50*) 51echo>&2"changing mode from$mode1to$mode2." 52chmod"$mode2""$name" 53;; 54esac 55esac 56# This bit is debatable---the SCM may not want to keep 57# cache in sync with the work tree (JIT does want to). 58 git-update-cache --"$name" 59} 60exit0