* [PATCH 3/3] cg-patch: Add -d option to apply patch directory
@ 2006-02-07 22:44 Jonas Fonseca
0 siblings, 0 replies; only message in thread
From: Jonas Fonseca @ 2006-02-07 22:44 UTC (permalink / raw)
To: Petr Baudis; +Cc: git
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
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2006-02-07 22:45 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-02-07 22:44 [PATCH 3/3] cg-patch: Add -d option to apply patch directory Jonas Fonseca
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.