blob: 47db6eaac88e9cdcf717a68d5f392461df0bb580 (
plain) (
blame)
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
|
#!/bin/sh
set -o errexit
set -o nounset
IFS='
'
if test "${IS_TEST_CASE:-1}" -eq '1'
then
DIR_TESTCASES="$(cd -- "$(dirname -- "$0")" && pwd -P)"
DIR_TEST="$(dirname "${DIR_TESTCASES}")"
else
DIR_TEST="$(cd -- "$(dirname -- "$0")" && pwd -P)"
DIR_TESTCASES="${DIR_TEST}/tests"
fi
DIR_ROOT="$(dirname "${DIR_TEST}")"
DIR_BIN="${DIR_ROOT}/bin"
DIR_TEMP="${DIR_TEST}/temp"
DIR_SOURCE="${DIR_TEMP}/source"
DIR_DESTINATION="${DIR_TEMP}/destination"
BIN_MAIN="${DIR_BIN}/incremental-git-filterbranch.sh"
if test ! -f "${BIN_MAIN}"
then
echo 'Failed to detect environment'>&2
exit 1
fi
initializeRepositories () {
rm -rf "${DIR_TEMP}"
mkdir "${DIR_TEMP}"
git init --quiet "${DIR_SOURCE}"
git -C "${DIR_SOURCE}" config --local user.email 'email@example.com'
git -C "${DIR_SOURCE}" config --local user.name 'John Doe'
mkdir "${DIR_SOURCE}/subdir"
touch "${DIR_SOURCE}/rootfile1"
git -C "${DIR_SOURCE}" add --all
git -C "${DIR_SOURCE}" commit --quiet --message 'Commit #1'
git -C "${DIR_SOURCE}" tag tag-01
touch "${DIR_SOURCE}/subdir/subfile1"
git -C "${DIR_SOURCE}" add --all
git -C "${DIR_SOURCE}" commit --quiet --message 'Commit #2'
touch "${DIR_SOURCE}/subdir/subfile2"
git -C "${DIR_SOURCE}" add --all
git -C "${DIR_SOURCE}" commit --quiet --message 'Commit #3'
git -C "${DIR_SOURCE}" tag tag-02
touch "${DIR_SOURCE}/subdir/subfile3"
git -C "${DIR_SOURCE}" add --all
git -C "${DIR_SOURCE}" commit --quiet --message 'Commit #4'
touch "${DIR_SOURCE}/rootfile2"
git -C "${DIR_SOURCE}" add --all
git -C "${DIR_SOURCE}" commit --quiet --message 'Commit #5'
git -C "${DIR_SOURCE}" tag tag-03
touch "${DIR_SOURCE}/rootfile3"
git -C "${DIR_SOURCE}" add --all
git -C "${DIR_SOURCE}" commit --quiet --message 'Commit #6'
touch "${DIR_SOURCE}/subdir/subfile3b"
git -C "${DIR_SOURCE}" add --all
git -C "${DIR_SOURCE}" commit --quiet --message 'Commit #4b'
git -C "${DIR_SOURCE}" checkout --quiet -b slave tag-02
touch "${DIR_SOURCE}/in-root-2"
git -C "${DIR_SOURCE}" add --all
git -C "${DIR_SOURCE}" commit --quiet --message 'Commit #7'
git -C "${DIR_SOURCE}" tag tag-04
touch "${DIR_SOURCE}/in-root-3"
git -C "${DIR_SOURCE}" add --all
git -C "${DIR_SOURCE}" commit --quiet --message 'Commit #8'
git init --bare --quiet "${DIR_DESTINATION}"
}
getTagList () {
getTagList_multiline=$(git -C "${1}" show-ref --tags | sed -E 's:^.*?refs/tags/::' || true)
printf '%s' "${getTagList_multiline}" | sort -b | tr '\n' ' ' | sed -E 's:^ | $::g'
}
|