chiark / gitweb /
Test suite: inarchivecopy: Do a "git init" and "git fetch" test too
[dgit.git] / absurd / git
1 #!/bin/sh
2 set -e
3
4 fail () {
5         echo >&2 "DGIT ABSURD GIT APPLY - FAILED: $*"
6         exit 127
7 }
8
9 self=${0%/*}
10 npath=${PATH#$self:}
11 if test "x$PATH" = "x$npath"; then
12         fail "PATH FILTER FAIL ($0 $self $PATH)"
13 fi
14
15 bypass=true
16 for arg in "$@"; do
17         case "$arg" in
18         apply)  bypass=false; break     ;;
19         -*)                             ;;
20         *)      bypass=true; break      ;;
21         esac
22 done
23
24 if $bypass; then
25         PATH=$npath
26         exec git "$@"
27 fi
28
29 echo >&2 "DGIT ABSURD GIT APPLY - NO BYPASS: $*"
30
31 #exec >/dev/tty 2>&1
32
33 index=0
34 noo=0
35
36 for arg in "$@"; do
37         case "$noo.$arg" in
38         1.--index)
39                 index=1
40                 continue
41                 ;;
42         ?.-*)
43                 fail "UNKNOWN OPTION $arg ($*)"
44                 ;;
45         0.apply)
46                 ;;
47         1.*)    patch="$arg"
48                 ;;
49         *)
50                 fail "BAD USAGE $arg ($noo $*)"
51         esac
52         noo=$(( $noo + 1 ))
53 done
54
55 if [ $noo != 2 ]; then
56         fail "NO PATCH ($*)"
57 fi
58
59 pwd=`pwd`
60 patch=${patch#$pwd/debian/patches/}
61 rm -f debian/patches/series
62 printf "%s\n" "$patch" >debian/patches/series
63
64 dpkg-source --before-build .
65
66 rm -rf .pc
67 git checkout debian/patches/series
68 git add -Af .
69
70 echo >&2 "DGIT ABSURD GIT APPLY - APPLIED $patch"
71 #printf 'APPLIED '; date --iso-8601=ns