Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion gix-refspec/src/parse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,10 @@ pub(crate) mod function {
}
};

let (mut src, dst) = match spec.find_byte(b':') {
// Split on the last colon like `strrchr()` in Git's `parse_refspec()` does, so that a
// push source may itself contain one - `:/message` and `<rev>:<path>` are both valid
// revisions. With a single colon this is the same position as the first one.
let (mut src, dst) = match spec.rfind_byte(b':') {
Some(pos) => {
if mode == Mode::Negative {
return Err(Error::NegativeWithDestination);
Expand Down
Binary file not shown.
Binary file not shown.
11 changes: 11 additions & 0 deletions gix-refspec/tests/fixtures/parse_baseline.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,11 @@ baseline push '^'

baseline fetch '^refs/heads/qa/*/*'
baseline push '^refs/heads/qa/*/*'

# a fetch source is a ref name, so it can't hold the colon that a push source may
baseline fetch 'a:b:c'
baseline fetch ':/message:refs/heads/x'

baseline push 'main~1'
baseline fetch 'main~1'
baseline push 'main~1:other~1'
Expand Down Expand Up @@ -92,6 +97,12 @@ baseline fetch 'refs/heads/main:refs/remotes/frotz/xyzzy'
baseline push 'main~1:refs/remotes/frotz/backup'
baseline push 'HEAD~4:refs/remotes/frotz/new'

# Git splits on the last colon, so a push source may contain one itself
baseline push 'a:b:c'
baseline push 'a:b:c:d'
baseline push ':/message:refs/heads/x'
baseline push 'HEAD:path:refs/heads/x'

baseline push 'HEAD'
baseline fetch 'HEAD'
baseline push '@'
Expand Down
Loading