From 02458785b93094dfc65b31a4ecf2a8e690143b03 Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Tue, 13 Feb 2018 23:12:23 +0300 Subject: Assume git repo URL fragment of 40 hex digits is a commit id --- libbpkg/manifest.cxx | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'libbpkg') diff --git a/libbpkg/manifest.cxx b/libbpkg/manifest.cxx index 81a9b8c..1c0650e 100644 --- a/libbpkg/manifest.cxx +++ b/libbpkg/manifest.cxx @@ -11,7 +11,7 @@ #include // strncmp(), strcmp() #include // move() #include // uint16_t, UINT16_MAX -#include // find(), replace() +#include // find(), find_if_not(), replace() #include // invalid_argument #include @@ -1961,7 +1961,20 @@ namespace bpkg commit = string (s, p + 1); } else if (!s.empty ()) - branch = s; + { + // A 40-characters fragment that consists of only hexadecimal digits is + // assumed to be a commit id. + // + if (s.size () == 40 && + find_if_not (s.begin (), s.end (), + + // Resolve the required overload. + // + static_cast (xdigit)) == s.end ()) + commit = s; + else + branch = s; + } } if (!branch && !commit) -- cgit v1.1