On Sun, May 03, 2015 at 07:11:35PM +0300, Niko Tyni wrote: > 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.
Whoops, the 'git fetch origin refs/notes/commits:refs/notes/commits' part bails out if there are no notes in the repository. Updated patch attached, this skips the note testing part if no notes are found in the first place. -- Niko Tyni [email protected]
>From 5759947ae220a842e5b471b02f9b79106b8ea86c 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 | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/git-debcherry b/git-debcherry index 4766600..6a1689f 100755 --- a/git-debcherry +++ b/git-debcherry @@ -172,6 +172,14 @@ git clone "$orig_git_dir" "$tmpdir"/clone 1>$log || _die "clone failed" export GIT_WORK_TREE=$tmpdir/clone export GIT_DIR=$tmpdir/clone/.git +if git fetch origin refs/notes/commits:refs/notes/commits >/dev/null 2>&1; then + debug "git notes found in the repository" + NOTES=true +else + debug "no git notes found in the repository" + NOTES=false +fi + tmp_upstream=$(tmpbranch upstream $upstream_sha1) tmp_head=$(tmpbranch head $head_sha1) @@ -189,8 +197,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 $NOTES && [ -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 +315,9 @@ if [ -s $tmpdir/patch-list ]; then fi _die "cherry-pick $hash failed" fi + if $NOTES && 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 +332,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

