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

Re: [PATCH] fetch: don't try to update unfetched tracking refs

From
Jeff King <peff@peff.net>
Date
May 27, 2013, 16:19 UTC
Message-ID
<20130527161934.GB9235@sigill.intra.peff.net>
In-Reply-To
<20130527160129.GN27005@serenity.lan>
On Mon, May 27, 2013 at 05:01:29PM +0100, John Keeping wrote:
Show 12 quoted lines
> > I'm not sure I understand what the last sentence means. I tried to add a
> > test like:
> [...]
> > but it does not fail with the existing code. Can you give an example
> > that fails?
> 
> I have this in my .git/config for git.git:
> 
>     [remote "origin"]
>             url = git://github.com/gitster/git
>             fetch = +refs/heads/*:refs/remotes/origin/*
>             fetch = +refs/notes/amlog:refs/notes/amlog

Ah, I see. It is not "the refspec on the command-line does not match a configured refspec", but rather "there exists a configured non-pattern refspec that does not match what was on the command-line (even if what was on the command-line did match another refspec)".

So your fix makes perfect sense. Do you mind squashing in this test below? I think it is a little less subtle than what you posted, as it sets up the situation explicitly in the test. It also checks that the refs we _did_ match still get updated ("master" in this case).

diff --git a/t/t5510-fetch.sh b/t/t5510-fetch.sh
index ff43e08..fde6891 100755
--- a/t/t5510-fetch.sh
+++ b/t/t5510-fetch.sh
@@ -422,6 +422,22 @@ test_expect_success 'configured fetch updates tracking' '
 	)
 '
 
+test_expect_success 'non-matching refspecs do not confuse tracking update' '
+	cd "$D" &&
+	git update-ref refs/odd/location HEAD &&
+	(
+		cd three &&
+		git update-ref refs/remotes/origin/master base-origin-master &&
+		git config --add remote.origin.fetch \
+			refs/odd/location:refs/remotes/origin/odd &&
+		o=$(git rev-parse --verify refs/remotes/origin/master) &&
+		git fetch origin master &&
+		n=$(git rev-parse --verify refs/remotes/origin/master) &&
+		test "$o" != "$n" &&
+		test_must_fail git rev-parse --verify refs/remotes/origin/odd
+	)
+'
+
 test_expect_success 'pushing nonexistent branch by mistake should not segv' '
 
 	cd "$D" &&

Thanks for the fix.

Acked-by: Jeff King <peff@peff.net>

-Peff
Previous: John KeepingNext: John Keeping
Message 4 of 6 in “fetch: don't try to update unfetched tracking refs”
  1. fetch: don't try to update unfetched tracking refsJohn Keeping, May 27, 2013
  2. Jeff KingMay 27, 2013
  3. John KeepingMay 27, 2013
  4. Jeff KingMay 27, 2013
  5. fetch: don't try to update unfetched tracking refsJohn Keeping, May 27, 2013
  6. Jeff KingMay 27, 2013

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.