aboutsummaryrefslogtreecommitdiff
path: root/bdep/git.txx
blob: 19a9d42c1ab3189546d3bea401a4fbd5c4235e4f (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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
// file      : bdep/git.txx -*- C++ -*-
// copyright : Copyright (c) 2014-2018 Code Synthesis Ltd
// license   : MIT; see accompanying LICENSE file

namespace bdep
{
  template <typename... A>
  void
  run_git (const standard_version& min_ver, const dir_path& repo, A&&... args)
  {
    process pr (start_git (min_ver,
                           repo,
                           0 /* stdin  */, 1 /* stdout */, 2 /* stderr */,
                           forward<A> (args)...));

    finish_git (pr);
  }

  void
  git_check_version (const standard_version& min_ver);

  template <typename I, typename O, typename E, typename... A>
  process
  start_git (const standard_version& min_ver,
             I&& in, O&& out, E&& err,
             A&&... args)
  {
    git_check_version (min_ver);

    return start (forward<I> (in), forward<O> (out), forward<E> (err),
                  "git",
                  forward<A> (args)...);
  }

  template <typename... A>
  optional<string>
  git_line (const standard_version& min_ver, bool ie, A&&... args)
  {
    fdpipe pipe (fdopen_pipe ());
    auto_fd null (ie ? fdnull () : auto_fd ());

    process pr (start_git (min_ver,
                           0                    /* stdin  */,
                           pipe                 /* stdout */,
                           ie ? null.get () : 2 /* stderr */,
                           forward<A> (args)...));

    return git_line (move (pr), move (pipe), ie);
  }
}