-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathget_commits
More file actions
executable file
·169 lines (161 loc) · 3.59 KB
/
get_commits
File metadata and controls
executable file
·169 lines (161 loc) · 3.59 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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
#!/bin/bash
CWD=$PWD
tmp=/tmp/tmp_dir_for_get_commits
tag=
end=
output_dir=patches
filter=
files=
list=1
get=0
SLOG_FILTER=0
FIXES=0
MISSING=""
usage()
{
cat <<EOF
Usage:
${0##*/} --tag <tag> [options]
this script must run inside linux upstream git repository.
Options:
--tag Get patches starting from this tag/commit
--end Get patches up-to this tag/commit
--files Filter commits to given file list
--list-only Only list changes
--output-dir Output dir for saving the patches
--get-patches Save patches to given output dir: '$output_dir'
--fixes Get only patches with 'Fixes' in commit message
--filter Get only patches missing in current OFED dir
-h, --help Show help message
EOF
}
while [ ! -z "$1" ]
do
case "$1" in
--list-only)
list=1
get=0
;;
--get-patches)
list=0
get=1
;;
--tag)
tag="$2"
shift
;;
--end)
end="$2"
shift
;;
--outdir)
output_dir="$2"
if [ -d "$output_dir" ]; then
echo "Directory '$output_dir' exists.. Aborting"
exit 1
fi
shift
;;
--output-dir)
output_dir="$2"
if [ -d "$output_dir" ]; then
echo "Directory '$output_dir' exists.. Aborting"
exit 1
fi
shift
;;
--files)
files="$2"
shift
;;
--filter)
SLOG_FILTER=1
;;
--fixes)
FIXES=1
;;
-h | *help)
usage
exit 0
;;
*)
echo "-E- Unsupported option: $1" >&2
exit 1
;;
esac
shift
done
if [ $SLOG_FILTER -eq 1 ]; then
cd $files
SLOG=$(git log --oneline --color=never)
cd $CWD
fi
files="$files/ofed_scripts/checkout_files"
git pull --dry-run | grep -q -v 'Already up-to-date.' && changed=1
if [ -z "$tag" ]; then
echo "must provide --tag" >&2
exit 1
fi
if [ -e "$files" ]; then
files=`cat $files`
filter="-- $files"
fi
echo TAG=$tag
echo Files: $files
if [ $list -eq 1 ]; then
git log --oneline --decorate ${tag}..${end} $filter
elif [ $get -eq 1 ]; then
echo "Take relevant patches.."
git format-patch -N -o $output_dir ${tag}..${end} $filter
git format-patch -N -qo $tmp ${tag}..${end}
fi
if [ $FIXES -eq 1 ] || [ $SLOG_FILTER -eq 1 ]; then
echo "Analyzing patches.."
for file in $(ls $output_dir)
do
if [ $FIXES -eq 1 ]; then
if !(cat $output_dir/$file | grep -Eq "^[F|f]ixes: [0-9a-f]{12,40}"); then
echo "$output_dir/$file - Missing Fixes, removing.."
rm -rf $output_dir/$file
continue
fi
fi
if [ $SLOG_FILTER -eq 1 ]; then
sub=$(cat $output_dir/$file | grep -A1 -w "Subject" | xargs -d '\n' | grep -oE "[0-9]*\].*" | grep -oE "[a-zA-Z].*" | head -1)
if (echo "$SLOG" | grep -qE "$sub *$");then
echo "$output_dir/$file - Subject inside, removing.."
rm -rf $output_dir/$file
continue
fi
fi
done
fi
#check and alert for partial patchs
if [ $get -eq 1 ];then
echo "Looking for partial patches.."
for file in $(ls $output_dir)
do
search=$(echo $file | sed 's/[0-9]*-//')
search=${search::50}
up_name=$(ls $tmp | grep $search)
if [ "X$up_name" == "X" ];then
MISSING="$MISSING$file\n"
continue
fi
if (! cmp --silent $output_dir/$file $tmp/$up_name); then
MISSING="$MISSING$file\n"
fi
done
rm -rf $tmp
fi
echo
echo "-------------------------------------------------------------------------"
echo "See results in $output_dir"
echo "-------------------------------------------------------------------------"
if [ "X$MISSING" != "X" ];then
echo
echo "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@"
echo "IMPORTANT: Patches that missing upstream parts: [PLEASE REVIEW]"
printf $MISSING
echo "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@"
fi