aboutsummaryrefslogtreecommitdiff
path: root/bdep/git.ixx
diff options
context:
space:
mode:
Diffstat (limited to 'bdep/git.ixx')
-rw-r--r--bdep/git.ixx28
1 files changed, 28 insertions, 0 deletions
diff --git a/bdep/git.ixx b/bdep/git.ixx
new file mode 100644
index 0000000..0ee94ac
--- /dev/null
+++ b/bdep/git.ixx
@@ -0,0 +1,28 @@
+// file : bdep/git.ixx -*- C++ -*-
+// copyright : Copyright (c) 2014-2018 Code Synthesis Ltd
+// license : MIT; see accompanying LICENSE file
+
+using namespace butl;
+
+namespace bdep
+{
+ optional<string>
+ git_line (process&&, fdpipe&&, bool);
+
+ template <typename... A>
+ inline optional<string>
+ git_line (const dir_path& repo, bool ie, A&&... args)
+ {
+ fdpipe pipe (fdopen_pipe ());
+ auto_fd null (ie ? fdnull () : auto_fd ());
+
+ process pr (start (0 /* stdin */,
+ pipe /* stdout */,
+ ie ? null.get () : 2 /* stderr */,
+ "git",
+ "-C", repo,
+ forward<A> (args)...));
+
+ return git_line (move (pr), move (pipe), ie);
+ }
+}