(CommandList children: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:test_description) op: Equal rhs: {(SQ <'push to a repository that borrows from elsewhere'>)} spids: [4] ) ] spids: [4] ) (C {(.)} {(./test-lib.sh)}) (C {(test_expect_success)} {(setup)} { (SQ <'\n'> <'\tmkdir alice-pub &&\n'> <'\t(\n'> <'\t\tcd alice-pub &&\n'> <'\t\tGIT_DIR=. git init\n'> <'\t) &&\n'> <'\tmkdir alice-work &&\n'> <'\t(\n'> <'\t\tcd alice-work &&\n'> <'\t\tgit init &&\n'> <'\t\t>file &&\n'> <'\t\tgit add . &&\n'> <'\t\tgit commit -m initial &&\n'> <'\t\tgit push ../alice-pub master\n'> <'\t) &&\n'> <'\n'> <'\t# Project Bob is a fork of project Alice\n'> <'\tmkdir bob-pub &&\n'> <'\t(\n'> <'\t\tcd bob-pub &&\n'> <'\t\tGIT_DIR=. git init &&\n'> <'\t\tmkdir -p objects/info &&\n'> <'\t\techo ../../alice-pub/objects >objects/info/alternates\n'> <'\t) &&\n'> <'\tgit clone alice-pub bob-work &&\n'> <'\t(\n'> <'\t\tcd bob-work &&\n'> <'\t\tgit push ../bob-pub master\n'> <'\t)\n'> ) } ) (C {(test_expect_success)} {(SQ <'alice works and pushes'>)} { (SQ <'\n'> <'\t(\n'> <'\t\tcd alice-work &&\n'> <'\t\techo more >file &&\n'> <'\t\tgit commit -a -m second &&\n'> <'\t\tgit push ../alice-pub :\n'> <'\t)\n'> ) } ) (C {(test_expect_success)} {(SQ <'bob fetches from alice, works and pushes'>)} { (SQ <'\n'> <'\t(\n'> <'\t\t# Bob acquires what Alice did in his work tree first.\n'> <'\t\t# Even though these objects are not directly in\n'> <'\t\t# the public repository of Bob, this push does not\n'> <'\t\t# need to send the commit Bob received from Alice\n'> <'\t\t# to his public repository, as all the object Alice\n'> <'\t\t# has at her public repository are available to it\n'> <'\t\t# via its alternates.\n'> <'\t\tcd bob-work &&\n'> <'\t\tgit pull ../alice-pub master &&\n'> <'\t\techo more bob >file &&\n'> <'\t\tgit commit -a -m third &&\n'> <'\t\tgit push ../bob-pub :\n'> <'\t) &&\n'> <'\n'> <'\t# Check that the second commit by Alice is not sent\n'> <'\t# to ../bob-pub\n'> <'\t(\n'> <'\t\tcd bob-pub &&\n'> <'\t\tsecond=$(git rev-parse HEAD^) &&\n'> <'\t\trm -f objects/info/alternates &&\n'> <'\t\ttest_must_fail git cat-file -t $second &&\n'> <'\t\techo ../../alice-pub/objects >objects/info/alternates\n'> <'\t)\n'> ) } ) (C {(test_expect_success)} {(SQ <'clean-up in case the previous failed'>)} { (SQ <'\n'> <'\t(\n'> <'\t\tcd bob-pub &&\n'> <'\t\techo ../../alice-pub/objects >objects/info/alternates\n'> <'\t)\n'> ) } ) (C {(test_expect_success)} {(SQ <'alice works and pushes again'>)} { (SQ <'\n'> <'\t(\n'> <'\t\t# Alice does not care what Bob does. She does not\n'> <'\t\t# even have to be aware of his existence. She just\n'> <'\t\t# keeps working and pushing\n'> <'\t\tcd alice-work &&\n'> <'\t\techo more alice >file &&\n'> <'\t\tgit commit -a -m fourth &&\n'> <'\t\tgit push ../alice-pub :\n'> <'\t)\n'> ) } ) (C {(test_expect_success)} {(SQ <'bob works and pushes'>)} { (SQ <'\n'> <'\t(\n'> <'\t\t# This time Bob does not pull from Alice, and\n'> <'\t\t# the master branch at her public repository points\n'> <'\t\t# at a commit Bob does not know about. This should\n'> <'\t\t# not prevent the push by Bob from succeeding.\n'> <'\t\tcd bob-work &&\n'> <'\t\techo yet more bob >file &&\n'> <'\t\tgit commit -a -m fifth &&\n'> <'\t\tgit push ../bob-pub :\n'> <'\t)\n'> ) } ) (C {(test_expect_success)} {(SQ <'alice works and pushes yet again'>)} { (SQ <'\n'> <'\t(\n'> <'\t\t# Alice does not care what Bob does. She does not\n'> <'\t\t# even have to be aware of his existence. She just\n'> <'\t\t# keeps working and pushing\n'> <'\t\tcd alice-work &&\n'> <'\t\techo more and more alice >file &&\n'> <'\t\tgit commit -a -m sixth.1 &&\n'> <'\t\techo more and more alice >>file &&\n'> <'\t\tgit commit -a -m sixth.2 &&\n'> <'\t\techo more and more alice >>file &&\n'> <'\t\tgit commit -a -m sixth.3 &&\n'> <'\t\tgit push ../alice-pub :\n'> <'\t)\n'> ) } ) (C {(test_expect_success)} {(SQ <'bob works and pushes again'>)} { (SQ <'\n'> <'\t(\n'> <'\t\tcd alice-pub &&\n'> <'\t\tgit cat-file commit master >../bob-work/commit\n'> <'\t) &&\n'> <'\t(\n'> <'\t\t# This time Bob does not pull from Alice, and\n'> <'\t\t# the master branch at her public repository points\n'> <'\t\t# at a commit Bob does not fully know about, but\n'> <'\t\t# he happens to have the commit object (but not the\n'> <'\t\t# necessary tree) in his repository from Alice.\n'> <'\t\t# This should not prevent the push by Bob from\n'> <'\t\t# succeeding.\n'> <'\t\tcd bob-work &&\n'> <'\t\tgit hash-object -t commit -w commit &&\n'> <'\t\techo even more bob >file &&\n'> <'\t\tgit commit -a -m seventh &&\n'> <'\t\tgit push ../bob-pub :\n'> <'\t)\n'> ) } ) (C {(test_done)}) ] )