aboutsummaryrefslogtreecommitdiff
path: root/bdep/git.ixx
blob: 0ee94acdd2a215828733bcbd3bd3199ac6a2573b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
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);
  }
}