blob: f56771d9efdb19294cfb4cb5d22962b109a135ac (
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
63
64
65
66
67
68
69
70
71
72
73
74
75
|
#!/usr/bin/env bash
gitcmd="git -c commit.gpgsign=false"
noapply=1
isreject=0
if [[ $1 == "--noapplied" ]]; then
noapply=1
shift
fi
if [ ! -z "$1" ]; then
file="$1"
elif [ -z "$1" ] && [ -f .git/rebase-apply/patch ]; then
file=".git/rebase-apply/patch"
noapply=1
isreject=1
else
echo "Please specify a file"
exit 1
fi
applied=$(echo $file | sed 's/.patch$/-applied\.patch/g')
if [ "$1" == "--reset" ]; then
$gitcmd am --abort
$gitcmd reset --hard
$gitcmd clean -f
exit 0
fi
(test "$isreject" != "1" && $gitcmd am -3 $file) || (
echo "Failures - Wiggling"
$gitcmd reset --hard
$gitcmd clean -f
errors=$($gitcmd apply --rej $file 2>&1)
echo "$errors" >> ~/patch.log
export missingfiles=""
export summaryfail=""
export summarygood=""
for i in $(find . -name \*.rej); do
base=$(echo "$i" | sed 's/.rej//g')
if [ -f "$i" ]; then
sed -e 's/^diff a\/\(.*\) b\/\(.*\)[[:space:]].*rejected.*$/--- \1\n+++ \2/' -i $i && wiggle -v -l --replace "$base" "$i"
rm "$base.porig" "$i"
else
echo "No such file: $base"
missingfiles="$missingfiles\n$base"
fi
done
for i in $($gitcmd status --porcelain | awk '{print $2}'); do
filedata=$(cat "$i")
if [ -f "$file" ] && [[ "$filedata" == *"<<<<<"* ]]; then
export summaryfail="$summaryfail\nFAILED TO APPLY: $i"
else
$gitcmd add --force "$i"
export summarygood="$summarygood\nAPPLIED CLEAN: $i"
fi
done
echo -e "$summarygood"
echo -e "$summaryfail"
if [[ "$errors" == *"No such file"* ]]; then
echo "===========================";
echo " "
echo " MISSING FILES"
echo $(echo "$errors" | grep "No such file")
echo -e "$missingfiles"
echo " "
echo "===========================";
fi
$gitcmd status
$gitcmd diff
)
if [[ "$noapply" != "1" ]] && [[ "$file" != *-applied.patch ]]; then
mv "$file" "$applied"
fi
|