Remove the ugly jit-style parent syntax.
[git/kirr.git] / git-apply-patch-script
blobb6387f66464fba58353b3fef423eeca327f570a7
1 #!/bin/sh
2 # Copyright (C) 2005 Junio C Hamano
4 # Applying diff between two trees to the work tree can be
5 # done with the following single command:
7 # GIT_EXTERNAL_DIFF=git-apply-patch-script git-diff-tree -p $tree1 $tree2
10 case "$#" in
11 2) exit 1 ;; # do not feed unmerged diff to me!
12 esac
13 name="$1" tmp1="$2" hex1="$3" mode1="$4" tmp2="$5" hex2="$6" mode2="$7"
14 case "$mode1" in *7??) mode1=+x ;; *6??) mode1=-x ;; esac
15 case "$mode2" in *7??) mode2=+x ;; *6??) mode2=-x ;; esac
17 if test -f "$name.orig" || test -f "$name.rej"
18 then
19 echo >&2 "Unresolved patch conflicts in the previous run found."
20 exit 1
22 # This will say "patching ..." so we do not say anything outselves.
24 diff -u -L "a/$name" -L "b/$name" "$tmp1" "$tmp2" | patch -p1
25 test -f "$name.rej" || {
26 case "$mode1,$mode2" in
27 .,?x)
28 # newly created
29 case "$mode2" in
30 +x)
31 echo >&2 "created $name with mode +x."
32 chmod "$mode2" "$name"
35 echo >&2 "created $name."
37 esac
38 git-update-cache --add -- "$name"
40 ?x,.)
41 # deleted
42 echo >&2 "deleted $name."
43 rm -f "$name"
44 git-update-cache --remove -- "$name"
47 # changed
48 case "$mode1,$mode2" in
49 "$mode2,$mode1") ;;
51 echo >&2 "changing mode from $mode1 to $mode2."
52 chmod "$mode2" "$name"
54 esac
55 esac
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"
60 exit 0