This repository was archived by the owner on Feb 18, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathupdate-code-from-vc.sh
More file actions
executable file
·87 lines (75 loc) · 2.13 KB
/
update-code-from-vc.sh
File metadata and controls
executable file
·87 lines (75 loc) · 2.13 KB
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
#!/bin/bash
# Script to update vtest2 source files taken from varnish-cache keeping the
# original commits intact
#
# Author: Nils Goroll <slink@uplex.de>
#
# This file is in the Public Domain
#
#
# USAGE:
# - Optionally set VARNISHSRC to your varnish-cache git repository
# - Everything else should be automatic
#
set -eux
MYDIR=$(dirname "$0")
MYDIR=$(realpath "${MYDIR}")
cd "${MYDIR}"
TOP=$(git rev-parse --show-toplevel)
##############################
# BEGIN config
VARNISHSRC=${VARNISHSRC:-https://github.com/varnishcache/varnish-cache.git}
VARNISHBRANCH=master
BASEF="${MYDIR}"/base_commit
BASE=$(cat "${BASEF}")
SPEC="${MYDIR}"/git-filter-repo-files.spec
# END config
##############################
tagbase="tag-ucfvc"
branchbase="branch-ucfvc"
workdir=$(mktemp -d)
function onexit {
cd
rm -rf "${workdir}"
}
trap onexit EXIT
cd "${workdir}"
git clone --no-tags -o origin --branch "${VARNISHBRANCH}" --single-branch "${VARNISHSRC}"
pushd varnish-cache
git remote remove origin
git tag "${tagbase}-base" "${BASE}"
git rebase -X theirs "${tagbase}-base"
git tag "${tagbase}-head"
NEWBASE=$(git rev-parse "${tagbase}-head")
git checkout -b "${branchbase}-squash" "${tagbase}-base"
git reset --soft "$(git rev-list --max-parents=0 HEAD)"
git commit -m "SQUASH"
git tag "${tagbase}-squash"
git cherry-pick "${tagbase}-base..${tagbase}-head"
git tag -d "${tagbase}-head" "${tagbase}-base"
git branch -D "${VARNISHBRANCH}"
git branch -a # dignostic only
git tag -l # dignostic only
popd
# now we have a simplified git history with only new commits since BASE
# - rewrite to vtest paths in a new repo
git init vc2vt
git filter-repo \
--source varnish-cache \
--target vc2vt \
--paths-from-file "${SPEC}"
cd vc2vt
git checkout "${branchbase}-squash"
git tag -l
# vc2vt now has all the new commits from varnish-cache but with the vtest
# path scheme
patchdir=$(mktemp --tmpdir -d ucfvc_patches.XXXXXXXXXX)
git format-patch -o "${patchdir}" "${tagbase}-squash"
# apply
cd "${TOP}"
git am "${patchdir}"/*
echo "${NEWBASE}" >"${BASEF}"
git commit -m 'Updated code from varnish-cache' "${BASEF}"
rm -rf "${patchdir}"
set +x
echo SUCCESS - commits have been added