#!/bin/bash
-cp /dev/null ../quilt-import.log
+#cp /dev/null ../quilt-import.log
log()
{
quilters=$(grep -v '^#' ../real_control | awk -F ' ' '$2=="quilt" { print $3; }')
for name in $quilters; do
+
sfile="../quilt/$name/series"
- base=$(sed -n 's/^[# ]*NEXT_BASE[ ]*\(.*\)[ ]*$/\1/p' "$sfile")
+ base=$(sed -n 's/^#[ ]*NEXT[-_]BASE[ ]*\([^ ]*\)[ ]*$/\1/p' "$sfile")
if [ -n "$base" ]; then
- base=$(grep -v '^#' ../real_control | awk -F ' ' '$3=="'"$base"'" { if ($2=="quilt") printf("quilt/%s", "'"$base"'"); else printf("%s/%s", "'"$base"'", $5); }')
+ nbase=$(grep -v '^#' ../real_control | awk -F ' ' '$3=="'"$base"'" { if ($2=="quilt") printf("quilt/%s", "'"$base"'"); else printf("%s/%s", "'"$base"'", $5); }')
+ [ -n "$nbase" ] && base="$nbase"
else
- base=$(sed -n 's/^[# ]*BASE[ ]*\(.*\)[ ]*$/\1/p' "$sfile")
+ base=$(sed -n 's/^#[ ]*BASE[ ]*\(.*\)[ ]*$/\1/p' "$sfile")
+ [ -n "$base" ] || {
+ # for stgit
+ base=$(sed '1{s/^#.*GIT commit \(.*\)$/\1/;q}' "$sfile")
+ [ -n "$base" ] ||
+ base="origin/master"
+ }
fi
rbase="$base"
case "$base" in
- *-git[0-9]*) rbase=$(wget -q -O - "http://www.kernel.org/pub/linux/kernel/v2.6/snapshots/patch-${base}.id")
+ *-git[0-9]*) rbase=$($(dirname $0)/get_gitid "${base}")
;;
commit*) rbase=$(expr "$base" : "commit[ ]*\(.*\)")
;;
log "Unknown BASE"
continue
}
+
+ # don't bother importing things that haven't changed
+ mb=$(git merge-base "$rbase_sha1" "quilt/$name")
+ change_size=$(cd ../quilt;git diff last_merge.. -- "$name/" | wc -c)
+ [ "$mb" = "$rbase_sha1" ] && [ $change_size -eq 0 ] && {
+ log "Unchanged quilt series $name"
+ continue
+ }
+
mv -f "$sfile" "$sfile.orig"
- if grep -q NEXT_PATCHES "$sfile.orig"; then
- do_echo=:
- while read line; do
- case $line in
- *NEXT_PATCHES_START*) do_echo=echo
- ;;
- *NEXT_PATCHES_END*) do_echo=:
- ;;
- esac
- $do_echo $line
- done <"$sfile.orig" >"$sfile"
- else
- cp "$sfile.orig" "$sfile"
- fi
+ do_echo=echo
+ grep -q NEXT_PATCHES "$sfile.orig" && do_echo=:
+ while read line; do
+ case $line in
+ *NEXT_PATCHES_START*) do_echo=echo
+ ;;
+ *NEXT_PATCHES_END*) do_echo=:
+ ;;
+ esac
+ $do_echo $line
+ done <"$sfile.orig" |
+ sed -e 's/[ ]*#.*$//' -e '/^[ ]*$/d' >"$sfile"
git show-ref --quiet --verify "refs/heads/quilt/$name" ||
execute git branch "quilt/$name" "$rbase_sha1"
- mv -f "$sfile" "$sfile.tmp"
- sed -e '/^[ ]*$/d' -e '/^[ ]*#/d' <"$sfile.tmp" >"$sfile"
- rm -f "$sfile.tmp"
[ -s "$sfile" ] || {
log " quilt series is empty"
- [ -f "$sfile.orig" ] &&
- mv -f "$sfile.orig" "$sfile"
+ mv -f "$sfile.orig" "$sfile"
execute git update-ref "refs/heads/quilt/$name" "$rbase_sha1"
continue
}
- execute git checkout "quilt/$name"
+ [ -d "../quilt-tmp" ] ||
+ execute git clone -s -l -n -q . ../quilt-tmp
+
+ log '$' cd ../quilt-tmp
+ cd ../quilt-tmp
execute git reset --hard "$rbase_sha1"
- author=$(grep -v '^#' ../real_control | awk -F ' ' '$3=="'"$name"'" { printf("%s", $1); }' | sed 's/,.*$//')
- execute git quiltimport --author "$author" --patches "../quilt/$name"
+ while read f <&5 ; do
+ old_head=$(git rev-parse --verify HEAD)
+ execute git am "../quilt/$name/$f"
+ new_head=$(git rev-parse --verify HEAD)
+ [ "$new_head" = "$old_head" ] && {
+ echo "Tree unchanged, please check ..."
+ bash -i || exit
+ }
+ done 5<"../quilt/$name/series"
- [ -f "$sfile.orig" ] &&
- mv -f "$sfile.orig" "$sfile"
+ log '$' cd ../next
+ cd ../next
+
+ execute git fetch -f ../quilt-tmp master:"quilt/$name"
+
+ mv -f "$sfile.orig" "$sfile"
done
-git checkout master
+[ -d "../quilt-tmp" ] &&
+ rm -rf ../quilt-tmp
+
+( cd ../quilt; git update-ref refs/heads/last_merge HEAD )
exit 0