From 5fd28d490b2b5627f2bdb8e1318c70de4469eb13 Mon Sep 17 00:00:00 2001 From: DanConwayDev Date: Fri, 12 Sep 2025 09:01:01 +0100 Subject: fix(sync): dont fetch tags available locally as it was only checking if tip is a commit thats present but a tip could be an annotated tag --- src/bin/ngit/sub_commands/init.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'src/bin/ngit/sub_commands/init.rs') diff --git a/src/bin/ngit/sub_commands/init.rs b/src/bin/ngit/sub_commands/init.rs index 11a812b..385eeca 100644 --- a/src/bin/ngit/sub_commands/init.rs +++ b/src/bin/ngit/sub_commands/init.rs @@ -9,6 +9,7 @@ use std::{ use anyhow::{Context, Result, bail}; use console::{Style, Term}; +use git2::Oid; use ngit::{ UrlWithoutSlash, cli_interactor::{ @@ -794,7 +795,13 @@ pub async fn launch(cli_args: &Cli, args: &SubCommandArgs) -> Result<()> { let mut required_oids = vec![]; for tip in origin_state.values() { if let Ok(exist) = git_repo.does_commit_exist(tip) { - if !exist { + let oid_exists_as_tag = Oid::from_str(tip).is_ok_and(|tip| { + git_repo + .git_repo + .find_object(tip, Some(git2::ObjectType::Tag)) + .is_ok() + }); + if !exist && !oid_exists_as_tag { required_oids.push(tip.clone()); } } -- cgit v1.2.3