From: Sean Whitton Date: Sun, 21 Jul 2019 08:31:50 +0000 (+0100) Subject: git-debpush: Check that patches are (un)applicable X-Git-Tag: archive/debian/9.5~10 X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=4bbb0ea95dcf9be8e26f19424ad3b5269a556783;p=dgit.git git-debpush: Check that patches are (un)applicable Closes: #932477 Signed-off-by: Sean Whitton --- diff --git a/git-debpush b/git-debpush index bd0357b5..84193751 100755 --- a/git-debpush +++ b/git-debpush @@ -121,6 +121,51 @@ check_treesame () { fi } +check_patches_apply () { + local should_match_branch="$1" + + local playground="$(git rev-parse --git-dir)/gdp" + local playtree="$playground/apply-patches" + local git_apply_rc=0 + + rm -rf "$playground" + mkdir -p "$playtree" + local pwd="$(pwd)" + cd "$playtree" + "$git_playtree_setup" . + + # checking out the upstream source and then d/patches on top + # ensures this check will work for a variety of quilt modes + git checkout -b upstream "$upstream_committish" + git checkout "$branch_commit" -- debian + + if [ -s "debian/patches/series" ]; then + while read patch; do + shopt -s extglob; patch="${patch%%?( )#*}"; shopt -u extglob + if [ -z "$patch" ]; then continue; fi + set +e + git apply --index "debian/patches/$patch" + git_apply_rc=$? + set -e + if ! [ $git_apply_rc = 0 ]; then + fail_check patches-applicable \ + "'git apply' failed to apply patch $patch" + break + fi + done or B<--quilt=unapplied>). +=item B + +Ignore any failures of the following two checks: + +=over 4 + +=item + +With B<--quilt=gbp>, B<--quilt=unapplied>, B<--quilt=baredebian>, +B<--quilt=dpm>, and B<--quilt=nofix>, the quilt patches should apply +cleanly to the upstream source with git-apply(1). + +=item + +With B<--quilt=dpm> and B<--quilt=nofix>, applying the quilt patches +to the upstream source should produce exactly the source tree to be +tagged. + +=back + =item B Permit upload to a suite called UNRELEASED. diff --git a/tests/tests/tagupl-baredebian b/tests/tests/tagupl-baredebian index 764debdc..b485abb9 100755 --- a/tests/tests/tagupl-baredebian +++ b/tests/tests/tagupl-baredebian @@ -17,7 +17,18 @@ t-tagupl-settings baredebian-test-minimum baredebian-test-core-prepush + +sed -i '15icorruption' debian/patches/0002-Edit-the-.c-file.patch +git add debian/patches/0002-Edit-the-.c-file.patch +git commit -m"corrupt a quilt patch to test the patches-applicable check" + tagname=test-dummy/$v + +t-expect-fail "'git apply' failed to apply patch 0002-Edit-the-.c-file.patch ('patches-applicable' check)" \ +t-tagupl-test --baredebian + +git reset --hard HEAD~1 + t-tagupl-test --baredebian git branch split.p dgit/dgit/sid # we didn't generate this here