From b937ec2bf461ec06bf601e854f694e86060eba59 Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Tue, 22 Sep 2020 22:18:18 +0300 Subject: Use system git rather than bundled one for some operations on Windows --- bdep/git.hxx | 43 ++++++++++++++++++++++++++++++++++++++----- 1 file changed, 38 insertions(+), 5 deletions(-) (limited to 'bdep/git.hxx') diff --git a/bdep/git.hxx b/bdep/git.hxx index dcf3407..bfc5cd2 100644 --- a/bdep/git.hxx +++ b/bdep/git.hxx @@ -17,15 +17,30 @@ namespace bdep // All functions that start git process take the minimum supported git // version as an argument. // + // They also take the system flag (only considered on Windows) that if true + // causes these functions to prefer the system git program (determined via + // PATH) over the bundled one (the bundled git is still used as a fallback). + // Normally, the caller should use the system git when operating on behalf + // of the user (commits, pushes, etc), so that the user interacts with the + // git program they expect. For the query requests (git repository status, + // etc) the bundled git should be used instead to avoid compatibility issues + // (e.g., symlink handling, etc; but when querying for potentially global + // configuration values such as author, system git should be used). Note + // that on POSIX the system git is used for everything. + // // Start git process. // template process - start_git (const semantic_version&, I&& in, O&& out, E&& err, A&&... args); + start_git (const semantic_version&, + bool system, + I&& in, O&& out, E&& err, + A&&... args); template process start_git (const semantic_version&, + bool system, const dir_path& repo, I&& in, O&& out, E&& err, A&&... args); @@ -33,11 +48,13 @@ namespace bdep template inline process start_git (const semantic_version& min_ver, + bool system, dir_path& repo, I&& in, O&& out, E&& err, A&&... args) { return start_git (min_ver, + system, const_cast (repo), forward (in), forward (out), forward (err), forward (args)...); @@ -53,15 +70,23 @@ namespace bdep template void run_git (const semantic_version&, + bool system, bool progress, const dir_path& repo, A&&... args); template inline void - run_git (const semantic_version& min_ver, const dir_path& repo, A&&... args) + run_git (const semantic_version& min_ver, + bool system, + const dir_path& repo, + A&&... args) { - run_git (min_ver, true /* progress */, repo, forward (args)...); + run_git (min_ver, + system, + true /* progress */, + repo, + forward (args)...); } // Return the first line of the git output. If ignore_error is true, then @@ -69,11 +94,15 @@ namespace bdep // template optional - git_line (const semantic_version&, bool ignore_error, A&&... args); + git_line (const semantic_version&, + bool system, + bool ignore_error, + A&&... args); template optional git_line (const semantic_version&, + bool system, const dir_path& repo, bool ignore_error, A&&... args); @@ -88,11 +117,15 @@ namespace bdep // template optional - git_string (const semantic_version&, bool ignore_error, A&&... args); + git_string (const semantic_version&, + bool system, + bool ignore_error, + A&&... args); template optional git_string (const semantic_version&, + bool system, const dir_path& repo, bool ignore_error, A&&... args); -- cgit v1.1