Re: [PATCH 4/4 (take 4)] Add test for the default merges in fetch.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Santi Béjar <sbejar@xxxxxxxxx> writes:

> +	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.

> +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

-
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]