chiark / gitweb /
Test suite: tartree-edit: Provide facility for comparing sets of git refs
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Sat, 2 Jul 2016 09:54:19 +0000 (10:54 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Sat, 2 Jul 2016 09:54:19 +0000 (10:54 +0100)
debian/changelog
tests/tartree-edit

index baf668a..d4ce806 100644 (file)
@@ -51,7 +51,7 @@ dgit (1.5~~) unstable; urgency=medium
     zealot is very slow and we need to give the other processes time
     to rollback and release the lock.
   * Test quilt single-debian-patch.
-  * Provide `tartree-edit gitfetchinfo' to help with comparing
+  * Provide `tartree-edit gitfetchinfo' etc. to help with comparing
     different test case git working tree tarballs.
 
  --
index 5a7c6b4..76e51b6 100755 (executable)
@@ -13,9 +13,57 @@ git_manip_play () {
        mkdir $play
 }
 
+gitfetchdiff_list () {
+       git for-each-ref --format '%(refname) %(objectname)' \
+               refs/remotes/"$1" \
+       | sed 's/^refs\/remotes\/[^\/]*\///' \
+       | sort >"$play/$2"
+}
+
+gitfetchdiff () {
+       local how="$1"
+       local a="$2"
+       local b="$3"
+       git_manip_play
+
+       rrab=refs/remotes/"$a+$b"
+
+       ulf=\
+"delete refs/remotes/$a/%l
+delete refs/remotes/$b/%l
+"
+       case "$how" in
+       diff)
+               git for-each-ref --format 'delete %(refname)' $rrab \
+                       | git update-ref --stdin
+               ;;
+       merge)
+               ulf=\
+"create $rrab/%l
+$ulf"
+               ;;
+       *)
+               fail "internal error bad how ($how)"
+               ;;
+       esac
+
+       gitfetchdiff_list "$a" a
+       gitfetchdiff_list "$b" b
+
+       diff --old-line-format='' --new-line-format='' \
+               --unchanged-line-format="$ulf" \
+               $play/a $play/b >$play/updates \
+       || test $? = 1
+
+       git update-ref --stdin <$play/updates
+       exit 0
+}
+
 case "$#.$1" in
 2.edit|2.done) mode="$1"; arg="$2" ;;
 3.gitfetchinfo)        mode="$1"; arg="$2"; remote="$3" ;;
+3.gitfetchinfo-diff)   gitfetchdiff diff "$2" "$3"     ;;
+3.gitfetchinfo-merge)  gitfetchdiff merge "$2" "$3"    ;;
 ?.-*)  fail "no options understood"                    ;;
 *)     fail "usage:
     tartree-edit edit|done DIRECTORY|TARBALL