From: Ian Jackson Date: Sat, 2 Jul 2016 09:54:19 +0000 (+0100) Subject: Test suite: tartree-edit: Provide facility for comparing sets of git refs X-Git-Tag: archive/debian/2.0~352 X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=dgit.git;a=commitdiff_plain;h=f0bea048243bf307dae2eb11e058be96b61a62e4 Test suite: tartree-edit: Provide facility for comparing sets of git refs --- diff --git a/debian/changelog b/debian/changelog index baf668a6..d4ce8065 100644 --- a/debian/changelog +++ b/debian/changelog @@ -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. -- diff --git a/tests/tartree-edit b/tests/tartree-edit index 5a7c6b43..76e51b67 100755 --- a/tests/tartree-edit +++ b/tests/tartree-edit @@ -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