Protect ourselves against naked refs
Signed-off-by: Alexis Sellier <alexis@radicle.xyz>
This commit is contained in:
parent
1906124497
commit
8b834a7b6e
|
|
@ -604,13 +604,15 @@ impl WriteRepository for Repository {
|
||||||
|
|
||||||
callbacks.update_tips(|name, old, new| {
|
callbacks.update_tips(|name, old, new| {
|
||||||
if let Ok(name) = git::RefString::try_from(name) {
|
if let Ok(name) = git::RefString::try_from(name) {
|
||||||
updates.push(RefUpdate::from(name, old, new));
|
if name.to_namespaced().is_some() {
|
||||||
} else {
|
updates.push(RefUpdate::from(name, old, new));
|
||||||
log::warn!("Invalid ref `{}` detected; aborting fetch", name);
|
// Returning `true` ensures the process is not aborted.
|
||||||
return false;
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// Returning `true` ensures the process is not aborted.
|
log::warn!("Invalid ref `{}` detected; aborting fetch", name);
|
||||||
true
|
|
||||||
|
false
|
||||||
});
|
});
|
||||||
|
|
||||||
{
|
{
|
||||||
|
|
@ -813,6 +815,15 @@ mod tests {
|
||||||
|
|
||||||
assert_eq!(alice_oid.target(), bob_oid.target());
|
assert_eq!(alice_oid.target(), bob_oid.target());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Canonical HEAD is set correctly.
|
||||||
|
let alice_repo = alice.repository(proj).unwrap();
|
||||||
|
let bob_repo = bob.repository(proj).unwrap();
|
||||||
|
|
||||||
|
assert_eq!(
|
||||||
|
bob_repo.backend.head().unwrap().target().unwrap(),
|
||||||
|
alice_repo.backend.head().unwrap().target().unwrap()
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue