#! /bin/sh # # darcs-apply-http # # Apply a patch to http server using curl and HTTP POST # # The push URI is read from the target repo: # _darcs/prefs/apply-url # # Extra curl options can be stored in local repo: # _darcs/prefs/darcs-apply-http.curl # # # Author: Pekka Pessi # # This software is copyright (C) 2007 Pekka Pessi. # This software is copyright (C) 2007 Nokia Corporation. All Rights Reserved. # # You are free to distribute this software under the terms of # the GNU General Public License version 2 or later. # # See the file GPL for more details. # url=`curl -sS --fail "$1/_darcs/prefs/apply-url"` || { echo $1/_darcs/prefs/apply-url: not found exit $? } conf=_darcs/prefs/darcs-apply-http.curl test -r $conf && config="--config $conf" case $url in /* ) # Try to make URL absolute schema=`echo $1 | sed 's-:.*--;'` hostport=`echo $1 | sed 's-^[^:]*://--; s-/.*--;'` url=$schema://$hostport$url ;; esac echo darcs-apply-http: post to $url >&2 perl -e 'while (<>) { $boundary=$1 if m/^Content-Type: .*boundary="([^"]+)"/; last if (m/^$/); } while (<>) { last if (/^--$boundary/o); } while (<>) { last if (m/^$/); } while (<>) { last if (/^--$boundary/o); s/=\s*\r?\n//; s/=([0-9A-F][0-9A-F])/chr(hex($1))/gei; print $_; }' | curl -sS $config --data-binary @- $url