summaryrefslogtreecommitdiff
path: root/tests/tests/badcommit-rewrite
blob: 3e2f37e71da47ab893a671e8dfa147a6283bb6d3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#!/bin/bash
set -e
. tests/lib

t-setup-import examplegit
t-tstunt-parsechangelog

cd $tmp/git/$p.git
git config core.sharedRepository true
chmod -R g+w objects
umask 022

cd $tmp/example

suite=stable

t-commit 'No changes, just send to stable' '' stable

t-make-badcommit
git reset --hard $badcommit

t-dgit -wgf build
t-dgit push --overwrite=1.2 stable
t-archive-process-incoming stable

rstable=refs/remotes/dgit/dgit/stable

t-dgit fetch stable
t-has-parent-or-is $rstable $badcommit

fixup=${DGIT_BADCOMMIT_FIXUP-dgit-badcommit-fixup}

cd $tmp/git/$p.git
git gc --aggressive --prune=all
rmdir objects/* ||:

$fixup --real

cd $tmp/$p
git symbolic-ref HEAD >../sym.before
git rev-parse HEAD >../ref.before

$fixup --real

git symbolic-ref HEAD >../sym.after
git rev-parse HEAD >../ref.after
diff ../sym.before ../sym.after
set +e; diff ../ref.before ../ref.after; rc=$?; set -e; test $rc = 1

t-dgit fetch stable

t-expect-fail "child $rstable lacks parent $badcommit" \
t-has-parent-or-is $rstable $badcommit

check_shared () {
	find "$1" -perm -200 \! -perm -020 -ls |tee $tmp/badperm
	test -f $tmp/badperm -a ! -s $tmp/badperm
}

check_shared $tmp/git/$p.git/objects

t-ok