git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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
Previous: Santi Béjar
Message 6 of 6 in “Fetch: branch properties for fetch.”
  1. 0/4 Fetch: branch properties for fetch.Santi Béjar, Sep 23, 2006
  2. 1/4 fetch: default remote repository from branch propertiesSanti Béjar, Sep 23, 2006
  3. 2/4 Add t5510 to test per branch configuration affecting git-fetch.Santi Béjar, Sep 23, 2006
  4. 3/4 fetch: get the remote branches to merge from the branch propertiesSanti Béjar, Sep 23, 2006
  5. 4/4 Add test for the default merges in fetch.Santi Béjar, Sep 23, 2006
  6. Junio C HamanoSep 24, 2006

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.