forked from victronenergy/venus
-
Notifications
You must be signed in to change notification settings - Fork 0
/
git-fetch-remote.sh
executable file
·60 lines (47 loc) · 1.53 KB
/
git-fetch-remote.sh
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
#!/bin/sh
printf "\n--------------- $1 - $2 -------------\n"
if [ $# -lt 4 ]; then
echo "$0 directory fetch-url push-url (upstream-url|-) (checkout-branch|-) (upstream-branch|-)"
exit 1
fi
prop=build/prop.`basename $1`
# fetch url / push url might differ, commonly fetch by https, push by ssh
echo "export fetch_url=$2" > $prop
echo "export git_repo=${2##*/}" > $prop
echo "export push_url=$3" >> $prop
if [ "$4" != "-" ]; then
echo "export upstream_url=$4" >> $prop
else
echo "export upstream_url=" >> $prop
fi
if [ "$5" != "-" ]; then
echo "export checkout_branch=$5" >> $prop
else
echo "export checkout_branch=" >> $prop
fi
if [ "$6" != "-" ]; then
echo "export upstream_full_branch=$6" >> $prop
echo "export upstream_branch=${6##*/}" >> $prop
else
echo "export upstream_full_branch=" >> $prop
echo "export upstream_branch=" >> $prop
fi
git clone --no-checkout $2 $1
# set the upstream to push changes back
git --git-dir=$1/.git remote set-url --push origin $3
# optionally set an upstream repository
if [ "$4" != "-" ]; then
git --git-dir=$1/.git remote add upstream $4
fi
# optionally checkout a branch
if [ "$5" != "-" ]; then
git --git-dir=$1/.git --work-tree=$1 checkout "$5"
fi
# Set the checkout branch as default upstream branch
#
# Switching to OE point venus is based on can be done with:
# ./repos branch -u 'origin/$upstream_branch'
#
git --git-dir=$1/.git --work-tree=$1 branch -u "origin/$5"
echo "Set git config log.follow=true, to handle all the recipe renames"
git --git-dir=$1/.git --work-tree=$1 config log.follow true