git-quiltimport: better parser to grok "enhanced" series files.
The previous parser wasn't able to grok: * empty lines; * annotated patch levels (trailing -pNNN annotations); * trailing comments. Now it understands them and uses the patch level hints as a git apply argument. Signed-off-by: Pierre Habouzit <madcoder@debian.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Pierre Habouzit committed
Mar 8, 2008 at 19:27 UTC
9dd5bded1bdc4f518aeed6a32ad70ccdd182dde5
1 file changed
+19
-3
git-quiltimport.sh
+19
-3
@@ -63,7 +63,23 @@ tmp_info="$tmp_dir/info"
63
commit=$(git rev-parse HEAD)
64
65
mkdir $tmp_dir || exit 2
66
-for patch_name in $(grep -v '^#' < "$QUILT_PATCHES/series" ); do
66
+while read patch_name level garbage
67
+do
68
+ case "$patch_name" in ''|'#'*) continue;; esac
69
+ case "$level" in
70
+ -p*);;
71
+ ''|'#'*)
72
+ level=;;
73
+ *)
74
+ echo "unable to parse patch level, ignoring it."
75
+ level=;;
76
+ esac
77
+ case "$garbage" in
78
+ ''|'#'*);;
79
+ *)
80
+ echo "trailing garbage found in series file: $garbage"
81
+ exit 1;;
82
+ esac
83
if ! [ -f "$QUILT_PATCHES/$patch_name" ] ; then
84
echo "$patch_name doesn't exist. Skipping."
85
continue
@@ -113,10 +129,10 @@ for patch_name in $(grep -v '^#' < "$QUILT_PATCHES/series" ); do
129
fi
130
131
if [ -z "$dry_run" ] ; then
116
- git apply --index -C1 "$tmp_patch" &&
132
+ git apply --index -C1 $level "$tmp_patch" &&
133
tree=$(git write-tree) &&
134
commit=$( (echo "$SUBJECT"; echo; cat "$tmp_msg") | git commit-tree $tree -p $commit) &&
135
git update-ref -m "quiltimport: $patch_name" HEAD $commit || exit 4
136
fi
121
-done
137
+done <"$QUILT_PATCHES/series"
138
rm -rf $tmp_dir || exit 5