Unified · Split
| @@ -113,7 +113,7 @@ pub(crate) mod function { · 112 unmodified lines | ||
| 113 | 113 | *spec = "HEAD".into(); |
| 114 | 114 | } |
| 115 | 115 | } |
| 116 | − let (src, src_had_pattern) = validated(src, operation == Operation::Push)?; | |
| 116 | + let (src, src_had_pattern) = validated(src, operation == Operation::Push && dst.is_some())?; | |
| 117 | 117 | let (dst, dst_had_pattern) = validated(dst, false)?; |
| 118 | 118 | if !dst_had_pattern && looks_like_object_hash(dst.unwrap_or_default()) { |
| 119 | 119 | return Err(Error::InvalidFetchDestination); |
| @@ -1,3 +1,3 @@ | ||
| 1 | 1 | version https://git-lfs.github.com/spec/v1 |
| 2 | −oid sha256:3fe4f4ca2f442e58b594faaa0f512c6fdf1df8f052995928eca9bede909794e9 | |
| 3 | −size 9360 | |
| 2 | +oid sha256:9d52f5fe25601c545187b0ac19b004f30488937b6907e8206333d2ba923c7b29 | |
| 3 | +size 9372 | |
| @@ -40,6 +40,10 @@ baseline push '^' · 39 unmodified lines | ||
| 40 | 40 | |
| 41 | 41 | baseline fetch '^refs/heads/qa/*/*' |
| 42 | 42 | baseline push '^refs/heads/qa/*/*' |
| 43 | +baseline push 'main~1' | |
| 44 | +baseline fetch 'main~1' | |
| 45 | +baseline push 'main~1:other~1' | |
| 46 | +baseline push ':main~1' | |
| 43 | 47 | |
| 44 | 48 | baseline push 'refs/heads/*:refs/remotes/frotz' |
| 45 | 49 | baseline push 'refs/heads:refs/remotes/frotz/*' |
| @@ -11,6 +11,42 @@ fn negative_unsupported() { · 10 unmodified lines | ||
| 11 | 11 | } |
| 12 | 12 | } |
| 13 | 13 | |
| 14 | +#[test] | |
| 15 | +fn revspecs_with_ref_name_destination() { | |
| 16 | + assert_parse( | |
| 17 | + "main~1:b", | |
| 18 | + Instruction::Push(Push::Matching { | |
| 19 | + src: b("main~1"), | |
| 20 | + dst: b("b"), | |
| 21 | + allow_non_fast_forward: false, | |
| 22 | + }), | |
| 23 | + ); | |
| 24 | + assert_parse( | |
| 25 | + "+main~1:b", | |
| 26 | + Instruction::Push(Push::Matching { | |
| 27 | + src: b("main~1"), | |
| 28 | + dst: b("b"), | |
| 29 | + allow_non_fast_forward: true, | |
| 30 | + }), | |
| 31 | + ); | |
| 32 | +} | |
| 33 | + | |
| 34 | +#[test] | |
| 35 | +fn destinations_must_be_ref_names() { | |
| 36 | + assert!(matches!( | |
| 37 | + try_parse("a~1:b~1", Operation::Push).unwrap_err(), | |
| 38 | + Error::ReferenceName(_) | |
| 39 | + )); | |
| 40 | +} | |
| 41 | + | |
| 42 | +#[test] | |
| 43 | +fn single_refs_must_be_refnames() { | |
| 44 | + assert!(matches!( | |
| 45 | + try_parse("a~1", Operation::Push).unwrap_err(), | |
| 46 | + Error::ReferenceName(_) | |
| 47 | + )); | |
| 48 | +} | |
| 49 | + | |
| 14 | 50 | #[test] |
| 15 | 51 | fn ampersand_is_resolved_to_head() { |
| 16 | 52 | assert_parse( |