blob: bd453b0c879373941c13c0bcb7c96cdc6e43e039 (
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
|
#!/bin/bash
# vim: set fileencoding=UTF-8:
# Copyright 2013 Red Hat, Inc.
# Author: Jan Pokorný <jpokorny at redhat dot com>
# Licensed under MIT license
set -eu
export LC=C
HERE=$(dirname "$(readlink -f "${BASH_SOURCE}")")
patch_figure_expr() {
local line file hunk offset perfile_expr= final_expr=
while read line; do
#echo "${line}"
case "${line}" in
patching\ file\ *|@@EOF@@)
if test -n "$perfile_expr"; then
final_expr=${final_expr:+${final_expr}::}
final_expr+="${file}:${perfile_expr}"
fi
file=${line#patching file }
perfile_expr=
;;
Hunk\ \#*\ succeeded\ at\ *\ \(offset\ *\ lines\).)
hunk=${line#Hunk #}
hunk=${hunk%% *}
offset=${line#* (offset }
offset=${offset% *}
perfile_expr=${perfile_expr:+${perfile_expr}:}
perfile_expr+="${hunk}/${offset}"
;;
esac
done < <(patch -o- "$@" 2>&1 >/dev/null; echo '@@EOF@@')
echo "${final_expr}"
}
patches=
args=
cnt=1
i=
while test ${cnt} -le $#; do
i="${@:${cnt}:1}"
case "${i}" in
-*|--*) args+=" ${i}";;
*) patches+=" ${i}";;
esac
let cnt+=1
done
#echo "${patches}"
#echo "${args}"
#cat ${patches} | patch_figure_expr ${args}
"${HERE}"/fix-offsets --expr "$(cat ${patches} | patch_figure_expr ${args})" ${patches}
|