summaryrefslogtreecommitdiff
path: root/git-debpush
diff options
context:
space:
mode:
authorSean Whitton <spwhitton@spwhitton.name>2019-07-21 09:31:50 +0100
committerIan Jackson <ijackson@chiark.greenend.org.uk>2019-07-22 16:09:15 +0100
commit4bbb0ea95dcf9be8e26f19424ad3b5269a556783 (patch)
treeb35e76567d1e57197a8200486b3cabb087b503dd /git-debpush
parentf6f6419eca67882b47632875d2ee7163f4d005c7 (diff)
git-debpush: Check that patches are (un)applicable
Closes: #932477 Signed-off-by: Sean Whitton <spwhitton@spwhitton.name>
Diffstat (limited to 'git-debpush')
-rwxr-xr-xgit-debpush58
1 files changed, 57 insertions, 1 deletions
diff --git a/git-debpush b/git-debpush
index bd0357b..8419375 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 <debian/patches/series
+
+ if $should_match_branch && [ $git_apply_rc = 0 ]; then
+ git commit -q -a -m"commit result of applying all patches"
+ check_treesame HEAD "$branch_commit" ':!debian' \
+ || fail_check patches-applicable \
+ "applying all patches does not yield $branch"
+ fi
+ fi
+
+ cd "$pwd"
+ rm -rf "$playground"
+}
+
# **** Parse command line ****
getopt=$(getopt -s bash -o 'nfu:' \
@@ -220,6 +265,9 @@ case "$branch" in
;;
esac
+# resolve $branch to a commit
+branch_commit="$(git rev-parse --verify ${branch}^{commit})"
+
# also check, if the branch does not have its own pushRemote or
# remote, whether there's a default push remote configured
remoteconfigs+=(remote.pushDefault)
@@ -342,16 +390,24 @@ if ! [ "x$upstream_tag" = "x" ] \
"upstream tag $upstream_tag is not an ancestor of $branch; probably a mistake"
fi
-# ---- Upstream tag tree nonidentical
+# ---- Quilt mode-specific checks
case "$quilt_mode" in
gbp)
check_treesame "$upstream_tag" "$branch" ':!debian' ':!**.gitignore' \
|| fail_check_upstream_nonidentical
+ check_patches_apply false
;;
unapplied)
check_treesame "$upstream_tag" "$branch" ':!debian' \
|| fail_check_upstream_nonidentical
+ check_patches_apply false
+ ;;
+ baredebian)
+ check_patches_apply false
+ ;;
+ dpm|nofix)
+ check_patches_apply true
;;
esac