From 95836cdbe8ed7c46bf28eb030e7723d1ab905553 Mon Sep 17 00:00:00 2001 From: Michael Zhao <44533763+Pistonight@users.noreply.github.com> Date: Sun, 3 Dec 2023 14:08:28 -0800 Subject: [PATCH] Fix error when git add fails because .gitmodules doesn't exist (#8) --- Cargo.lock | 2 +- Cargo.toml | 2 +- src/submodule.rs | 6 ++++-- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 960b754..0bc2768 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -157,7 +157,7 @@ checksum = "969488b55f8ac402214f3f5fd243ebb7206cf82de60d3172994707a4bcc2b829" [[package]] name = "magoo" -version = "0.1.3" +version = "0.1.4" dependencies = [ "clap", "fs4", diff --git a/Cargo.toml b/Cargo.toml index b39c6d8..19d7a3b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "magoo" -version = "0.1.3" +version = "0.1.4" edition = "2021" description = "A wrapper for git submodule that simplifies the workflows" repository = "https://github.com/Pistonite/magoo" diff --git a/src/submodule.rs b/src/submodule.rs index 4f177bd..65b4ffa 100644 --- a/src/submodule.rs +++ b/src/submodule.rs @@ -460,7 +460,8 @@ impl Submodule { top_level_dir.join(".gitmodules"), &format!("submodule.{name}"), ); - context.add(".gitmodules")?; + // add may fail if .gitmodules doesn't exist + let _ = context.add(".gitmodules"); } self.in_gitmodules = None; Ok(()) @@ -471,7 +472,8 @@ impl Submodule { if let Some(in_index) = &self.in_index { println_info!("Deleting `{}` in index", in_index.path); context.remove_from_index(&in_index.path)?; - context.add(".gitmodules")?; + // add may fail if .gitmodules doesn't exist + let _ = context.add(".gitmodules"); } self.in_index = None; Ok(())