aboutsummaryrefslogtreecommitdiff
path: root/src/libutil/git.hh
blob: cb13ef0e5bb149ec56ba4a71cb4c25b9285f26a4 (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
#pragma once

#include <string>
#include <string_view>
#include <optional>

namespace nix {

namespace git {

// A line from the output of `git ls-remote --symref`.
//
// These can be of two kinds:
//
// - Symbolic references of the form
//
//      ref: {target}	{reference}
//
//    where {target} is itself a reference and {reference} is optional
//
// - Object references of the form
//
//      {target}	{reference}
//
//    where {target} is a commit id and {reference} is mandatory
struct LsRemoteRefLine {
    enum struct Kind {
        Symbolic,
        Object
    };
    Kind kind;
    std::string target;
    std::optional<std::string> reference;
};

std::optional<LsRemoteRefLine> parseLsRemoteLine(std::string_view line);

}

}