1 if [ -z "$REG_DIR" ]; then
2 echo "ERROR: You cannot run tests by hand" >&2
8 export PATH=$PWD/..:$PATH
11 export TOUCH_DATE="200701010000.00"
12 export GIT_AUTHOR_DATE="2007-01-01 00:00:00 UTC"
13 export GIT_COMMITTER_DATE="2007-01-01 00:00:00 UTC"
14 export GIT_AUTHOR_NAME="Author Name"
15 export GIT_AUTHOR_EMAIL="author@email"
16 export GIT_COMMITTER_NAME="Commiter Name"
17 export GIT_COMMITTER_EMAIL="commiter@email"
28 if [ -r "$REG_DIR/../os.$UNAME_S" ]; then
29 . "$REG_DIR/../os.$UNAME_S"
31 die "Unsupported operating system: $UNAME_S"
36 sed -e "s,$PWD,PATH,g" \
37 -e "s,$REG_DIR/\.\./,,g" \
38 -e "s,^Usage: guilt-,Usage: guilt ,g" \
39 -e "s,\.\.\. initial, initial,g" \
40 -e "s,^Already on\( branch\)\? [\"']\([^\"']*\)[\"']$,Already on \"\2\",g" \
41 -e "s,^Switched to branch [\"']\([^\"']*\)[\"'],Switched to branch \"\1\",g" \
42 -e "\\,^Deleted branch guilt/.* (was .*).$,d"
46 # (1.0 kB, 1.0 kiB) copied, ...
49 sed -e 's:^\([0-9]*\) bytes (\([0-9]*\.[0-9]* .B\).*) copied.*$:\1 bytes (\2) copied:'
58 rv=`(("$@" 2>&1; echo $? >&4) | replace_path >&3 ) 4>&1`
61 echo "% FAIL: The above command should succeed but failed."
66 # usage: shouldfail <cmd>..
72 rv=`(("$@" 2>&1; echo $? >&4) | replace_path >&3 ) 4>&1`
75 echo "% FAIL: The above command should fail but succeeded."
84 find .git/refs/patches -type f -exec dump_ref {} \; 2> /dev/null || true
85 find .git/refs/patches -type d -exec dump_reg {} \; 2> /dev/null || true
86 find .git/patches -exec dump_reg {} \;
90 function setup_git_repo
92 # set up the repo so we have something interesting to run guilt on
95 git commit -s -m "initial" 2> /dev/null > /dev/null
97 # The HEAD should be a specific hash. Abort the test if it is not.
98 # If we kept on executing, the test would just fail in mysterious
100 rev=`git rev-parse HEAD`
101 [ "d4850419ccc1146c7169f500725ce504b9774ed0" != "$rev" ] && \
102 die "setup_git_repo HEAD check failed (HEAD: $rev)"
104 # Explicitly set config that the tests rely on.
105 git config log.date default
106 git config log.decorate no
107 git config guilt.diffstat false
108 git config guilt.reusebranch false
111 function setup_guilt_repo
113 mkdir -p .git/patches/master
115 # patch to modify a file
116 cp "$REG_DIR/data/modify.patch" .git/patches/master/modify
118 # patch to add a new file
119 cp "$REG_DIR/data/add.patch" .git/patches/master/add
121 # patch to remove an existing file
122 cp "$REG_DIR/data/remove.patch" .git/patches/master/remove
124 # patch to change a mode
125 cp "$REG_DIR/data/mode.patch" .git/patches/master/mode
127 # the series file of all the things
128 cp "$REG_DIR/data/series" .git/patches/master/series
131 touch .git/patches/master/status
134 touch .git/patches/master/status
136 touch -a -m -t "$TOUCH_DATE" .git/patches/master/modify
137 touch -a -m -t "$TOUCH_DATE" .git/patches/master/add
138 touch -a -m -t "$TOUCH_DATE" .git/patches/master/remove
139 touch -a -m -t "$TOUCH_DATE" .git/patches/master/mode
142 function reset_git_repo
146 git reset --hard d4850419ccc1146c7169f500725ce504b9774ed0