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

[PATCH] Permit refspec source side to parse as a sha1

From
Daniel Barkalow <barkalow@iabervon.org>
Date
Mar 21, 2008, 00:54 UTC
Message-ID
<alpine.LNX.1.00.0803202049090.19665@iabervon.org>

This fixes "git push origin HEAD~1:foo". "git fetch origin HEAD~1:foo" will report "Couldn't find remote ref HEAD~1", while "git fetch origin HEAD**1:foo" reports "Invalid refspec 'HEAD**1:foo'"

That is, HEAD~1 is something you're not allowed to ask the remote for, while HEAD**1 doesn't mean anything.

Signed-off-by: Daniel Barkalow <barkalow@iabervon.org>
---
Note that this actually tries to look up the source side, so "git 
fetch origin HEAD^3:foo" usually gives a wrongish error message. But this 
only applies to error cases which nobody is likely to attempt anyway, and 
they still come out as errors regardless.
 remote.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)
diff --git a/remote.c b/remote.c
index 9700a33..d737579 100644
--- a/remote.c
+++ b/remote.c
@@ -434,8 +434,10 @@ struct refspec *parse_ref_spec(int nr_refspec, const char **refspec)
 		rs[i].src = xstrndup(sp, ep - sp);
 
 		if (*rs[i].src) {
+			unsigned char sha1[20];
 			st = check_ref_format(rs[i].src);
-			if (st && st != CHECK_REF_FORMAT_ONELEVEL)
+			if (st && st != CHECK_REF_FORMAT_ONELEVEL &&
+			    get_sha1(rs[i].src, sha1))
 				die("Invalid refspec '%s'", refspec[i]);
 		}
 		if (rs[i].dst && *rs[i].dst) {
-- 
1.5.4.3.610.gea6cd
Next: Junio C Hamano
Message 1 of 20 in “Permit refspec source side to parse as a sha1”
  1. Permit refspec source side to parse as a sha1Daniel Barkalow, Mar 21, 2008
  2. Junio C HamanoMar 21, 2008
  3. Junio C HamanoMar 21, 2008
  4. Daniel BarkalowMar 21, 2008
  5. Junio C HamanoMar 21, 2008
  6. Daniel BarkalowMar 21, 2008
  7. Junio C HamanoMar 21, 2008
  8. Daniel BarkalowMar 21, 2008
  9. remote.c: Fix overtight refspec validationJunio C Hamano, Mar 21, 2008
  10. Daniel BarkalowMar 21, 2008
  11. Junio C HamanoMar 21, 2008
  12. Daniel BarkalowMar 22, 2008
  13. Junio C HamanoMar 22, 2008
  14. Daniel BarkalowMar 22, 2008
  15. Linus TorvaldsMar 26, 2008
  16. Junio C HamanoMar 26, 2008
  17. Junio C HamanoMar 26, 2008
  18. Daniel BarkalowMar 26, 2008
  19. Junio C HamanoMar 26, 2008
  20. Jeff KingMar 26, 2008

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.