#!/bin/sh global test_description := ''ext::cmd remote "connect" helper'' source ./test-lib.sh test_expect_success setup ' test_tick && git commit --allow-empty -m initial && test_tick && git commit --allow-empty -m second && test_tick && git commit --allow-empty -m third && test_tick && git tag -a -m "tip three" three && test_tick && git commit --allow-empty -m fourth ' test_expect_success clone ' cmd=$(echo "echo >&2 ext::sh invoked && %S .." | sed -e "s/ /% /g") && git clone "ext::sh -c %S% ." dst && git for-each-ref refs/heads/ refs/tags/ >expect && ( cd dst && git config remote.origin.url "ext::sh -c $cmd" && git for-each-ref refs/heads/ refs/tags/ ) >actual && test_cmp expect actual ' test_expect_success 'update following tag' ' test_tick && git commit --allow-empty -m fifth && test_tick && git tag -a -m "tip five" five && git for-each-ref refs/heads/ refs/tags/ >expect && ( cd dst && git pull && git for-each-ref refs/heads/ refs/tags/ >../actual ) && test_cmp expect actual ' test_expect_success 'update backfilled tag' ' test_tick && git commit --allow-empty -m sixth && test_tick && git tag -a -m "tip two" two three^1 && git for-each-ref refs/heads/ refs/tags/ >expect && ( cd dst && git pull && git for-each-ref refs/heads/ refs/tags/ >../actual ) && test_cmp expect actual ' test_expect_success 'update backfilled tag without primary transfer' ' test_tick && git tag -a -m "tip one " one two^1 && git for-each-ref refs/heads/ refs/tags/ >expect && ( cd dst && git pull && git for-each-ref refs/heads/ refs/tags/ >../actual ) && test_cmp expect actual ' test_expect_success 'set up fake git-daemon' ' mkdir remote && git init --bare remote/one.git && mkdir remote/host && git init --bare remote/host/two.git && write_script fake-daemon <<-\EOF && git daemon --inetd \ --informative-errors \ --export-all \ --base-path="$TRASH_DIRECTORY/remote" \ --interpolated-path="$TRASH_DIRECTORY/remote/%H%D" \ "$TRASH_DIRECTORY/remote" EOF export TRASH_DIRECTORY && PATH=$TRASH_DIRECTORY:$PATH ' test_expect_success 'ext command can connect to git daemon (no vhost)' ' rm -rf dst && git clone "ext::fake-daemon %G/one.git" dst ' test_expect_success 'ext command can connect to git daemon (vhost)' ' rm -rf dst && git clone "ext::fake-daemon %G/two.git %Vhost" dst ' test_done (CommandList children: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:test_description) op: Equal rhs: {(SQ <"ext::cmd remote \"connect\" helper">)} spids: [4] ) ] spids: [4] ) (C {(.)} {(./test-lib.sh)}) (C {(test_expect_success)} {(setup)} { (SQ <"\n"> <"\ttest_tick &&\n"> <"\tgit commit --allow-empty -m initial &&\n"> <"\ttest_tick &&\n"> <"\tgit commit --allow-empty -m second &&\n"> <"\ttest_tick &&\n"> <"\tgit commit --allow-empty -m third &&\n"> <"\ttest_tick &&\n"> <"\tgit tag -a -m \"tip three\" three &&\n"> <"\n"> <"\ttest_tick &&\n"> <"\tgit commit --allow-empty -m fourth\n"> ) } ) (C {(test_expect_success)} {(clone)} { (SQ <"\n"> <"\tcmd=$(echo \"echo >&2 ext::sh invoked && %S ..\" | sed -e \"s/ /% /g\") &&\n"> <"\tgit clone \"ext::sh -c %S% .\" dst &&\n"> <"\tgit for-each-ref refs/heads/ refs/tags/ >expect &&\n"> <"\t(\n"> <"\t\tcd dst &&\n"> <"\t\tgit config remote.origin.url \"ext::sh -c $cmd\" &&\n"> <"\t\tgit for-each-ref refs/heads/ refs/tags/\n"> <"\t) >actual &&\n"> <"\ttest_cmp expect actual\n"> ) } ) (C {(test_expect_success)} {(SQ <"update following tag">)} { (SQ <"\n"> <"\ttest_tick &&\n"> <"\tgit commit --allow-empty -m fifth &&\n"> <"\ttest_tick &&\n"> <"\tgit tag -a -m \"tip five\" five &&\n"> <"\tgit for-each-ref refs/heads/ refs/tags/ >expect &&\n"> <"\t(\n"> <"\t\tcd dst &&\n"> <"\t\tgit pull &&\n"> <"\t\tgit for-each-ref refs/heads/ refs/tags/ >../actual\n"> <"\t) &&\n"> <"\ttest_cmp expect actual\n"> ) } ) (C {(test_expect_success)} {(SQ <"update backfilled tag">)} { (SQ <"\n"> <"\ttest_tick &&\n"> <"\tgit commit --allow-empty -m sixth &&\n"> <"\ttest_tick &&\n"> <"\tgit tag -a -m \"tip two\" two three^1 &&\n"> <"\tgit for-each-ref refs/heads/ refs/tags/ >expect &&\n"> <"\t(\n"> <"\t\tcd dst &&\n"> <"\t\tgit pull &&\n"> <"\t\tgit for-each-ref refs/heads/ refs/tags/ >../actual\n"> <"\t) &&\n"> <"\ttest_cmp expect actual\n"> ) } ) (C {(test_expect_success)} {(SQ <"update backfilled tag without primary transfer">)} { (SQ <"\n"> <"\ttest_tick &&\n"> <"\tgit tag -a -m \"tip one \" one two^1 &&\n"> <"\tgit for-each-ref refs/heads/ refs/tags/ >expect &&\n"> <"\t(\n"> <"\t\tcd dst &&\n"> <"\t\tgit pull &&\n"> <"\t\tgit for-each-ref refs/heads/ refs/tags/ >../actual\n"> <"\t) &&\n"> <"\ttest_cmp expect actual\n"> ) } ) (C {(test_expect_success)} {(SQ <"set up fake git-daemon">)} { (SQ <"\n"> <"\tmkdir remote &&\n"> <"\tgit init --bare remote/one.git &&\n"> <"\tmkdir remote/host &&\n"> <"\tgit init --bare remote/host/two.git &&\n"> <"\twrite_script fake-daemon <<-\\EOF &&\n"> <"\tgit daemon --inetd \\\n"> <"\t\t--informative-errors \\\n"> <"\t\t--export-all \\\n"> <"\t\t--base-path=\"$TRASH_DIRECTORY/remote\" \\\n"> <"\t\t--interpolated-path=\"$TRASH_DIRECTORY/remote/%H%D\" \\\n"> <"\t\t\"$TRASH_DIRECTORY/remote\"\n"> <"\tEOF\n"> <"\texport TRASH_DIRECTORY &&\n"> <"\tPATH=$TRASH_DIRECTORY:$PATH\n"> ) } ) (C {(test_expect_success)} {(SQ <"ext command can connect to git daemon (no vhost)">)} {(SQ <"\n"> <"\trm -rf dst &&\n"> <"\tgit clone \"ext::fake-daemon %G/one.git\" dst\n">)} ) (C {(test_expect_success)} {(SQ <"ext command can connect to git daemon (vhost)">)} { (SQ <"\n"> <"\trm -rf dst &&\n"> <"\tgit clone \"ext::fake-daemon %G/two.git %Vhost\" dst\n">) } ) (C {(test_done)}) ] )