chiark / gitweb /
git-debpush: check_treesame: Show diffstat when there is a diff
[dgit.git] / git-debpush
index dee358b2c43370a8fcca42b76abe85749f457642..bd0357b5dc3a301979297023efc67dce5fb727e3 100755 (executable)
@@ -38,6 +38,8 @@ set -o pipefail
 # **** Helper functions and variables ****
 
 us="$(basename $0)"
+git_playtree_setup=git-playtree-setup ###substituted###
+git_playtree_setup=${DEBPUSH_GIT_PLAYTREE_SETUP-$git_playtree_setup}
 
 cleanup() {
     if [ -d "$temp" ]; then
@@ -79,6 +81,11 @@ fail_check () {
     fi
 }
 
+fail_check_upstream_nonidentical () {
+    fail_check upstream-nonidentical \
+ "the upstream source in tag $upstream_tag is not identical to the upstream source in $branch"
+}
+
 find_last_tag () {
     local prefix=$1
 
@@ -92,6 +99,28 @@ find_last_tag () {
     set -o pipefail
 }
 
+check_treesame () {
+    local first=$1
+    local second=$2
+    shift 2
+
+    set +e
+    git diff --quiet --exit-code "$first".."$second" -- . "$@"
+    git_diff_rc=$?
+    set -e
+
+    # show the user what the difference was
+    if [ $git_diff_rc = 1 ]; then
+        git diff --compact-summary "$first".."$second" -- . "$@"
+    fi
+
+    if [ $git_diff_rc -le 1 ]; then
+        return $git_diff_rc
+    else
+        fail "'git diff' exited with unexpected code $git_diff_rc"
+    fi
+}
+
 # **** Parse command line ****
 
 getopt=$(getopt -s bash -o 'nfu:' \
@@ -222,9 +251,9 @@ case "$format" in
     '3.0 (quilt)')  upstream=true ;;
     '3.0 (native)') upstream=false ;;
     '1.0'|'')
-       if get_file_from_ref debian/source/options | grep '^-sn *$'; then
+       if get_file_from_ref debian/source/options | grep -q '^-sn *$'; then
            upstream=false
-        elif get_file_from_ref debian/source/options | grep '^-sk *$'; then
+        elif get_file_from_ref debian/source/options | grep -q '^-sk *$'; then
            upstream=true
        else
            fail 'please see "SOURCE FORMAT 1.0" in git-debpush(1)'
@@ -313,6 +342,19 @@ if ! [ "x$upstream_tag" = "x" ] \
  "upstream tag $upstream_tag is not an ancestor of $branch; probably a mistake"
 fi
 
+# ---- Upstream tag tree nonidentical
+
+case "$quilt_mode" in
+    gbp)
+        check_treesame "$upstream_tag" "$branch" ':!debian' ':!**.gitignore' \
+            || fail_check_upstream_nonidentical
+        ;;
+    unapplied)
+        check_treesame "$upstream_tag" "$branch" ':!debian' \
+            || fail_check_upstream_nonidentical
+        ;;
+esac
+
 # ---- Summary
 
 if $failed_check; then
@@ -356,12 +398,13 @@ if [ "$format" = "3.0 (quilt)" ]; then
     fi
 fi
 
-git tag "${git_tag_opts[@]}" -s -F- "$debian_tag" "$branch" <<EOF
-$source release $version for $target
+tagmessage="$source release $version for $target
 
 [dgit distro=$distro split$quilt_mode_text]
 [dgit please-upload$upstream_info]
-EOF
+"
+
+git tag "${git_tag_opts[@]}" -s -m "$tagmessage" "$debian_tag" "$branch"
 
 # **** Do a git push ****