[Pkg-zsh-commits] [zsh] 01/09: Add debian/bin/commit2quilt for easier cherry-picking

Axel Beckert abe at deuxchevaux.org
Mon Oct 13 21:11:44 UTC 2014


This is an automated email from the git hooks/post-receive script.

abe pushed a commit to branch debian
in repository zsh.

commit 503d680705b895cd960a081f26569ae7c2a2d7c4
Author: Axel Beckert <abe at deuxchevaux.org>
Date:   Mon Oct 13 22:35:34 2014 +0200

    Add debian/bin/commit2quilt for easier cherry-picking
    
    Based on ft's patch2quilt, but simpler and with less restrictions.
---
 debian/bin/commit2quilt    | 68 ++++++++++++++++++++++++++++++++++++++++++++++
 debian/pkg-zsh-workflow.md | 10 +++++--
 2 files changed, 76 insertions(+), 2 deletions(-)

diff --git a/debian/bin/commit2quilt b/debian/bin/commit2quilt
new file mode 100755
index 0000000..dee525b
--- /dev/null
+++ b/debian/bin/commit2quilt
@@ -0,0 +1,68 @@
+#!/bin/sh
+
+# commit2quilt, based on patch2quilt
+# Copyright (c) 2011, Frank Terbeck <ft at bewatermyfriend.org>
+# Copyright (c) 2014, Axel Beckert <abe at debian.org>
+#
+# Permission to use, copy, modify, and/or distribute this software for any
+# purpose with or without fee is hereby granted, provided that the above
+# copyright notice and this permission notice appear in all copies.
+#
+# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+#
+# Often, we may want to backport a patch from upstream to our package. If
+# that's just a matter of cherry-picking a patch from upstream, this script can
+# help. We don't really want to git cherry-pick, but rather add a new patch to
+# our quilt series. In short, this script automates doing that.
+#
+# Call it like this:
+#   % git fetch zsh
+#   % debian/bin/commit2quilt $commit_id
+#
+# `commit2quilt' requires `quilt', `git' and $GIT_EDITOR or
+# emacsclient available.
+
+set -e
+
+for where in ./ ../ ../../ ../../../ ../../../../ ../../../../../; do
+    if [ -e ${where}debian/rules -a -d ${where}debian/patches ]; then
+        export QUILT_PATCHES=debian/patches
+        break
+    fi
+done
+
+export GIT_EDITOR=${GIT_EDITOR:-emacsclient}
+
+if [ $# -ne 1 ]; then
+    printf 'usage: patch2quilt <commit-id>\n'
+    exit 1
+fi
+
+commitid="$1"
+shortid="`echo -n $commitid | cut -c1-8`"
+desc="`git show $commitid | egrep '^    [^ ]' | head -1 | sed -e 's/^[- *:]*//'`"
+filename="cherry-pick-$shortid-`echo "$desc" | tr -c 'a-zA-Z0-9' '-' | tr 'A-Z' 'a-z' | sed -e 's/--*/-/g;s/-$//'`.patch"
+echo "$filename"
+
+if quilt series | fgrep -q "$filename"; then
+    echo "Patch $filename ($commitid) already existing" 1>&2
+    exit 1
+fi
+
+git show "$commitid" | filterdiff -x a/ChangeLog > "${where}debian/patches/$filename"
+echo "$filename" >> "${where}debian/patches/series"
+sed -e '1 s/^commit/Origin: commit/; 4 d; 5 s/^    /Description: /; 6 d' -i "${where}debian/patches/$filename"
+"${GIT_EDITOR}" "${where}debian/patches/$filename"
+git add "${where}debian/patches/$filename" "${where}debian/patches/series"
+quilt push -a
+quilt pop -a
+git commit -m "Cherry-pick $shortid ($desc) from upstream" -v --edit
+
+exit 0
+
diff --git a/debian/pkg-zsh-workflow.md b/debian/pkg-zsh-workflow.md
index 7f37b30..1db83f2 100644
--- a/debian/pkg-zsh-workflow.md
+++ b/debian/pkg-zsh-workflow.md
@@ -120,13 +120,17 @@ the above can be largely automated if the patch applies to the current
 state of the debian branch.
 
     % patchname="cherry-pick-$shortcommitid-description-with-dashes"
-    % git show $commitid > debian/patches/$patchname
+    % git show $commitid | filterdiff -x a/ChangeLog > debian/patches/$patchname
     % sed -e '1 s/^commit/Origin: commit/' -i debian/patches/$patchname
     % echo $patchname >> debian/patches/series
+    % $EDITOR debian/patches/$patchname
+    % git add debian/patches/series debian/patches/$patchname
+    % git commit -v
 
 Patches from upstream will likely include changes to the ChangeLog
 file. Those changes will probably not apply cleanly, so just open the
-created patch file and delete all hunks that do changes in ChangeLog.
+created patch file and delete all hunks that do changes in
+ChangeLog. The `filterdiff` command above should catch that.
 
     % $EDITOR debian/patches/$patchname
 
@@ -134,6 +138,8 @@ Check if the patch applies
 
     % quilt push
 
+All the above is mostly automated in `debian/bin/commit2patch`.
+
 ##### Finish import of the patch
 
 Refresh the patch to get rid of any fuzz or offset:

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/collab-maint/zsh.git



More information about the Pkg-zsh-commits mailing list