Package: gitpkg
Version: 0.26
Severity: wishlist
Tags: patch
I'm trying out a git-debcherry based workflow that would store DEP-3
style patch metadata (particularly volatile things like Forwarded and
Applied-Upstream headers) in git notes attached to the commits touching
upstream code.
Unfortunately git-debcherry doesn't currently preserve the notes or
include them in the generated patches. Please consider the attached
proposed patch that fixes this.
(It's a bit unfortunate that DEP-3 specifies that the metadata must come
before the triple dash ('---'), but 'git format-patch --notes' insists
on outputting the notes after that. That can be easily fixed with some
post-processing, though.)
-- System Information:
Debian Release: 8.0
APT prefers unstable
APT policy: (500, 'unstable')
Architecture: amd64 (x86_64)
Kernel: Linux 3.16.0-4-amd64 (SMP w/4 CPU cores)
Locale: LANG=en_US.UTF-8, LC_CTYPE=fi_FI.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Init: systemd (via /run/systemd/system)
Versions of packages gitpkg depends on:
ii dpkg-dev 1.17.25
ii git 1:2.1.4-2.1
gitpkg recommends no packages.
Versions of packages gitpkg suggests:
ii devscripts 2.15.3
-- no debconf information
>From 803072c9c475879a9fb8fb4abecf321a890006d8 Mon Sep 17 00:00:00 2001
From: Niko Tyni <[email protected]>
Date: Sun, 3 May 2015 18:38:13 +0300
Subject: [PATCH] Preserve git notes in git-debcherry
There's currently no notes filter for git-filter-branch, so we need
to use the commit filter instead.
---
git-debcherry | 16 ++++++++++++++--
1 file changed, 14 insertions(+), 2 deletions(-)
diff --git a/git-debcherry b/git-debcherry
index 4766600..64702ac 100755
--- a/git-debcherry
+++ b/git-debcherry
@@ -172,6 +172,8 @@ git clone "$orig_git_dir" "$tmpdir"/clone 1>$log || _die "clone failed"
export GIT_WORK_TREE=$tmpdir/clone
export GIT_DIR=$tmpdir/clone/.git
+git fetch origin refs/notes/commits:refs/notes/commits 1>$log 2>&1 || _die "fetching notes failed"
+
tmp_upstream=$(tmpbranch upstream $upstream_sha1)
tmp_head=$(tmpbranch head $head_sha1)
@@ -189,8 +191,15 @@ _time $LINENO
{
# git-filter-branch doesn't really understand GIT_WORK_TREE
cd $GIT_WORK_TREE
-if ! git filter-branch -f --prune-empty --index-filter \
+if ! git filter-branch -f --index-filter \
'git rm --ignore-unmatch --cached -r .pc debian' \
+ --commit-filter '\
+ NEW=$(git_commit_non_empty_tree "$@"); \
+ if [ -n "$NEW" ] && \
+ git notes show "$GIT_COMMIT" >/dev/null 2>&1 && \
+ ! git notes show "$NEW" >/dev/null 2>&1; then \
+ git notes copy "$GIT_COMMIT" "$NEW"; \
+ fi; echo "$NEW"' \
"$tmp_upstream".."$tmp_head" 1>$log 2>&1 ; then
_die "filtering failed"
fi
@@ -300,6 +309,9 @@ if [ -s $tmpdir/patch-list ]; then
fi
_die "cherry-pick $hash failed"
fi
+ if git notes show $hash >/dev/null 2>&1; then
+ git notes copy $hash HEAD;
+ fi
if [ -z "$(git diff $base)" ]; then
base=$(git rev-parse HEAD);
debug "new base ${base}"
@@ -314,7 +326,7 @@ else
if [ -n "$patch_dir" ]; then
mkdir -p "$patch_dir" || _die "mkdir failed";
echo "# exported from git by git-debcherry" > "$patch_dir/series"
- if PATCHES=$(git format-patch -o "$patch_dir" "$base"..HEAD ); then
+ if PATCHES=$(git format-patch --notes -o "$patch_dir" "$base"..HEAD ); then
if [ -n "$PATCHES" ]; then
echo "$PATCHES" | sed -e "s,$patch_dir/,,g" -e 's, ,\n,g' >> "$patch_dir/series"
else
--
2.1.4