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

Re: git fetch over ssh trouble

From
Junio C Hamano <junkio@cox.net>
Date
Jan 26, 2007, 06:10 UTC
Message-ID
<7vejpi2u91.fsf@assigned-by-dhcp.cox.net>
In-Reply-To
<20070126053400.GB18058@fieldses.org>
"J. Bruce Fields" <bfields@fieldses.org> writes:
Show 16 quoted lines
>> I wonder what should happen when you do not have anything
>> defined for "linus-nfs" shorthand.
>
> Oops; I didn't notice that!
>
>> Should it fetch HEAD?
>
> In my case I'd want it to either default to what I actually wanted
> (+refs/heads/*:refs/remotes/linux-nfs/*), or just fail with something
> helpful:
>
> 	"Nothing to fetch"?
> 	"No refspec given, and no default fetch configured for linux-nfs"?
> 	"What do you want me to fetch?"?
>
> I don't know.

Saying "let's grab everything" is certainly tempting, but I think it is a bit too much. How about doing this instead, then?

-- >8 -- [PATCH] parse-remote: do not barf on a remote shorthand without any refs to fetch.

Signed-off-by: Junio C Hamano <junkio@cox.net>
diff --git a/git-parse-remote.sh b/git-parse-remote.sh
index 1122c83..7e87f2e 100755
--- a/git-parse-remote.sh
+++ b/git-parse-remote.sh
@@ -81,7 +81,14 @@ get_remote_default_refs_for_push () {
 # is to help prevent randomly "globbed" ref from being chosen as
 # a merge candidate
 expand_refs_wildcard () {
+	remote="$1"
+	shift
 	first_one=yes
+	if test "$#" = 0
+	then
+		echo empty
+		echo >&2 "Nothing specified for fetching with remote.$remote.fetch"
+	fi
 	for ref
 	do
 		lref=${ref#'+'}
@@ -132,7 +139,7 @@ canon_refs_list_for_fetch () {
 	if test "$1" = "-d"
 	then
 		shift ; remote="$1" ; shift
-		set $(expand_refs_wildcard "$@")
+		set $(expand_refs_wildcard "$remote" "$@")
 		is_explicit="$1"
 		shift
 		if test "$remote" = "$(get_default_remote)"
Previous: J. Bruce FieldsNext: J. Bruce Fields
Message 4 of 5 in “git fetch over ssh trouble”
  1. J. Bruce FieldsJan 26, 2007
  2. Junio C HamanoJan 26, 2007
  3. J. Bruce FieldsJan 26, 2007
  4. Junio C HamanoJan 26, 2007
  5. J. Bruce FieldsJan 26, 2007

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.