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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxxx>
---
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
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux