From 499738de711ee96343163550f2e053bdba248c1a Mon Sep 17 00:00:00 2001 From: Fintan Halpenny Date: Thu, 5 Oct 2023 12:31:37 +0100 Subject: [PATCH] radicle: fix divergence check The `graph_descendant_of` method is strict in that it will return false if the two `Oid`s are equal -- they are strictly not descendants. If the `head` is the same as the `canonical_oid`, no error should be returned and the `push` can happen without any issues. Add a check for `head != canonical_oid` before the `graph_descendant_check`. Signed-off-by: Fintan Halpenny X-Clacks-Overhead: GNU Terry Pratchett --- radicle-remote-helper/src/push.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/radicle-remote-helper/src/push.rs b/radicle-remote-helper/src/push.rs index 0b002139..25ffab76 100644 --- a/radicle-remote-helper/src/push.rs +++ b/radicle-remote-helper/src/push.rs @@ -230,7 +230,9 @@ pub fn run( let head = working.find_reference(src.as_str())?; let head = head.peel_to_commit()?.id(); - if !working.graph_descendant_of(head, **canonical_oid)? { + if head != **canonical_oid + && !working.graph_descendant_of(head, **canonical_oid)? + { eprintln!( "hint: you are attempting to push a commit that would \ cause your upstream to diverge from the canonical head"