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

#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);

}

}