diff options
author | Jan Pokorný <jpokorny@redhat.com> | 2013-10-10 15:17:33 +0200 |
---|---|---|
committer | Jan Pokorný <jpokorny@redhat.com> | 2013-10-10 15:17:33 +0200 |
commit | 8ac6fd870d1339102155da6e75c1af9ed609dcb0 (patch) | |
tree | 570e7465341fd347c6fbae1344e775aa99565be9 /patch-fix-offsets | |
parent | 95d2e7bd9fa4538059a94fd1f04626a46f9a14d1 (diff) | |
download | patch-fix-offsets-8ac6fd870d1339102155da6e75c1af9ed609dcb0.tar.gz patch-fix-offsets-8ac6fd870d1339102155da6e75c1af9ed609dcb0.tar.xz patch-fix-offsets-8ac6fd870d1339102155da6e75c1af9ed609dcb0.zip |
Add proper README and patch-fix-offsets (recommended!) wrapper
Signed-off-by: Jan Pokorný <jpokorny@redhat.com>
Diffstat (limited to 'patch-fix-offsets')
-rwxr-xr-x | patch-fix-offsets | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/patch-fix-offsets b/patch-fix-offsets new file mode 100755 index 0000000..b7ef3cb --- /dev/null +++ b/patch-fix-offsets @@ -0,0 +1,55 @@ +#!/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}" + echo "${i}" + 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} |