Re: [PATCH 4/4 (take 4)] Add test for the default merges in fetch.
- From
Junio C Hamano <junkio@cox.net>
- Date
- Sep 24, 2006, 01:49 UTC
- Message-ID
- <7vbqp6m3t6.fsf@assigned-by-dhcp.cox.net>
- In-Reply-To
- <87sliie20o.fsf@gmail.com>
Santi Béjar <sbejar@gmail.com> writes:
Show 11 quoted lines
> + cd .. &&
> + git clone . three &&
> + cd three &&
> + git repo-config branch.master.remote two
> + git repo-config branch.master.merge refs/heads/one
> + {
> + echo "URL: ../two/.git/"
> + echo "Pull: refs/heads/master:refs/heads/two"
> + echo "Pull: refs/heads/one:refs/heads/one"
> + } >.git/remotes/two
> 'Please string them with && unless there is a compelling reason not to.
That would catch a potential error exit from repo-config, although it is not a focus of this test. We have caught breakage of parts of the system by tests meant for unrelated parts of the system number of times.
Show 12 quoted lines
> +test_expect_success "fetch test for-merge" '
> + cd "$D" &&
> + cd three &&
> + git fetch &&
> + test -f .git/refs/heads/two &&
> + test -f .git/refs/heads/one &&
> + {
> + echo -e "not-for-merge branch \047master\047 of ../two/"
> + echo -e " branch \047one\047 of ../two/"
> + } > expected &&
> + cut -f 2- .git/FETCH_HEAD > actual &&
> + diff expected actual'Testing for the explicit implementation detail (namely, the human readable part of the merge log message per branch) makes me feel uneasy. Also I've stayed away from "echo -e" for some inexplicable fear of portability issues and I do not see a reason to use it here. Time to learn to use '\'' perhaps?
I would have:
- arranged branch tips of all the repos that are potentially involved to have different object names;
- checked for the commit object names at the beginning of the resulting FETCH_HEAD and not-for-merge markers;
- ignored the "branch 'foo' of repo" log message pieces;.
In other words, this on top of yours, which I am going to commit.
diff --git a/t/t5510-fetch.sh b/t/t5510-fetch.sh index 2d8da59..df0ae48 100755 --- a/t/t5510-fetch.sh +++ b/t/t5510-fetch.sh @@ -30,8 +30,8 @@ test_expect_success "clone and setup chi cd .. && git clone . three && cd three && - git repo-config branch.master.remote two - git repo-config branch.master.merge refs/heads/one + git repo-config branch.master.remote two && + git repo-config branch.master.merge refs/heads/one && { echo "URL: ../two/.git/" echo "Pull: refs/heads/master:refs/heads/two" @@ -57,11 +57,13 @@ test_expect_success "fetch test for-merg git fetch && test -f .git/refs/heads/two && test -f .git/refs/heads/one && + master_in_two=`cd ../two && git rev-parse master` && + one_in_two=`cd ../two && git rev-parse one` && { - echo -e "not-for-merge branch \047master\047 of ../two/" - echo -e " branch \047one\047 of ../two/" - } > expected && - cut -f 2- .git/FETCH_HEAD > actual && + echo "$master_in_two not-for-merge" + echo "$one_in_two " + } >expected && + cut -f -2 .git/FETCH_HEAD >actual && diff expected actual' test_done