From: Jonas Fonseca <fonseca@diku•dk>
To: Petr Baudis <pasky@ucw•cz>
Cc: git@vger•kernel.org
Subject: [PATCH 3/3] cg-patch: Add -d option to apply patch directory
Date: Tue, 7 Feb 2006 23:44:41 +0100 [thread overview]
Message-ID: <20060207224441.GC24790@diku.dk> (raw)
It tries to do some minimal sanity checking on the individual patch
files, to ensure that they are created with cg-mkpatch. This includes
checking that the filename starts with [0-9]*-, the patch is non-empty,
and it contains author information from git-cat-file output.
Signed-off-by: Jonas Fonseca <fonseca@diku•dk>
---
commit 35f920438f1c9f7413d708eeb57da7ea3dd8909a
tree 602514ba6eed872f936fdd133f17a12933fce38b
parent 77defc166986330f4285db8faf206c1176a6c4ae
author Jonas Fonseca <fonseca@diku•dk> Tue, 07 Feb 2006 23:30:42 +0100
committer Jonas Fonseca <fonseca@antimatter•localdomain> Tue, 07 Feb 2006 23:30:42 +0100
cg-patch | 26 ++++++++++++++++++++++++++
1 files changed, 26 insertions(+), 0 deletions(-)
diff --git a/cg-patch b/cg-patch
index 90dfd30..e783985 100755
--- a/cg-patch
+++ b/cg-patch
@@ -12,6 +12,11 @@
#
# OPTIONS
# -------
+# -d DIRNAME:: Apply all patches in directory
+# Instead of applying the patch from stdin, apply all patches in the
+# specified directory. This can be used to import a range of patches
+# made with cg-mkpatch -d.
+#
# -R:: Apply in reverse
# Applies the patch in reverse (therefore effectively unapplies it)
#
@@ -68,11 +73,32 @@ redzone_border()
redzone_reset
}
+apply_directory() {
+ directory="$1"
+ patch="$(mktemp -t gitpatch.XXXXXX)"
+
+ find "$directory" -name '[0-9]*-*' | while read file; do
+ sed -n '/^---$/,$p' < "$file" > "$patch"
+ [ -s "$patch" ] || die "No patch found in '$file'"
+
+ author="$(sed -n '/^author /p' < "$patch")"
+ [ "$author" ] || die "No author info found in '$file'"
+
+ eval "$(echo "$author" | pick_author)"
+ echo "Applying ${file#$directory/}"
+ cg-patch < "$patch"
+ sed '/^---$/,$d' < "$file" | cg-commit
+ done
+}
reverse=
while optparse; do
if optparse -R; then
reverse=1
+ elif optparse -d=; then
+ [ -d "$OPTARG" ] || die "Not a directory '$OPTARG'."
+ apply_directory "$(echo "$OPTARG" | sed 's,/*$,,')"
+ exit
else
optfail
fi
--
Jonas Fonseca
reply other threads:[~2006-02-07 22:45 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20060207224441.GC24790@diku.dk \
--to=fonseca@diku$(echo .)dk \
--cc=git@vger$(echo .)kernel.org \
--cc=pasky@ucw$(echo .)cz \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox