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

Re: Errors when updating an old git.git repository

From
Junio C Hamano <junkio@cox.net>
Date
Dec 27, 2006, 00:22 UTC
Message-ID
<7v1wmmchmc.fsf@assigned-by-dhcp.cox.net>
In-Reply-To
<Pine.LNX.4.63.0612262350070.19693@wbgn013.biozentrum.uni-wuerzburg.de>
Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:
Show 12 quoted lines
> Git works quite as expected here, so there is nothing to fix.
>
>> error: no such remote ref refs/heads/jc/bind
>> error: no such remote ref refs/heads/jc/bind-2
>> error: no such remote ref refs/heads/gb/diffdelta
>
> Since you said it is an older git repository, I guess that in your 
> .git/remotes/origin are some lines like this:
>
> 	Pull: refs/heads/jc/bind:refs/heads/jc/bind
>
> So, you _asked_ git to fetch these three branches!

I think it only half explains the problem. Maybe my memory is failing, but I do not recall pushing out any of these topic branches, perhaps except jc/bind long time ago.

How did Hannu end up with these branches, both under his $GIT_DIR/refs/heads/ and in $GIT_DIR/remotes/origin or remote.origin.fetch in $GIT_DIR/config?

I see identical failure report from ancient time
	http://article.gmane.org/gmane.comp.version-control.git/21629
Maybe I did push them out earlier.

How about doing something like this? In explain_fetch_failure I think we could look at $ls_remote_result and automagically fix remotes/$remote_nick or remote.$remote_nick.fetch, but I am lazy ;-)

-- >8 --
diff --git a/git-fetch.sh b/git-fetch.sh
index ffbd44f..361dfa3 100755
--- a/git-fetch.sh
+++ b/git-fetch.sh
@@ -81,6 +81,7 @@ case "$#" in
 esac
 
 remote_nick="$1"
+datasrc=$(get_data_source "$1")
 remote=$(get_remote_url "$@")
 refs=
 rref=
@@ -272,6 +273,21 @@ then
 	fi
 fi
 
+explain_fetch_failure () {
+	where=
+	case "$datasrc" in
+	'') ;;
+	config) where="remotes.$remote_nick.fetch configuration" ;;
+	branch) where=".git/branches/$remote_nick file" ;;
+	remotes) where=".git/remotes/$remote_nick file" ;;
+	esac
+	if test "z$where" != z
+	then		  	
+		echo >&2 "You may have stale remote branches in $where"
+		echo >&2 "Remove them if they do not exist anymore."
+	fi
+}
+
 fetch_main () {
   reflist="$1"
   refs=
@@ -325,8 +341,10 @@ fetch_main () {
 			break
 		done
 	  )
-	  expr "z$head" : "z$_x40\$" >/dev/null ||
+	  expr "z$head" : "z$_x40\$" >/dev/null || {
+	  	explain_fetch_failure
 		die "No such ref $remote_name at $remote"
+	  }
 	  echo >&2 "Fetching $remote_name from $remote using $proto"
 	  git-http-fetch -v -a "$head" "$remote/" || exit
 	  ;;
@@ -385,6 +403,7 @@ fetch_main () {
 	  case "$sha1" in
 	  failed)
 		  echo >&2 "Fetch failure: $remote"
+		  explain_fetch_failure
 		  exit 1 ;;
 	  # special line coming from index-pack with the pack name
 	  pack)
Previous: Johannes SchindelinNext: Hannu Koivisto
Message 5 of 7 in “Errors when updating an old git.git repository”
  1. Hannu KoivistoDec 26, 2006
  2. Lars HjemliDec 26, 2006
  3. Hannu KoivistoDec 26, 2006
  4. Johannes SchindelinDec 26, 2006
  5. Junio C HamanoDec 27, 2006
  6. Hannu KoivistoDec 27, 2006
  7. Junio C HamanoDec 27, 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.