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

[PATCH 2/2] t/t5510-fetch.sh: improve testing with explicit URL and merge spec

From
Brandon Casey <casey@nrlssc.navy.mil>
Date
Sep 9, 2010, 18:56 UTC
Message-ID
<NYNWO-6R8khWRYvZHfeUgZWw3DJpqSnrL38KkBJYm9iti69nWEX9zBwCvwiTEGTR8e9aY62V_L8@cipher.nrlssc.navy.mil>
In-Reply-To
<7vtymipddv.fsf@alter.siamese.dyndns.org>
From: Brandon Casey <drafnel@gmail.com>

Commit 6106ce46 introduced a test to demonstrate fetch's failure to retrieve any objects or update FETCH_HEAD when it was supplied a repository URL and the current branch had a configured merge spec. This commit expands the original test based on comments from Junio Hamano. In addition to actually verifying that the fetch updates FETCH_HEAD correctly, and does not update the current branch, two more tests are added to ensure that the merge configuration is ignored even when the supplied URL matches the URL of the remote configured for the branch.

Signed-off-by: Brandon Casey <casey@nrlssc.navy.mil>
---
 t/t5510-fetch.sh |   30 ++++++++++++++++++++++++++++--
 1 files changed, 28 insertions(+), 2 deletions(-)
diff --git a/t/t5510-fetch.sh b/t/t5510-fetch.sh
index 8fbd894..efb42d1 100755
--- a/t/t5510-fetch.sh
+++ b/t/t5510-fetch.sh
@@ -240,10 +240,36 @@ test_expect_success 'fetch with a non-applying branch.<name>.merge' '
 	git fetch blub
 '
 
-test_expect_success 'fetch from GIT URL with a non-applying branch.<name>.merge' '
+# URL supplied to fetch does not match the url of the configured branch's remote
+test_expect_success 'fetch from GIT URL with a non-applying branch.<name>.merge [1]' '
+	one_head=$(cd one && git rev-parse HEAD) &&
+	this_head=$(git rev-parse HEAD) &&
 	git update-ref -d FETCH_HEAD &&
 	git fetch one &&
-	git rev-parse --verify FETCH_HEAD
+	test $one_head = "$(git rev-parse --verify FETCH_HEAD)" &&
+	test $this_head = "$(git rev-parse --verify HEAD)"
+'
+
+# URL supplied to fetch matches the url of the configured branch's remote and
+# the merge spec matches the branch the remote HEAD points to
+test_expect_success 'fetch from GIT URL with a non-applying branch.<name>.merge [2]' '
+	one_ref=$(cd one && git symbolic-ref HEAD) &&
+	git config branch.master.remote blub &&
+	git config branch.master.merge "$one_ref" &&
+	git update-ref -d FETCH_HEAD &&
+	git fetch one &&
+	test $one_head = "$(git rev-parse --verify FETCH_HEAD)" &&
+	test $this_head = "$(git rev-parse --verify HEAD)"
+'
+
+# URL supplied to fetch matches the url of the configured branch's remote, but
+# the merge spec does not match the branch the remote HEAD points to
+test_expect_success 'fetch from GIT URL with a non-applying branch.<name>.merge [3]' '
+	git config branch.master.merge "${one_ref}_not" &&
+	git update-ref -d FETCH_HEAD &&
+	git fetch one &&
+	test $one_head = "$(git rev-parse --verify FETCH_HEAD)" &&
+	test $this_head = "$(git rev-parse --verify HEAD)"
 '
 
 # the strange name is: a\!'b
-- 
1.7.2.1
Previous: Brandon Casey
Message 13 of 13 in “reducing object store size with remote alternates or shallow clone?”
  1. Kumar GalaAug 24, 2010
  2. Junio C HamanoAug 24, 2010
  3. Brandon CaseyAug 24, 2010
  4. Junio C HamanoAug 24, 2010
  5. Brandon CaseyAug 24, 2010
  6. 1/2 t/t5510: demonstrate failure to fetch when current branch has merge refBrandon Casey, Aug 25, 2010
  7. Junio C HamanoAug 25, 2010
  8. 2/2 builtin/fetch.c: ignore merge config when not fetching from branch's remoteBrandon Casey, Aug 25, 2010
  9. Jonathan NiederAug 25, 2010
  10. Brandon CaseyAug 25, 2010
  11. Junio C HamanoAug 25, 2010
  12. 1/2 builtin/fetch.c: comment that branch->remote_name is usable when has_mergeBrandon Casey, Sep 9, 2010
  13. 2/2 t/t5510-fetch.sh: improve testing with explicit URL and merge specBrandon Casey, Sep 9, 2010

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.