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

Re: Confusing git pull error message

From
Jeff King <peff@peff.net>
Date
Oct 5, 2009, 11:53 UTC
Message-ID
<20091005115308.GA2122@coredump.intra.peff.net>
In-Reply-To
<4AC9D952.3050108@viscovery.net>
On Mon, Oct 05, 2009 at 01:32:34PM +0200, Johannes Sixt wrote:
Show 15 quoted lines
> Unfortunately, this is not water-tight. See what I just observed:
> 
>   $ git pull hk
>   From /exports/repos/hk/viscovery
>      9455552..6429037  master     -> hk/master
>   Your configuration specifies to merge the ref
>   'master' from the remote, but no such ref
>   was fetched.
> 
> The message is confusing when it says "'master' was not fetched" when
> clearly master _was_ fetched.
> 
> More importantly, the message is wrong to say that "Your configuration
> specifies to merge the ref 'master' from the remote", because I have this
> configuration:

Ah, yeah. Looking at %(upstream) from for-each-ref (which is how we determine to show that message) always uses the configured remote. But if we have asked for another remote, then that doesn't make much sense.

So I think we need something like this. I wasn't able to figure out a test case to trigger the first code path below, though. It may not be possible; if we give a refspec on the command line, either it will be a candidate for merging or, if it does not exist, fetch will barf. So it may be that we can just collapse it down to a single case.

diff --git a/git-pull.sh b/git-pull.sh
index edf3ce3..a831db5 100755
--- a/git-pull.sh
+++ b/git-pull.sh
@@ -97,6 +97,18 @@ error_on_no_merge_candidates () {
 		echo "Please specify which branch you want to merge on the command"
 		echo "line and try again (e.g. 'git pull <repository> <refspec>')."
 		echo "See git-pull(1) for details."
+	elif [ -n "$1" ]; then
+		if [ $# -gt 1 ]; then
+			echo "You asked to pull from the remote '$1', but none"
+			echo "of the things you asked to fetch were candidates"
+			echo "for merging."
+		else
+			echo "You asked to pull from the remote '$1', but did"
+			echo "not specify a branch to merge. Because this is"
+			echo "not the default configured remote for your current"
+			echo "branch, you must specify a branch on the command"
+			echo "line."
+		fi
 	elif [ -z "$upstream" ]; then
 		echo "You asked me to pull without telling me which branch you"
 		echo "want to merge with, and 'branch.${curr_branch}.merge' in"
Previous: Johannes SixtNext: Johannes Sixt
Message 19 of 28 in “Confusing git pull error message”
  1. John TapsellSep 12, 2009
  2. Jeff KingSep 12, 2009
  3. John TapsellSep 12, 2009
  4. Jeff KingSep 12, 2009
  5. Sverre RabbelierSep 12, 2009
  6. Jeff KingSep 12, 2009
  7. Sverre RabbelierSep 12, 2009
  8. Junio C HamanoSep 13, 2009
  9. Jeff KingSep 13, 2009
  10. Junio C HamanoSep 13, 2009
  11. Jeff KingSep 13, 2009
  12. Junio C HamanoSep 13, 2009
  13. John TapsellSep 13, 2009
  14. Junio C HamanoSep 13, 2009
  15. Junio C HamanoSep 13, 2009
  16. Jeff KingSep 13, 2009
  17. Jeff KingSep 14, 2009
  18. Johannes SixtOct 5, 2009
  19. Jeff KingOct 5, 2009
  20. Johannes SixtOct 5, 2009
  21. Junio C HamanoOct 5, 2009
  22. Jeff KingOct 5, 2009
  23. Jeff KingOct 5, 2009
  24. Nanako ShiraishiOct 8, 2009
  25. Junio C HamanoOct 9, 2009
  26. Junio C HamanoOct 10, 2009
  27. Junio C HamanoOct 5, 2009
  28. Jeff KingOct 5, 2009

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.