From 7db456d60f7344dae1ce7b25ba46b6639a8c4116 Mon Sep 17 00:00:00 2001 From: yuanyan Date: Wed, 18 Dec 2024 15:40:24 +0800 Subject: [PATCH 1/2] add GIT_CHECKOUT_DISABLE_PATHSPEC_MATCH support --- src/build.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/build.rs b/src/build.rs index d3c95f6559..1cf3f98d96 100644 --- a/src/build.rs +++ b/src/build.rs @@ -491,6 +491,11 @@ impl<'cb> CheckoutBuilder<'cb> { self.flag(raw::GIT_CHECKOUT_CONFLICT_STYLE_DIFF3, on) } + /// Treat paths as a simple list. + pub fn disable_pathspec_match(&mut self, on: bool) -> &mut CheckoutBuilder<'cb> { + self.flag(raw::GIT_CHECKOUT_DISABLE_PATHSPEC_MATCH, on) + } + /// Indicate whether to apply filters like CRLF conversion. pub fn disable_filters(&mut self, disable: bool) -> &mut CheckoutBuilder<'cb> { self.disable_filters = disable; From 9ae249f53d07982e04017eb26cc976c99ec1c571 Mon Sep 17 00:00:00 2001 From: Eric Huss Date: Wed, 18 Dec 2024 09:06:45 -0800 Subject: [PATCH 2/2] Clarify disable_pathspec_match docs --- src/build.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/build.rs b/src/build.rs index 1cf3f98d96..4ac62439b7 100644 --- a/src/build.rs +++ b/src/build.rs @@ -491,7 +491,8 @@ impl<'cb> CheckoutBuilder<'cb> { self.flag(raw::GIT_CHECKOUT_CONFLICT_STYLE_DIFF3, on) } - /// Treat paths as a simple list. + /// Treat paths specified in [`CheckoutBuilder::path`] as exact file paths + /// instead of as pathspecs. pub fn disable_pathspec_match(&mut self, on: bool) -> &mut CheckoutBuilder<'cb> { self.flag(raw::GIT_CHECKOUT_DISABLE_PATHSPEC_MATCH, on) } @@ -520,8 +521,13 @@ impl<'cb> CheckoutBuilder<'cb> { /// Add a path to be checked out. /// + /// The path is a [pathspec] pattern, unless + /// [`CheckoutBuilder::disable_pathspec_match`] is set. + /// /// If no paths are specified, then all files are checked out. Otherwise /// only these specified paths are checked out. + /// + /// [pathspec]: https://git-scm.com/docs/gitglossary.html#Documentation/gitglossary.txt-aiddefpathspecapathspec pub fn path(&mut self, path: T) -> &mut CheckoutBuilder<'cb> { let path = util::cstring_to_repo_path(path).unwrap(); self.path_ptrs.push(path.as_ptr());