#!/bin/sh global test_description := ''push from/to a shallow clone over http'' source ./test-lib.sh source "$TEST_DIRECTORY"/lib-httpd.sh start_httpd proc commit { echo $1 >tracked && git add tracked && git commit -m $1 } test_expect_success 'setup' ' git config --global transfer.fsckObjects true && commit 1 && commit 2 && commit 3 && commit 4 && git clone . full && ( git init full-abc && cd full-abc && commit a && commit b && commit c ) && git clone --no-local --depth=2 .git shallow && git --git-dir=shallow/.git log --format=%s >actual && cat <expect && 4 3 EOF test_cmp expect actual && git clone --no-local --depth=2 full-abc/.git shallow2 && git --git-dir=shallow2/.git log --format=%s >actual && cat <expect && c b EOF test_cmp expect actual ' test_expect_success 'push to shallow repo via http' ' git clone --bare --no-local shallow "$HTTPD_DOCUMENT_ROOT_PATH/repo.git" && ( cd "$HTTPD_DOCUMENT_ROOT_PATH/repo.git" && git config http.receivepack true ) && ( cd full && commit 9 && git push $HTTPD_URL/smart/repo.git +master:refs/remotes/top/master ) && ( cd "$HTTPD_DOCUMENT_ROOT_PATH/repo.git" && git fsck && git log --format=%s top/master >actual && cat <expect && 9 4 3 EOF test_cmp expect actual ) ' test_expect_success 'push from shallow repo via http' ' mv "$HTTPD_DOCUMENT_ROOT_PATH/repo.git" shallow-upstream.git && git clone --bare --no-local full "$HTTPD_DOCUMENT_ROOT_PATH/repo.git" && ( cd "$HTTPD_DOCUMENT_ROOT_PATH/repo.git" && git config http.receivepack true ) && commit 10 && git push $HTTPD_URL/smart/repo.git +master:refs/remotes/top/master && ( cd "$HTTPD_DOCUMENT_ROOT_PATH/repo.git" && git fsck && git log --format=%s top/master >actual && cat <expect && 10 4 3 2 1 EOF test_cmp expect actual ) ' stop_httpd test_done (CommandList children: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:test_description) op: Equal rhs: {(SQ <"push from/to a shallow clone over http">)} spids: [4] ) ] spids: [4] ) (C {(.)} {(./test-lib.sh)}) (C {(.)} {(DQ ($ VSub_Name "$TEST_DIRECTORY")) (/lib-httpd.sh)}) (C {(start_httpd)}) (FuncDef name: commit body: (BraceGroup children: [ (AndOr children: [ (SimpleCommand words: [{(echo)} {(DQ ($ VSub_Number "$1"))}] redirects: [(Redir op_id:Redir_Great fd:-1 arg_word:{(tracked)} spids:[37])] ) (AndOr children: [ (C {(git)} {(add)} {(tracked)}) (C {(git)} {(commit)} {(-m)} {(DQ ($ VSub_Number "$1"))}) ] op_id: Op_DAmp ) ] op_id: Op_DAmp ) ] spids: [28] ) spids: [24 27] ) (C {(test_expect_success)} {(SQ )} { (SQ <"\n"> <"\tgit config --global transfer.fsckObjects true &&\n"> <"\tcommit 1 &&\n"> <"\tcommit 2 &&\n"> <"\tcommit 3 &&\n"> <"\tcommit 4 &&\n"> <"\tgit clone . full &&\n"> <"\t(\n"> <"\tgit init full-abc &&\n"> <"\tcd full-abc &&\n"> <"\tcommit a &&\n"> <"\tcommit b &&\n"> <"\tcommit c\n"> <"\t) &&\n"> <"\tgit clone --no-local --depth=2 .git shallow &&\n"> <"\tgit --git-dir=shallow/.git log --format=%s >actual &&\n"> <"\tcat <expect &&\n"> <"4\n"> <"3\n"> <"EOF\n"> <"\ttest_cmp expect actual &&\n"> <"\tgit clone --no-local --depth=2 full-abc/.git shallow2 &&\n"> <"\tgit --git-dir=shallow2/.git log --format=%s >actual &&\n"> <"\tcat <expect &&\n"> <"c\n"> <"b\n"> <"EOF\n"> <"\ttest_cmp expect actual\n"> ) } ) (C {(test_expect_success)} {(SQ <"push to shallow repo via http">)} { (SQ <"\n"> <"\tgit clone --bare --no-local shallow \"$HTTPD_DOCUMENT_ROOT_PATH/repo.git\" &&\n"> <"\t(\n"> <"\tcd \"$HTTPD_DOCUMENT_ROOT_PATH/repo.git\" &&\n"> <"\tgit config http.receivepack true\n"> <"\t) &&\n"> <"\t(\n"> <"\tcd full &&\n"> <"\tcommit 9 &&\n"> <"\tgit push $HTTPD_URL/smart/repo.git +master:refs/remotes/top/master\n"> <"\t) &&\n"> <"\t(\n"> <"\tcd \"$HTTPD_DOCUMENT_ROOT_PATH/repo.git\" &&\n"> <"\tgit fsck &&\n"> <"\tgit log --format=%s top/master >actual &&\n"> <"\tcat <expect &&\n"> <"9\n"> <"4\n"> <"3\n"> <"EOF\n"> <"\ttest_cmp expect actual\n"> <"\t)\n"> ) } ) (C {(test_expect_success)} {(SQ <"push from shallow repo via http">)} { (SQ <"\n"> <"\tmv \"$HTTPD_DOCUMENT_ROOT_PATH/repo.git\" shallow-upstream.git &&\n"> <"\tgit clone --bare --no-local full \"$HTTPD_DOCUMENT_ROOT_PATH/repo.git\" &&\n"> <"\t(\n"> <"\tcd \"$HTTPD_DOCUMENT_ROOT_PATH/repo.git\" &&\n"> <"\tgit config http.receivepack true\n"> <"\t) &&\n"> <"\tcommit 10 &&\n"> <"\tgit push $HTTPD_URL/smart/repo.git +master:refs/remotes/top/master &&\n"> <"\t(\n"> <"\tcd \"$HTTPD_DOCUMENT_ROOT_PATH/repo.git\" &&\n"> <"\tgit fsck &&\n"> <"\tgit log --format=%s top/master >actual &&\n"> <"\tcat <expect &&\n"> <"10\n"> <"4\n"> <"3\n"> <"2\n"> <"1\n"> <"EOF\n"> <"\ttest_cmp expect actual\n"> <"\t)\n"> ) } ) (C {(stop_httpd)}) (C {(test_done)}) ] )