aboutsummaryrefslogtreecommitdiff
path: root/bdep/git.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'bdep/git.cxx')
-rw-r--r--bdep/git.cxx23
1 files changed, 18 insertions, 5 deletions
diff --git a/bdep/git.cxx b/bdep/git.cxx
index cc697b3..f9bdc04 100644
--- a/bdep/git.cxx
+++ b/bdep/git.cxx
@@ -24,10 +24,8 @@ namespace bdep
static optional<semantic_version> bun_git_ver;
#endif
- // Check that git is at least of the specified minimum supported version.
- //
- void
- git_check_version (const semantic_version& min_ver, bool system)
+ bool
+ git_try_check_version (const semantic_version& min_ver, bool system)
{
// Query and cache git version on the first call.
//
@@ -50,9 +48,24 @@ namespace bdep
// Note that we don't expect the min_ver to contain the build component,
// that doesn't matter functionality-wise for git.
//
- if (*gv < min_ver)
+ return *gv >= min_ver;
+ }
+
+ // As above but issue diagnostics and fail if git is older than the
+ // specified minimum supported version.
+ //
+ void
+ git_check_version (const semantic_version& min_ver, bool system)
+ {
+ if (!git_try_check_version (min_ver, system))
+ {
+ optional<semantic_version>& gv (system ? sys_git_ver : bun_git_ver);
+
+ assert (gv); // Must have been cached by git_try_check_version().
+
fail << "unsupported git version " << *gv <<
info << "minimum supported version is " << min_ver << endf;
+ }
}
// Return git process path and the --exec-path option, if it is required for