#!/bin/sh global test_description := ''pull options'' source ./test-lib.sh test_expect_success 'setup' ' mkdir parent && (cd parent && git init && echo one >file && git add file && git commit -m one) ' test_expect_success 'git pull -q' ' mkdir clonedq && (cd clonedq && git init && git pull -q "../parent" >out 2>err && test_must_be_empty err && test_must_be_empty out) ' test_expect_success 'git pull -q --rebase' ' mkdir clonedqrb && (cd clonedqrb && git init && git pull -q --rebase "../parent" >out 2>err && test_must_be_empty err && test_must_be_empty out && git pull -q --rebase "../parent" >out 2>err && test_must_be_empty err && test_must_be_empty out) ' test_expect_success 'git pull' ' mkdir cloned && (cd cloned && git init && git pull "../parent" >out 2>err && test -s err && test_must_be_empty out) ' test_expect_success 'git pull --rebase' ' mkdir clonedrb && (cd clonedrb && git init && git pull --rebase "../parent" >out 2>err && test -s err && test_must_be_empty out) ' test_expect_success 'git pull -v' ' mkdir clonedv && (cd clonedv && git init && git pull -v "../parent" >out 2>err && test -s err && test_must_be_empty out) ' test_expect_success 'git pull -v --rebase' ' mkdir clonedvrb && (cd clonedvrb && git init && git pull -v --rebase "../parent" >out 2>err && test -s err && test_must_be_empty out) ' test_expect_success 'git pull -v -q' ' mkdir clonedvq && (cd clonedvq && git init && git pull -v -q "../parent" >out 2>err && test_must_be_empty out && test_must_be_empty err) ' test_expect_success 'git pull -q -v' ' mkdir clonedqv && (cd clonedqv && git init && git pull -q -v "../parent" >out 2>err && test_must_be_empty out && test -s err) ' test_expect_success 'git pull --force' ' mkdir clonedoldstyle && (cd clonedoldstyle && git init && cat >>.git/config <<-\EOF && [remote "one"] url = ../parent fetch = refs/heads/master:refs/heads/mirror [remote "two"] url = ../parent fetch = refs/heads/master:refs/heads/origin [branch "master"] remote = two merge = refs/heads/master EOF git pull two && test_commit A && git branch -f origin && git pull --all --force ) ' test_expect_success 'git pull --all' ' mkdir clonedmulti && (cd clonedmulti && git init && cat >>.git/config <<-\EOF && [remote "one"] url = ../parent fetch = refs/heads/*:refs/remotes/one/* [remote "two"] url = ../parent fetch = refs/heads/*:refs/remotes/two/* [branch "master"] remote = one merge = refs/heads/master EOF git pull --all ) ' test_expect_success 'git pull --dry-run' ' test_when_finished "rm -rf clonedry" && git init clonedry && ( cd clonedry && git pull --dry-run ../parent && test_path_is_missing .git/FETCH_HEAD && test_path_is_missing .git/refs/heads/master && test_path_is_missing .git/index && test_path_is_missing file ) ' test_expect_success 'git pull --all --dry-run' ' test_when_finished "rm -rf cloneddry" && git init clonedry && ( cd clonedry && git remote add origin ../parent && git pull --all --dry-run && test_path_is_missing .git/FETCH_HEAD && test_path_is_missing .git/refs/remotes/origin/master && test_path_is_missing .git/index && test_path_is_missing file ) ' test_expect_success 'git pull --allow-unrelated-histories' ' test_when_finished "rm -fr src dst" && git init src && ( cd src && test_commit one && test_commit two ) && git clone src dst && ( cd src && git checkout --orphan side HEAD^ && test_commit three ) && ( cd dst && test_must_fail git pull ../src side && git pull --allow-unrelated-histories ../src side ) ' test_done (CommandList children: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:test_description) op: Equal rhs: {(SQ <"pull options">)} spids: [4] ) ] spids: [4] ) (C {(.)} {(./test-lib.sh)}) (C {(test_expect_success)} {(SQ )} { (SQ <"\n"> <"\tmkdir parent &&\n"> <"\t(cd parent && git init &&\n"> <"\t echo one >file && git add file &&\n"> <"\t git commit -m one)\n"> ) } ) (C {(test_expect_success)} {(SQ <"git pull -q">)} { (SQ <"\n"> <"\tmkdir clonedq &&\n"> <"\t(cd clonedq && git init &&\n"> <"\tgit pull -q \"../parent\" >out 2>err &&\n"> <"\ttest_must_be_empty err &&\n"> <"\ttest_must_be_empty out)\n"> ) } ) (C {(test_expect_success)} {(SQ <"git pull -q --rebase">)} { (SQ <"\n"> <"\tmkdir clonedqrb &&\n"> <"\t(cd clonedqrb && git init &&\n"> <"\tgit pull -q --rebase \"../parent\" >out 2>err &&\n"> <"\ttest_must_be_empty err &&\n"> <"\ttest_must_be_empty out &&\n"> <"\tgit pull -q --rebase \"../parent\" >out 2>err &&\n"> <"\ttest_must_be_empty err &&\n"> <"\ttest_must_be_empty out)\n"> ) } ) (C {(test_expect_success)} {(SQ <"git pull">)} { (SQ <"\n"> <"\tmkdir cloned &&\n"> <"\t(cd cloned && git init &&\n"> <"\tgit pull \"../parent\" >out 2>err &&\n"> <"\ttest -s err &&\n"> <"\ttest_must_be_empty out)\n"> ) } ) (C {(test_expect_success)} {(SQ <"git pull --rebase">)} { (SQ <"\n"> <"\tmkdir clonedrb &&\n"> <"\t(cd clonedrb && git init &&\n"> <"\tgit pull --rebase \"../parent\" >out 2>err &&\n"> <"\ttest -s err &&\n"> <"\ttest_must_be_empty out)\n"> ) } ) (C {(test_expect_success)} {(SQ <"git pull -v">)} { (SQ <"\n"> <"\tmkdir clonedv &&\n"> <"\t(cd clonedv && git init &&\n"> <"\tgit pull -v \"../parent\" >out 2>err &&\n"> <"\ttest -s err &&\n"> <"\ttest_must_be_empty out)\n"> ) } ) (C {(test_expect_success)} {(SQ <"git pull -v --rebase">)} { (SQ <"\n"> <"\tmkdir clonedvrb &&\n"> <"\t(cd clonedvrb && git init &&\n"> <"\tgit pull -v --rebase \"../parent\" >out 2>err &&\n"> <"\ttest -s err &&\n"> <"\ttest_must_be_empty out)\n"> ) } ) (C {(test_expect_success)} {(SQ <"git pull -v -q">)} { (SQ <"\n"> <"\tmkdir clonedvq &&\n"> <"\t(cd clonedvq && git init &&\n"> <"\tgit pull -v -q \"../parent\" >out 2>err &&\n"> <"\ttest_must_be_empty out &&\n"> <"\ttest_must_be_empty err)\n"> ) } ) (C {(test_expect_success)} {(SQ <"git pull -q -v">)} { (SQ <"\n"> <"\tmkdir clonedqv &&\n"> <"\t(cd clonedqv && git init &&\n"> <"\tgit pull -q -v \"../parent\" >out 2>err &&\n"> <"\ttest_must_be_empty out &&\n"> <"\ttest -s err)\n"> ) } ) (C {(test_expect_success)} {(SQ <"git pull --force">)} { (SQ <"\n"> <"\tmkdir clonedoldstyle &&\n"> <"\t(cd clonedoldstyle && git init &&\n"> <"\tcat >>.git/config <<-\\EOF &&\n"> <"\t[remote \"one\"]\n"> <"\t\turl = ../parent\n"> <"\t\tfetch = refs/heads/master:refs/heads/mirror\n"> <"\t[remote \"two\"]\n"> <"\t\turl = ../parent\n"> <"\t\tfetch = refs/heads/master:refs/heads/origin\n"> <"\t[branch \"master\"]\n"> <"\t\tremote = two\n"> <"\t\tmerge = refs/heads/master\n"> <"\tEOF\n"> <"\tgit pull two &&\n"> <"\ttest_commit A &&\n"> <"\tgit branch -f origin &&\n"> <"\tgit pull --all --force\n"> <"\t)\n"> ) } ) (C {(test_expect_success)} {(SQ <"git pull --all">)} { (SQ <"\n"> <"\tmkdir clonedmulti &&\n"> <"\t(cd clonedmulti && git init &&\n"> <"\tcat >>.git/config <<-\\EOF &&\n"> <"\t[remote \"one\"]\n"> <"\t\turl = ../parent\n"> <"\t\tfetch = refs/heads/*:refs/remotes/one/*\n"> <"\t[remote \"two\"]\n"> <"\t\turl = ../parent\n"> <"\t\tfetch = refs/heads/*:refs/remotes/two/*\n"> <"\t[branch \"master\"]\n"> <"\t\tremote = one\n"> <"\t\tmerge = refs/heads/master\n"> <"\tEOF\n"> <"\tgit pull --all\n"> <"\t)\n"> ) } ) (C {(test_expect_success)} {(SQ <"git pull --dry-run">)} { (SQ <"\n"> <"\ttest_when_finished \"rm -rf clonedry\" &&\n"> <"\tgit init clonedry &&\n"> <"\t(\n"> <"\t\tcd clonedry &&\n"> <"\t\tgit pull --dry-run ../parent &&\n"> <"\t\ttest_path_is_missing .git/FETCH_HEAD &&\n"> <"\t\ttest_path_is_missing .git/refs/heads/master &&\n"> <"\t\ttest_path_is_missing .git/index &&\n"> <"\t\ttest_path_is_missing file\n"> <"\t)\n"> ) } ) (C {(test_expect_success)} {(SQ <"git pull --all --dry-run">)} { (SQ <"\n"> <"\ttest_when_finished \"rm -rf cloneddry\" &&\n"> <"\tgit init clonedry &&\n"> <"\t(\n"> <"\t\tcd clonedry &&\n"> <"\t\tgit remote add origin ../parent &&\n"> <"\t\tgit pull --all --dry-run &&\n"> <"\t\ttest_path_is_missing .git/FETCH_HEAD &&\n"> <"\t\ttest_path_is_missing .git/refs/remotes/origin/master &&\n"> <"\t\ttest_path_is_missing .git/index &&\n"> <"\t\ttest_path_is_missing file\n"> <"\t)\n"> ) } ) (C {(test_expect_success)} {(SQ <"git pull --allow-unrelated-histories">)} { (SQ <"\n"> <"\ttest_when_finished \"rm -fr src dst\" &&\n"> <"\tgit init src &&\n"> <"\t(\n"> <"\t\tcd src &&\n"> <"\t\ttest_commit one &&\n"> <"\t\ttest_commit two\n"> <"\t) &&\n"> <"\tgit clone src dst &&\n"> <"\t(\n"> <"\t\tcd src &&\n"> <"\t\tgit checkout --orphan side HEAD^ &&\n"> <"\t\ttest_commit three\n"> <"\t) &&\n"> <"\t(\n"> <"\t\tcd dst &&\n"> <"\t\ttest_must_fail git pull ../src side &&\n"> <"\t\tgit pull --allow-unrelated-histories ../src side\n"> <"\t)\n"> ) } ) (C {(test_done)}) ] )