Repository navigation
Expand file tree
/
Copy pathgitinitquilt.sh
More file actions
executable file
·117 lines (99 loc) · 1.76 KB
/
Copy pathgitinitquilt.sh
File metadata and controls
executable file
·117 lines (99 loc) · 1.76 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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
#!/bin/sh
usage()
{
echo "Usage:"
echo "`basename $0` [-dp] <repository> <patches>"
echo "Where:"
echo " -d: dry run"
echo " -f: force 'quilt pop' and 'git reset'"
exit -1
}
while getopts "df" opt
do
case $opt in
d) DRYRUN=yes;;
f) FORCE=yes;;
?) echo "Invalid argument $opt"
usage;;
esac
done
shift $(($OPTIND - 1))
if [ "x$1" = "x" ]; then
usage
fi
if [ "x$2" = "x" ]; then
usage
fi
REPO=`(cd $1; pwd)`
PATCHES=~/defconfig/patches/linux/$2
repo_is_init()
{
repo=$1
if [ ! -e $repo/patches ]; then
return 1;
fi
return 0
}
exit_repo()
{
repo_is_init $1 || return 0
repo=$1
(
cd $repo
quilt applied 1>/dev/null 2>&1
if [ $? -eq 0 ]; then
echo "Removing quilt patches..."
if [ "x$DRYRUN" = "xyes" ]; then
echo quilt pop -a
else
msg=`quilt pop -a`
if [ $? -ne 0 ]; then
if [ "x$FORCE" = "xyes" ]; then
quilt pop -af
else
echo "Please check unmreged quilt differences."
return 1
fi
fi
fi
fi
git diff --exit-code 1>/dev/null 2>&1
if [ $? -ne 0 ]; then
if [ "x$FORCE" = "xyes" ]; then
echo "Resetting git repository..."
if [ "x$DRYRUN" = "xyes" ]; then
echo git reset --hard
else
git reset --hard 1>/dev/null 2>&1 || return 1
fi
else
echo "Please check unmreged git differences."
return 1
fi
fi
echo "Unlinking quilt repository..."
if [ "x$DRYRUN" = "xyes" ]; then
echo rm -f $repo/patches
else
rm -f $repo/patches
fi
)
}
init_repo()
{
repo_is_init $1 && return 0
repo=$1
patches=$2
(
cd $repo
echo "Linking quilt repository..."
if [ "x$DRYRUN" = "xyes" ]; then
echo ln -s $patches ./patches
else
ln -s $patches ./patches
fi
)
}
echo "Working on $REPO..."
exit_repo $REPO || exit 1
init_repo $REPO $PATCHES