init xsteam
This commit is contained in:
parent
6b07d8e593
commit
c1b80be038
58
.gitignore
vendored
Normal file
58
.gitignore
vendored
Normal file
@ -0,0 +1,58 @@
|
||||
# These are some examples of commonly ignored file patterns.
|
||||
# You should customize this list as applicable to your project.
|
||||
# Learn more about .gitignore:
|
||||
# https://www.atlassian.com/git/tutorials/saving-changes/gitignore
|
||||
|
||||
# Node artifact files
|
||||
node_modules/
|
||||
dist/
|
||||
/build
|
||||
build/
|
||||
release/
|
||||
/release
|
||||
|
||||
# Compiled Java class files
|
||||
*.class
|
||||
|
||||
# Compiled Python bytecode
|
||||
*.py[cod]
|
||||
|
||||
# Log files
|
||||
*.log
|
||||
|
||||
# Package files
|
||||
*.jar
|
||||
|
||||
# Maven
|
||||
target/
|
||||
dist/
|
||||
|
||||
# JetBrains IDE
|
||||
.idea/
|
||||
|
||||
# Unit test reports
|
||||
TEST*.xml
|
||||
|
||||
# Generated by MacOS
|
||||
.DS_Store
|
||||
|
||||
# Generated by Windows
|
||||
Thumbs.db
|
||||
|
||||
# Applications
|
||||
*.app
|
||||
*.war
|
||||
|
||||
# Large media files
|
||||
*.mp4
|
||||
*.tiff
|
||||
*.avi
|
||||
*.flv
|
||||
*.mov
|
||||
*.wmv
|
||||
|
||||
#屏蔽zvo测试数据
|
||||
*.zvo
|
||||
*.torrent
|
||||
*.m3u8
|
||||
|
7
.vscode/launch.json
vendored
Normal file
7
.vscode/launch.json
vendored
Normal file
@ -0,0 +1,7 @@
|
||||
{
|
||||
// 使用 IntelliSense 了解相关属性。
|
||||
// 悬停以查看现有属性的描述。
|
||||
// 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387
|
||||
"version": "0.2.0",
|
||||
"configurations": []
|
||||
}
|
114
.vscode/settings.json
vendored
Normal file
114
.vscode/settings.json
vendored
Normal file
@ -0,0 +1,114 @@
|
||||
{
|
||||
"cmake.configureOnOpen": false,
|
||||
"files.associations": {
|
||||
"qframe": "cpp",
|
||||
"stop_token": "cpp",
|
||||
"memory": "cpp",
|
||||
"semaphore": "cpp",
|
||||
"condition_variable": "cpp",
|
||||
"qtabbar": "cpp",
|
||||
"any": "cpp",
|
||||
"array": "cpp",
|
||||
"atomic": "cpp",
|
||||
"bit": "cpp",
|
||||
"*.tcc": "cpp",
|
||||
"bitset": "cpp",
|
||||
"cctype": "cpp",
|
||||
"chrono": "cpp",
|
||||
"clocale": "cpp",
|
||||
"cmath": "cpp",
|
||||
"codecvt": "cpp",
|
||||
"compare": "cpp",
|
||||
"complex": "cpp",
|
||||
"concepts": "cpp",
|
||||
"coroutine": "cpp",
|
||||
"csignal": "cpp",
|
||||
"cstdarg": "cpp",
|
||||
"cstddef": "cpp",
|
||||
"cstdint": "cpp",
|
||||
"cstdio": "cpp",
|
||||
"cstdlib": "cpp",
|
||||
"cstring": "cpp",
|
||||
"ctime": "cpp",
|
||||
"cwchar": "cpp",
|
||||
"cwctype": "cpp",
|
||||
"deque": "cpp",
|
||||
"list": "cpp",
|
||||
"map": "cpp",
|
||||
"set": "cpp",
|
||||
"string": "cpp",
|
||||
"unordered_map": "cpp",
|
||||
"unordered_set": "cpp",
|
||||
"vector": "cpp",
|
||||
"exception": "cpp",
|
||||
"algorithm": "cpp",
|
||||
"functional": "cpp",
|
||||
"iterator": "cpp",
|
||||
"memory_resource": "cpp",
|
||||
"netfwd": "cpp",
|
||||
"numeric": "cpp",
|
||||
"optional": "cpp",
|
||||
"random": "cpp",
|
||||
"ratio": "cpp",
|
||||
"source_location": "cpp",
|
||||
"string_view": "cpp",
|
||||
"system_error": "cpp",
|
||||
"tuple": "cpp",
|
||||
"type_traits": "cpp",
|
||||
"utility": "cpp",
|
||||
"fstream": "cpp",
|
||||
"future": "cpp",
|
||||
"initializer_list": "cpp",
|
||||
"iomanip": "cpp",
|
||||
"iosfwd": "cpp",
|
||||
"iostream": "cpp",
|
||||
"istream": "cpp",
|
||||
"limits": "cpp",
|
||||
"mutex": "cpp",
|
||||
"new": "cpp",
|
||||
"numbers": "cpp",
|
||||
"ostream": "cpp",
|
||||
"sstream": "cpp",
|
||||
"stdexcept": "cpp",
|
||||
"streambuf": "cpp",
|
||||
"thread": "cpp",
|
||||
"cfenv": "cpp",
|
||||
"cinttypes": "cpp",
|
||||
"typeindex": "cpp",
|
||||
"typeinfo": "cpp",
|
||||
"variant": "cpp",
|
||||
"qpushbutton": "cpp",
|
||||
"qvboxlayout": "cpp",
|
||||
"qpainter": "cpp",
|
||||
"qpainterpath": "cpp",
|
||||
"expected": "cpp",
|
||||
"qdialog": "cpp",
|
||||
"qapplication": "cpp",
|
||||
"qtablewidget": "cpp",
|
||||
"qwidget": "cpp",
|
||||
"forward_list": "cpp",
|
||||
"format": "cpp",
|
||||
"span": "cpp",
|
||||
"valarray": "cpp",
|
||||
"charconv": "cpp",
|
||||
"regex": "cpp",
|
||||
"stdfloat": "cpp",
|
||||
"qcombobox": "cpp",
|
||||
"text_encoding": "cpp",
|
||||
"qtablewidgetitem": "cpp",
|
||||
"qstandarditemmodel": "cpp",
|
||||
"qstandarditem": "cpp",
|
||||
"qhboxlayout": "cpp",
|
||||
"qlabel": "cpp",
|
||||
"qtableview": "cpp",
|
||||
"qsettings": "cpp",
|
||||
"qstringlist": "cpp",
|
||||
"qwindow": "cpp",
|
||||
"qstring": "cpp",
|
||||
"shared_mutex": "cpp",
|
||||
"qgroupbox": "cpp",
|
||||
"qheaderview": "cpp",
|
||||
"qabstractlistmodel": "cpp"
|
||||
},
|
||||
"Codegeex.RepoIndex": true
|
||||
}
|
28
.vscode/tasks.json
vendored
Normal file
28
.vscode/tasks.json
vendored
Normal file
@ -0,0 +1,28 @@
|
||||
{
|
||||
"tasks": [
|
||||
{
|
||||
"type": "cppbuild",
|
||||
"label": "C/C++: gcc.exe 生成活动文件",
|
||||
"command": "D:\\Dev\\msys64\\mingw64\\bin\\gcc.exe",
|
||||
"args": [
|
||||
"-fdiagnostics-color=always",
|
||||
"-g",
|
||||
"${file}",
|
||||
"-o",
|
||||
"${fileDirname}\\${fileBasenameNoExtension}.exe"
|
||||
],
|
||||
"options": {
|
||||
"cwd": "${fileDirname}"
|
||||
},
|
||||
"problemMatcher": [
|
||||
"$gcc"
|
||||
],
|
||||
"group": {
|
||||
"kind": "build",
|
||||
"isDefault": true
|
||||
},
|
||||
"detail": "调试器生成的任务。"
|
||||
}
|
||||
],
|
||||
"version": "2.0.0"
|
||||
}
|
21
3rdparty/ValveFileVDF/LICENSE
vendored
Normal file
21
3rdparty/ValveFileVDF/LICENSE
vendored
Normal file
@ -0,0 +1,21 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) Matthias Moeller 2016 m_moeller@live.de
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
278
3rdparty/ValveFileVDF/Readme.md
vendored
Normal file
278
3rdparty/ValveFileVDF/Readme.md
vendored
Normal file
@ -0,0 +1,278 @@
|
||||
# Valve Data Format (.vdf) Reader and Writer in C++
|
||||
|
||||
[![CMake](https://github.com/TinyTinni/ValveFileVDF/actions/workflows/cmake.yml/badge.svg)](https://github.com/TinyTinni/ValveFileVDF/actions/workflows/cmake.yml)
|
||||
|
||||
Valve uses its own JSON-like data format: [KeyValue, also known as vdf.](https://developer.valvesoftware.com/wiki/KeyValues)
|
||||
e.g. in game manifest files or as SteamCMD output.
|
||||
This header-only file provides a parser and writer to load and save the given data.
|
||||
|
||||
## Features:
|
||||
- read and write vdf data in C++
|
||||
- build-in encodings: `char` and `wchar_t`
|
||||
- supports custom character sets
|
||||
- support for C++ (//) and C (/**/) comments
|
||||
- `#include`/`#base` keyword (note: searches for files in the current working directory)
|
||||
- platform independent
|
||||
- header-only
|
||||
|
||||
## Requirements
|
||||
- C++11
|
||||
|
||||
(works with the C++11 features of vs120/"Visual Studio 2013" and newer)
|
||||
|
||||
## Test Requirements
|
||||
- C++17 (uses [doctest](https://github.com/doctest/doctest))
|
||||
|
||||
## How-To Use
|
||||
First, you have to include the main file `vdf-Parser.h`.
|
||||
This file provides several functions and data-structures which are
|
||||
in the namespace `tyti::vdf`.
|
||||
|
||||
All functions and data structures supports wide characters.
|
||||
The wide character data structure is indicated by the commonly known `w`-prefix.
|
||||
Functions are templates and don't need a prefix.
|
||||
|
||||
To read an file, create a stream e.g. `std::ifsteam` or `std::wifstream`
|
||||
and call the `tyti::vdf::read` function.
|
||||
```c++
|
||||
std::ifstream file("PathToMyFile");
|
||||
auto root = tyti::vdf::read(file);
|
||||
```
|
||||
You can also define a sequence of character defined by a range.
|
||||
```c++
|
||||
std::string blob;
|
||||
...
|
||||
auto root = tyti::vdf::read(std::cbegin(blob), std::cend(blob));
|
||||
|
||||
//given .vdf below, following holds
|
||||
assert(root.name == "name");
|
||||
const std::shared_ptr<tyti::vdf::object> child = root.childs["child0"];
|
||||
assert(child->name == "child0");
|
||||
const std::string& k = root[0].attribs["attrib0"];
|
||||
assert(k == "value");
|
||||
```
|
||||
|
||||
The `tyti::vdf::object` is a tree like data structure.
|
||||
It has its name, some attributes as a pair of `key` and `value`
|
||||
and its object childs. Below you can see a vdf data structure and how it is stored by naming:
|
||||
```javascript
|
||||
"name"
|
||||
{
|
||||
"attrib0" "value" // saved as a pair, first -> key, second -> value
|
||||
"#base" "includeFile.vdf" // appends object defined in the file to childs
|
||||
"child0"
|
||||
{
|
||||
...
|
||||
}
|
||||
...
|
||||
}
|
||||
```
|
||||
|
||||
Given such an object, you can also write it into vdf files via:
|
||||
```c++
|
||||
tyti::vdf::write(file, object);
|
||||
```
|
||||
|
||||
## Multi-Key and Custom Output Type
|
||||
|
||||
It is also possible to customize your output dataformat.
|
||||
Per default, the parser stores all items in a std::unordered_map, which, per definition,
|
||||
doesn't allow different entries with the same key.
|
||||
|
||||
However, the Valve vdf format supports multiple keys. Therefore, the output data format
|
||||
has to store all items in e.g. a std::unordered_multimap.
|
||||
|
||||
You can change the output format by passing the output type via template argument to
|
||||
the read function
|
||||
```c++
|
||||
namespace tyti;
|
||||
vdf::object no_multi_key = vdf::read(file);
|
||||
vdf::multikey_object multi_key = vdf::read<vdf::multikey_object>(file);
|
||||
```
|
||||
|
||||
__Note__: The interface of [std::unordered_map](http://en.cppreference.com/w/cpp/container/unordered_map) and [std::unordered_multimap](http://en.cppreference.com/w/cpp/container/unordered_multimap)
|
||||
are different when you access the elements.
|
||||
|
||||
It is also possible to create your own data structure which is used by the parser.
|
||||
Your output class needs to define 3 functions with the following signature:
|
||||
|
||||
```c++
|
||||
void add_attribute(std::basic_string<CHAR> key, std::basic_string<CHAR> value);
|
||||
void add_child(std::unique_ptr< MYCLASS > child);
|
||||
void set_name(std::basic_string<CHAR> n);
|
||||
```
|
||||
where ```MYCLASS``` is the tpe of your class and ```CHAR``` the type of your character set.
|
||||
Also, the type has to be [default constructible](http://en.cppreference.com/w/cpp/types/is_default_constructible)
|
||||
and [move constructible](http://en.cppreference.com/w/cpp/types/is_move_constructible).
|
||||
|
||||
This also allows you, to inspect the file without storing it in a data structure.
|
||||
Lets say, for example, you want to count all attributes of a file without storing it.
|
||||
You can do this by using this class
|
||||
|
||||
```c++
|
||||
struct counter
|
||||
{
|
||||
size_t num_attributes = 0;
|
||||
void add_attribute(std::string key, std::string value)
|
||||
{
|
||||
++num_attributes;
|
||||
}
|
||||
void add_child(std::unique_ptr< counter > child)
|
||||
{
|
||||
num_attributes += child->num_attributes;
|
||||
}
|
||||
void set_name(std::string n)
|
||||
{}
|
||||
};
|
||||
```
|
||||
|
||||
and then call the read function
|
||||
```c++
|
||||
counter num = tyti::vdf::read<counter>(file);
|
||||
```
|
||||
|
||||
## Options
|
||||
|
||||
You can configure the parser, the non default options are not well tested yet.
|
||||
|
||||
```c++
|
||||
struct Options
|
||||
{
|
||||
bool strip_escape_symbols; //default true
|
||||
bool ignore_all_platform_conditionals; // default false
|
||||
bool ignore_includes; //default false
|
||||
};
|
||||
|
||||
```
|
||||
|
||||
## Reference
|
||||
```c++
|
||||
/////////////////////////////////////////////////////////////
|
||||
// pre-defined output classes
|
||||
/////////////////////////////////////////////////////////////
|
||||
// default output object
|
||||
template<typename T>
|
||||
basic_object<T>
|
||||
{
|
||||
std::basic_string<char_type> name;
|
||||
std::unordered_map<std::basic_string<char_type>, std::basic_string<char_type> > attribs;
|
||||
std::unordered_map<std::basic_string<char_type>, std::shared_ptr< basic_object<char_type> > > childs;
|
||||
};
|
||||
typedef basic_object<char> object;
|
||||
typedef basic_object<wchar_t> wobject
|
||||
|
||||
// output object with multikey support
|
||||
template<typename T>
|
||||
basic_multikey_object<T>
|
||||
{
|
||||
std::basic_string<char_type> name;
|
||||
std::unordered_multimap<std::basic_string<char_type>, std::basic_string<char_type> > attribs;
|
||||
std::unordered_multimap<std::basic_string<char_type>, std::shared_ptr< basic_object<char_type> > > childs;
|
||||
};
|
||||
typedef basic_multikey_object<char> multikey_object;
|
||||
typedef basic_multikey_object<wchar_t> wmultikey_object
|
||||
|
||||
/////////////////////////////////////////////////////////////
|
||||
// error codes
|
||||
/////////////////////////////////////////////////////////////
|
||||
/*
|
||||
Possible error codes:
|
||||
std::errc::protocol_error: file is mailformatted
|
||||
std::errc::not_enough_memory: not enough space
|
||||
std::errc::invalid_argument: iterators throws e.g. out of range
|
||||
*/
|
||||
|
||||
/////////////////////////////////////////////////////////////
|
||||
// read from stream
|
||||
/////////////////////////////////////////////////////////////
|
||||
|
||||
/** \brief Loads a stream (e.g. filestream) into the memory and parses the vdf formatted data.
|
||||
throws "std::bad_alloc" if file buffer could not be allocated
|
||||
throws "std::runtime_error" if a parsing error occured
|
||||
*/
|
||||
template<ytpename OutputT, typename iStreamT>
|
||||
std::vector<OutputT> read(iStreamT& inStream, const Options &opt = Options{});
|
||||
|
||||
template<typename iStreamT>
|
||||
std::vector<basic_object<typename iStreamT::char_type>> read(iStreamT& inStream, const Options &opt = Options{});
|
||||
|
||||
/** \brief Loads a stream (e.g. filestream) into the memory and parses the vdf formatted data.
|
||||
throws "std::bad_alloc" if file buffer could not be allocated
|
||||
ok == false, if a parsing error occured
|
||||
*/
|
||||
template<typename OutputT, typename iStreamT>
|
||||
std::vector<OutputT> read(iStreamT& inStream, bool* ok, const Options &opt = Options{});
|
||||
|
||||
template<typename iStreamT>
|
||||
std::vector<basic_object<typename iStreamT::char_type>> read(iStreamT& inStream, bool* ok, const Options &opt = Options{});
|
||||
|
||||
/** \brief Loads a stream (e.g. filestream) into the memory and parses the vdf formatted data.
|
||||
throws "std::bad_alloc" if file buffer could not be allocated
|
||||
*/
|
||||
template<typename OutputT, typename iStreamT>
|
||||
std::vector<OutputT> read(iStreamT& inStream, std::error_code& ec, const Options &opt = Options{});
|
||||
|
||||
template<typename iStreamT>
|
||||
std::vector<basic_object<iStreamT::char_type>> read(iStreamT& inStream, std::error_code& ec, const Options &opt = Options{});
|
||||
|
||||
/////////////////////////////////////////////////////////////
|
||||
// read from memory
|
||||
/////////////////////////////////////////////////////////////
|
||||
|
||||
/** \brief Read VDF formatted sequences defined by the range [first, last).
|
||||
If the file is mailformatted, parser will try to read it until it can.
|
||||
@param first begin iterator
|
||||
@param end end iterator
|
||||
|
||||
throws "std::runtime_error" if a parsing error occured
|
||||
throws "std::bad_alloc" if not enough memory could be allocated
|
||||
*/
|
||||
template<typename OutputT, typename IterT>
|
||||
std::vector<OutputT> read(IterT first, IterT last, const Options &opt = Options{});
|
||||
|
||||
template<typename IterT>
|
||||
std::vector<basic_object<typename std::iterator_traits<IterT>::value_type>> read(IterT first, IterT last, const Options &opt = Options{});
|
||||
|
||||
/** \brief Read VDF formatted sequences defined by the range [first, last).
|
||||
If the file is mailformatted, parser will try to read it until it can.
|
||||
@param first begin iterator
|
||||
@param end end iterator
|
||||
@param ok output bool. true, if parser successed, false, if parser failed
|
||||
*/
|
||||
template<typename OutputT, typename IterT>
|
||||
std::vector<OutputT> read(IterT first, IterT last, bool* ok, const Options &opt = Options{}) noexcept;
|
||||
|
||||
template<typename IterT>
|
||||
std::vector<basic_object<typename std::iterator_traits<IterT>::value_type>> read(IterT first, IterT last, bool* ok, const Options &opt = Options{}) noexcept;
|
||||
|
||||
|
||||
|
||||
/** \brief Read VDF formatted sequences defined by the range [first, last).
|
||||
If the file is mailformatted, parser will try to read it until it can.
|
||||
@param first begin iterator
|
||||
@param end end iterator
|
||||
@param ec output bool. 0 if ok, otherwise, holds an system error code
|
||||
*/
|
||||
template<typename OutputT, typename IterT>
|
||||
std::vector<OutputT> read(IterT first, IterT last, std::error_code& ec, const Options &opt = Options{}) noexcept;
|
||||
|
||||
template<typename IterT>
|
||||
std::vector<basic_object<typename std::iterator_traits<IterT>::value_type>> read(IterT first, IterT last, std::error_code& ec, const Options &opt = Options{}) noexcept;
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Writer functions
|
||||
/// writes given obj into out in vdf style
|
||||
/// Output is prettyfied, using tabs
|
||||
template<typename oStreamT, typename T>
|
||||
void write(oStreamT& out, const T& obj, const Options &opt = Options{});
|
||||
|
||||
```
|
||||
|
||||
## Remarks for Errors
|
||||
The current version is a greedy implementation and jumps over unrecognized fields.
|
||||
Therefore, the error detection is very imprecise an does not give the line, where the error occurs.
|
||||
|
||||
## License
|
||||
|
||||
[MIT License](./LICENSE) © Matthias Möller. Made with ♥ in Germany.
|
19
3rdparty/ValveFileVDF/fuzzing/CMakeLists.txt
vendored
Normal file
19
3rdparty/ValveFileVDF/fuzzing/CMakeLists.txt
vendored
Normal file
@ -0,0 +1,19 @@
|
||||
set(FUZZ_RUNTIME
|
||||
10
|
||||
CACHE STRING "Number of seconds to run fuzz tests during ctest run")
|
||||
|
||||
set (CMAKE_CXX_STANDARD 17)
|
||||
add_executable(fuzzing main.cpp)
|
||||
target_link_libraries(fuzzing PRIVATE -coverage -fsanitize=fuzzer)
|
||||
if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
|
||||
target_compile_options(fuzzing PRIVATE -fsanitize=fuzzer)
|
||||
target_link_libraries(fuzzing PUBLIC -fsanitize=address,undefined)
|
||||
target_compile_definitions(fuzzing PRIVATE "-D_LIBCPP_DISABLE_DEPRECATION_WARNINGS")
|
||||
elseif("${CMAKE_CXX_COMPILER_ID}" MATCHES "MSVC")
|
||||
target_compile_options(fuzzing PRIVATE /fsanitize=fuzzer)
|
||||
target_compile_definitions(fuzzing PRIVATE "-D_SILENCE_ALL_CXX17_DEPRECATION_WARNINGS")
|
||||
endif()
|
||||
|
||||
target_link_libraries(fuzzing PRIVATE ValveFileVDF)
|
||||
|
||||
add_test(NAME fuzzing_run COMMAND fuzzing -max_total_time=${FUZZ_RUNTIME} -timeout=${FUZZ_RUNTIME})
|
13
3rdparty/ValveFileVDF/fuzzing/main.cpp
vendored
Normal file
13
3rdparty/ValveFileVDF/fuzzing/main.cpp
vendored
Normal file
@ -0,0 +1,13 @@
|
||||
#include <cstdint>
|
||||
#include <string_view>
|
||||
|
||||
#include <vdf_parser.hpp>
|
||||
#include <iostream>
|
||||
|
||||
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
|
||||
{
|
||||
std::string_view test_corpus{reinterpret_cast<const char *>(data), size};
|
||||
bool ok;
|
||||
auto result = tyti::vdf::read(test_corpus.begin(), test_corpus.end(), &ok);
|
||||
return 0;
|
||||
}
|
821
3rdparty/ValveFileVDF/include/vdf_parser.hpp
vendored
Normal file
821
3rdparty/ValveFileVDF/include/vdf_parser.hpp
vendored
Normal file
@ -0,0 +1,821 @@
|
||||
// MIT License
|
||||
//
|
||||
// Copyright(c) 2016 Matthias Moeller
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files(the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and / or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions :
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
#ifndef __TYTI_STEAM_VDF_PARSER_H__
|
||||
#define __TYTI_STEAM_VDF_PARSER_H__
|
||||
|
||||
#include <algorithm>
|
||||
#include <fstream>
|
||||
#include <functional>
|
||||
#include <iterator>
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <unordered_map>
|
||||
#include <unordered_set>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#include <exception>
|
||||
#include <system_error>
|
||||
|
||||
// for wstring support
|
||||
#include <cwchar>
|
||||
#include <string>
|
||||
|
||||
// internal
|
||||
#include <stack>
|
||||
|
||||
// VS < 2015 has only partial C++11 support
|
||||
#if defined(_MSC_VER) && _MSC_VER < 1900
|
||||
#ifndef CONSTEXPR
|
||||
#define CONSTEXPR
|
||||
#endif
|
||||
|
||||
#ifndef NOEXCEPT
|
||||
#define NOEXCEPT
|
||||
#endif
|
||||
#else
|
||||
#ifndef CONSTEXPR
|
||||
#define CONSTEXPR constexpr
|
||||
#define TYTI_UNDEF_CONSTEXPR
|
||||
#endif
|
||||
|
||||
#ifndef NOEXCEPT
|
||||
#define NOEXCEPT noexcept
|
||||
#define TYTI_UNDEF_NOEXCEPT
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
namespace tyti
|
||||
{
|
||||
namespace vdf
|
||||
{
|
||||
namespace detail
|
||||
{
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// Helper functions selecting the right encoding (char/wchar_T)
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
template <typename T> struct literal_macro_help
|
||||
{
|
||||
static CONSTEXPR const char *result(const char *c, const wchar_t *) NOEXCEPT
|
||||
{
|
||||
return c;
|
||||
}
|
||||
static CONSTEXPR char result(const char c, const wchar_t) NOEXCEPT
|
||||
{
|
||||
return c;
|
||||
}
|
||||
};
|
||||
|
||||
template <> struct literal_macro_help<wchar_t>
|
||||
{
|
||||
static CONSTEXPR const wchar_t *result(const char *,
|
||||
const wchar_t *wc) NOEXCEPT
|
||||
{
|
||||
return wc;
|
||||
}
|
||||
static CONSTEXPR wchar_t result(const char, const wchar_t wc) NOEXCEPT
|
||||
{
|
||||
return wc;
|
||||
}
|
||||
};
|
||||
#define TYTI_L(type, text) \
|
||||
vdf::detail::literal_macro_help<type>::result(text, L##text)
|
||||
|
||||
inline std::string string_converter(const std::string &w) NOEXCEPT { return w; }
|
||||
|
||||
inline std::string string_converter(const std::wstring &w) NOEXCEPT
|
||||
{
|
||||
std::mbstate_t state = std::mbstate_t();
|
||||
auto wstr = w.data();
|
||||
// unsafe: ignores any error handling
|
||||
// and disables warning that wcsrtombs_s should be used
|
||||
#ifdef WIN32
|
||||
#pragma warning(push)
|
||||
#pragma warning(disable : 4996)
|
||||
#endif
|
||||
std::size_t len = 1 + std::wcsrtombs(nullptr, &wstr, 0, &state);
|
||||
std::string mbstr(len, '\0');
|
||||
std::wcsrtombs(&mbstr[0], &wstr, mbstr.size(), &state);
|
||||
#ifdef WIN32
|
||||
#pragma warning(pop)
|
||||
#endif
|
||||
return mbstr;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// Writer helper functions
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
template <typename charT> class tabs
|
||||
{
|
||||
const size_t t;
|
||||
|
||||
public:
|
||||
explicit CONSTEXPR tabs(size_t i) NOEXCEPT : t(i) {}
|
||||
std::basic_string<charT> print() const
|
||||
{
|
||||
return std::basic_string<charT>(t, TYTI_L(charT, '\t'));
|
||||
}
|
||||
inline CONSTEXPR tabs operator+(size_t i) const NOEXCEPT
|
||||
{
|
||||
return tabs(t + i);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename oStreamT>
|
||||
oStreamT &operator<<(oStreamT &s, const tabs<typename oStreamT::char_type> t)
|
||||
{
|
||||
s << t.print();
|
||||
return s;
|
||||
}
|
||||
} // end namespace detail
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// Interface
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/// custom objects and their corresponding write functions
|
||||
|
||||
/// basic object node. Every object has a name and can contains attributes saved
|
||||
/// as key_value pairs or childrens
|
||||
template <typename CharT> struct basic_object
|
||||
{
|
||||
typedef CharT char_type;
|
||||
std::basic_string<char_type> name;
|
||||
std::unordered_map<std::basic_string<char_type>,
|
||||
std::basic_string<char_type>>
|
||||
attribs;
|
||||
std::unordered_map<std::basic_string<char_type>,
|
||||
std::shared_ptr<basic_object<char_type>>>
|
||||
childs;
|
||||
|
||||
void add_attribute(std::basic_string<char_type> key,
|
||||
std::basic_string<char_type> value)
|
||||
{
|
||||
attribs.emplace(std::move(key), std::move(value));
|
||||
}
|
||||
void add_child(std::unique_ptr<basic_object<char_type>> child)
|
||||
{
|
||||
std::shared_ptr<basic_object<char_type>> obj{child.release()};
|
||||
childs.emplace(obj->name, obj);
|
||||
}
|
||||
void set_name(std::basic_string<char_type> n) { name = std::move(n); }
|
||||
};
|
||||
|
||||
template <typename CharT> struct basic_multikey_object
|
||||
{
|
||||
typedef CharT char_type;
|
||||
std::basic_string<char_type> name;
|
||||
std::unordered_multimap<std::basic_string<char_type>,
|
||||
std::basic_string<char_type>>
|
||||
attribs;
|
||||
std::unordered_multimap<std::basic_string<char_type>,
|
||||
std::shared_ptr<basic_multikey_object<char_type>>>
|
||||
childs;
|
||||
|
||||
void add_attribute(std::basic_string<char_type> key,
|
||||
std::basic_string<char_type> value)
|
||||
{
|
||||
attribs.emplace(std::move(key), std::move(value));
|
||||
}
|
||||
void add_child(std::unique_ptr<basic_multikey_object<char_type>> child)
|
||||
{
|
||||
std::shared_ptr<basic_multikey_object<char_type>> obj{child.release()};
|
||||
childs.emplace(obj->name, obj);
|
||||
}
|
||||
void set_name(std::basic_string<char_type> n) { name = std::move(n); }
|
||||
};
|
||||
|
||||
typedef basic_object<char> object;
|
||||
typedef basic_object<wchar_t> wobject;
|
||||
typedef basic_multikey_object<char> multikey_object;
|
||||
typedef basic_multikey_object<wchar_t> wmultikey_object;
|
||||
|
||||
struct Options
|
||||
{
|
||||
bool strip_escape_symbols;
|
||||
bool ignore_all_platform_conditionals;
|
||||
bool ignore_includes;
|
||||
|
||||
Options()
|
||||
: strip_escape_symbols(true), ignore_all_platform_conditionals(false),
|
||||
ignore_includes(false)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
// forward decls
|
||||
// forward decl
|
||||
template <typename OutputT, typename iStreamT>
|
||||
OutputT read(iStreamT &inStream, const Options &opt = Options{});
|
||||
|
||||
/** \brief writes given object tree in vdf format to given stream.
|
||||
Output is prettyfied, using tabs
|
||||
*/
|
||||
template <typename oStreamT, typename T>
|
||||
void write(oStreamT &s, const T &r,
|
||||
const detail::tabs<typename oStreamT::char_type> tab =
|
||||
detail::tabs<typename oStreamT::char_type>(0))
|
||||
{
|
||||
typedef typename oStreamT::char_type charT;
|
||||
using namespace detail;
|
||||
s << tab << TYTI_L(charT, '"') << r.name << TYTI_L(charT, "\"\n") << tab
|
||||
<< TYTI_L(charT, "{\n");
|
||||
for (const auto &i : r.attribs)
|
||||
s << tab + 1 << TYTI_L(charT, '"') << i.first
|
||||
<< TYTI_L(charT, "\"\t\t\"") << i.second << TYTI_L(charT, "\"\n");
|
||||
for (const auto &i : r.childs)
|
||||
if (i.second)
|
||||
write(s, *i.second, tab + 1);
|
||||
s << tab << TYTI_L(charT, "}\n");
|
||||
}
|
||||
|
||||
namespace detail
|
||||
{
|
||||
template <typename iStreamT>
|
||||
std::basic_string<typename iStreamT::char_type> read_file(iStreamT &inStream)
|
||||
{
|
||||
// cache the file
|
||||
typedef typename iStreamT::char_type charT;
|
||||
std::basic_string<charT> str;
|
||||
inStream.seekg(0, std::ios::end);
|
||||
str.resize(static_cast<size_t>(inStream.tellg()));
|
||||
if (str.empty())
|
||||
return str;
|
||||
|
||||
inStream.seekg(0, std::ios::beg);
|
||||
inStream.read(&str[0], static_cast<std::streamsize>(str.size()));
|
||||
return str;
|
||||
}
|
||||
|
||||
/** \brief Read VDF formatted sequences defined by the range [first, last).
|
||||
If the file is mailformatted, parser will try to read it until it can.
|
||||
@param first begin iterator
|
||||
@param end end iterator
|
||||
@param exclude_files list of files which cant be included anymore.
|
||||
prevents circular includes
|
||||
|
||||
can thow:
|
||||
- "std::runtime_error" if a parsing error occured
|
||||
- "std::bad_alloc" if not enough memory coup be allocated
|
||||
*/
|
||||
template <typename OutputT, typename IterT>
|
||||
std::vector<std::unique_ptr<OutputT>> read_internal(
|
||||
IterT first, const IterT last,
|
||||
std::unordered_set<
|
||||
std::basic_string<typename std::iterator_traits<IterT>::value_type>>
|
||||
&exclude_files,
|
||||
const Options &opt)
|
||||
{
|
||||
static_assert(std::is_default_constructible<OutputT>::value,
|
||||
"Output Type must be default constructible (provide "
|
||||
"constructor without arguments)");
|
||||
static_assert(std::is_move_constructible<OutputT>::value,
|
||||
"Output Type must be move constructible");
|
||||
|
||||
typedef typename std::iterator_traits<IterT>::value_type charT;
|
||||
|
||||
const std::basic_string<charT> comment_end_str = TYTI_L(charT, "*/");
|
||||
const std::basic_string<charT> whitespaces = TYTI_L(charT, " \n\v\f\r\t");
|
||||
|
||||
#ifdef WIN32
|
||||
std::function<bool(const std::basic_string<charT> &)> is_platform_str =
|
||||
[](const std::basic_string<charT> &in)
|
||||
{
|
||||
return in == TYTI_L(charT, "$WIN32") || in == TYTI_L(charT, "$WINDOWS");
|
||||
};
|
||||
#elif __APPLE__
|
||||
// WIN32 stands for pc in general
|
||||
std::function<bool(const std::basic_string<charT> &)> is_platform_str =
|
||||
[](const std::basic_string<charT> &in)
|
||||
{
|
||||
return in == TYTI_L(charT, "$WIN32") || in == TYTI_L(charT, "$POSIX") ||
|
||||
in == TYTI_L(charT, "$OSX");
|
||||
};
|
||||
|
||||
#elif __linux__
|
||||
// WIN32 stands for pc in general
|
||||
std::function<bool(const std::basic_string<charT> &)> is_platform_str =
|
||||
[](const std::basic_string<charT> &in)
|
||||
{
|
||||
return in == TYTI_L(charT, "$WIN32") || in == TYTI_L(charT, "$POSIX") ||
|
||||
in == TYTI_L(charT, "$LINUX");
|
||||
};
|
||||
#else
|
||||
std::function<bool(const std::basic_string<charT> &)> is_platform_str =
|
||||
[](const std::basic_string<charT> &in) { return false; };
|
||||
#endif
|
||||
|
||||
if (opt.ignore_all_platform_conditionals)
|
||||
is_platform_str = [](const std::basic_string<charT> &)
|
||||
{ return false; };
|
||||
|
||||
// function for skipping a comment block
|
||||
// iter: iterator poition to the position after a '/'
|
||||
auto skip_comments = [&comment_end_str](IterT iter,
|
||||
const IterT &last) -> IterT
|
||||
{
|
||||
++iter;
|
||||
if (iter == last)
|
||||
return last;
|
||||
|
||||
if (*iter == TYTI_L(charT, '/'))
|
||||
{
|
||||
// line comment, skip whole line
|
||||
iter = std::find(iter + 1, last, TYTI_L(charT, '\n'));
|
||||
if (iter == last)
|
||||
return last;
|
||||
}
|
||||
|
||||
if (*iter == '*')
|
||||
{
|
||||
// block comment, skip until next occurance of "*\"
|
||||
iter = std::search(iter + 1, last, std::begin(comment_end_str),
|
||||
std::end(comment_end_str));
|
||||
if (std::distance(iter, last) <= 2)
|
||||
return last;
|
||||
iter += 2;
|
||||
}
|
||||
|
||||
return iter;
|
||||
};
|
||||
|
||||
auto end_quote = [](IterT iter, const IterT &last) -> IterT
|
||||
{
|
||||
const auto begin = iter;
|
||||
auto last_esc = iter;
|
||||
if (iter == last)
|
||||
throw std::runtime_error{"quote was opened but not closed."};
|
||||
do
|
||||
{
|
||||
++iter;
|
||||
iter = std::find(iter, last, TYTI_L(charT, '\"'));
|
||||
if (iter == last)
|
||||
break;
|
||||
|
||||
last_esc = std::prev(iter);
|
||||
while (last_esc != begin && *last_esc == '\\')
|
||||
--last_esc;
|
||||
} while (!(std::distance(last_esc, iter) % 2) && iter != last);
|
||||
if (iter == last)
|
||||
throw std::runtime_error{"quote was opened but not closed."};
|
||||
return iter;
|
||||
};
|
||||
|
||||
auto end_word = [&whitespaces](IterT iter, const IterT &last) -> IterT
|
||||
{
|
||||
const auto begin = iter;
|
||||
auto last_esc = iter;
|
||||
if (iter == last)
|
||||
throw std::runtime_error{"quote was opened but not closed."};
|
||||
do
|
||||
{
|
||||
++iter;
|
||||
iter = std::find_first_of(iter, last, std::begin(whitespaces),
|
||||
std::end(whitespaces));
|
||||
if (iter == last)
|
||||
break;
|
||||
|
||||
last_esc = std::prev(iter);
|
||||
while (last_esc != begin && *last_esc == '\\')
|
||||
--last_esc;
|
||||
} while (!(std::distance(last_esc, iter) % 2) && iter != last);
|
||||
if (iter == last)
|
||||
throw std::runtime_error{"word wasnt properly ended"};
|
||||
return iter;
|
||||
};
|
||||
|
||||
auto skip_whitespaces = [&whitespaces](IterT iter,
|
||||
const IterT &last) -> IterT
|
||||
{
|
||||
if (iter == last)
|
||||
return iter;
|
||||
iter = std::find_if_not(iter, last,
|
||||
[&whitespaces](charT c)
|
||||
{
|
||||
// return true if whitespace
|
||||
return std::any_of(std::begin(whitespaces),
|
||||
std::end(whitespaces),
|
||||
[c](charT pc)
|
||||
{ return pc == c; });
|
||||
});
|
||||
return iter;
|
||||
};
|
||||
|
||||
std::function<void(std::basic_string<charT> &)> strip_escape_symbols =
|
||||
[](std::basic_string<charT> &s)
|
||||
{
|
||||
auto quote_searcher = [&s](size_t pos)
|
||||
{ return s.find(TYTI_L(charT, "\\\""), pos); };
|
||||
auto p = quote_searcher(0);
|
||||
while (p != s.npos)
|
||||
{
|
||||
s.replace(p, 2, TYTI_L(charT, "\""));
|
||||
p = quote_searcher(p);
|
||||
}
|
||||
auto searcher = [&s](size_t pos)
|
||||
{ return s.find(TYTI_L(charT, "\\\\"), pos); };
|
||||
p = searcher(0);
|
||||
while (p != s.npos)
|
||||
{
|
||||
s.replace(p, 2, TYTI_L(charT, "\\"));
|
||||
p = searcher(p);
|
||||
}
|
||||
};
|
||||
|
||||
if (!opt.strip_escape_symbols)
|
||||
strip_escape_symbols = [](std::basic_string<charT> &) {};
|
||||
|
||||
auto conditional_fullfilled =
|
||||
[&skip_whitespaces, &is_platform_str](IterT &iter, const IterT &last)
|
||||
{
|
||||
iter = skip_whitespaces(iter, last);
|
||||
if (iter == last)
|
||||
return true;
|
||||
if (*iter == '[')
|
||||
{
|
||||
++iter;
|
||||
if (iter == last)
|
||||
throw std::runtime_error("conditional not closed");
|
||||
const auto end = std::find(iter, last, ']');
|
||||
if (end == last)
|
||||
throw std::runtime_error("conditional not closed");
|
||||
const bool negate = *iter == '!';
|
||||
if (negate)
|
||||
++iter;
|
||||
auto conditional = std::basic_string<charT>(iter, end);
|
||||
|
||||
const bool is_platform = is_platform_str(conditional);
|
||||
iter = end + 1;
|
||||
|
||||
return static_cast<bool>(is_platform ^ negate);
|
||||
}
|
||||
return true;
|
||||
};
|
||||
|
||||
// read header
|
||||
// first, quoted name
|
||||
std::unique_ptr<OutputT> curObj = nullptr;
|
||||
std::vector<std::unique_ptr<OutputT>> roots;
|
||||
std::stack<std::unique_ptr<OutputT>> lvls;
|
||||
auto curIter = first;
|
||||
|
||||
while (curIter != last && *curIter != '\0')
|
||||
{
|
||||
// find first starting attrib/child, or ending
|
||||
curIter = skip_whitespaces(curIter, last);
|
||||
if (curIter == last || *curIter == '\0')
|
||||
break;
|
||||
if (*curIter == TYTI_L(charT, '/'))
|
||||
{
|
||||
curIter = skip_comments(curIter, last);
|
||||
if (curIter == last || *curIter == '\0')
|
||||
throw std::runtime_error("Unexpected eof");
|
||||
}
|
||||
else if (*curIter != TYTI_L(charT, '}'))
|
||||
{
|
||||
// get key
|
||||
const auto keyEnd = (*curIter == TYTI_L(charT, '\"'))
|
||||
? end_quote(curIter, last)
|
||||
: end_word(curIter, last);
|
||||
if (*curIter == TYTI_L(charT, '\"'))
|
||||
++curIter;
|
||||
std::basic_string<charT> key(curIter, keyEnd);
|
||||
strip_escape_symbols(key);
|
||||
curIter = keyEnd + ((*keyEnd == TYTI_L(charT, '\"')) ? 1 : 0);
|
||||
if (curIter == last)
|
||||
throw std::runtime_error{"key opened, but never closed"};
|
||||
|
||||
curIter = skip_whitespaces(curIter, last);
|
||||
|
||||
if (!conditional_fullfilled(curIter, last))
|
||||
continue;
|
||||
if (curIter == last)
|
||||
throw std::runtime_error{"key declared, but no value"};
|
||||
|
||||
while (*curIter == TYTI_L(charT, '/'))
|
||||
{
|
||||
|
||||
curIter = skip_comments(curIter, last);
|
||||
if (curIter == last || *curIter == '}')
|
||||
throw std::runtime_error{"key declared, but no value"};
|
||||
curIter = skip_whitespaces(curIter, last);
|
||||
if (curIter == last || *curIter == '}')
|
||||
throw std::runtime_error{"key declared, but no value"};
|
||||
}
|
||||
// get value
|
||||
if (*curIter != '{')
|
||||
{
|
||||
if (curIter == last)
|
||||
throw std::runtime_error{"key declared, but no value"};
|
||||
const auto valueEnd = (*curIter == TYTI_L(charT, '\"'))
|
||||
? end_quote(curIter, last)
|
||||
: end_word(curIter, last);
|
||||
if (valueEnd == last)
|
||||
throw std::runtime_error("No closed word");
|
||||
if (*curIter == TYTI_L(charT, '\"'))
|
||||
++curIter;
|
||||
if (curIter == last)
|
||||
throw std::runtime_error("No closed word");
|
||||
|
||||
auto value = std::basic_string<charT>(curIter, valueEnd);
|
||||
strip_escape_symbols(value);
|
||||
curIter =
|
||||
valueEnd + ((*valueEnd == TYTI_L(charT, '\"')) ? 1 : 0);
|
||||
|
||||
if (!conditional_fullfilled(curIter, last))
|
||||
continue;
|
||||
|
||||
// process value
|
||||
if (key != TYTI_L(charT, "#include") &&
|
||||
key != TYTI_L(charT, "#base"))
|
||||
{
|
||||
if (curObj)
|
||||
{
|
||||
curObj->add_attribute(std::move(key), std::move(value));
|
||||
}
|
||||
else
|
||||
{
|
||||
throw std::runtime_error{
|
||||
"unexpected key without object"};
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!opt.ignore_includes &&
|
||||
exclude_files.find(value) == exclude_files.end())
|
||||
{
|
||||
exclude_files.insert(value);
|
||||
std::basic_ifstream<charT> i(
|
||||
detail::string_converter(value));
|
||||
auto str = read_file(i);
|
||||
auto file_objs = read_internal<OutputT>(
|
||||
str.begin(), str.end(), exclude_files, opt);
|
||||
for (auto &n : file_objs)
|
||||
{
|
||||
if (curObj)
|
||||
curObj->add_child(std::move(n));
|
||||
else
|
||||
roots.push_back(std::move(n));
|
||||
}
|
||||
exclude_files.erase(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (*curIter == '{')
|
||||
{
|
||||
if (curObj)
|
||||
lvls.push(std::move(curObj));
|
||||
curObj = std::make_unique<OutputT>();
|
||||
curObj->set_name(std::move(key));
|
||||
++curIter;
|
||||
}
|
||||
}
|
||||
// end of new object
|
||||
else if (curObj && *curIter == TYTI_L(charT, '}'))
|
||||
{
|
||||
if (!lvls.empty())
|
||||
{
|
||||
// get object before
|
||||
std::unique_ptr<OutputT> prev{std::move(lvls.top())};
|
||||
lvls.pop();
|
||||
|
||||
// add finished obj to obj before and release it from processing
|
||||
prev->add_child(std::move(curObj));
|
||||
curObj = std::move(prev);
|
||||
}
|
||||
else
|
||||
{
|
||||
roots.push_back(std::move(curObj));
|
||||
curObj.reset();
|
||||
}
|
||||
++curIter;
|
||||
}
|
||||
else
|
||||
{
|
||||
throw std::runtime_error{"unexpected '}'"};
|
||||
}
|
||||
}
|
||||
if (curObj != nullptr || !lvls.empty())
|
||||
{
|
||||
throw std::runtime_error{"object is not closed with '}'"};
|
||||
}
|
||||
|
||||
return roots;
|
||||
}
|
||||
|
||||
} // namespace detail
|
||||
|
||||
/** \brief Read VDF formatted sequences defined by the range [first, last).
|
||||
If the file is mailformatted, parser will try to read it until it can.
|
||||
@param first begin iterator
|
||||
@param end end iterator
|
||||
|
||||
can thow:
|
||||
- "std::runtime_error" if a parsing error occured
|
||||
- "std::bad_alloc" if not enough memory coup be allocated
|
||||
*/
|
||||
template <typename OutputT, typename IterT>
|
||||
OutputT read(IterT first, const IterT last, const Options &opt = Options{})
|
||||
{
|
||||
auto exclude_files = std::unordered_set<
|
||||
std::basic_string<typename std::iterator_traits<IterT>::value_type>>{};
|
||||
auto roots =
|
||||
detail::read_internal<OutputT>(first, last, exclude_files, opt);
|
||||
|
||||
OutputT result;
|
||||
if (roots.size() > 1)
|
||||
{
|
||||
for (auto &i : roots)
|
||||
result.add_child(std::move(i));
|
||||
}
|
||||
else if (roots.size() == 1)
|
||||
result = std::move(*roots[0]);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/** \brief Read VDF formatted sequences defined by the range [first, last).
|
||||
If the file is mailformatted, parser will try to read it until it can.
|
||||
@param first begin iterator
|
||||
@param end end iterator
|
||||
@param ec output bool. 0 if ok, otherwise, holds an system error code
|
||||
|
||||
Possible error codes:
|
||||
std::errc::protocol_error: file is mailformatted
|
||||
std::errc::not_enough_memory: not enough space
|
||||
std::errc::invalid_argument: iterators throws e.g. out of range
|
||||
*/
|
||||
template <typename OutputT, typename IterT>
|
||||
OutputT read(IterT first, IterT last, std::error_code &ec,
|
||||
const Options &opt = Options{}) NOEXCEPT
|
||||
|
||||
{
|
||||
ec.clear();
|
||||
OutputT r{};
|
||||
try
|
||||
{
|
||||
r = read<OutputT>(first, last, opt);
|
||||
}
|
||||
catch (std::runtime_error &)
|
||||
{
|
||||
ec = std::make_error_code(std::errc::protocol_error);
|
||||
}
|
||||
catch (std::bad_alloc &)
|
||||
{
|
||||
ec = std::make_error_code(std::errc::not_enough_memory);
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
ec = std::make_error_code(std::errc::invalid_argument);
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
||||
/** \brief Read VDF formatted sequences defined by the range [first, last).
|
||||
If the file is mailformatted, parser will try to read it until it can.
|
||||
@param first begin iterator
|
||||
@param end end iterator
|
||||
@param ok output bool. true, if parser successed, false, if parser failed
|
||||
*/
|
||||
template <typename OutputT, typename IterT>
|
||||
OutputT read(IterT first, const IterT last, bool *ok,
|
||||
const Options &opt = Options{}) NOEXCEPT
|
||||
{
|
||||
std::error_code ec;
|
||||
auto r = read<OutputT>(first, last, ec, opt);
|
||||
if (ok)
|
||||
*ok = !ec;
|
||||
return r;
|
||||
}
|
||||
|
||||
template <typename IterT>
|
||||
inline auto read(IterT first, const IterT last, bool *ok,
|
||||
const Options &opt = Options{}) NOEXCEPT
|
||||
-> basic_object<typename std::iterator_traits<IterT>::value_type>
|
||||
{
|
||||
return read<basic_object<typename std::iterator_traits<IterT>::value_type>>(
|
||||
first, last, ok, opt);
|
||||
}
|
||||
|
||||
template <typename IterT>
|
||||
inline auto read(IterT first, IterT last, std::error_code &ec,
|
||||
const Options &opt = Options{}) NOEXCEPT
|
||||
-> basic_object<typename std::iterator_traits<IterT>::value_type>
|
||||
{
|
||||
return read<basic_object<typename std::iterator_traits<IterT>::value_type>>(
|
||||
first, last, ec, opt);
|
||||
}
|
||||
|
||||
template <typename IterT>
|
||||
inline auto read(IterT first, const IterT last, const Options &opt = Options{})
|
||||
-> basic_object<typename std::iterator_traits<IterT>::value_type>
|
||||
{
|
||||
return read<basic_object<typename std::iterator_traits<IterT>::value_type>>(
|
||||
first, last, opt);
|
||||
}
|
||||
|
||||
/** \brief Loads a stream (e.g. filestream) into the memory and parses the vdf
|
||||
formatted data. throws "std::bad_alloc" if file buffer could not be allocated
|
||||
*/
|
||||
template <typename OutputT, typename iStreamT>
|
||||
OutputT read(iStreamT &inStream, std::error_code &ec,
|
||||
const Options &opt = Options{})
|
||||
{
|
||||
// cache the file
|
||||
typedef typename iStreamT::char_type charT;
|
||||
std::basic_string<charT> str = detail::read_file(inStream);
|
||||
|
||||
// parse it
|
||||
return read<OutputT>(str.begin(), str.end(), ec, opt);
|
||||
}
|
||||
|
||||
template <typename iStreamT>
|
||||
inline basic_object<typename iStreamT::char_type>
|
||||
read(iStreamT &inStream, std::error_code &ec, const Options &opt = Options{})
|
||||
{
|
||||
return read<basic_object<typename iStreamT::char_type>>(inStream, ec, opt);
|
||||
}
|
||||
|
||||
/** \brief Loads a stream (e.g. filestream) into the memory and parses the vdf
|
||||
formatted data. throws "std::bad_alloc" if file buffer could not be allocated
|
||||
ok == false, if a parsing error occured
|
||||
*/
|
||||
template <typename OutputT, typename iStreamT>
|
||||
OutputT read(iStreamT &inStream, bool *ok, const Options &opt = Options{})
|
||||
{
|
||||
std::error_code ec;
|
||||
const auto r = read<OutputT>(inStream, ec, opt);
|
||||
if (ok)
|
||||
*ok = !ec;
|
||||
return r;
|
||||
}
|
||||
|
||||
template <typename iStreamT>
|
||||
inline basic_object<typename iStreamT::char_type>
|
||||
read(iStreamT &inStream, bool *ok, const Options &opt = Options{})
|
||||
{
|
||||
return read<basic_object<typename iStreamT::char_type>>(inStream, ok, opt);
|
||||
}
|
||||
|
||||
/** \brief Loads a stream (e.g. filestream) into the memory and parses the vdf
|
||||
formatted data. throws "std::bad_alloc" if file buffer could not be allocated
|
||||
throws "std::runtime_error" if a parsing error occured
|
||||
*/
|
||||
template <typename OutputT, typename iStreamT>
|
||||
OutputT read(iStreamT &inStream, const Options &opt)
|
||||
{
|
||||
|
||||
// cache the file
|
||||
typedef typename iStreamT::char_type charT;
|
||||
std::basic_string<charT> str = detail::read_file(inStream);
|
||||
// parse it
|
||||
return read<OutputT>(str.begin(), str.end(), opt);
|
||||
}
|
||||
|
||||
template <typename iStreamT>
|
||||
inline basic_object<typename iStreamT::char_type>
|
||||
read(iStreamT &inStream, const Options &opt = Options{})
|
||||
{
|
||||
return read<basic_object<typename iStreamT::char_type>>(inStream, opt);
|
||||
}
|
||||
|
||||
} // namespace vdf
|
||||
} // namespace tyti
|
||||
#ifndef TYTI_NO_L_UNDEF
|
||||
#undef TYTI_L
|
||||
#endif
|
||||
|
||||
#ifdef TYTI_UNDEF_CONSTEXPR
|
||||
#undef CONSTEXPR
|
||||
#undef TYTI_NO_L_UNDEF
|
||||
#endif
|
||||
|
||||
#ifdef TYTI_UNDEF_NOTHROW
|
||||
#undef NOTHROW
|
||||
#undef TYTI_UNDEF_NOTHROW
|
||||
#endif
|
||||
|
||||
#endif //__TYTI_STEAM_VDF_PARSER_H__
|
42
3rdparty/ValveFileVDF/python/CMakeLists.txt
vendored
Normal file
42
3rdparty/ValveFileVDF/python/CMakeLists.txt
vendored
Normal file
@ -0,0 +1,42 @@
|
||||
cmake_minimum_required (VERSION 3.11.2018)
|
||||
project (vdf-Python)
|
||||
|
||||
set(CMAKE_INCLUDE_CURRENT_DIR ON)
|
||||
|
||||
find_package(Git REQUIRED)
|
||||
find_package(Python COMPONENTS Interpreter Development)
|
||||
|
||||
option(DOWNLOAD_PYBIND11 "Download PyBind11. (Requires Git)" ${Git_FOUND})
|
||||
|
||||
set(PYBIND11_PATH "${CMAKE_BINARY_DIR}/pybind11" CACHE FILEPATH "Path to pybind11")
|
||||
if (${DOWNLOAD_PYBIND11})
|
||||
#include(ExternalProject)
|
||||
set (_GIT_CMD "clone")
|
||||
if (EXISTS ${PYBIND11_PATH})
|
||||
message(STATUS "pull pybind11")
|
||||
execute_process(COMMAND ${GIT_EXECUTABLE} pull
|
||||
WORKING_DIRECTORY "${PYBIND11_PATH}")
|
||||
else()
|
||||
message(STATUS "clone pybind11")
|
||||
execute_process(COMMAND ${GIT_EXECUTABLE} ${_GIT_CMD} https://github.com/pybind/pybind11.git ${PYBIND11_PATH}
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if (NOT EXISTS ${PYBIND11_PATH}/CMakeLists.txt)
|
||||
message(FATAL_ERROR "Could not found pybind11.\n Please specify PYBIND11_PATH or check DOWNLOAD_PYBIND11")
|
||||
endif()
|
||||
|
||||
add_subdirectory(${PYBIND11_PATH})
|
||||
pybind11_add_module(vdf "../vdf_parser.hpp;vdf_python_bindings.cpp;Readme.md")
|
||||
target_link_libraries(vdf PRIVATE Python::Python ValveFileVDF)
|
||||
|
||||
|
||||
## add tests
|
||||
include(CTest)
|
||||
if (BUILD_TESTING)
|
||||
add_test(NAME vdf_python_test COMMAND ${Python_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/test.py WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/../tests/testdata")
|
||||
set(ppath $ENV{PYTHONPATH})
|
||||
LIST(APPEND ppath "$<TARGET_FILE_DIR:vdf>")
|
||||
set_tests_properties(vdf_python_test PROPERTIES ENVIRONMENT "PYTHONPATH=${ppath}" DEPENDS vdf)
|
||||
endif()
|
18
3rdparty/ValveFileVDF/python/Readme.md
vendored
Normal file
18
3rdparty/ValveFileVDF/python/Readme.md
vendored
Normal file
@ -0,0 +1,18 @@
|
||||
# Python Interface
|
||||
|
||||
Adds a simple interface for Python.
|
||||
Use CMake (>=3.12) to build the .pyd file.
|
||||
|
||||
Interface may change in the future.
|
||||
|
||||
Module Example:
|
||||
```python
|
||||
import vdf
|
||||
|
||||
mydict = vdf.read_file("test_file.vdf")
|
||||
#mydict is a standard dictionary
|
||||
|
||||
value = mydict[key]
|
||||
|
||||
mydict2 = vdf.read("vdf_file{"key":"value"}")
|
||||
```
|
15
3rdparty/ValveFileVDF/python/test.py
vendored
Normal file
15
3rdparty/ValveFileVDF/python/test.py
vendored
Normal file
@ -0,0 +1,15 @@
|
||||
import unittest
|
||||
import vdf
|
||||
|
||||
class MyTest(unittest.TestCase):
|
||||
|
||||
def test_read_file(self):
|
||||
d = vdf.read_file("DST_Manifest.acf")
|
||||
self.assertEqual(d["appid"], "343050")
|
||||
self.assertEqual(d["UserConfig"], {})
|
||||
self.assertEqual(len(d["MountedDepots"]), 1)
|
||||
self.assertEqual(d["another attribute with fancy space"], "yay")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
47
3rdparty/ValveFileVDF/python/vdf_python_bindings.cpp
vendored
Normal file
47
3rdparty/ValveFileVDF/python/vdf_python_bindings.cpp
vendored
Normal file
@ -0,0 +1,47 @@
|
||||
#include "vdf_parser.hpp"
|
||||
#include <fstream>
|
||||
#include <string>
|
||||
|
||||
#include <pybind11/pybind11.h>
|
||||
#include <pybind11/stl_bind.h>
|
||||
|
||||
namespace py = pybind11;
|
||||
|
||||
struct python_object
|
||||
{
|
||||
py::dict dict;
|
||||
std::string name;
|
||||
|
||||
void add_attribute(std::string key, std::string value)
|
||||
{
|
||||
dict[py::cast(std::move(key))] = py::cast(std::move(value));
|
||||
}
|
||||
void add_child(std::unique_ptr< python_object > child)
|
||||
{
|
||||
std::string n = std::move(child->name);
|
||||
dict[py::cast(n)] = std::move(child->dict);
|
||||
}
|
||||
void set_name(std::string n)
|
||||
{
|
||||
name = std::move(n);
|
||||
}
|
||||
};
|
||||
|
||||
py::dict py_read_file(const char* filename)
|
||||
{
|
||||
std::ifstream input(filename);
|
||||
return tyti::vdf::read<python_object>(input).dict;
|
||||
}
|
||||
|
||||
py::dict py_read(const std::string& filename)
|
||||
{
|
||||
return tyti::vdf::read<python_object>(std::begin(filename), std::end(filename)).dict;
|
||||
}
|
||||
|
||||
PYBIND11_MODULE(vdf, m)
|
||||
{
|
||||
m.doc() = "Read and Write Valve's vdf files.";
|
||||
|
||||
m.def("read", &py_read, "Read vdf from memory");
|
||||
m.def("read_file", &py_read_file, "Read vdf file");
|
||||
}
|
26
3rdparty/ValveFileVDF/tests/CMakeLists.txt
vendored
Normal file
26
3rdparty/ValveFileVDF/tests/CMakeLists.txt
vendored
Normal file
@ -0,0 +1,26 @@
|
||||
|
||||
set(SRCS
|
||||
"main.cpp"
|
||||
"vdf_parser_test.cpp"
|
||||
"../Readme.md")
|
||||
|
||||
add_executable(tests ${SRCS})
|
||||
set_property(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY VS_STARTUP_PROJECT tests) #requires cmake 3.6
|
||||
set_property(TARGET tests PROPERTY COMPILE_WARNING_AS_ERROR ON)
|
||||
add_definitions("-DSOURCE_DIR=\"${CMAKE_CURRENT_SOURCE_DIR}\"")
|
||||
target_compile_features(tests PUBLIC cxx_std_17)
|
||||
target_link_libraries(tests PRIVATE ValveFileVDF)
|
||||
|
||||
target_compile_options(tests PRIVATE
|
||||
$<$<OR:$<CXX_COMPILER_ID:Clang>,$<CXX_COMPILER_ID:AppleClang>,$<CXX_COMPILER_ID:GNU>>:
|
||||
-Wall -Wextra -Wconversion -pedantic-errors -Wsign-conversion>
|
||||
$<$<CXX_COMPILER_ID:MSVC>:
|
||||
/W4>)
|
||||
|
||||
if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
|
||||
target_link_libraries(tests PUBLIC -fsanitize=address,undefined)
|
||||
endif()
|
||||
|
||||
if (BUILD_TESTING)
|
||||
add_test(NAME vdf_tests COMMAND tests)
|
||||
endif()
|
7106
3rdparty/ValveFileVDF/tests/doctest.h
vendored
Normal file
7106
3rdparty/ValveFileVDF/tests/doctest.h
vendored
Normal file
File diff suppressed because it is too large
Load Diff
35
3rdparty/ValveFileVDF/tests/main.cpp
vendored
Normal file
35
3rdparty/ValveFileVDF/tests/main.cpp
vendored
Normal file
@ -0,0 +1,35 @@
|
||||
#define DOCTEST_CONFIG_IMPLEMENT
|
||||
#include "doctest.h"
|
||||
#include <iostream>
|
||||
|
||||
const char *testdata_dir = SOURCE_DIR "/testdata/";
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <direct.h>
|
||||
#define cwd _getcwd
|
||||
#define cd _chdir
|
||||
#else
|
||||
#include "unistd.h"
|
||||
#define cwd getcwd
|
||||
#define cd chdir
|
||||
#endif
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
|
||||
doctest::Context context;
|
||||
context.applyCommandLine(argc, argv);
|
||||
|
||||
if (cd(testdata_dir) != 0)
|
||||
{
|
||||
std::cerr << "Cannot set working directory to " << testdata_dir
|
||||
<< std::endl;
|
||||
return 1;
|
||||
}
|
||||
|
||||
int result = context.run();
|
||||
|
||||
// your clean-up...
|
||||
|
||||
return result;
|
||||
}
|
52
3rdparty/ValveFileVDF/tests/testdata/DST_Manifest.acf
vendored
Normal file
52
3rdparty/ValveFileVDF/tests/testdata/DST_Manifest.acf
vendored
Normal file
@ -0,0 +1,52 @@
|
||||
"#base" "baseFile1.vdf"
|
||||
|
||||
//simple check
|
||||
"AppState"
|
||||
{
|
||||
"appid" "343050"
|
||||
"Universe" "1"
|
||||
"name" "Don't Starve Together Dedicated Server"
|
||||
"StateFlags" "4"
|
||||
"installdir" "Don't Starve Together Dedicated Server"
|
||||
"LastUpdated" "1462118047"
|
||||
"UpdateResult" "0"
|
||||
"UpdateResult" "1"
|
||||
no_quoted_attrib_support yes
|
||||
"SizeOnDisk" "663289971"
|
||||
"buildid" "1101428"
|
||||
"LastOwner" "76561198937928833"
|
||||
"BytesToDownload" "39029520"
|
||||
"BytesDownloaded" "39029520"
|
||||
"AutoUpdateBehavior" "0"
|
||||
"AllowOtherDownloadsWhileRunning" "0"
|
||||
"#include" "includeFile1.vdf"
|
||||
"#base" "baseFile1.vdf"
|
||||
"#1_attrib" "1"
|
||||
"emptyAttrib" ""
|
||||
"commentInValue" "no//comment"
|
||||
"escape_quote" "\"quote\""
|
||||
"escape_quote_backslash" "quote_with_other_escapes\\\"\\"
|
||||
"tab_escape" "new\ttab"
|
||||
"new_line_escape" "new\nline"
|
||||
|
||||
"conditional" "macos" [$OSX]
|
||||
"conditional" "not osx" [!$OSX]
|
||||
|
||||
// inline comment
|
||||
"UserConfig"
|
||||
{
|
||||
}
|
||||
|
||||
// comment with a "quote"
|
||||
"MountedDepots"
|
||||
{
|
||||
"343051" "8201905585059905072"
|
||||
}
|
||||
"another attribute with fancy space" "yay"
|
||||
|
||||
/* super
|
||||
block
|
||||
comment
|
||||
*/
|
||||
|
||||
}
|
7
3rdparty/ValveFileVDF/tests/testdata/baseFile1.vdf
vendored
Normal file
7
3rdparty/ValveFileVDF/tests/testdata/baseFile1.vdf
vendored
Normal file
@ -0,0 +1,7 @@
|
||||
"BaseInclude"
|
||||
{
|
||||
// skip comment
|
||||
"BaseAttrib" "Yes"
|
||||
"#base" "baseFile1.vdf"
|
||||
"#include" "includeFile1.vdf"
|
||||
}
|
BIN
3rdparty/ValveFileVDF/tests/testdata/broken_file.acf
vendored
Normal file
BIN
3rdparty/ValveFileVDF/tests/testdata/broken_file.acf
vendored
Normal file
Binary file not shown.
1
3rdparty/ValveFileVDF/tests/testdata/fuzzing_data/crash-1
vendored
Normal file
1
3rdparty/ValveFileVDF/tests/testdata/fuzzing_data/crash-1
vendored
Normal file
@ -0,0 +1 @@
|
||||
f*/*<2A><><EFBFBD><EFBFBD>/<0C>
|
BIN
3rdparty/ValveFileVDF/tests/testdata/fuzzing_data/crash-2
vendored
Normal file
BIN
3rdparty/ValveFileVDF/tests/testdata/fuzzing_data/crash-2
vendored
Normal file
Binary file not shown.
BIN
3rdparty/ValveFileVDF/tests/testdata/fuzzing_data/crash-3
vendored
Normal file
BIN
3rdparty/ValveFileVDF/tests/testdata/fuzzing_data/crash-3
vendored
Normal file
Binary file not shown.
3
3rdparty/ValveFileVDF/tests/testdata/fuzzing_data/timeout-1
vendored
Normal file
3
3rdparty/ValveFileVDF/tests/testdata/fuzzing_data/timeout-1
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
-<2D>
|
||||
/
|
||||
{
|
4
3rdparty/ValveFileVDF/tests/testdata/includeFile1.vdf
vendored
Normal file
4
3rdparty/ValveFileVDF/tests/testdata/includeFile1.vdf
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
"IncludedStuff"
|
||||
{
|
||||
"#include" "baseFile1.vdf"
|
||||
}
|
249
3rdparty/ValveFileVDF/tests/testdata/issue14.vdf
vendored
Normal file
249
3rdparty/ValveFileVDF/tests/testdata/issue14.vdf
vendored
Normal file
@ -0,0 +1,249 @@
|
||||
"InstallConfigStore"
|
||||
{
|
||||
"SDL_GamepadBind" "03000000de280000ff11000001000000,Steam Virtual Gamepad,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b8,lefttrigger:+a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b9,righttrigger:-a2,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Windows\n03000000de280000ff11000000000000,Steam Virtual Gamepad,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b8,lefttrigger:+a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b9,righttrigger:-a2,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Windows\n03000000de280000ff11000000007701,Steam Virtual Gamepad,a:b0,b:b1,x:b2,y:b3,back:b6,start:b7,leftstick:b8,rightstick:b9,leftshoulder:b4,rightshoulder:b5,dpup:b10,dpdown:b12,dpleft:b13,dpright:b11,leftx:a1,lefty:a0~,rightx:a3,righty:a2~,lefttrigger:a4,righttrigger:a5,"
|
||||
"Software"
|
||||
{
|
||||
"Valve"
|
||||
{
|
||||
"Steam"
|
||||
{
|
||||
"MTBF" "917051485"
|
||||
"AutoUpdateWindowEnabled" "0"
|
||||
"SurveyDateType" "3"
|
||||
"ipv6check_http_state" "bad"
|
||||
"RecentWebSocketNon443Failures" ""
|
||||
"ipv6check_udp_state" "bad"
|
||||
"RecentWebSocket443Failures" "1685436844,1685577986,1685578002,1685578049,1685578301"
|
||||
"RecentTCPFailures" ""
|
||||
"RecentUDPFailures" ""
|
||||
"CellIDServerOverride" "159"
|
||||
"SurveyDate" "2018-01-31"
|
||||
"cip" "02000000c3566e9d751d6cc90000b0e47803"
|
||||
"SurveyDateVersion" "3972811748885790880"
|
||||
"Rate" "10000"
|
||||
"RecentDownloadRate" "37459893"
|
||||
"Perf"
|
||||
{
|
||||
"GameProfiles"
|
||||
{
|
||||
"Global"
|
||||
{
|
||||
"0"
|
||||
{
|
||||
"0" ""
|
||||
}
|
||||
}
|
||||
"App"
|
||||
{
|
||||
"769"
|
||||
{
|
||||
"0"
|
||||
{
|
||||
"0" ""
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
"ConnectCache"
|
||||
{
|
||||
"3ff7c4de1" "02000000e5612ff4115500bebac017645b06a4ebb83298f6785562b389066712606bca0249a631118b1e2532426086a8dba72489fa63341526aa1606e2e9df214a06f9538817aaf57a553d22dd1638650dcc2ab62de0a60b10c3b04e8f774829194960cd1165ed8be5450da966830e49d840da6980da1a08615a0b9bfca43287460be4fecd37d3f4362ba675eb342fee5a341cb9b700113cb9c199e085a7ba9d3c3072e59f4f0700959fb31870637f54dba060916431a5b911d172c7f78464035e41761edc038218ab7ab07aac52d6fe1bea5f3decce506de9164d090d86c46452bfc947a714142afbad0add32be88ff800355d244d6794a173db5248c255b487f9f418ad21c42955e54a69a2c7d96cf39acef319cd862b67cc255967e5e7a9c978e99e3c64cebdb34dc12f1689f2d63a6f3a737100f521fd31b59c495e790f72d2148808bf2aeee5222af3f143e5410b5a17665e1b308bc3e86af4a0fb1d113c66cc44f625368255c5410104586fac9f3f2a4bf788526e48dfeb186b123b1500ff47f71bd798b3719c3917cecf7b4b6afac54960ca637ab78ff55009091b88891679c9476a9a98ee3461ef2ea1937bdacd4e45a62ec9067d820517925c1e4405375ad88a4b74c814368f498d24591fa87dfbc153ef84c0cfaf72dc8c3f243e7f6529e2f296dfd35839ecd0d427700b7f31fb3"
|
||||
}
|
||||
"ShaderCacheManager"
|
||||
{
|
||||
"CurrentBucketDriver" ""
|
||||
"CurrentBucketGPU" ""
|
||||
"HasCurrentBucket" "1"
|
||||
"EnableShaderBackgroundProcessing" "0"
|
||||
}
|
||||
"CMWebSocket"
|
||||
{
|
||||
"ext4-ord.steamserver.net:443"
|
||||
{
|
||||
"LastPingTimestamp" "1685578300"
|
||||
"LastLoadValue" "0"
|
||||
"LastPingValue" "100000"
|
||||
}
|
||||
"ext6-iad1.steamserver.net.:443"
|
||||
{
|
||||
"LastPingTimestamp" "0"
|
||||
}
|
||||
"ext2-ord.steamserver.net:27021"
|
||||
{
|
||||
"LastPingTimestamp" "1685578048"
|
||||
"LastPingValue" "100000"
|
||||
"LastLoadValue" "0"
|
||||
}
|
||||
"ext2-lax1.steamserver.net:443"
|
||||
{
|
||||
"LastPingTimestamp" "0"
|
||||
}
|
||||
"ext1-lax1.steamserver.net:443"
|
||||
{
|
||||
"LastPingTimestamp" "0"
|
||||
}
|
||||
"ext3-ord.steamserver.net:27021"
|
||||
{
|
||||
"LastPingTimestamp" "0"
|
||||
}
|
||||
"ext6-iad1.steamserver.net.:27021"
|
||||
{
|
||||
"LastPingTimestamp" "0"
|
||||
}
|
||||
"ext4-ord.steamserver.net:27021"
|
||||
{
|
||||
"LastPingTimestamp" "0"
|
||||
}
|
||||
"ext2-ord.steamserver.net:443"
|
||||
{
|
||||
"LastPingTimestamp" "0"
|
||||
}
|
||||
"ext1-ord.steamserver.net:443"
|
||||
{
|
||||
"LastPingTimestamp" "1685578002"
|
||||
"LastPingValue" "100000"
|
||||
"LastLoadValue" "0"
|
||||
}
|
||||
"ext2-lax1.steamserver.net:27021"
|
||||
{
|
||||
"LastPingTimestamp" "1685578301"
|
||||
"LastLoadValue" "25"
|
||||
"LastPingValue" "221"
|
||||
}
|
||||
"ext1-ord.steamserver.net:27021"
|
||||
{
|
||||
"LastPingTimestamp" "1685578300"
|
||||
"LastLoadValue" "0"
|
||||
"LastPingValue" "100000"
|
||||
}
|
||||
"ext1-lax1.steamserver.net:27021"
|
||||
{
|
||||
"LastPingTimestamp" "0"
|
||||
}
|
||||
"ext5-iad1.steamserver.net:27021"
|
||||
{
|
||||
"LastPingTimestamp" "1685578049"
|
||||
"LastLoadValue" "30"
|
||||
"LastPingValue" "307"
|
||||
}
|
||||
"ext5-iad1.steamserver.net:443"
|
||||
{
|
||||
"LastPingTimestamp" "0"
|
||||
}
|
||||
"ext3-ord.steamserver.net:443"
|
||||
{
|
||||
"LastPingTimestamp" "0"
|
||||
}
|
||||
}
|
||||
"Accounts"
|
||||
{
|
||||
"lixi442860990"
|
||||
{
|
||||
"SteamID" "76561198312248332"
|
||||
}
|
||||
}
|
||||
"depots"
|
||||
{
|
||||
"1426216"
|
||||
{
|
||||
"DecryptionKey" "e3bcedc8dde41929d61cf843016c562bda456120c67062bcf59fae4a11eb4b4f"
|
||||
}
|
||||
"1503452"
|
||||
{
|
||||
"DecryptionKey" "6219cf8e1233e7672147221b611f54e26c64541d48f653a3fd8c429fac86fa84"
|
||||
}
|
||||
"880941"
|
||||
{
|
||||
"DecryptionKey" "ce9aa368e895b19d481941c1bc33d93fa1b495f6046caeee282580a6eac1a99c"
|
||||
}
|
||||
"1426213"
|
||||
{
|
||||
"DecryptionKey" "f00c27168f613be65a380acbe6b2666daf9b554f4aa1183dfe34db8d972a7e22"
|
||||
}
|
||||
"1203221"
|
||||
{
|
||||
"DecryptionKey" "788b93ea9ea92552d334bdb7fa9caf5f21f98dded4a670c54926bf0a2bd1d74f"
|
||||
}
|
||||
"1426211"
|
||||
{
|
||||
"DecryptionKey" "c450c44e032e27d0308cf864259fb2af91bcfc58401a0caf33bb8efba85bb323"
|
||||
}
|
||||
"1426212"
|
||||
{
|
||||
"DecryptionKey" "99090c0728bfb9251f59c85c9f06484721d78edc05c8ae341ec5c9467a1f5a1d"
|
||||
}
|
||||
"1426214"
|
||||
{
|
||||
"DecryptionKey" "3ee79053f80ab473ad36bdd01364181fe32c56004ed1bc42571d745dd4b8a107"
|
||||
}
|
||||
"1426215"
|
||||
{
|
||||
"DecryptionKey" "eab052b3f590730d382a0d51d66cb4d410fc090cd2ca62cc11d16b63b0b2836b"
|
||||
}
|
||||
"1426217"
|
||||
{
|
||||
"DecryptionKey" "2cfd11044ff54f4000d4fa6678b2bf9f3ef01d938f1cb65f40e6302ee3ab2fa5"
|
||||
}
|
||||
"1426218"
|
||||
{
|
||||
"DecryptionKey" "eea43f33f312e1c8dd17ffe314b66a3973f90903055e1a6d67ed0fdbc9e645b3"
|
||||
}
|
||||
"1426219"
|
||||
{
|
||||
"DecryptionKey" "608b4e63ab758b67708f2d8dc51a102db4863b8072a41ca049d2df2b87f95163"
|
||||
}
|
||||
"1503450"
|
||||
{
|
||||
"DecryptionKey" "70395ff068a2b079a71aa86404c73c8eb4a0c7d0062e8ed224b0b816c99a3190"
|
||||
}
|
||||
"1503451"
|
||||
{
|
||||
"DecryptionKey" "213d830db33d439cfe41a1b95ace67a705a2ba3ebf969a43651054d36eeb578f"
|
||||
}
|
||||
"1503453"
|
||||
{
|
||||
"DecryptionKey" "ce7e4e2e59b4d9a610c74f070fc986a108f44ff1f59594b5fe19aa7997798479"
|
||||
}
|
||||
"228988"
|
||||
{
|
||||
"DecryptionKey" "1845444d5e2cfd0ae65ae4a8fedb6e2fbf776fcc5b913ab4ac461bc9a74f8358"
|
||||
}
|
||||
"228990"
|
||||
{
|
||||
"DecryptionKey" "44d8c45ce229a11c4f231a3d2a350eaf80b0d69a8af938ec7ccca720f694b0e8"
|
||||
}
|
||||
"1304931"
|
||||
{
|
||||
"DecryptionKey" "81611074b6fd0d2e108d34562aca73115d01d6bea3f08092b8d98aad42c2f0fb"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
"Authentication"
|
||||
{
|
||||
"RememberedMachineID"
|
||||
{
|
||||
"3ff7c4de1" "eyAidHlwIjogIkpXVCIsICJhbGciOiAiRWREU0EiIH0.eyAiaXNzIjogInI6MEQyQV8yMjk2RTMxNV83NzFFMCIsICJzdWIiOiAiNzY1NjExOTgzMTIyNDgzMzIiLCAiYXVkIjogWyAibWFjaGluZSIgXSwgImV4cCI6IDE3MDM3NzE1NjQsICJuYmYiOiAxNjc2Nzk2ODgxLCAiaWF0IjogMTY4NTQzNjg4MSwgImp0aSI6ICIwRDMzXzIyOTZFMzE1XzM1NzkxIiwgIm9hdCI6IDE2ODU0MzY4ODEsICJydF9leHAiOiAxNzAzNzcwMTg1LCAicGVyIjogMCwgImlwX3N1YmplY3QiOiAiNTguMTcuNjEuODMiLCAiaXBfY29uZmlybWVyIjogIjU4LjE3LjYxLjgzIiB9.ga7z9QCw9t3PKBBdZzoil6UF-sFeNA-LvjziPEF-mdjxgRsFgo4AjtoAMeCg90PsdgTtXqsqToAl9LJpIyrcBw"
|
||||
}
|
||||
}
|
||||
"streaming"
|
||||
{
|
||||
"ClientID" "-2065686191053516812"
|
||||
}
|
||||
"Music"
|
||||
{
|
||||
"LocalLibrary"
|
||||
{
|
||||
"Directories"
|
||||
{
|
||||
"0" "02000000807c0fe9141d6db992de1003515788e69d14a3f66d574cb6822f6d085b70ea1f74833f19ab5d09380b2ac0e7d2ab00b3fe4f38163ab31c13ab8791111053cc44a010b3f7573b7313847f795bc4df98a1"
|
||||
"1" "02000000807c0fe9141d6db992de1003515788e39c1eb6f7507b089d822d61080f2af3532dd83f07aa4b0136575bc2e3dfb30490eb4826021ab31002ab85e7707c24da74a40a9feb66481661847f7153448d10e602e49d5c3997f57bc0330d59cc897b8f"
|
||||
}
|
||||
}
|
||||
}
|
||||
"WebStorage"
|
||||
{
|
||||
"DownloadsStoreRecentlyCompleted" "{"version":1,"data":[{"appid":228980,"total_bytes":123069936,"downloaded_bytes":123069936,"active":false,"paused":false,"completed":true,"deferred_time":0,"queue_index":-1,"update_result":0,"update_error":"","completed_time":1685578382,"buildid":11255752,"target_buildid":11255752,"launch_on_completion":false,"update_type_info":[{"has_update":true,"completed_update":true,"total_bytes":123069936,"downloaded_bytes":123069936},{"has_update":false,"completed_update":false,"total_bytes":0,"downloaded_bytes":0},{"has_update":false,"completed_update":false,"total_bytes":0,"downloaded_bytes":0}],"patch_notes_gid":""}]}"
|
||||
}
|
||||
}
|
240
3rdparty/ValveFileVDF/tests/vdf_parser_test.cpp
vendored
Normal file
240
3rdparty/ValveFileVDF/tests/vdf_parser_test.cpp
vendored
Normal file
@ -0,0 +1,240 @@
|
||||
#include <algorithm>
|
||||
#include <filesystem>
|
||||
#include <fstream>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
|
||||
#define TYTI_NO_L_UNDEF
|
||||
#include <vdf_parser.hpp>
|
||||
#define T_L(x) TYTI_L(charT, x)
|
||||
using namespace tyti;
|
||||
|
||||
#include "doctest.h"
|
||||
|
||||
template <typename charT>
|
||||
void check_DST_AST(const vdf::basic_object<charT> &obj)
|
||||
{
|
||||
CHECK(obj.name == T_L("AppState"));
|
||||
REQUIRE(obj.attribs.size() == 24);
|
||||
REQUIRE(obj.childs.size() == 4);
|
||||
|
||||
CHECK(obj.attribs.at(T_L("appid")) == T_L("343050"));
|
||||
|
||||
CHECK(obj.attribs.at(T_L("buildid")) == T_L("1101428"));
|
||||
CHECK(obj.attribs.at(T_L("#1_attrib")) == T_L("1"));
|
||||
CHECK(obj.attribs.at(T_L("emptyAttrib")) == T_L(""));
|
||||
CHECK(obj.attribs.at(T_L("escape_quote")) == T_L(R"("quote")"));
|
||||
CHECK(obj.attribs.at(T_L("no_quoted_attrib_support")) == T_L("yes"));
|
||||
// "C2017 can occur when the stringize operator is used with strings that
|
||||
// include escape sequences."
|
||||
// https://docs.microsoft.com/en-us/previous-versions/visualstudio/visual-studio-2013/29t70y03(v=vs.120)
|
||||
#if !defined(_MSC_VER) || (_MSC_VER > 1800)
|
||||
CHECK(obj.attribs.at(T_L("escape_quote_backslash")) ==
|
||||
T_L("quote_with_other_escapes\\\"\\"));
|
||||
CHECK(obj.attribs.at(T_L("tab_escape")) == T_L("new\\ttab"));
|
||||
CHECK(obj.attribs.at(T_L("new_line_escape")) == T_L("new\\nline"));
|
||||
#endif
|
||||
|
||||
CHECK(obj.childs.at(T_L("UserConfig"))->name == T_L("UserConfig"));
|
||||
CHECK(obj.childs.at(T_L("UserConfig"))->childs.empty());
|
||||
|
||||
const auto &inc = obj.childs.at(T_L("IncludedStuff"));
|
||||
CHECK(inc->name == T_L("IncludedStuff"));
|
||||
const auto &base = obj.childs.at(T_L("BaseInclude"));
|
||||
REQUIRE(base->attribs.size() == 1);
|
||||
CHECK(base->attribs.at(T_L("BaseAttrib")) == T_L("Yes"));
|
||||
CHECK(obj.attribs.at(T_L("another attribute with fancy space")) ==
|
||||
T_L("yay"));
|
||||
}
|
||||
|
||||
template <typename charT>
|
||||
void check_DST_AST_multikey(const vdf::basic_multikey_object<charT> &obj)
|
||||
{
|
||||
CHECK(obj.name == T_L("AppState"));
|
||||
REQUIRE(obj.attribs.size() == 25);
|
||||
REQUIRE(obj.childs.size() == 4);
|
||||
|
||||
CHECK(obj.attribs.find(T_L("appid"))->second == T_L("343050"));
|
||||
|
||||
CHECK(obj.attribs.find(T_L("buildid"))->second == T_L("1101428"));
|
||||
CHECK(obj.attribs.find(T_L("#1_attrib"))->second == T_L("1"));
|
||||
CHECK(obj.attribs.find(T_L("emptyAttrib"))->second == T_L(""));
|
||||
CHECK(obj.attribs.find(T_L("no_quoted_attrib_support"))->second ==
|
||||
T_L("yes"));
|
||||
|
||||
CHECK(obj.attribs.count(T_L("UpdateResult")) == 2);
|
||||
|
||||
CHECK(obj.childs.find(T_L("UserConfig"))->second->name ==
|
||||
T_L("UserConfig"));
|
||||
CHECK(obj.childs.find(T_L("UserConfig"))->second->childs.empty());
|
||||
|
||||
const auto &inc = obj.childs.find(T_L("IncludedStuff"))->second;
|
||||
CHECK(inc->name == T_L("IncludedStuff"));
|
||||
const auto &base = obj.childs.find(T_L("BaseInclude"))->second;
|
||||
REQUIRE(base->attribs.size() == 1);
|
||||
CHECK(base->attribs.find(T_L("BaseAttrib"))->second == T_L("Yes"));
|
||||
CHECK(obj.attribs.find(T_L("another attribute with fancy space"))->second ==
|
||||
T_L("yay"));
|
||||
}
|
||||
|
||||
TEST_CASE_TEMPLATE("Read File", charT, char, wchar_t)
|
||||
{
|
||||
SUBCASE("bool return")
|
||||
{
|
||||
std::basic_ifstream<charT> file("DST_Manifest.acf");
|
||||
bool ok;
|
||||
auto objects = vdf::read(file, &ok);
|
||||
|
||||
REQUIRE(ok);
|
||||
auto it = objects.childs.find(T_L("AppState"));
|
||||
CHECK(it != objects.childs.end());
|
||||
check_DST_AST(*(it->second));
|
||||
}
|
||||
|
||||
SUBCASE("ec return")
|
||||
{
|
||||
std::basic_ifstream<charT> file("DST_Manifest.acf");
|
||||
std::error_code ec;
|
||||
auto objects = vdf::read(file, ec);
|
||||
|
||||
REQUIRE(!ec);
|
||||
auto it = objects.childs.find(T_L("AppState"));
|
||||
CHECK(it != objects.childs.end());
|
||||
check_DST_AST(*(it->second));
|
||||
}
|
||||
|
||||
SUBCASE("exception")
|
||||
{
|
||||
std::basic_ifstream<charT> file("DST_Manifest.acf");
|
||||
auto objects = vdf::read(file);
|
||||
auto it = objects.childs.find(T_L("AppState"));
|
||||
CHECK(it != objects.childs.end());
|
||||
check_DST_AST(*(it->second));
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE_TEMPLATE("Read String", charT, char, wchar_t)
|
||||
{
|
||||
std::basic_string<charT> attribs(
|
||||
T_L("\"firstNode\"{\"SecondNode\"{\"Key\" \"Value\" //myComment\n}}"));
|
||||
bool ok;
|
||||
vdf::read(attribs.begin(), attribs.end(), &ok);
|
||||
|
||||
REQUIRE(ok);
|
||||
}
|
||||
|
||||
// todo: error checking
|
||||
TEST_CASE_TEMPLATE("Find Error", charT, char, wchar_t)
|
||||
{
|
||||
bool ok;
|
||||
std::basic_string<charT> attribs(
|
||||
T_L("\"firstNode\"{\"SecondNode\"{\"Key\" //myComment\n}}"));
|
||||
vdf::read(attribs.begin(), attribs.end(), &ok);
|
||||
|
||||
REQUIRE(!ok);
|
||||
}
|
||||
|
||||
TEST_CASE_TEMPLATE("Write and Read", charT, char, wchar_t)
|
||||
{
|
||||
std::basic_string<charT> attribs(
|
||||
T_L("\"firstNode\"{\"SecondNode\"{\"Key\" \"Value\" //myComment\n}}"));
|
||||
bool ok;
|
||||
auto obj = vdf::read(attribs.begin(), attribs.end(), &ok);
|
||||
|
||||
REQUIRE(ok);
|
||||
|
||||
std::basic_stringstream<charT> output;
|
||||
vdf::write(output, obj);
|
||||
obj = vdf::read(output);
|
||||
|
||||
CHECK(obj.name == T_L("firstNode"));
|
||||
|
||||
CHECK(obj.attribs.empty() == true);
|
||||
REQUIRE(obj.childs.size() == 1);
|
||||
const auto &secondNode = obj.childs.at(T_L("SecondNode"));
|
||||
|
||||
CHECK(secondNode->name == T_L("SecondNode"));
|
||||
REQUIRE(secondNode->attribs.size() == 1);
|
||||
CHECK(secondNode->childs.empty() == true);
|
||||
CHECK(secondNode->attribs.at(T_L("Key")) == T_L("Value"));
|
||||
}
|
||||
|
||||
TEST_CASE_TEMPLATE("read multikey", charT, char, wchar_t)
|
||||
{
|
||||
std::basic_ifstream<charT> file("DST_Manifest.acf");
|
||||
auto objects = vdf::read<vdf::basic_multikey_object<charT>>(file);
|
||||
auto it = objects.childs.find(T_L("AppState"));
|
||||
CHECK(it != objects.childs.end());
|
||||
check_DST_AST_multikey(*(it->second));
|
||||
}
|
||||
|
||||
TEST_CASE_TEMPLATE("read broken file", charT, char, wchar_t)
|
||||
{
|
||||
#ifndef WIN32
|
||||
if constexpr (std::is_same_v<charT, wchar_t>)
|
||||
return;
|
||||
#endif
|
||||
std::basic_ifstream<charT> file("broken_file.acf");
|
||||
std::error_code ec;
|
||||
auto objects = vdf::read(file, ec);
|
||||
REQUIRE(ec);
|
||||
REQUIRE(objects.name.empty());
|
||||
REQUIRE(objects.attribs.empty());
|
||||
REQUIRE(objects.childs.empty());
|
||||
}
|
||||
|
||||
TEST_CASE_TEMPLATE("read broken file throw", charT, char, wchar_t)
|
||||
{
|
||||
#ifndef WIN32
|
||||
if constexpr (std::is_same_v<charT, wchar_t>)
|
||||
return;
|
||||
#endif
|
||||
std::basic_ifstream<charT> file("broken_file.acf");
|
||||
CHECK_THROWS(vdf::read(file));
|
||||
}
|
||||
|
||||
TEST_CASE("issue14")
|
||||
{
|
||||
std::ifstream input_file("issue14.vdf", std::ios::in);
|
||||
CHECK_THROWS(tyti::vdf::read(input_file));
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////
|
||||
// readme test
|
||||
/////////////////////////////////////////////////////////////
|
||||
|
||||
TEST_CASE("counter test")
|
||||
{
|
||||
struct counter
|
||||
{
|
||||
size_t num_attributes;
|
||||
counter() : num_attributes(0) {}
|
||||
void add_attribute(std::string, std::string) { ++num_attributes; }
|
||||
void add_child(std::unique_ptr<counter> child)
|
||||
{
|
||||
num_attributes += child->num_attributes;
|
||||
}
|
||||
void set_name(std::string) {}
|
||||
};
|
||||
|
||||
std::ifstream file("DST_Manifest.acf");
|
||||
counter num = tyti::vdf::read<counter>(file);
|
||||
CHECK(num.num_attributes == 29);
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////
|
||||
// fuzzer findings
|
||||
/////////////////////////////////////////////////////////////
|
||||
TEST_CASE("fuzzing_files")
|
||||
{
|
||||
|
||||
for (auto const &dir_entry :
|
||||
std::filesystem::directory_iterator{"fuzzing_data"})
|
||||
{
|
||||
SUBCASE(dir_entry.path().filename().string().c_str())
|
||||
{
|
||||
std::ifstream f(dir_entry.path().string());
|
||||
CHECK_THROWS(tyti::vdf::read(f));
|
||||
}
|
||||
}
|
||||
}
|
195
3rdparty/curl/bin/curl-config
vendored
Normal file
195
3rdparty/curl/bin/curl-config
vendored
Normal file
@ -0,0 +1,195 @@
|
||||
#!/bin/sh
|
||||
#***************************************************************************
|
||||
# _ _ ____ _
|
||||
# Project ___| | | | _ \| |
|
||||
# / __| | | | |_) | |
|
||||
# | (__| |_| | _ <| |___
|
||||
# \___|\___/|_| \_\_____|
|
||||
#
|
||||
# Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
#
|
||||
# This software is licensed as described in the file COPYING, which
|
||||
# you should have received as part of this distribution. The terms
|
||||
# are also available at https://curl.se/docs/copyright.html.
|
||||
#
|
||||
# You may opt to use, copy, modify, merge, publish, distribute and/or sell
|
||||
# copies of the Software, and permit persons to whom the Software is
|
||||
# furnished to do so, under the terms of the COPYING file.
|
||||
#
|
||||
# This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||
# KIND, either express or implied.
|
||||
#
|
||||
# SPDX-License-Identifier: curl
|
||||
#
|
||||
###########################################################################
|
||||
|
||||
# shellcheck disable=SC2006
|
||||
|
||||
prefix='F:\SourceCode\curl\build\curl'
|
||||
# Used in 'libdir'
|
||||
# shellcheck disable=SC2034
|
||||
exec_prefix="${prefix}"
|
||||
# shellcheck disable=SC2034
|
||||
includedir="${prefix}/include"
|
||||
cppflag_curl_staticlib='-DCURL_STATICLIB'
|
||||
|
||||
usage()
|
||||
{
|
||||
cat <<EOF
|
||||
Usage: curl-config [OPTION]
|
||||
|
||||
Available values for OPTION include:
|
||||
|
||||
--built-shared says 'yes' if libcurl was built shared
|
||||
--ca CA bundle install path
|
||||
--cc compiler
|
||||
--cflags preprocessor and compiler flags
|
||||
--checkfor [version] check for (lib)curl of the specified version
|
||||
--configure the arguments given to configure when building curl
|
||||
--features newline separated list of enabled features
|
||||
--help display this help and exit
|
||||
--libs library linking information
|
||||
--prefix curl install prefix
|
||||
--protocols newline separated list of enabled protocols
|
||||
--ssl-backends output the SSL backends libcurl was built to support
|
||||
--static-libs static libcurl library linking information
|
||||
--version output version information
|
||||
--vernum output version as a hexadecimal number
|
||||
EOF
|
||||
|
||||
exit "$1"
|
||||
}
|
||||
|
||||
if test "$#" -eq 0; then
|
||||
usage 1
|
||||
fi
|
||||
|
||||
while test "$#" -gt 0; do
|
||||
case "$1" in
|
||||
--built-shared)
|
||||
echo 'no'
|
||||
;;
|
||||
|
||||
--ca)
|
||||
echo ''
|
||||
;;
|
||||
|
||||
--cc)
|
||||
echo 'D:/Dev/msys64/mingw64/bin/cc.exe'
|
||||
;;
|
||||
|
||||
--prefix)
|
||||
echo "$prefix"
|
||||
;;
|
||||
|
||||
--feature|--features)
|
||||
for feature in alt-svc AsynchDNS HSTS HTTP2 HTTP3 HTTPS-proxy IDN IPv6 Largefile libz NTLM PSL SSL threadsafe TLS-SRP UnixSockets zstd ''; do
|
||||
test -n "$feature" && echo "$feature"
|
||||
done
|
||||
;;
|
||||
|
||||
--protocols)
|
||||
# shellcheck disable=SC2043
|
||||
for protocol in DICT FILE FTP FTPS GOPHER GOPHERS HTTP HTTPS IMAP IMAPS IPFS IPNS LDAP LDAPS MQTT POP3 POP3S RTSP SCP SFTP SMB SMBS SMTP SMTPS TELNET TFTP; do
|
||||
echo "$protocol"
|
||||
done
|
||||
;;
|
||||
|
||||
--version)
|
||||
echo 'libcurl 8.11.0-DEV'
|
||||
exit 0
|
||||
;;
|
||||
|
||||
--checkfor)
|
||||
checkfor="$2"
|
||||
cmajor=`echo "$checkfor" | cut -d. -f1`
|
||||
cminor=`echo "$checkfor" | cut -d. -f2`
|
||||
# when extracting the patch part we strip off everything after a
|
||||
# dash as that's used for things like version 1.2.3-pre1
|
||||
cpatch=`echo "$checkfor" | cut -d. -f3 | cut -d- -f1`
|
||||
|
||||
vmajor=`echo '8.11.0-DEV' | cut -d. -f1`
|
||||
vminor=`echo '8.11.0-DEV' | cut -d. -f2`
|
||||
# when extracting the patch part we strip off everything after a
|
||||
# dash as that's used for things like version 1.2.3-pre1
|
||||
vpatch=`echo '8.11.0-DEV' | cut -d. -f3 | cut -d- -f1`
|
||||
|
||||
if test "$vmajor" -gt "$cmajor"; then
|
||||
exit 0
|
||||
fi
|
||||
if test "$vmajor" -eq "$cmajor"; then
|
||||
if test "$vminor" -gt "$cminor"; then
|
||||
exit 0
|
||||
fi
|
||||
if test "$vminor" -eq "$cminor"; then
|
||||
if test "$cpatch" -le "$vpatch"; then
|
||||
exit 0
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
echo "requested version $checkfor is newer than existing 8.11.0-DEV"
|
||||
exit 1
|
||||
;;
|
||||
|
||||
--vernum)
|
||||
echo '080b00'
|
||||
exit 0
|
||||
;;
|
||||
|
||||
--help)
|
||||
usage 0
|
||||
;;
|
||||
|
||||
--cflags)
|
||||
if test "X$cppflag_curl_staticlib" = 'X-DCURL_STATICLIB'; then
|
||||
CPPFLAG_CURL_STATICLIB='-DCURL_STATICLIB '
|
||||
else
|
||||
CPPFLAG_CURL_STATICLIB=''
|
||||
fi
|
||||
if test "X${prefix}/include" = 'X/usr/include'; then
|
||||
echo "${CPPFLAG_CURL_STATICLIB}"
|
||||
else
|
||||
echo "${CPPFLAG_CURL_STATICLIB}-I${prefix}/include"
|
||||
fi
|
||||
;;
|
||||
|
||||
--libs)
|
||||
if test "X${exec_prefix}/lib" != 'X/usr/lib' -a "X${exec_prefix}/lib" != 'X/usr/lib64'; then
|
||||
CURLLIBDIR="-L${exec_prefix}/lib "
|
||||
else
|
||||
CURLLIBDIR=''
|
||||
fi
|
||||
if test 'Xno' = 'Xno'; then
|
||||
echo "${CURLLIBDIR}-lcurl -lidn2 -lws2_32 -lbcrypt -lssl -lcrypto -lz -lzstd -lnghttp2 -lnghttp3 -lwldap32 -lpsl -lssh2 -ladvapi32 -lcrypt32"
|
||||
else
|
||||
echo "${CURLLIBDIR}-lcurl"
|
||||
fi
|
||||
;;
|
||||
|
||||
--ssl-backends)
|
||||
echo 'OpenSSL v3+'
|
||||
;;
|
||||
|
||||
--static-libs)
|
||||
if test 'Xyes' != 'Xno'; then
|
||||
echo "${exec_prefix}/lib/libcurl.a -LD:/Dev/msys64/mingw64/bin/../lib -LD:/Dev/msys64/mingw64/lib -lidn2 -lws2_32 -lbcrypt -lssl -lcrypto -lz -lzstd -lnghttp2 -lnghttp3 -lwldap32 -lpsl -lssh2 -ladvapi32 -lcrypt32"
|
||||
else
|
||||
echo 'curl was built with static libraries disabled' >&2
|
||||
exit 1
|
||||
fi
|
||||
;;
|
||||
|
||||
--configure)
|
||||
echo
|
||||
;;
|
||||
|
||||
*)
|
||||
echo "unknown option: $1"
|
||||
usage 1
|
||||
;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
|
||||
exit 0
|
BIN
3rdparty/curl/bin/curl.exe
vendored
Normal file
BIN
3rdparty/curl/bin/curl.exe
vendored
Normal file
Binary file not shown.
714
3rdparty/curl/bin/mk-ca-bundle.pl
vendored
Normal file
714
3rdparty/curl/bin/mk-ca-bundle.pl
vendored
Normal file
@ -0,0 +1,714 @@
|
||||
#!/usr/bin/env perl
|
||||
# ***************************************************************************
|
||||
# * _ _ ____ _
|
||||
# * Project ___| | | | _ \| |
|
||||
# * / __| | | | |_) | |
|
||||
# * | (__| |_| | _ <| |___
|
||||
# * \___|\___/|_| \_\_____|
|
||||
# *
|
||||
# * Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
# *
|
||||
# * This software is licensed as described in the file COPYING, which
|
||||
# * you should have received as part of this distribution. The terms
|
||||
# * are also available at https://curl.se/docs/copyright.html.
|
||||
# *
|
||||
# * You may opt to use, copy, modify, merge, publish, distribute and/or sell
|
||||
# * copies of the Software, and permit persons to whom the Software is
|
||||
# * furnished to do so, under the terms of the COPYING file.
|
||||
# *
|
||||
# * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||
# * KIND, either express or implied.
|
||||
# *
|
||||
# * SPDX-License-Identifier: curl
|
||||
# *
|
||||
# ***************************************************************************
|
||||
# This Perl script creates a fresh ca-bundle.crt file for use with libcurl.
|
||||
# It downloads certdata.txt from Mozilla's source tree (see URL below),
|
||||
# then parses certdata.txt and extracts CA Root Certificates into PEM format.
|
||||
# These are then processed with the OpenSSL commandline tool to produce the
|
||||
# final ca-bundle.crt file.
|
||||
# The script is based on the parse-certs script written by Roland Krikava.
|
||||
# This Perl script works on almost any platform since its only external
|
||||
# dependency is the OpenSSL commandline tool for optional text listing.
|
||||
# Hacked by Guenter Knauf.
|
||||
#
|
||||
use Encode;
|
||||
use Getopt::Std;
|
||||
use MIME::Base64;
|
||||
use strict;
|
||||
use warnings;
|
||||
use vars qw($opt_b $opt_d $opt_f $opt_h $opt_i $opt_k $opt_l $opt_m $opt_n $opt_p $opt_q $opt_s $opt_t $opt_u $opt_v $opt_w);
|
||||
use List::Util;
|
||||
use Text::Wrap;
|
||||
use Time::Local;
|
||||
my $MOD_SHA = "Digest::SHA";
|
||||
eval "require $MOD_SHA";
|
||||
if ($@) {
|
||||
$MOD_SHA = "Digest::SHA::PurePerl";
|
||||
eval "require $MOD_SHA";
|
||||
}
|
||||
eval "require LWP::UserAgent";
|
||||
|
||||
my %urls = (
|
||||
'nss' =>
|
||||
'https://hg.mozilla.org/projects/nss/raw-file/default/lib/ckfw/builtins/certdata.txt',
|
||||
'central' =>
|
||||
'https://hg.mozilla.org/mozilla-central/raw-file/default/security/nss/lib/ckfw/builtins/certdata.txt',
|
||||
'beta' =>
|
||||
'https://hg.mozilla.org/releases/mozilla-beta/raw-file/default/security/nss/lib/ckfw/builtins/certdata.txt',
|
||||
'release' =>
|
||||
'https://hg.mozilla.org/releases/mozilla-release/raw-file/default/security/nss/lib/ckfw/builtins/certdata.txt',
|
||||
);
|
||||
|
||||
$opt_d = 'release';
|
||||
|
||||
# If the OpenSSL commandline is not in search path you can configure it here!
|
||||
my $openssl = 'openssl';
|
||||
|
||||
my $version = '1.29';
|
||||
|
||||
$opt_w = 76; # default base64 encoded lines length
|
||||
|
||||
# default cert types to include in the output (default is to include CAs which
|
||||
# may issue SSL server certs)
|
||||
my $default_mozilla_trust_purposes = "SERVER_AUTH";
|
||||
my $default_mozilla_trust_levels = "TRUSTED_DELEGATOR";
|
||||
$opt_p = $default_mozilla_trust_purposes . ":" . $default_mozilla_trust_levels;
|
||||
|
||||
my @valid_mozilla_trust_purposes = (
|
||||
"DIGITAL_SIGNATURE",
|
||||
"NON_REPUDIATION",
|
||||
"KEY_ENCIPHERMENT",
|
||||
"DATA_ENCIPHERMENT",
|
||||
"KEY_AGREEMENT",
|
||||
"KEY_CERT_SIGN",
|
||||
"CRL_SIGN",
|
||||
"SERVER_AUTH",
|
||||
"CLIENT_AUTH",
|
||||
"CODE_SIGNING",
|
||||
"EMAIL_PROTECTION",
|
||||
"IPSEC_END_SYSTEM",
|
||||
"IPSEC_TUNNEL",
|
||||
"IPSEC_USER",
|
||||
"TIME_STAMPING",
|
||||
"STEP_UP_APPROVED"
|
||||
);
|
||||
|
||||
my @valid_mozilla_trust_levels = (
|
||||
"TRUSTED_DELEGATOR", # CAs
|
||||
"NOT_TRUSTED", # Don't trust these certs.
|
||||
"MUST_VERIFY_TRUST", # This explicitly tells us that it ISN'T a CA but is
|
||||
# otherwise ok. In other words, this should tell the
|
||||
# app to ignore any other sources that claim this is
|
||||
# a CA.
|
||||
"TRUSTED" # This cert is trusted, but only for itself and not
|
||||
# for delegates (i.e. it is not a CA).
|
||||
);
|
||||
|
||||
my $default_signature_algorithms = $opt_s = "MD5";
|
||||
|
||||
my @valid_signature_algorithms = (
|
||||
"MD5",
|
||||
"SHA1",
|
||||
"SHA256",
|
||||
"SHA384",
|
||||
"SHA512"
|
||||
);
|
||||
|
||||
$0 =~ s@.*(/|\\)@@;
|
||||
$Getopt::Std::STANDARD_HELP_VERSION = 1;
|
||||
getopts('bd:fhiklmnp:qs:tuvw:');
|
||||
|
||||
if(!defined($opt_d)) {
|
||||
# to make plain "-d" use not cause warnings, and actually still work
|
||||
$opt_d = 'release';
|
||||
}
|
||||
|
||||
# Use predefined URL or else custom URL specified on command line.
|
||||
my $url;
|
||||
if(defined($urls{$opt_d})) {
|
||||
$url = $urls{$opt_d};
|
||||
if(!$opt_k && $url !~ /^https:\/\//i) {
|
||||
die "The URL for '$opt_d' is not HTTPS. Use -k to override (insecure).\n";
|
||||
}
|
||||
}
|
||||
else {
|
||||
$url = $opt_d;
|
||||
}
|
||||
|
||||
if ($opt_i) {
|
||||
print ("=" x 78 . "\n");
|
||||
print "Script Version : $version\n";
|
||||
print "Perl Version : $]\n";
|
||||
print "Operating System Name : $^O\n";
|
||||
print "Getopt::Std.pm Version : ${Getopt::Std::VERSION}\n";
|
||||
print "Encode::Encoding.pm Version : ${Encode::Encoding::VERSION}\n";
|
||||
print "MIME::Base64.pm Version : ${MIME::Base64::VERSION}\n";
|
||||
print "LWP::UserAgent.pm Version : ${LWP::UserAgent::VERSION}\n" if($LWP::UserAgent::VERSION);
|
||||
print "LWP.pm Version : ${LWP::VERSION}\n" if($LWP::VERSION);
|
||||
print "Digest::SHA.pm Version : ${Digest::SHA::VERSION}\n" if ($Digest::SHA::VERSION);
|
||||
print "Digest::SHA::PurePerl.pm Version : ${Digest::SHA::PurePerl::VERSION}\n" if ($Digest::SHA::PurePerl::VERSION);
|
||||
print ("=" x 78 . "\n");
|
||||
}
|
||||
|
||||
sub warning_message() {
|
||||
if ( $opt_d =~ m/^risk$/i ) { # Long Form Warning and Exit
|
||||
print "Warning: Use of this script may pose some risk:\n";
|
||||
print "\n";
|
||||
print " 1) If you use HTTP URLs they are subject to a man in the middle attack\n";
|
||||
print " 2) Default to 'release', but more recent updates may be found in other trees\n";
|
||||
print " 3) certdata.txt file format may change, lag time to update this script\n";
|
||||
print " 4) Generally unwise to blindly trust CAs without manual review & verification\n";
|
||||
print " 5) Mozilla apps use additional security checks aren't represented in certdata\n";
|
||||
print " 6) Use of this script will make a security engineer grind his teeth and\n";
|
||||
print " swear at you. ;)\n";
|
||||
exit;
|
||||
} else { # Short Form Warning
|
||||
print "Warning: Use of this script may pose some risk, -d risk for more details.\n";
|
||||
}
|
||||
}
|
||||
|
||||
sub HELP_MESSAGE() {
|
||||
print "Usage:\t${0} [-b] [-d<certdata>] [-f] [-i] [-k] [-l] [-n] [-p<purposes:levels>] [-q] [-s<algorithms>] [-t] [-u] [-v] [-w<l>] [<outputfile>]\n";
|
||||
print "\t-b\tbackup an existing version of ca-bundle.crt\n";
|
||||
print "\t-d\tspecify Mozilla tree to pull certdata.txt or custom URL\n";
|
||||
print "\t\t Valid names are:\n";
|
||||
print "\t\t ", join( ", ", map { ( $_ =~ m/$opt_d/ ) ? "$_ (default)" : "$_" } sort keys %urls ), "\n";
|
||||
print "\t-f\tforce rebuild even if certdata.txt is current\n";
|
||||
print "\t-i\tprint version info about used modules\n";
|
||||
print "\t-k\tallow URLs other than HTTPS, enable HTTP fallback (insecure)\n";
|
||||
print "\t-l\tprint license info about certdata.txt\n";
|
||||
print "\t-m\tinclude meta data in output\n";
|
||||
print "\t-n\tno download of certdata.txt (to use existing)\n";
|
||||
print wrap("\t","\t\t", "-p\tlist of Mozilla trust purposes and levels for certificates to include in output. Takes the form of a comma separated list of purposes, a colon, and a comma separated list of levels. (default: $default_mozilla_trust_purposes:$default_mozilla_trust_levels)"), "\n";
|
||||
print "\t\t Valid purposes are:\n";
|
||||
print wrap("\t\t ","\t\t ", join( ", ", "ALL", @valid_mozilla_trust_purposes ) ), "\n";
|
||||
print "\t\t Valid levels are:\n";
|
||||
print wrap("\t\t ","\t\t ", join( ", ", "ALL", @valid_mozilla_trust_levels ) ), "\n";
|
||||
print "\t-q\tbe really quiet (no progress output at all)\n";
|
||||
print wrap("\t","\t\t", "-s\tcomma separated list of certificate signatures/hashes to output in plain text mode. (default: $default_signature_algorithms)\n");
|
||||
print "\t\t Valid signature algorithms are:\n";
|
||||
print wrap("\t\t ","\t\t ", join( ", ", "ALL", @valid_signature_algorithms ) ), "\n";
|
||||
print "\t-t\tinclude plain text listing of certificates\n";
|
||||
print "\t-u\tunlink (remove) certdata.txt after processing\n";
|
||||
print "\t-v\tbe verbose and print out processed CAs\n";
|
||||
print "\t-w <l>\twrap base64 output lines after <l> chars (default: ${opt_w})\n";
|
||||
exit;
|
||||
}
|
||||
|
||||
sub VERSION_MESSAGE() {
|
||||
print "${0} version ${version} running Perl ${]} on ${^O}\n";
|
||||
}
|
||||
|
||||
warning_message() unless ($opt_q || $url =~ m/^(ht|f)tps:/i );
|
||||
HELP_MESSAGE() if ($opt_h);
|
||||
|
||||
sub report($@) {
|
||||
my $output = shift;
|
||||
|
||||
print STDERR $output . "\n" unless $opt_q;
|
||||
}
|
||||
|
||||
sub is_in_list($@) {
|
||||
my $target = shift;
|
||||
|
||||
return defined(List::Util::first { $target eq $_ } @_);
|
||||
}
|
||||
|
||||
# Parses $param_string as a case insensitive comma separated list with optional
|
||||
# whitespace validates that only allowed parameters are supplied
|
||||
sub parse_csv_param($$@) {
|
||||
my $description = shift;
|
||||
my $param_string = shift;
|
||||
my @valid_values = @_;
|
||||
|
||||
my @values = map {
|
||||
s/^\s+//; # strip leading spaces
|
||||
s/\s+$//; # strip trailing spaces
|
||||
uc $_ # return the modified string as upper case
|
||||
} split( ',', $param_string );
|
||||
|
||||
# Find all values which are not in the list of valid values or "ALL"
|
||||
my @invalid = grep { !is_in_list($_,"ALL",@valid_values) } @values;
|
||||
|
||||
if ( scalar(@invalid) > 0 ) {
|
||||
# Tell the user which parameters were invalid and print the standard help
|
||||
# message which will exit
|
||||
print "Error: Invalid ", $description, scalar(@invalid) == 1 ? ": " : "s: ", join( ", ", map { "\"$_\"" } @invalid ), "\n";
|
||||
HELP_MESSAGE();
|
||||
}
|
||||
|
||||
@values = @valid_values if ( is_in_list("ALL",@values) );
|
||||
|
||||
return @values;
|
||||
}
|
||||
|
||||
sub sha256 {
|
||||
my $result;
|
||||
if ($Digest::SHA::VERSION || $Digest::SHA::PurePerl::VERSION) {
|
||||
open(FILE, $_[0]) or die "Can't open '$_[0]': $!";
|
||||
binmode(FILE);
|
||||
$result = $MOD_SHA->new(256)->addfile(*FILE)->hexdigest;
|
||||
close(FILE);
|
||||
} else {
|
||||
# Use OpenSSL command if Perl Digest::SHA modules not available
|
||||
$result = `"$openssl" dgst -r -sha256 "$_[0]"`;
|
||||
$result =~ s/^([0-9a-f]{64}) .+/$1/is;
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
sub oldhash {
|
||||
my $hash = "";
|
||||
open(C, "<$_[0]") || return 0;
|
||||
while(<C>) {
|
||||
chomp;
|
||||
if($_ =~ /^\#\# SHA256: (.*)/) {
|
||||
$hash = $1;
|
||||
last;
|
||||
}
|
||||
}
|
||||
close(C);
|
||||
return $hash;
|
||||
}
|
||||
|
||||
if ( $opt_p !~ m/:/ ) {
|
||||
print "Error: Mozilla trust identifier list must include both purposes and levels\n";
|
||||
HELP_MESSAGE();
|
||||
}
|
||||
|
||||
(my $included_mozilla_trust_purposes_string, my $included_mozilla_trust_levels_string) = split( ':', $opt_p );
|
||||
my @included_mozilla_trust_purposes = parse_csv_param( "trust purpose", $included_mozilla_trust_purposes_string, @valid_mozilla_trust_purposes );
|
||||
my @included_mozilla_trust_levels = parse_csv_param( "trust level", $included_mozilla_trust_levels_string, @valid_mozilla_trust_levels );
|
||||
|
||||
my @included_signature_algorithms = parse_csv_param( "signature algorithm", $opt_s, @valid_signature_algorithms );
|
||||
|
||||
sub should_output_cert(%) {
|
||||
my %trust_purposes_by_level = @_;
|
||||
|
||||
foreach my $level (@included_mozilla_trust_levels) {
|
||||
# for each level we want to output, see if any of our desired purposes are
|
||||
# included
|
||||
return 1 if ( defined( List::Util::first { is_in_list( $_, @included_mozilla_trust_purposes ) } @{$trust_purposes_by_level{$level}} ) );
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
my $crt = $ARGV[0] || 'ca-bundle.crt';
|
||||
(my $txt = $url) =~ s@(.*/|\?.*)@@g;
|
||||
|
||||
my $stdout = $crt eq '-';
|
||||
my $resp;
|
||||
my $fetched;
|
||||
|
||||
my $oldhash = oldhash($crt);
|
||||
|
||||
report "SHA256 of old file: $oldhash";
|
||||
|
||||
if(!$opt_n) {
|
||||
report "Downloading $txt ...";
|
||||
|
||||
# If we have an HTTPS URL then use curl
|
||||
if($url =~ /^https:\/\//i) {
|
||||
my $curl = `curl -V`;
|
||||
if($curl) {
|
||||
if($curl =~ /^Protocols:.* https( |$)/m) {
|
||||
report "Get certdata with curl!";
|
||||
my $proto = !$opt_k ? "--proto =https" : "";
|
||||
my $quiet = $opt_q ? "-s" : "";
|
||||
my @out = `curl -w %{response_code} $proto $quiet -o "$txt" "$url"`;
|
||||
if(!$? && @out && $out[0] == 200) {
|
||||
$fetched = 1;
|
||||
report "Downloaded $txt";
|
||||
}
|
||||
else {
|
||||
report "Failed downloading via HTTPS with curl";
|
||||
if(-e $txt && !unlink($txt)) {
|
||||
report "Failed to remove '$txt': $!";
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
report "curl lacks https support";
|
||||
}
|
||||
}
|
||||
else {
|
||||
report "curl not found";
|
||||
}
|
||||
}
|
||||
|
||||
# If nothing was fetched then use LWP
|
||||
if(!$fetched) {
|
||||
if($url =~ /^https:\/\//i) {
|
||||
report "Falling back to HTTP";
|
||||
$url =~ s/^https:\/\//http:\/\//i;
|
||||
}
|
||||
if(!$opt_k) {
|
||||
report "URLs other than HTTPS are disabled by default, to enable use -k";
|
||||
exit 1;
|
||||
}
|
||||
report "Get certdata with LWP!";
|
||||
if(!defined(${LWP::UserAgent::VERSION})) {
|
||||
report "LWP is not available (LWP::UserAgent not found)";
|
||||
exit 1;
|
||||
}
|
||||
my $ua = new LWP::UserAgent(agent => "$0/$version");
|
||||
$ua->env_proxy();
|
||||
$resp = $ua->mirror($url, $txt);
|
||||
if($resp && $resp->code eq '304') {
|
||||
report "Not modified";
|
||||
exit 0 if -e $crt && !$opt_f;
|
||||
}
|
||||
else {
|
||||
$fetched = 1;
|
||||
report "Downloaded $txt";
|
||||
}
|
||||
if(!$resp || $resp->code !~ /^(?:200|304)$/) {
|
||||
report "Unable to download latest data: "
|
||||
. ($resp? $resp->code . ' - ' . $resp->message : "LWP failed");
|
||||
exit 1 if -e $crt || ! -r $txt;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
my $filedate = $resp ? $resp->last_modified : (stat($txt))[9];
|
||||
my $datesrc = "as of";
|
||||
if(!$filedate) {
|
||||
# mxr.mozilla.org gave us a time, hg.mozilla.org does not!
|
||||
$filedate = time();
|
||||
$datesrc="downloaded on";
|
||||
}
|
||||
|
||||
# get the hash from the download file
|
||||
my $newhash= sha256($txt);
|
||||
|
||||
if(!$opt_f && $oldhash eq $newhash) {
|
||||
report "Downloaded file identical to previous run\'s source file. Exiting";
|
||||
if($opt_u && -e $txt && !unlink($txt)) {
|
||||
report "Failed to remove $txt: $!\n";
|
||||
}
|
||||
exit;
|
||||
}
|
||||
|
||||
report "SHA256 of new file: $newhash";
|
||||
|
||||
my $currentdate = scalar gmtime($filedate);
|
||||
|
||||
my $format = $opt_t ? "plain text and " : "";
|
||||
if( $stdout ) {
|
||||
open(CRT, '> -') or die "Couldn't open STDOUT: $!\n";
|
||||
} else {
|
||||
open(CRT,">$crt.~") or die "Couldn't open $crt.~: $!\n";
|
||||
}
|
||||
print CRT <<EOT;
|
||||
##
|
||||
## Bundle of CA Root Certificates
|
||||
##
|
||||
## Certificate data from Mozilla ${datesrc}: ${currentdate} GMT
|
||||
##
|
||||
## Find updated versions here: https://curl.se/docs/caextract.html
|
||||
##
|
||||
## This is a bundle of X.509 certificates of public Certificate Authorities
|
||||
## (CA). These were automatically extracted from Mozilla's root certificates
|
||||
## file (certdata.txt). This file can be found in the mozilla source tree:
|
||||
## ${url}
|
||||
##
|
||||
## It contains the certificates in ${format}PEM format and therefore
|
||||
## can be directly used with curl / libcurl / php_curl, or with
|
||||
## an Apache+mod_ssl webserver for SSL client authentication.
|
||||
## Just configure this file as the SSLCACertificateFile.
|
||||
##
|
||||
## Conversion done with mk-ca-bundle.pl version $version.
|
||||
## SHA256: $newhash
|
||||
##
|
||||
|
||||
EOT
|
||||
|
||||
report "Processing '$txt' ...";
|
||||
my $caname;
|
||||
my $certnum = 0;
|
||||
my $skipnum = 0;
|
||||
my $start_of_cert = 0;
|
||||
my $main_block = 0;
|
||||
my $main_block_name;
|
||||
my $trust_block = 0;
|
||||
my $trust_block_name;
|
||||
my @precert;
|
||||
my $cka_value;
|
||||
my $valid = 0;
|
||||
|
||||
open(TXT,"$txt") or die "Couldn't open $txt: $!\n";
|
||||
while (<TXT>) {
|
||||
if (/\*\*\*\*\* BEGIN LICENSE BLOCK \*\*\*\*\*/) {
|
||||
print CRT;
|
||||
print if ($opt_l);
|
||||
while (<TXT>) {
|
||||
print CRT;
|
||||
print if ($opt_l);
|
||||
last if (/\*\*\*\*\* END LICENSE BLOCK \*\*\*\*\*/);
|
||||
}
|
||||
next;
|
||||
}
|
||||
# The input file format consists of blocks of Mozilla objects.
|
||||
# The blocks are separated by blank lines but may be related.
|
||||
elsif(/^\s*$/) {
|
||||
$main_block = 0;
|
||||
$trust_block = 0;
|
||||
next;
|
||||
}
|
||||
# Each certificate has a main block.
|
||||
elsif(/^# Certificate "(.*)"/) {
|
||||
(!$main_block && !$trust_block) or die "Unexpected certificate block";
|
||||
$main_block = 1;
|
||||
$main_block_name = $1;
|
||||
# Reset all other certificate variables.
|
||||
$trust_block = 0;
|
||||
$trust_block_name = "";
|
||||
$valid = 0;
|
||||
$start_of_cert = 0;
|
||||
$caname = "";
|
||||
$cka_value = "";
|
||||
undef @precert;
|
||||
next;
|
||||
}
|
||||
# Each certificate's main block is followed by a trust block.
|
||||
elsif(/^# Trust for (?:Certificate )?"(.*)"/) {
|
||||
(!$main_block && !$trust_block) or die "Unexpected trust block";
|
||||
$trust_block = 1;
|
||||
$trust_block_name = $1;
|
||||
if($main_block_name ne $trust_block_name) {
|
||||
die "cert name \"$main_block_name\" != trust name \"$trust_block_name\"";
|
||||
}
|
||||
next;
|
||||
}
|
||||
# Ignore other blocks.
|
||||
#
|
||||
# There is a documentation comment block, a BEGINDATA block, and a bunch of
|
||||
# blocks starting with "# Explicitly Distrust <certname>".
|
||||
#
|
||||
# The latter is for certificates that have already been removed and are not
|
||||
# included. Not all explicitly distrusted certificates are ignored at this
|
||||
# point, just those without an actual certificate.
|
||||
elsif(!$main_block && !$trust_block) {
|
||||
next;
|
||||
}
|
||||
elsif(/^#/) {
|
||||
# The commented lines in a main block are plaintext metadata that describes
|
||||
# the certificate. Issuer, Subject, Fingerprint, etc.
|
||||
if($main_block) {
|
||||
push @precert, $_ if not /^#$/;
|
||||
if(/^# Not Valid After : (.*)/) {
|
||||
my $stamp = $1;
|
||||
use Time::Piece;
|
||||
# Not Valid After : Thu Sep 30 14:01:15 2021
|
||||
my $t = Time::Piece->strptime($stamp, "%a %b %d %H:%M:%S %Y");
|
||||
my $delta = ($t->epoch - time()); # negative means no longer valid
|
||||
if($delta < 0) {
|
||||
$skipnum++;
|
||||
report "Skipping: $main_block_name is not valid anymore" if ($opt_v);
|
||||
$valid = 0;
|
||||
}
|
||||
else {
|
||||
$valid = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
next;
|
||||
}
|
||||
elsif(!$valid) {
|
||||
next;
|
||||
}
|
||||
|
||||
chomp;
|
||||
|
||||
if($main_block) {
|
||||
if(/^CKA_CLASS CK_OBJECT_CLASS CKO_CERTIFICATE/) {
|
||||
!$start_of_cert or die "Duplicate CKO_CERTIFICATE object";
|
||||
$start_of_cert = 1;
|
||||
next;
|
||||
}
|
||||
elsif(!$start_of_cert) {
|
||||
next;
|
||||
}
|
||||
elsif(/^CKA_LABEL UTF8 \"(.*)\"/) {
|
||||
($caname eq "") or die "Duplicate CKA_LABEL attribute";
|
||||
$caname = $1;
|
||||
if($caname ne $main_block_name) {
|
||||
die "caname \"$caname\" != cert name \"$main_block_name\"";
|
||||
}
|
||||
next;
|
||||
}
|
||||
elsif(/^CKA_VALUE MULTILINE_OCTAL/) {
|
||||
($cka_value eq "") or die "Duplicate CKA_VALUE attribute";
|
||||
while (<TXT>) {
|
||||
last if (/^END/);
|
||||
chomp;
|
||||
my @octets = split(/\\/);
|
||||
shift @octets;
|
||||
for (@octets) {
|
||||
$cka_value .= chr(oct);
|
||||
}
|
||||
}
|
||||
next;
|
||||
}
|
||||
elsif (/^CKA_NSS_SERVER_DISTRUST_AFTER (CK_BBOOL CK_FALSE|MULTILINE_OCTAL)/) {
|
||||
# Example:
|
||||
# CKA_NSS_SERVER_DISTRUST_AFTER MULTILINE_OCTAL
|
||||
# \062\060\060\066\061\067\060\060\060\060\060\060\132
|
||||
# END
|
||||
if($1 eq "MULTILINE_OCTAL") {
|
||||
my @timestamp;
|
||||
while (<TXT>) {
|
||||
last if (/^END/);
|
||||
chomp;
|
||||
my @octets = split(/\\/);
|
||||
shift @octets;
|
||||
for (@octets) {
|
||||
push @timestamp, chr(oct);
|
||||
}
|
||||
}
|
||||
scalar(@timestamp) == 13 or die "Failed parsing timestamp";
|
||||
# A trailing Z in the timestamp signifies UTC
|
||||
if($timestamp[12] ne "Z") {
|
||||
report "distrust date stamp is not using UTC";
|
||||
}
|
||||
# Example date: 200617000000Z
|
||||
# Means 2020-06-17 00:00:00 UTC
|
||||
my $distrustat =
|
||||
timegm($timestamp[10] . $timestamp[11], # second
|
||||
$timestamp[8] . $timestamp[9], # minute
|
||||
$timestamp[6] . $timestamp[7], # hour
|
||||
$timestamp[4] . $timestamp[5], # day
|
||||
($timestamp[2] . $timestamp[3]) - 1, # month
|
||||
"20" . $timestamp[0] . $timestamp[1]); # year
|
||||
if(time >= $distrustat) {
|
||||
# not trusted anymore
|
||||
$skipnum++;
|
||||
report "Skipping: $main_block_name is not trusted anymore" if ($opt_v);
|
||||
$valid = 0;
|
||||
}
|
||||
else {
|
||||
# still trusted
|
||||
}
|
||||
}
|
||||
next;
|
||||
}
|
||||
else {
|
||||
next;
|
||||
}
|
||||
}
|
||||
|
||||
if(!$trust_block || !$start_of_cert || $caname eq "" || $cka_value eq "") {
|
||||
die "Certificate extraction failed";
|
||||
}
|
||||
|
||||
my %trust_purposes_by_level;
|
||||
|
||||
if(/^CKA_CLASS CK_OBJECT_CLASS CKO_NSS_TRUST/) {
|
||||
# now scan the trust part to determine how we should trust this cert
|
||||
while (<TXT>) {
|
||||
if(/^\s*$/) {
|
||||
$trust_block = 0;
|
||||
last;
|
||||
}
|
||||
if (/^CKA_TRUST_([A-Z_]+)\s+CK_TRUST\s+CKT_NSS_([A-Z_]+)\s*$/) {
|
||||
if ( !is_in_list($1,@valid_mozilla_trust_purposes) ) {
|
||||
report "Warning: Unrecognized trust purpose for cert: $caname. Trust purpose: $1. Trust Level: $2";
|
||||
} elsif ( !is_in_list($2,@valid_mozilla_trust_levels) ) {
|
||||
report "Warning: Unrecognized trust level for cert: $caname. Trust purpose: $1. Trust Level: $2";
|
||||
} else {
|
||||
push @{$trust_purposes_by_level{$2}}, $1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# Sanity check that an explicitly distrusted certificate only has trust
|
||||
# purposes with a trust level of NOT_TRUSTED.
|
||||
#
|
||||
# Certificate objects that are explicitly distrusted are in a certificate
|
||||
# block that starts # Certificate "Explicitly Distrust(ed) <certname>",
|
||||
# where "Explicitly Distrust(ed) " was prepended to the original cert name.
|
||||
if($caname =~ /distrust/i ||
|
||||
$main_block_name =~ /distrust/i ||
|
||||
$trust_block_name =~ /distrust/i) {
|
||||
my @levels = keys %trust_purposes_by_level;
|
||||
if(scalar(@levels) != 1 || $levels[0] ne "NOT_TRUSTED") {
|
||||
die "\"$caname\" must have all trust purposes at level NOT_TRUSTED.";
|
||||
}
|
||||
}
|
||||
|
||||
if ( !should_output_cert(%trust_purposes_by_level) ) {
|
||||
$skipnum ++;
|
||||
report "Skipping: $caname lacks acceptable trust level" if ($opt_v);
|
||||
} else {
|
||||
my $encoded = MIME::Base64::encode_base64($cka_value, '');
|
||||
$encoded =~ s/(.{1,${opt_w}})/$1\n/g;
|
||||
my $pem = "-----BEGIN CERTIFICATE-----\n"
|
||||
. $encoded
|
||||
. "-----END CERTIFICATE-----\n";
|
||||
print CRT "\n$caname\n";
|
||||
my $maxStringLength = length(decode('UTF-8', $caname, Encode::FB_CROAK | Encode::LEAVE_SRC));
|
||||
print CRT ("=" x $maxStringLength . "\n");
|
||||
if ($opt_t) {
|
||||
foreach my $key (sort keys %trust_purposes_by_level) {
|
||||
my $string = $key . ": " . join(", ", @{$trust_purposes_by_level{$key}});
|
||||
print CRT $string . "\n";
|
||||
}
|
||||
}
|
||||
if($opt_m) {
|
||||
print CRT for @precert;
|
||||
}
|
||||
if (!$opt_t) {
|
||||
print CRT $pem;
|
||||
} else {
|
||||
my $pipe = "";
|
||||
foreach my $hash (@included_signature_algorithms) {
|
||||
$pipe = "|$openssl x509 -" . $hash . " -fingerprint -noout -inform PEM";
|
||||
if (!$stdout) {
|
||||
$pipe .= " >> $crt.~";
|
||||
close(CRT) or die "Couldn't close $crt.~: $!";
|
||||
}
|
||||
open(TMP, $pipe) or die "Couldn't open openssl pipe: $!";
|
||||
print TMP $pem;
|
||||
close(TMP) or die "Couldn't close openssl pipe: $!";
|
||||
if (!$stdout) {
|
||||
open(CRT, ">>$crt.~") or die "Couldn't open $crt.~: $!";
|
||||
}
|
||||
}
|
||||
$pipe = "|$openssl x509 -text -inform PEM";
|
||||
if (!$stdout) {
|
||||
$pipe .= " >> $crt.~";
|
||||
close(CRT) or die "Couldn't close $crt.~: $!";
|
||||
}
|
||||
open(TMP, $pipe) or die "Couldn't open openssl pipe: $!";
|
||||
print TMP $pem;
|
||||
close(TMP) or die "Couldn't close openssl pipe: $!";
|
||||
if (!$stdout) {
|
||||
open(CRT, ">>$crt.~") or die "Couldn't open $crt.~: $!";
|
||||
}
|
||||
}
|
||||
report "Processed: $caname" if ($opt_v);
|
||||
$certnum ++;
|
||||
}
|
||||
}
|
||||
}
|
||||
close(TXT) or die "Couldn't close $txt: $!\n";
|
||||
close(CRT) or die "Couldn't close $crt.~: $!\n";
|
||||
unless( $stdout ) {
|
||||
if ($opt_b && -e $crt) {
|
||||
my $bk = 1;
|
||||
while (-e "$crt.~${bk}~") {
|
||||
$bk++;
|
||||
}
|
||||
rename $crt, "$crt.~${bk}~" or die "Failed to create backup $crt.~$bk}~: $!\n";
|
||||
} elsif( -e $crt ) {
|
||||
unlink( $crt ) or die "Failed to remove $crt: $!\n";
|
||||
}
|
||||
rename "$crt.~", $crt or die "Failed to rename $crt.~ to $crt: $!\n";
|
||||
}
|
||||
if($opt_u && -e $txt && !unlink($txt)) {
|
||||
report "Failed to remove $txt: $!\n";
|
||||
}
|
||||
report "Done ($certnum CA certs processed, $skipnum skipped).";
|
3261
3rdparty/curl/include/curl/curl.h
vendored
Normal file
3261
3rdparty/curl/include/curl/curl.h
vendored
Normal file
File diff suppressed because it is too large
Load Diff
79
3rdparty/curl/include/curl/curlver.h
vendored
Normal file
79
3rdparty/curl/include/curl/curlver.h
vendored
Normal file
@ -0,0 +1,79 @@
|
||||
#ifndef CURLINC_CURLVER_H
|
||||
#define CURLINC_CURLVER_H
|
||||
/***************************************************************************
|
||||
* _ _ ____ _
|
||||
* Project ___| | | | _ \| |
|
||||
* / __| | | | |_) | |
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
*
|
||||
* This software is licensed as described in the file COPYING, which
|
||||
* you should have received as part of this distribution. The terms
|
||||
* are also available at https://curl.se/docs/copyright.html.
|
||||
*
|
||||
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
|
||||
* copies of the Software, and permit persons to whom the Software is
|
||||
* furnished to do so, under the terms of the COPYING file.
|
||||
*
|
||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||
* KIND, either express or implied.
|
||||
*
|
||||
* SPDX-License-Identifier: curl
|
||||
*
|
||||
***************************************************************************/
|
||||
|
||||
/* This header file contains nothing but libcurl version info, generated by
|
||||
a script at release-time. This was made its own header file in 7.11.2 */
|
||||
|
||||
/* This is the global package copyright */
|
||||
#define LIBCURL_COPYRIGHT "Daniel Stenberg, <daniel@haxx.se>."
|
||||
|
||||
/* This is the version number of the libcurl package from which this header
|
||||
file origins: */
|
||||
#define LIBCURL_VERSION "8.11.0-DEV"
|
||||
|
||||
/* The numeric version number is also available "in parts" by using these
|
||||
defines: */
|
||||
#define LIBCURL_VERSION_MAJOR 8
|
||||
#define LIBCURL_VERSION_MINOR 11
|
||||
#define LIBCURL_VERSION_PATCH 0
|
||||
|
||||
/* This is the numeric version of the libcurl version number, meant for easier
|
||||
parsing and comparisons by programs. The LIBCURL_VERSION_NUM define will
|
||||
always follow this syntax:
|
||||
|
||||
0xXXYYZZ
|
||||
|
||||
Where XX, YY and ZZ are the main version, release and patch numbers in
|
||||
hexadecimal (using 8 bits each). All three numbers are always represented
|
||||
using two digits. 1.2 would appear as "0x010200" while version 9.11.7
|
||||
appears as "0x090b07".
|
||||
|
||||
This 6-digit (24 bits) hexadecimal number does not show pre-release number,
|
||||
and it is always a greater number in a more recent release. It makes
|
||||
comparisons with greater than and less than work.
|
||||
|
||||
Note: This define is the full hex number and _does not_ use the
|
||||
CURL_VERSION_BITS() macro since curl's own configure script greps for it
|
||||
and needs it to contain the full number.
|
||||
*/
|
||||
#define LIBCURL_VERSION_NUM 0x080b00
|
||||
|
||||
/*
|
||||
* This is the date and time when the full source package was created. The
|
||||
* timestamp is not stored in git, as the timestamp is properly set in the
|
||||
* tarballs by the maketgz script.
|
||||
*
|
||||
* The format of the date follows this template:
|
||||
*
|
||||
* "2007-11-23"
|
||||
*/
|
||||
#define LIBCURL_TIMESTAMP "[unreleased]"
|
||||
|
||||
#define CURL_VERSION_BITS(x,y,z) ((x)<<16|(y)<<8|(z))
|
||||
#define CURL_AT_LEAST_VERSION(x,y,z) \
|
||||
(LIBCURL_VERSION_NUM >= CURL_VERSION_BITS(x, y, z))
|
||||
|
||||
#endif /* CURLINC_CURLVER_H */
|
125
3rdparty/curl/include/curl/easy.h
vendored
Normal file
125
3rdparty/curl/include/curl/easy.h
vendored
Normal file
@ -0,0 +1,125 @@
|
||||
#ifndef CURLINC_EASY_H
|
||||
#define CURLINC_EASY_H
|
||||
/***************************************************************************
|
||||
* _ _ ____ _
|
||||
* Project ___| | | | _ \| |
|
||||
* / __| | | | |_) | |
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
*
|
||||
* This software is licensed as described in the file COPYING, which
|
||||
* you should have received as part of this distribution. The terms
|
||||
* are also available at https://curl.se/docs/copyright.html.
|
||||
*
|
||||
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
|
||||
* copies of the Software, and permit persons to whom the Software is
|
||||
* furnished to do so, under the terms of the COPYING file.
|
||||
*
|
||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||
* KIND, either express or implied.
|
||||
*
|
||||
* SPDX-License-Identifier: curl
|
||||
*
|
||||
***************************************************************************/
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Flag bits in the curl_blob struct: */
|
||||
#define CURL_BLOB_COPY 1 /* tell libcurl to copy the data */
|
||||
#define CURL_BLOB_NOCOPY 0 /* tell libcurl to NOT copy the data */
|
||||
|
||||
struct curl_blob {
|
||||
void *data;
|
||||
size_t len;
|
||||
unsigned int flags; /* bit 0 is defined, the rest are reserved and should be
|
||||
left zeroes */
|
||||
};
|
||||
|
||||
CURL_EXTERN CURL *curl_easy_init(void);
|
||||
CURL_EXTERN CURLcode curl_easy_setopt(CURL *curl, CURLoption option, ...);
|
||||
CURL_EXTERN CURLcode curl_easy_perform(CURL *curl);
|
||||
CURL_EXTERN void curl_easy_cleanup(CURL *curl);
|
||||
|
||||
/*
|
||||
* NAME curl_easy_getinfo()
|
||||
*
|
||||
* DESCRIPTION
|
||||
*
|
||||
* Request internal information from the curl session with this function.
|
||||
* The third argument MUST be pointing to the specific type of the used option
|
||||
* which is documented in each manpage of the option. The data pointed to
|
||||
* will be filled in accordingly and can be relied upon only if the function
|
||||
* returns CURLE_OK. This function is intended to get used *AFTER* a performed
|
||||
* transfer, all results from this function are undefined until the transfer
|
||||
* is completed.
|
||||
*/
|
||||
CURL_EXTERN CURLcode curl_easy_getinfo(CURL *curl, CURLINFO info, ...);
|
||||
|
||||
|
||||
/*
|
||||
* NAME curl_easy_duphandle()
|
||||
*
|
||||
* DESCRIPTION
|
||||
*
|
||||
* Creates a new curl session handle with the same options set for the handle
|
||||
* passed in. Duplicating a handle could only be a matter of cloning data and
|
||||
* options, internal state info and things like persistent connections cannot
|
||||
* be transferred. It is useful in multithreaded applications when you can run
|
||||
* curl_easy_duphandle() for each new thread to avoid a series of identical
|
||||
* curl_easy_setopt() invokes in every thread.
|
||||
*/
|
||||
CURL_EXTERN CURL *curl_easy_duphandle(CURL *curl);
|
||||
|
||||
/*
|
||||
* NAME curl_easy_reset()
|
||||
*
|
||||
* DESCRIPTION
|
||||
*
|
||||
* Re-initializes a CURL handle to the default values. This puts back the
|
||||
* handle to the same state as it was in when it was just created.
|
||||
*
|
||||
* It does keep: live connections, the Session ID cache, the DNS cache and the
|
||||
* cookies.
|
||||
*/
|
||||
CURL_EXTERN void curl_easy_reset(CURL *curl);
|
||||
|
||||
/*
|
||||
* NAME curl_easy_recv()
|
||||
*
|
||||
* DESCRIPTION
|
||||
*
|
||||
* Receives data from the connected socket. Use after successful
|
||||
* curl_easy_perform() with CURLOPT_CONNECT_ONLY option.
|
||||
*/
|
||||
CURL_EXTERN CURLcode curl_easy_recv(CURL *curl, void *buffer, size_t buflen,
|
||||
size_t *n);
|
||||
|
||||
/*
|
||||
* NAME curl_easy_send()
|
||||
*
|
||||
* DESCRIPTION
|
||||
*
|
||||
* Sends data over the connected socket. Use after successful
|
||||
* curl_easy_perform() with CURLOPT_CONNECT_ONLY option.
|
||||
*/
|
||||
CURL_EXTERN CURLcode curl_easy_send(CURL *curl, const void *buffer,
|
||||
size_t buflen, size_t *n);
|
||||
|
||||
|
||||
/*
|
||||
* NAME curl_easy_upkeep()
|
||||
*
|
||||
* DESCRIPTION
|
||||
*
|
||||
* Performs connection upkeep for the given session handle.
|
||||
*/
|
||||
CURL_EXTERN CURLcode curl_easy_upkeep(CURL *curl);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* end of extern "C" */
|
||||
#endif
|
||||
|
||||
#endif
|
74
3rdparty/curl/include/curl/header.h
vendored
Normal file
74
3rdparty/curl/include/curl/header.h
vendored
Normal file
@ -0,0 +1,74 @@
|
||||
#ifndef CURLINC_HEADER_H
|
||||
#define CURLINC_HEADER_H
|
||||
/***************************************************************************
|
||||
* _ _ ____ _
|
||||
* Project ___| | | | _ \| |
|
||||
* / __| | | | |_) | |
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
*
|
||||
* This software is licensed as described in the file COPYING, which
|
||||
* you should have received as part of this distribution. The terms
|
||||
* are also available at https://curl.se/docs/copyright.html.
|
||||
*
|
||||
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
|
||||
* copies of the Software, and permit persons to whom the Software is
|
||||
* furnished to do so, under the terms of the COPYING file.
|
||||
*
|
||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||
* KIND, either express or implied.
|
||||
*
|
||||
* SPDX-License-Identifier: curl
|
||||
*
|
||||
***************************************************************************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct curl_header {
|
||||
char *name; /* this might not use the same case */
|
||||
char *value;
|
||||
size_t amount; /* number of headers using this name */
|
||||
size_t index; /* ... of this instance, 0 or higher */
|
||||
unsigned int origin; /* see bits below */
|
||||
void *anchor; /* handle privately used by libcurl */
|
||||
};
|
||||
|
||||
/* 'origin' bits */
|
||||
#define CURLH_HEADER (1<<0) /* plain server header */
|
||||
#define CURLH_TRAILER (1<<1) /* trailers */
|
||||
#define CURLH_CONNECT (1<<2) /* CONNECT headers */
|
||||
#define CURLH_1XX (1<<3) /* 1xx headers */
|
||||
#define CURLH_PSEUDO (1<<4) /* pseudo headers */
|
||||
|
||||
typedef enum {
|
||||
CURLHE_OK,
|
||||
CURLHE_BADINDEX, /* header exists but not with this index */
|
||||
CURLHE_MISSING, /* no such header exists */
|
||||
CURLHE_NOHEADERS, /* no headers at all exist (yet) */
|
||||
CURLHE_NOREQUEST, /* no request with this number was used */
|
||||
CURLHE_OUT_OF_MEMORY, /* out of memory while processing */
|
||||
CURLHE_BAD_ARGUMENT, /* a function argument was not okay */
|
||||
CURLHE_NOT_BUILT_IN /* if API was disabled in the build */
|
||||
} CURLHcode;
|
||||
|
||||
CURL_EXTERN CURLHcode curl_easy_header(CURL *easy,
|
||||
const char *name,
|
||||
size_t index,
|
||||
unsigned int origin,
|
||||
int request,
|
||||
struct curl_header **hout);
|
||||
|
||||
CURL_EXTERN struct curl_header *curl_easy_nextheader(CURL *easy,
|
||||
unsigned int origin,
|
||||
int request,
|
||||
struct curl_header *prev);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* end of extern "C" */
|
||||
#endif
|
||||
|
||||
#endif /* CURLINC_HEADER_H */
|
85
3rdparty/curl/include/curl/mprintf.h
vendored
Normal file
85
3rdparty/curl/include/curl/mprintf.h
vendored
Normal file
@ -0,0 +1,85 @@
|
||||
#ifndef CURLINC_MPRINTF_H
|
||||
#define CURLINC_MPRINTF_H
|
||||
/***************************************************************************
|
||||
* _ _ ____ _
|
||||
* Project ___| | | | _ \| |
|
||||
* / __| | | | |_) | |
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
*
|
||||
* This software is licensed as described in the file COPYING, which
|
||||
* you should have received as part of this distribution. The terms
|
||||
* are also available at https://curl.se/docs/copyright.html.
|
||||
*
|
||||
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
|
||||
* copies of the Software, and permit persons to whom the Software is
|
||||
* furnished to do so, under the terms of the COPYING file.
|
||||
*
|
||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||
* KIND, either express or implied.
|
||||
*
|
||||
* SPDX-License-Identifier: curl
|
||||
*
|
||||
***************************************************************************/
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h> /* needed for FILE */
|
||||
#include "curl.h" /* for CURL_EXTERN */
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifndef CURL_TEMP_PRINTF
|
||||
#if (defined(__GNUC__) || defined(__clang__) || \
|
||||
defined(__IAR_SYSTEMS_ICC__)) && \
|
||||
defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) && \
|
||||
!defined(CURL_NO_FMT_CHECKS)
|
||||
#if defined(__MINGW32__) && !defined(__clang__)
|
||||
#if defined(__MINGW_PRINTF_FORMAT) /* mingw-w64 3.0.0+. Needs stdio.h. */
|
||||
#define CURL_TEMP_PRINTF(fmt, arg) \
|
||||
__attribute__((format(__MINGW_PRINTF_FORMAT, fmt, arg)))
|
||||
#else
|
||||
#define CURL_TEMP_PRINTF(fmt, arg)
|
||||
#endif
|
||||
#else
|
||||
#define CURL_TEMP_PRINTF(fmt, arg) \
|
||||
__attribute__((format(printf, fmt, arg)))
|
||||
#endif
|
||||
#else
|
||||
#define CURL_TEMP_PRINTF(fmt, arg)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
CURL_EXTERN int curl_mprintf(const char *format, ...)
|
||||
CURL_TEMP_PRINTF(1, 2);
|
||||
CURL_EXTERN int curl_mfprintf(FILE *fd, const char *format, ...)
|
||||
CURL_TEMP_PRINTF(2, 3);
|
||||
CURL_EXTERN int curl_msprintf(char *buffer, const char *format, ...)
|
||||
CURL_TEMP_PRINTF(2, 3);
|
||||
CURL_EXTERN int curl_msnprintf(char *buffer, size_t maxlength,
|
||||
const char *format, ...)
|
||||
CURL_TEMP_PRINTF(3, 4);
|
||||
CURL_EXTERN int curl_mvprintf(const char *format, va_list args)
|
||||
CURL_TEMP_PRINTF(1, 0);
|
||||
CURL_EXTERN int curl_mvfprintf(FILE *fd, const char *format, va_list args)
|
||||
CURL_TEMP_PRINTF(2, 0);
|
||||
CURL_EXTERN int curl_mvsprintf(char *buffer, const char *format, va_list args)
|
||||
CURL_TEMP_PRINTF(2, 0);
|
||||
CURL_EXTERN int curl_mvsnprintf(char *buffer, size_t maxlength,
|
||||
const char *format, va_list args)
|
||||
CURL_TEMP_PRINTF(3, 0);
|
||||
CURL_EXTERN char *curl_maprintf(const char *format, ...)
|
||||
CURL_TEMP_PRINTF(1, 2);
|
||||
CURL_EXTERN char *curl_mvaprintf(const char *format, va_list args)
|
||||
CURL_TEMP_PRINTF(1, 0);
|
||||
|
||||
#undef CURL_TEMP_PRINTF
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* end of extern "C" */
|
||||
#endif
|
||||
|
||||
#endif /* CURLINC_MPRINTF_H */
|
485
3rdparty/curl/include/curl/multi.h
vendored
Normal file
485
3rdparty/curl/include/curl/multi.h
vendored
Normal file
@ -0,0 +1,485 @@
|
||||
#ifndef CURLINC_MULTI_H
|
||||
#define CURLINC_MULTI_H
|
||||
/***************************************************************************
|
||||
* _ _ ____ _
|
||||
* Project ___| | | | _ \| |
|
||||
* / __| | | | |_) | |
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
*
|
||||
* This software is licensed as described in the file COPYING, which
|
||||
* you should have received as part of this distribution. The terms
|
||||
* are also available at https://curl.se/docs/copyright.html.
|
||||
*
|
||||
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
|
||||
* copies of the Software, and permit persons to whom the Software is
|
||||
* furnished to do so, under the terms of the COPYING file.
|
||||
*
|
||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||
* KIND, either express or implied.
|
||||
*
|
||||
* SPDX-License-Identifier: curl
|
||||
*
|
||||
***************************************************************************/
|
||||
/*
|
||||
This is an "external" header file. Do not give away any internals here!
|
||||
|
||||
GOALS
|
||||
|
||||
o Enable a "pull" interface. The application that uses libcurl decides where
|
||||
and when to ask libcurl to get/send data.
|
||||
|
||||
o Enable multiple simultaneous transfers in the same thread without making it
|
||||
complicated for the application.
|
||||
|
||||
o Enable the application to select() on its own file descriptors and curl's
|
||||
file descriptors simultaneous easily.
|
||||
|
||||
*/
|
||||
|
||||
/*
|
||||
* This header file should not really need to include "curl.h" since curl.h
|
||||
* itself includes this file and we expect user applications to do #include
|
||||
* <curl/curl.h> without the need for especially including multi.h.
|
||||
*
|
||||
* For some reason we added this include here at one point, and rather than to
|
||||
* break existing (wrongly written) libcurl applications, we leave it as-is
|
||||
* but with this warning attached.
|
||||
*/
|
||||
#include "curl.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#if defined(BUILDING_LIBCURL) || defined(CURL_STRICTER)
|
||||
typedef struct Curl_multi CURLM;
|
||||
#else
|
||||
typedef void CURLM;
|
||||
#endif
|
||||
|
||||
typedef enum {
|
||||
CURLM_CALL_MULTI_PERFORM = -1, /* please call curl_multi_perform() or
|
||||
curl_multi_socket*() soon */
|
||||
CURLM_OK,
|
||||
CURLM_BAD_HANDLE, /* the passed-in handle is not a valid CURLM handle */
|
||||
CURLM_BAD_EASY_HANDLE, /* an easy handle was not good/valid */
|
||||
CURLM_OUT_OF_MEMORY, /* if you ever get this, you are in deep sh*t */
|
||||
CURLM_INTERNAL_ERROR, /* this is a libcurl bug */
|
||||
CURLM_BAD_SOCKET, /* the passed in socket argument did not match */
|
||||
CURLM_UNKNOWN_OPTION, /* curl_multi_setopt() with unsupported option */
|
||||
CURLM_ADDED_ALREADY, /* an easy handle already added to a multi handle was
|
||||
attempted to get added - again */
|
||||
CURLM_RECURSIVE_API_CALL, /* an api function was called from inside a
|
||||
callback */
|
||||
CURLM_WAKEUP_FAILURE, /* wakeup is unavailable or failed */
|
||||
CURLM_BAD_FUNCTION_ARGUMENT, /* function called with a bad parameter */
|
||||
CURLM_ABORTED_BY_CALLBACK,
|
||||
CURLM_UNRECOVERABLE_POLL,
|
||||
CURLM_LAST
|
||||
} CURLMcode;
|
||||
|
||||
/* just to make code nicer when using curl_multi_socket() you can now check
|
||||
for CURLM_CALL_MULTI_SOCKET too in the same style it works for
|
||||
curl_multi_perform() and CURLM_CALL_MULTI_PERFORM */
|
||||
#define CURLM_CALL_MULTI_SOCKET CURLM_CALL_MULTI_PERFORM
|
||||
|
||||
/* bitmask bits for CURLMOPT_PIPELINING */
|
||||
#define CURLPIPE_NOTHING 0L
|
||||
#define CURLPIPE_HTTP1 1L
|
||||
#define CURLPIPE_MULTIPLEX 2L
|
||||
|
||||
typedef enum {
|
||||
CURLMSG_NONE, /* first, not used */
|
||||
CURLMSG_DONE, /* This easy handle has completed. 'result' contains
|
||||
the CURLcode of the transfer */
|
||||
CURLMSG_LAST /* last, not used */
|
||||
} CURLMSG;
|
||||
|
||||
struct CURLMsg {
|
||||
CURLMSG msg; /* what this message means */
|
||||
CURL *easy_handle; /* the handle it concerns */
|
||||
union {
|
||||
void *whatever; /* message-specific data */
|
||||
CURLcode result; /* return code for transfer */
|
||||
} data;
|
||||
};
|
||||
typedef struct CURLMsg CURLMsg;
|
||||
|
||||
/* Based on poll(2) structure and values.
|
||||
* We do not use pollfd and POLL* constants explicitly
|
||||
* to cover platforms without poll(). */
|
||||
#define CURL_WAIT_POLLIN 0x0001
|
||||
#define CURL_WAIT_POLLPRI 0x0002
|
||||
#define CURL_WAIT_POLLOUT 0x0004
|
||||
|
||||
struct curl_waitfd {
|
||||
curl_socket_t fd;
|
||||
short events;
|
||||
short revents;
|
||||
};
|
||||
|
||||
/*
|
||||
* Name: curl_multi_init()
|
||||
*
|
||||
* Desc: initialize multi-style curl usage
|
||||
*
|
||||
* Returns: a new CURLM handle to use in all 'curl_multi' functions.
|
||||
*/
|
||||
CURL_EXTERN CURLM *curl_multi_init(void);
|
||||
|
||||
/*
|
||||
* Name: curl_multi_add_handle()
|
||||
*
|
||||
* Desc: add a standard curl handle to the multi stack
|
||||
*
|
||||
* Returns: CURLMcode type, general multi error code.
|
||||
*/
|
||||
CURL_EXTERN CURLMcode curl_multi_add_handle(CURLM *multi_handle,
|
||||
CURL *curl_handle);
|
||||
|
||||
/*
|
||||
* Name: curl_multi_remove_handle()
|
||||
*
|
||||
* Desc: removes a curl handle from the multi stack again
|
||||
*
|
||||
* Returns: CURLMcode type, general multi error code.
|
||||
*/
|
||||
CURL_EXTERN CURLMcode curl_multi_remove_handle(CURLM *multi_handle,
|
||||
CURL *curl_handle);
|
||||
|
||||
/*
|
||||
* Name: curl_multi_fdset()
|
||||
*
|
||||
* Desc: Ask curl for its fd_set sets. The app can use these to select() or
|
||||
* poll() on. We want curl_multi_perform() called as soon as one of
|
||||
* them are ready.
|
||||
*
|
||||
* Returns: CURLMcode type, general multi error code.
|
||||
*/
|
||||
CURL_EXTERN CURLMcode curl_multi_fdset(CURLM *multi_handle,
|
||||
fd_set *read_fd_set,
|
||||
fd_set *write_fd_set,
|
||||
fd_set *exc_fd_set,
|
||||
int *max_fd);
|
||||
|
||||
/*
|
||||
* Name: curl_multi_wait()
|
||||
*
|
||||
* Desc: Poll on all fds within a CURLM set as well as any
|
||||
* additional fds passed to the function.
|
||||
*
|
||||
* Returns: CURLMcode type, general multi error code.
|
||||
*/
|
||||
CURL_EXTERN CURLMcode curl_multi_wait(CURLM *multi_handle,
|
||||
struct curl_waitfd extra_fds[],
|
||||
unsigned int extra_nfds,
|
||||
int timeout_ms,
|
||||
int *ret);
|
||||
|
||||
/*
|
||||
* Name: curl_multi_poll()
|
||||
*
|
||||
* Desc: Poll on all fds within a CURLM set as well as any
|
||||
* additional fds passed to the function.
|
||||
*
|
||||
* Returns: CURLMcode type, general multi error code.
|
||||
*/
|
||||
CURL_EXTERN CURLMcode curl_multi_poll(CURLM *multi_handle,
|
||||
struct curl_waitfd extra_fds[],
|
||||
unsigned int extra_nfds,
|
||||
int timeout_ms,
|
||||
int *ret);
|
||||
|
||||
/*
|
||||
* Name: curl_multi_wakeup()
|
||||
*
|
||||
* Desc: wakes up a sleeping curl_multi_poll call.
|
||||
*
|
||||
* Returns: CURLMcode type, general multi error code.
|
||||
*/
|
||||
CURL_EXTERN CURLMcode curl_multi_wakeup(CURLM *multi_handle);
|
||||
|
||||
/*
|
||||
* Name: curl_multi_perform()
|
||||
*
|
||||
* Desc: When the app thinks there is data available for curl it calls this
|
||||
* function to read/write whatever there is right now. This returns
|
||||
* as soon as the reads and writes are done. This function does not
|
||||
* require that there actually is data available for reading or that
|
||||
* data can be written, it can be called just in case. It returns
|
||||
* the number of handles that still transfer data in the second
|
||||
* argument's integer-pointer.
|
||||
*
|
||||
* Returns: CURLMcode type, general multi error code. *NOTE* that this only
|
||||
* returns errors etc regarding the whole multi stack. There might
|
||||
* still have occurred problems on individual transfers even when
|
||||
* this returns OK.
|
||||
*/
|
||||
CURL_EXTERN CURLMcode curl_multi_perform(CURLM *multi_handle,
|
||||
int *running_handles);
|
||||
|
||||
/*
|
||||
* Name: curl_multi_cleanup()
|
||||
*
|
||||
* Desc: Cleans up and removes a whole multi stack. It does not free or
|
||||
* touch any individual easy handles in any way. We need to define
|
||||
* in what state those handles will be if this function is called
|
||||
* in the middle of a transfer.
|
||||
*
|
||||
* Returns: CURLMcode type, general multi error code.
|
||||
*/
|
||||
CURL_EXTERN CURLMcode curl_multi_cleanup(CURLM *multi_handle);
|
||||
|
||||
/*
|
||||
* Name: curl_multi_info_read()
|
||||
*
|
||||
* Desc: Ask the multi handle if there is any messages/informationals from
|
||||
* the individual transfers. Messages include informationals such as
|
||||
* error code from the transfer or just the fact that a transfer is
|
||||
* completed. More details on these should be written down as well.
|
||||
*
|
||||
* Repeated calls to this function will return a new struct each
|
||||
* time, until a special "end of msgs" struct is returned as a signal
|
||||
* that there is no more to get at this point.
|
||||
*
|
||||
* The data the returned pointer points to will not survive calling
|
||||
* curl_multi_cleanup().
|
||||
*
|
||||
* The 'CURLMsg' struct is meant to be very simple and only contain
|
||||
* very basic information. If more involved information is wanted,
|
||||
* we will provide the particular "transfer handle" in that struct
|
||||
* and that should/could/would be used in subsequent
|
||||
* curl_easy_getinfo() calls (or similar). The point being that we
|
||||
* must never expose complex structs to applications, as then we will
|
||||
* undoubtably get backwards compatibility problems in the future.
|
||||
*
|
||||
* Returns: A pointer to a filled-in struct, or NULL if it failed or ran out
|
||||
* of structs. It also writes the number of messages left in the
|
||||
* queue (after this read) in the integer the second argument points
|
||||
* to.
|
||||
*/
|
||||
CURL_EXTERN CURLMsg *curl_multi_info_read(CURLM *multi_handle,
|
||||
int *msgs_in_queue);
|
||||
|
||||
/*
|
||||
* Name: curl_multi_strerror()
|
||||
*
|
||||
* Desc: The curl_multi_strerror function may be used to turn a CURLMcode
|
||||
* value into the equivalent human readable error string. This is
|
||||
* useful for printing meaningful error messages.
|
||||
*
|
||||
* Returns: A pointer to a null-terminated error message.
|
||||
*/
|
||||
CURL_EXTERN const char *curl_multi_strerror(CURLMcode);
|
||||
|
||||
/*
|
||||
* Name: curl_multi_socket() and
|
||||
* curl_multi_socket_all()
|
||||
*
|
||||
* Desc: An alternative version of curl_multi_perform() that allows the
|
||||
* application to pass in one of the file descriptors that have been
|
||||
* detected to have "action" on them and let libcurl perform.
|
||||
* See manpage for details.
|
||||
*/
|
||||
#define CURL_POLL_NONE 0
|
||||
#define CURL_POLL_IN 1
|
||||
#define CURL_POLL_OUT 2
|
||||
#define CURL_POLL_INOUT 3
|
||||
#define CURL_POLL_REMOVE 4
|
||||
|
||||
#define CURL_SOCKET_TIMEOUT CURL_SOCKET_BAD
|
||||
|
||||
#define CURL_CSELECT_IN 0x01
|
||||
#define CURL_CSELECT_OUT 0x02
|
||||
#define CURL_CSELECT_ERR 0x04
|
||||
|
||||
typedef int (*curl_socket_callback)(CURL *easy, /* easy handle */
|
||||
curl_socket_t s, /* socket */
|
||||
int what, /* see above */
|
||||
void *userp, /* private callback
|
||||
pointer */
|
||||
void *socketp); /* private socket
|
||||
pointer */
|
||||
/*
|
||||
* Name: curl_multi_timer_callback
|
||||
*
|
||||
* Desc: Called by libcurl whenever the library detects a change in the
|
||||
* maximum number of milliseconds the app is allowed to wait before
|
||||
* curl_multi_socket() or curl_multi_perform() must be called
|
||||
* (to allow libcurl's timed events to take place).
|
||||
*
|
||||
* Returns: The callback should return zero.
|
||||
*/
|
||||
typedef int (*curl_multi_timer_callback)(CURLM *multi, /* multi handle */
|
||||
long timeout_ms, /* see above */
|
||||
void *userp); /* private callback
|
||||
pointer */
|
||||
|
||||
CURL_EXTERN CURLMcode CURL_DEPRECATED(7.19.5, "Use curl_multi_socket_action()")
|
||||
curl_multi_socket(CURLM *multi_handle, curl_socket_t s, int *running_handles);
|
||||
|
||||
CURL_EXTERN CURLMcode curl_multi_socket_action(CURLM *multi_handle,
|
||||
curl_socket_t s,
|
||||
int ev_bitmask,
|
||||
int *running_handles);
|
||||
|
||||
CURL_EXTERN CURLMcode CURL_DEPRECATED(7.19.5, "Use curl_multi_socket_action()")
|
||||
curl_multi_socket_all(CURLM *multi_handle, int *running_handles);
|
||||
|
||||
#ifndef CURL_ALLOW_OLD_MULTI_SOCKET
|
||||
/* This macro below was added in 7.16.3 to push users who recompile to use
|
||||
the new curl_multi_socket_action() instead of the old curl_multi_socket()
|
||||
*/
|
||||
#define curl_multi_socket(x,y,z) curl_multi_socket_action(x,y,0,z)
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Name: curl_multi_timeout()
|
||||
*
|
||||
* Desc: Returns the maximum number of milliseconds the app is allowed to
|
||||
* wait before curl_multi_socket() or curl_multi_perform() must be
|
||||
* called (to allow libcurl's timed events to take place).
|
||||
*
|
||||
* Returns: CURLM error code.
|
||||
*/
|
||||
CURL_EXTERN CURLMcode curl_multi_timeout(CURLM *multi_handle,
|
||||
long *milliseconds);
|
||||
|
||||
typedef enum {
|
||||
/* This is the socket callback function pointer */
|
||||
CURLOPT(CURLMOPT_SOCKETFUNCTION, CURLOPTTYPE_FUNCTIONPOINT, 1),
|
||||
|
||||
/* This is the argument passed to the socket callback */
|
||||
CURLOPT(CURLMOPT_SOCKETDATA, CURLOPTTYPE_OBJECTPOINT, 2),
|
||||
|
||||
/* set to 1 to enable pipelining for this multi handle */
|
||||
CURLOPT(CURLMOPT_PIPELINING, CURLOPTTYPE_LONG, 3),
|
||||
|
||||
/* This is the timer callback function pointer */
|
||||
CURLOPT(CURLMOPT_TIMERFUNCTION, CURLOPTTYPE_FUNCTIONPOINT, 4),
|
||||
|
||||
/* This is the argument passed to the timer callback */
|
||||
CURLOPT(CURLMOPT_TIMERDATA, CURLOPTTYPE_OBJECTPOINT, 5),
|
||||
|
||||
/* maximum number of entries in the connection cache */
|
||||
CURLOPT(CURLMOPT_MAXCONNECTS, CURLOPTTYPE_LONG, 6),
|
||||
|
||||
/* maximum number of (pipelining) connections to one host */
|
||||
CURLOPT(CURLMOPT_MAX_HOST_CONNECTIONS, CURLOPTTYPE_LONG, 7),
|
||||
|
||||
/* maximum number of requests in a pipeline */
|
||||
CURLOPT(CURLMOPT_MAX_PIPELINE_LENGTH, CURLOPTTYPE_LONG, 8),
|
||||
|
||||
/* a connection with a content-length longer than this
|
||||
will not be considered for pipelining */
|
||||
CURLOPT(CURLMOPT_CONTENT_LENGTH_PENALTY_SIZE, CURLOPTTYPE_OFF_T, 9),
|
||||
|
||||
/* a connection with a chunk length longer than this
|
||||
will not be considered for pipelining */
|
||||
CURLOPT(CURLMOPT_CHUNK_LENGTH_PENALTY_SIZE, CURLOPTTYPE_OFF_T, 10),
|
||||
|
||||
/* a list of site names(+port) that are blocked from pipelining */
|
||||
CURLOPT(CURLMOPT_PIPELINING_SITE_BL, CURLOPTTYPE_OBJECTPOINT, 11),
|
||||
|
||||
/* a list of server types that are blocked from pipelining */
|
||||
CURLOPT(CURLMOPT_PIPELINING_SERVER_BL, CURLOPTTYPE_OBJECTPOINT, 12),
|
||||
|
||||
/* maximum number of open connections in total */
|
||||
CURLOPT(CURLMOPT_MAX_TOTAL_CONNECTIONS, CURLOPTTYPE_LONG, 13),
|
||||
|
||||
/* This is the server push callback function pointer */
|
||||
CURLOPT(CURLMOPT_PUSHFUNCTION, CURLOPTTYPE_FUNCTIONPOINT, 14),
|
||||
|
||||
/* This is the argument passed to the server push callback */
|
||||
CURLOPT(CURLMOPT_PUSHDATA, CURLOPTTYPE_OBJECTPOINT, 15),
|
||||
|
||||
/* maximum number of concurrent streams to support on a connection */
|
||||
CURLOPT(CURLMOPT_MAX_CONCURRENT_STREAMS, CURLOPTTYPE_LONG, 16),
|
||||
|
||||
CURLMOPT_LASTENTRY /* the last unused */
|
||||
} CURLMoption;
|
||||
|
||||
|
||||
/*
|
||||
* Name: curl_multi_setopt()
|
||||
*
|
||||
* Desc: Sets options for the multi handle.
|
||||
*
|
||||
* Returns: CURLM error code.
|
||||
*/
|
||||
CURL_EXTERN CURLMcode curl_multi_setopt(CURLM *multi_handle,
|
||||
CURLMoption option, ...);
|
||||
|
||||
|
||||
/*
|
||||
* Name: curl_multi_assign()
|
||||
*
|
||||
* Desc: This function sets an association in the multi handle between the
|
||||
* given socket and a private pointer of the application. This is
|
||||
* (only) useful for curl_multi_socket uses.
|
||||
*
|
||||
* Returns: CURLM error code.
|
||||
*/
|
||||
CURL_EXTERN CURLMcode curl_multi_assign(CURLM *multi_handle,
|
||||
curl_socket_t sockfd, void *sockp);
|
||||
|
||||
/*
|
||||
* Name: curl_multi_get_handles()
|
||||
*
|
||||
* Desc: Returns an allocated array holding all handles currently added to
|
||||
* the multi handle. Marks the final entry with a NULL pointer. If
|
||||
* there is no easy handle added to the multi handle, this function
|
||||
* returns an array with the first entry as a NULL pointer.
|
||||
*
|
||||
* Returns: NULL on failure, otherwise a CURL **array pointer
|
||||
*/
|
||||
CURL_EXTERN CURL **curl_multi_get_handles(CURLM *multi_handle);
|
||||
|
||||
/*
|
||||
* Name: curl_push_callback
|
||||
*
|
||||
* Desc: This callback gets called when a new stream is being pushed by the
|
||||
* server. It approves or denies the new stream. It can also decide
|
||||
* to completely fail the connection.
|
||||
*
|
||||
* Returns: CURL_PUSH_OK, CURL_PUSH_DENY or CURL_PUSH_ERROROUT
|
||||
*/
|
||||
#define CURL_PUSH_OK 0
|
||||
#define CURL_PUSH_DENY 1
|
||||
#define CURL_PUSH_ERROROUT 2 /* added in 7.72.0 */
|
||||
|
||||
struct curl_pushheaders; /* forward declaration only */
|
||||
|
||||
CURL_EXTERN char *curl_pushheader_bynum(struct curl_pushheaders *h,
|
||||
size_t num);
|
||||
CURL_EXTERN char *curl_pushheader_byname(struct curl_pushheaders *h,
|
||||
const char *name);
|
||||
|
||||
typedef int (*curl_push_callback)(CURL *parent,
|
||||
CURL *easy,
|
||||
size_t num_headers,
|
||||
struct curl_pushheaders *headers,
|
||||
void *userp);
|
||||
|
||||
/*
|
||||
* Name: curl_multi_waitfds()
|
||||
*
|
||||
* Desc: Ask curl for fds for polling. The app can use these to poll on.
|
||||
* We want curl_multi_perform() called as soon as one of them are
|
||||
* ready. Passing zero size allows to get just a number of fds.
|
||||
*
|
||||
* Returns: CURLMcode type, general multi error code.
|
||||
*/
|
||||
CURL_EXTERN CURLMcode curl_multi_waitfds(CURLM *multi,
|
||||
struct curl_waitfd *ufds,
|
||||
unsigned int size,
|
||||
unsigned int *fd_count);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* end of extern "C" */
|
||||
#endif
|
||||
|
||||
#endif
|
70
3rdparty/curl/include/curl/options.h
vendored
Normal file
70
3rdparty/curl/include/curl/options.h
vendored
Normal file
@ -0,0 +1,70 @@
|
||||
#ifndef CURLINC_OPTIONS_H
|
||||
#define CURLINC_OPTIONS_H
|
||||
/***************************************************************************
|
||||
* _ _ ____ _
|
||||
* Project ___| | | | _ \| |
|
||||
* / __| | | | |_) | |
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
*
|
||||
* This software is licensed as described in the file COPYING, which
|
||||
* you should have received as part of this distribution. The terms
|
||||
* are also available at https://curl.se/docs/copyright.html.
|
||||
*
|
||||
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
|
||||
* copies of the Software, and permit persons to whom the Software is
|
||||
* furnished to do so, under the terms of the COPYING file.
|
||||
*
|
||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||
* KIND, either express or implied.
|
||||
*
|
||||
* SPDX-License-Identifier: curl
|
||||
*
|
||||
***************************************************************************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef enum {
|
||||
CURLOT_LONG, /* long (a range of values) */
|
||||
CURLOT_VALUES, /* (a defined set or bitmask) */
|
||||
CURLOT_OFF_T, /* curl_off_t (a range of values) */
|
||||
CURLOT_OBJECT, /* pointer (void *) */
|
||||
CURLOT_STRING, /* (char * to null-terminated buffer) */
|
||||
CURLOT_SLIST, /* (struct curl_slist *) */
|
||||
CURLOT_CBPTR, /* (void * passed as-is to a callback) */
|
||||
CURLOT_BLOB, /* blob (struct curl_blob *) */
|
||||
CURLOT_FUNCTION /* function pointer */
|
||||
} curl_easytype;
|
||||
|
||||
/* Flag bits */
|
||||
|
||||
/* "alias" means it is provided for old programs to remain functional,
|
||||
we prefer another name */
|
||||
#define CURLOT_FLAG_ALIAS (1<<0)
|
||||
|
||||
/* The CURLOPTTYPE_* id ranges can still be used to figure out what type/size
|
||||
to use for curl_easy_setopt() for the given id */
|
||||
struct curl_easyoption {
|
||||
const char *name;
|
||||
CURLoption id;
|
||||
curl_easytype type;
|
||||
unsigned int flags;
|
||||
};
|
||||
|
||||
CURL_EXTERN const struct curl_easyoption *
|
||||
curl_easy_option_by_name(const char *name);
|
||||
|
||||
CURL_EXTERN const struct curl_easyoption *
|
||||
curl_easy_option_by_id(CURLoption id);
|
||||
|
||||
CURL_EXTERN const struct curl_easyoption *
|
||||
curl_easy_option_next(const struct curl_easyoption *prev);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* end of extern "C" */
|
||||
#endif
|
||||
#endif /* CURLINC_OPTIONS_H */
|
35
3rdparty/curl/include/curl/stdcheaders.h
vendored
Normal file
35
3rdparty/curl/include/curl/stdcheaders.h
vendored
Normal file
@ -0,0 +1,35 @@
|
||||
#ifndef CURLINC_STDCHEADERS_H
|
||||
#define CURLINC_STDCHEADERS_H
|
||||
/***************************************************************************
|
||||
* _ _ ____ _
|
||||
* Project ___| | | | _ \| |
|
||||
* / __| | | | |_) | |
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
*
|
||||
* This software is licensed as described in the file COPYING, which
|
||||
* you should have received as part of this distribution. The terms
|
||||
* are also available at https://curl.se/docs/copyright.html.
|
||||
*
|
||||
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
|
||||
* copies of the Software, and permit persons to whom the Software is
|
||||
* furnished to do so, under the terms of the COPYING file.
|
||||
*
|
||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||
* KIND, either express or implied.
|
||||
*
|
||||
* SPDX-License-Identifier: curl
|
||||
*
|
||||
***************************************************************************/
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
size_t fread(void *, size_t, size_t, FILE *);
|
||||
size_t fwrite(const void *, size_t, size_t, FILE *);
|
||||
|
||||
int strcasecmp(const char *, const char *);
|
||||
int strncasecmp(const char *, const char *, size_t);
|
||||
|
||||
#endif /* CURLINC_STDCHEADERS_H */
|
496
3rdparty/curl/include/curl/system.h
vendored
Normal file
496
3rdparty/curl/include/curl/system.h
vendored
Normal file
@ -0,0 +1,496 @@
|
||||
#ifndef CURLINC_SYSTEM_H
|
||||
#define CURLINC_SYSTEM_H
|
||||
/***************************************************************************
|
||||
* _ _ ____ _
|
||||
* Project ___| | | | _ \| |
|
||||
* / __| | | | |_) | |
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
*
|
||||
* This software is licensed as described in the file COPYING, which
|
||||
* you should have received as part of this distribution. The terms
|
||||
* are also available at https://curl.se/docs/copyright.html.
|
||||
*
|
||||
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
|
||||
* copies of the Software, and permit persons to whom the Software is
|
||||
* furnished to do so, under the terms of the COPYING file.
|
||||
*
|
||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||
* KIND, either express or implied.
|
||||
*
|
||||
* SPDX-License-Identifier: curl
|
||||
*
|
||||
***************************************************************************/
|
||||
|
||||
/*
|
||||
* Try to keep one section per platform, compiler and architecture, otherwise,
|
||||
* if an existing section is reused for a different one and later on the
|
||||
* original is adjusted, probably the piggybacking one can be adversely
|
||||
* changed.
|
||||
*
|
||||
* In order to differentiate between platforms/compilers/architectures use
|
||||
* only compiler built-in predefined preprocessor symbols.
|
||||
*
|
||||
* curl_off_t
|
||||
* ----------
|
||||
*
|
||||
* For any given platform/compiler curl_off_t must be typedef'ed to a 64-bit
|
||||
* wide signed integral data type. The width of this data type must remain
|
||||
* constant and independent of any possible large file support settings.
|
||||
*
|
||||
* As an exception to the above, curl_off_t shall be typedef'ed to a 32-bit
|
||||
* wide signed integral data type if there is no 64-bit type.
|
||||
*
|
||||
* As a general rule, curl_off_t shall not be mapped to off_t. This rule shall
|
||||
* only be violated if off_t is the only 64-bit data type available and the
|
||||
* size of off_t is independent of large file support settings. Keep your
|
||||
* build on the safe side avoiding an off_t gating. If you have a 64-bit
|
||||
* off_t then take for sure that another 64-bit data type exists, dig deeper
|
||||
* and you will find it.
|
||||
*
|
||||
*/
|
||||
|
||||
#if defined(__DJGPP__) || defined(__GO32__)
|
||||
# if defined(__DJGPP__) && (__DJGPP__ > 1)
|
||||
# define CURL_TYPEOF_CURL_OFF_T long long
|
||||
# define CURL_FORMAT_CURL_OFF_T "lld"
|
||||
# define CURL_FORMAT_CURL_OFF_TU "llu"
|
||||
# define CURL_SUFFIX_CURL_OFF_T LL
|
||||
# define CURL_SUFFIX_CURL_OFF_TU ULL
|
||||
# else
|
||||
# define CURL_TYPEOF_CURL_OFF_T long
|
||||
# define CURL_FORMAT_CURL_OFF_T "ld"
|
||||
# define CURL_FORMAT_CURL_OFF_TU "lu"
|
||||
# define CURL_SUFFIX_CURL_OFF_T L
|
||||
# define CURL_SUFFIX_CURL_OFF_TU UL
|
||||
# endif
|
||||
# define CURL_TYPEOF_CURL_SOCKLEN_T int
|
||||
|
||||
#elif defined(__SALFORDC__)
|
||||
# define CURL_TYPEOF_CURL_OFF_T long
|
||||
# define CURL_FORMAT_CURL_OFF_T "ld"
|
||||
# define CURL_FORMAT_CURL_OFF_TU "lu"
|
||||
# define CURL_SUFFIX_CURL_OFF_T L
|
||||
# define CURL_SUFFIX_CURL_OFF_TU UL
|
||||
# define CURL_TYPEOF_CURL_SOCKLEN_T int
|
||||
|
||||
#elif defined(__BORLANDC__)
|
||||
# if (__BORLANDC__ < 0x520)
|
||||
# define CURL_TYPEOF_CURL_OFF_T long
|
||||
# define CURL_FORMAT_CURL_OFF_T "ld"
|
||||
# define CURL_FORMAT_CURL_OFF_TU "lu"
|
||||
# define CURL_SUFFIX_CURL_OFF_T L
|
||||
# define CURL_SUFFIX_CURL_OFF_TU UL
|
||||
# else
|
||||
# define CURL_TYPEOF_CURL_OFF_T __int64
|
||||
# define CURL_FORMAT_CURL_OFF_T "I64d"
|
||||
# define CURL_FORMAT_CURL_OFF_TU "I64u"
|
||||
# define CURL_SUFFIX_CURL_OFF_T i64
|
||||
# define CURL_SUFFIX_CURL_OFF_TU ui64
|
||||
# endif
|
||||
# define CURL_TYPEOF_CURL_SOCKLEN_T int
|
||||
|
||||
#elif defined(__TURBOC__)
|
||||
# define CURL_TYPEOF_CURL_OFF_T long
|
||||
# define CURL_FORMAT_CURL_OFF_T "ld"
|
||||
# define CURL_FORMAT_CURL_OFF_TU "lu"
|
||||
# define CURL_SUFFIX_CURL_OFF_T L
|
||||
# define CURL_SUFFIX_CURL_OFF_TU UL
|
||||
# define CURL_TYPEOF_CURL_SOCKLEN_T int
|
||||
|
||||
#elif defined(__POCC__)
|
||||
# if (__POCC__ < 280)
|
||||
# define CURL_TYPEOF_CURL_OFF_T long
|
||||
# define CURL_FORMAT_CURL_OFF_T "ld"
|
||||
# define CURL_FORMAT_CURL_OFF_TU "lu"
|
||||
# define CURL_SUFFIX_CURL_OFF_T L
|
||||
# define CURL_SUFFIX_CURL_OFF_TU UL
|
||||
# elif defined(_MSC_VER)
|
||||
# define CURL_TYPEOF_CURL_OFF_T __int64
|
||||
# define CURL_FORMAT_CURL_OFF_T "I64d"
|
||||
# define CURL_FORMAT_CURL_OFF_TU "I64u"
|
||||
# define CURL_SUFFIX_CURL_OFF_T i64
|
||||
# define CURL_SUFFIX_CURL_OFF_TU ui64
|
||||
# else
|
||||
# define CURL_TYPEOF_CURL_OFF_T long long
|
||||
# define CURL_FORMAT_CURL_OFF_T "lld"
|
||||
# define CURL_FORMAT_CURL_OFF_TU "llu"
|
||||
# define CURL_SUFFIX_CURL_OFF_T LL
|
||||
# define CURL_SUFFIX_CURL_OFF_TU ULL
|
||||
# endif
|
||||
# define CURL_TYPEOF_CURL_SOCKLEN_T int
|
||||
|
||||
#elif defined(__LCC__)
|
||||
# if defined(__MCST__) /* MCST eLbrus Compiler Collection */
|
||||
# define CURL_TYPEOF_CURL_OFF_T long
|
||||
# define CURL_FORMAT_CURL_OFF_T "ld"
|
||||
# define CURL_FORMAT_CURL_OFF_TU "lu"
|
||||
# define CURL_SUFFIX_CURL_OFF_T L
|
||||
# define CURL_SUFFIX_CURL_OFF_TU UL
|
||||
# define CURL_TYPEOF_CURL_SOCKLEN_T socklen_t
|
||||
# define CURL_PULL_SYS_TYPES_H 1
|
||||
# define CURL_PULL_SYS_SOCKET_H 1
|
||||
# else /* Local (or Little) C Compiler */
|
||||
# define CURL_TYPEOF_CURL_OFF_T long
|
||||
# define CURL_FORMAT_CURL_OFF_T "ld"
|
||||
# define CURL_FORMAT_CURL_OFF_TU "lu"
|
||||
# define CURL_SUFFIX_CURL_OFF_T L
|
||||
# define CURL_SUFFIX_CURL_OFF_TU UL
|
||||
# define CURL_TYPEOF_CURL_SOCKLEN_T int
|
||||
# endif
|
||||
|
||||
#elif defined(macintosh)
|
||||
# include <ConditionalMacros.h>
|
||||
# if TYPE_LONGLONG
|
||||
# define CURL_TYPEOF_CURL_OFF_T long long
|
||||
# define CURL_FORMAT_CURL_OFF_T "lld"
|
||||
# define CURL_FORMAT_CURL_OFF_TU "llu"
|
||||
# define CURL_SUFFIX_CURL_OFF_T LL
|
||||
# define CURL_SUFFIX_CURL_OFF_TU ULL
|
||||
# else
|
||||
# define CURL_TYPEOF_CURL_OFF_T long
|
||||
# define CURL_FORMAT_CURL_OFF_T "ld"
|
||||
# define CURL_FORMAT_CURL_OFF_TU "lu"
|
||||
# define CURL_SUFFIX_CURL_OFF_T L
|
||||
# define CURL_SUFFIX_CURL_OFF_TU UL
|
||||
# endif
|
||||
# define CURL_TYPEOF_CURL_SOCKLEN_T unsigned int
|
||||
|
||||
#elif defined(__TANDEM)
|
||||
# if ! defined(__LP64)
|
||||
/* Required for 32-bit NonStop builds only. */
|
||||
# define CURL_TYPEOF_CURL_OFF_T long long
|
||||
# define CURL_FORMAT_CURL_OFF_T "lld"
|
||||
# define CURL_FORMAT_CURL_OFF_TU "llu"
|
||||
# define CURL_SUFFIX_CURL_OFF_T LL
|
||||
# define CURL_SUFFIX_CURL_OFF_TU ULL
|
||||
# define CURL_TYPEOF_CURL_SOCKLEN_T int
|
||||
# endif
|
||||
|
||||
#elif defined(_WIN32_WCE)
|
||||
# define CURL_TYPEOF_CURL_OFF_T __int64
|
||||
# define CURL_FORMAT_CURL_OFF_T "I64d"
|
||||
# define CURL_FORMAT_CURL_OFF_TU "I64u"
|
||||
# define CURL_SUFFIX_CURL_OFF_T i64
|
||||
# define CURL_SUFFIX_CURL_OFF_TU ui64
|
||||
# define CURL_TYPEOF_CURL_SOCKLEN_T int
|
||||
|
||||
#elif defined(__MINGW32__)
|
||||
# include <inttypes.h>
|
||||
# define CURL_TYPEOF_CURL_OFF_T long long
|
||||
# define CURL_FORMAT_CURL_OFF_T PRId64
|
||||
# define CURL_FORMAT_CURL_OFF_TU PRIu64
|
||||
# define CURL_SUFFIX_CURL_OFF_T LL
|
||||
# define CURL_SUFFIX_CURL_OFF_TU ULL
|
||||
# define CURL_TYPEOF_CURL_SOCKLEN_T int
|
||||
# define CURL_PULL_SYS_TYPES_H 1
|
||||
|
||||
#elif defined(__VMS)
|
||||
# if defined(__VAX)
|
||||
# define CURL_TYPEOF_CURL_OFF_T long
|
||||
# define CURL_FORMAT_CURL_OFF_T "ld"
|
||||
# define CURL_FORMAT_CURL_OFF_TU "lu"
|
||||
# define CURL_SUFFIX_CURL_OFF_T L
|
||||
# define CURL_SUFFIX_CURL_OFF_TU UL
|
||||
# else
|
||||
# define CURL_TYPEOF_CURL_OFF_T long long
|
||||
# define CURL_FORMAT_CURL_OFF_T "lld"
|
||||
# define CURL_FORMAT_CURL_OFF_TU "llu"
|
||||
# define CURL_SUFFIX_CURL_OFF_T LL
|
||||
# define CURL_SUFFIX_CURL_OFF_TU ULL
|
||||
# endif
|
||||
# define CURL_TYPEOF_CURL_SOCKLEN_T unsigned int
|
||||
|
||||
#elif defined(__OS400__)
|
||||
# define CURL_TYPEOF_CURL_OFF_T long long
|
||||
# define CURL_FORMAT_CURL_OFF_T "lld"
|
||||
# define CURL_FORMAT_CURL_OFF_TU "llu"
|
||||
# define CURL_SUFFIX_CURL_OFF_T LL
|
||||
# define CURL_SUFFIX_CURL_OFF_TU ULL
|
||||
# define CURL_TYPEOF_CURL_SOCKLEN_T socklen_t
|
||||
# define CURL_PULL_SYS_TYPES_H 1
|
||||
# define CURL_PULL_SYS_SOCKET_H 1
|
||||
|
||||
#elif defined(__MVS__)
|
||||
# if defined(_LONG_LONG)
|
||||
# define CURL_TYPEOF_CURL_OFF_T long long
|
||||
# define CURL_FORMAT_CURL_OFF_T "lld"
|
||||
# define CURL_FORMAT_CURL_OFF_TU "llu"
|
||||
# define CURL_SUFFIX_CURL_OFF_T LL
|
||||
# define CURL_SUFFIX_CURL_OFF_TU ULL
|
||||
# elif defined(_LP64)
|
||||
# define CURL_TYPEOF_CURL_OFF_T long
|
||||
# define CURL_FORMAT_CURL_OFF_T "ld"
|
||||
# define CURL_FORMAT_CURL_OFF_TU "lu"
|
||||
# define CURL_SUFFIX_CURL_OFF_T L
|
||||
# define CURL_SUFFIX_CURL_OFF_TU UL
|
||||
# else
|
||||
# define CURL_TYPEOF_CURL_OFF_T long
|
||||
# define CURL_FORMAT_CURL_OFF_T "ld"
|
||||
# define CURL_FORMAT_CURL_OFF_TU "lu"
|
||||
# define CURL_SUFFIX_CURL_OFF_T L
|
||||
# define CURL_SUFFIX_CURL_OFF_TU UL
|
||||
# endif
|
||||
# define CURL_TYPEOF_CURL_SOCKLEN_T socklen_t
|
||||
# define CURL_PULL_SYS_TYPES_H 1
|
||||
# define CURL_PULL_SYS_SOCKET_H 1
|
||||
|
||||
#elif defined(__370__)
|
||||
# if defined(__IBMC__) || defined(__IBMCPP__)
|
||||
# if defined(_ILP32)
|
||||
# elif defined(_LP64)
|
||||
# endif
|
||||
# if defined(_LONG_LONG)
|
||||
# define CURL_TYPEOF_CURL_OFF_T long long
|
||||
# define CURL_FORMAT_CURL_OFF_T "lld"
|
||||
# define CURL_FORMAT_CURL_OFF_TU "llu"
|
||||
# define CURL_SUFFIX_CURL_OFF_T LL
|
||||
# define CURL_SUFFIX_CURL_OFF_TU ULL
|
||||
# elif defined(_LP64)
|
||||
# define CURL_TYPEOF_CURL_OFF_T long
|
||||
# define CURL_FORMAT_CURL_OFF_T "ld"
|
||||
# define CURL_FORMAT_CURL_OFF_TU "lu"
|
||||
# define CURL_SUFFIX_CURL_OFF_T L
|
||||
# define CURL_SUFFIX_CURL_OFF_TU UL
|
||||
# else
|
||||
# define CURL_TYPEOF_CURL_OFF_T long
|
||||
# define CURL_FORMAT_CURL_OFF_T "ld"
|
||||
# define CURL_FORMAT_CURL_OFF_TU "lu"
|
||||
# define CURL_SUFFIX_CURL_OFF_T L
|
||||
# define CURL_SUFFIX_CURL_OFF_TU UL
|
||||
# endif
|
||||
# define CURL_TYPEOF_CURL_SOCKLEN_T socklen_t
|
||||
# define CURL_PULL_SYS_TYPES_H 1
|
||||
# define CURL_PULL_SYS_SOCKET_H 1
|
||||
# endif
|
||||
|
||||
#elif defined(TPF)
|
||||
# define CURL_TYPEOF_CURL_OFF_T long
|
||||
# define CURL_FORMAT_CURL_OFF_T "ld"
|
||||
# define CURL_FORMAT_CURL_OFF_TU "lu"
|
||||
# define CURL_SUFFIX_CURL_OFF_T L
|
||||
# define CURL_SUFFIX_CURL_OFF_TU UL
|
||||
# define CURL_TYPEOF_CURL_SOCKLEN_T int
|
||||
|
||||
#elif defined(__TINYC__) /* also known as tcc */
|
||||
# define CURL_TYPEOF_CURL_OFF_T long long
|
||||
# define CURL_FORMAT_CURL_OFF_T "lld"
|
||||
# define CURL_FORMAT_CURL_OFF_TU "llu"
|
||||
# define CURL_SUFFIX_CURL_OFF_T LL
|
||||
# define CURL_SUFFIX_CURL_OFF_TU ULL
|
||||
# define CURL_TYPEOF_CURL_SOCKLEN_T socklen_t
|
||||
# define CURL_PULL_SYS_TYPES_H 1
|
||||
# define CURL_PULL_SYS_SOCKET_H 1
|
||||
|
||||
#elif defined(__SUNPRO_C) || defined(__SUNPRO_CC) /* Oracle Solaris Studio */
|
||||
# if !defined(__LP64) && (defined(__ILP32) || \
|
||||
defined(__i386) || \
|
||||
defined(__sparcv8) || \
|
||||
defined(__sparcv8plus))
|
||||
# define CURL_TYPEOF_CURL_OFF_T long long
|
||||
# define CURL_FORMAT_CURL_OFF_T "lld"
|
||||
# define CURL_FORMAT_CURL_OFF_TU "llu"
|
||||
# define CURL_SUFFIX_CURL_OFF_T LL
|
||||
# define CURL_SUFFIX_CURL_OFF_TU ULL
|
||||
# elif defined(__LP64) || \
|
||||
defined(__amd64) || defined(__sparcv9)
|
||||
# define CURL_TYPEOF_CURL_OFF_T long
|
||||
# define CURL_FORMAT_CURL_OFF_T "ld"
|
||||
# define CURL_FORMAT_CURL_OFF_TU "lu"
|
||||
# define CURL_SUFFIX_CURL_OFF_T L
|
||||
# define CURL_SUFFIX_CURL_OFF_TU UL
|
||||
# endif
|
||||
# define CURL_TYPEOF_CURL_SOCKLEN_T socklen_t
|
||||
# define CURL_PULL_SYS_TYPES_H 1
|
||||
# define CURL_PULL_SYS_SOCKET_H 1
|
||||
|
||||
#elif defined(__xlc__) /* IBM xlc compiler */
|
||||
# if !defined(_LP64)
|
||||
# define CURL_TYPEOF_CURL_OFF_T long long
|
||||
# define CURL_FORMAT_CURL_OFF_T "lld"
|
||||
# define CURL_FORMAT_CURL_OFF_TU "llu"
|
||||
# define CURL_SUFFIX_CURL_OFF_T LL
|
||||
# define CURL_SUFFIX_CURL_OFF_TU ULL
|
||||
# else
|
||||
# define CURL_TYPEOF_CURL_OFF_T long
|
||||
# define CURL_FORMAT_CURL_OFF_T "ld"
|
||||
# define CURL_FORMAT_CURL_OFF_TU "lu"
|
||||
# define CURL_SUFFIX_CURL_OFF_T L
|
||||
# define CURL_SUFFIX_CURL_OFF_TU UL
|
||||
# endif
|
||||
# define CURL_TYPEOF_CURL_SOCKLEN_T socklen_t
|
||||
# define CURL_PULL_SYS_TYPES_H 1
|
||||
# define CURL_PULL_SYS_SOCKET_H 1
|
||||
|
||||
#elif defined(__hpux) /* HP aCC compiler */
|
||||
# if !defined(_LP64)
|
||||
# define CURL_TYPEOF_CURL_OFF_T long long
|
||||
# define CURL_FORMAT_CURL_OFF_T "lld"
|
||||
# define CURL_FORMAT_CURL_OFF_TU "llu"
|
||||
# define CURL_SUFFIX_CURL_OFF_T LL
|
||||
# define CURL_SUFFIX_CURL_OFF_TU ULL
|
||||
# else
|
||||
# define CURL_TYPEOF_CURL_OFF_T long
|
||||
# define CURL_FORMAT_CURL_OFF_T "ld"
|
||||
# define CURL_FORMAT_CURL_OFF_TU "lu"
|
||||
# define CURL_SUFFIX_CURL_OFF_T L
|
||||
# define CURL_SUFFIX_CURL_OFF_TU UL
|
||||
# endif
|
||||
# define CURL_TYPEOF_CURL_SOCKLEN_T socklen_t
|
||||
# define CURL_PULL_SYS_TYPES_H 1
|
||||
# define CURL_PULL_SYS_SOCKET_H 1
|
||||
|
||||
/* ===================================== */
|
||||
/* KEEP MSVC THE PENULTIMATE ENTRY */
|
||||
/* ===================================== */
|
||||
|
||||
#elif defined(_MSC_VER)
|
||||
# if (_MSC_VER >= 1800)
|
||||
# include <inttypes.h>
|
||||
# define CURL_TYPEOF_CURL_OFF_T __int64
|
||||
# define CURL_FORMAT_CURL_OFF_T PRId64
|
||||
# define CURL_FORMAT_CURL_OFF_TU PRIu64
|
||||
# define CURL_SUFFIX_CURL_OFF_T i64
|
||||
# define CURL_SUFFIX_CURL_OFF_TU ui64
|
||||
# elif (_MSC_VER >= 900) && (_INTEGRAL_MAX_BITS >= 64)
|
||||
# define CURL_TYPEOF_CURL_OFF_T __int64
|
||||
# define CURL_FORMAT_CURL_OFF_T "I64d"
|
||||
# define CURL_FORMAT_CURL_OFF_TU "I64u"
|
||||
# define CURL_SUFFIX_CURL_OFF_T i64
|
||||
# define CURL_SUFFIX_CURL_OFF_TU ui64
|
||||
# else
|
||||
# define CURL_TYPEOF_CURL_OFF_T long
|
||||
# define CURL_FORMAT_CURL_OFF_T "ld"
|
||||
# define CURL_FORMAT_CURL_OFF_TU "lu"
|
||||
# define CURL_SUFFIX_CURL_OFF_T L
|
||||
# define CURL_SUFFIX_CURL_OFF_TU UL
|
||||
# endif
|
||||
# define CURL_TYPEOF_CURL_SOCKLEN_T int
|
||||
|
||||
/* ===================================== */
|
||||
/* KEEP GENERIC GCC THE LAST ENTRY */
|
||||
/* ===================================== */
|
||||
|
||||
#elif defined(__GNUC__) && !defined(_SCO_DS)
|
||||
# if !defined(__LP64__) && \
|
||||
(defined(__ILP32__) || defined(__i386__) || defined(__hppa__) || \
|
||||
defined(__ppc__) || defined(__powerpc__) || defined(__arm__) || \
|
||||
defined(__sparc__) || defined(__mips__) || defined(__sh__) || \
|
||||
defined(__XTENSA__) || \
|
||||
(defined(__SIZEOF_LONG__) && __SIZEOF_LONG__ == 4) || \
|
||||
(defined(__LONG_MAX__) && __LONG_MAX__ == 2147483647L))
|
||||
# define CURL_TYPEOF_CURL_OFF_T long long
|
||||
# define CURL_FORMAT_CURL_OFF_T "lld"
|
||||
# define CURL_FORMAT_CURL_OFF_TU "llu"
|
||||
# define CURL_SUFFIX_CURL_OFF_T LL
|
||||
# define CURL_SUFFIX_CURL_OFF_TU ULL
|
||||
# elif defined(__LP64__) || \
|
||||
defined(__x86_64__) || defined(__ppc64__) || defined(__sparc64__) || \
|
||||
defined(__e2k__) || \
|
||||
(defined(__SIZEOF_LONG__) && __SIZEOF_LONG__ == 8) || \
|
||||
(defined(__LONG_MAX__) && __LONG_MAX__ == 9223372036854775807L)
|
||||
# define CURL_TYPEOF_CURL_OFF_T long
|
||||
# define CURL_FORMAT_CURL_OFF_T "ld"
|
||||
# define CURL_FORMAT_CURL_OFF_TU "lu"
|
||||
# define CURL_SUFFIX_CURL_OFF_T L
|
||||
# define CURL_SUFFIX_CURL_OFF_TU UL
|
||||
# endif
|
||||
# define CURL_TYPEOF_CURL_SOCKLEN_T socklen_t
|
||||
# define CURL_PULL_SYS_TYPES_H 1
|
||||
# define CURL_PULL_SYS_SOCKET_H 1
|
||||
|
||||
#else
|
||||
/* generic "safe guess" on old 32-bit style */
|
||||
# define CURL_TYPEOF_CURL_OFF_T long
|
||||
# define CURL_FORMAT_CURL_OFF_T "ld"
|
||||
# define CURL_FORMAT_CURL_OFF_TU "lu"
|
||||
# define CURL_SUFFIX_CURL_OFF_T L
|
||||
# define CURL_SUFFIX_CURL_OFF_TU UL
|
||||
# define CURL_TYPEOF_CURL_SOCKLEN_T int
|
||||
#endif
|
||||
|
||||
#ifdef _AIX
|
||||
/* AIX needs <sys/poll.h> */
|
||||
#define CURL_PULL_SYS_POLL_H
|
||||
#endif
|
||||
|
||||
/* CURL_PULL_SYS_TYPES_H is defined above when inclusion of header file */
|
||||
/* sys/types.h is required here to properly make type definitions below. */
|
||||
#ifdef CURL_PULL_SYS_TYPES_H
|
||||
# include <sys/types.h>
|
||||
#endif
|
||||
|
||||
/* CURL_PULL_SYS_SOCKET_H is defined above when inclusion of header file */
|
||||
/* sys/socket.h is required here to properly make type definitions below. */
|
||||
#ifdef CURL_PULL_SYS_SOCKET_H
|
||||
# include <sys/socket.h>
|
||||
#endif
|
||||
|
||||
/* CURL_PULL_SYS_POLL_H is defined above when inclusion of header file */
|
||||
/* sys/poll.h is required here to properly make type definitions below. */
|
||||
#ifdef CURL_PULL_SYS_POLL_H
|
||||
# include <sys/poll.h>
|
||||
#endif
|
||||
|
||||
/* Data type definition of curl_socklen_t. */
|
||||
#ifdef CURL_TYPEOF_CURL_SOCKLEN_T
|
||||
typedef CURL_TYPEOF_CURL_SOCKLEN_T curl_socklen_t;
|
||||
#endif
|
||||
|
||||
/* Data type definition of curl_off_t. */
|
||||
|
||||
#ifdef CURL_TYPEOF_CURL_OFF_T
|
||||
typedef CURL_TYPEOF_CURL_OFF_T curl_off_t;
|
||||
#endif
|
||||
|
||||
/*
|
||||
* CURL_ISOCPP and CURL_OFF_T_C definitions are done here in order to allow
|
||||
* these to be visible and exported by the external libcurl interface API,
|
||||
* while also making them visible to the library internals, simply including
|
||||
* curl_setup.h, without actually needing to include curl.h internally.
|
||||
* If some day this section would grow big enough, all this should be moved
|
||||
* to its own header file.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Figure out if we can use the ## preprocessor operator, which is supported
|
||||
* by ISO/ANSI C and C++. Some compilers support it without setting __STDC__
|
||||
* or __cplusplus so we need to carefully check for them too.
|
||||
*/
|
||||
|
||||
#if defined(__STDC__) || defined(_MSC_VER) || defined(__cplusplus) || \
|
||||
defined(__HP_aCC) || defined(__BORLANDC__) || defined(__LCC__) || \
|
||||
defined(__POCC__) || defined(__SALFORDC__) || defined(__HIGHC__) || \
|
||||
defined(__ILEC400__)
|
||||
/* This compiler is believed to have an ISO compatible preprocessor */
|
||||
#define CURL_ISOCPP
|
||||
#else
|
||||
/* This compiler is believed NOT to have an ISO compatible preprocessor */
|
||||
#undef CURL_ISOCPP
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Macros for minimum-width signed and unsigned curl_off_t integer constants.
|
||||
*/
|
||||
|
||||
#if defined(__BORLANDC__) && (__BORLANDC__ == 0x0551)
|
||||
# define CURLINC_OFF_T_C_HLPR2(x) x
|
||||
# define CURLINC_OFF_T_C_HLPR1(x) CURLINC_OFF_T_C_HLPR2(x)
|
||||
# define CURL_OFF_T_C(Val) CURLINC_OFF_T_C_HLPR1(Val) ## \
|
||||
CURLINC_OFF_T_C_HLPR1(CURL_SUFFIX_CURL_OFF_T)
|
||||
# define CURL_OFF_TU_C(Val) CURLINC_OFF_T_C_HLPR1(Val) ## \
|
||||
CURLINC_OFF_T_C_HLPR1(CURL_SUFFIX_CURL_OFF_TU)
|
||||
#else
|
||||
# ifdef CURL_ISOCPP
|
||||
# define CURLINC_OFF_T_C_HLPR2(Val,Suffix) Val ## Suffix
|
||||
# else
|
||||
# define CURLINC_OFF_T_C_HLPR2(Val,Suffix) Val/**/Suffix
|
||||
# endif
|
||||
# define CURLINC_OFF_T_C_HLPR1(Val,Suffix) CURLINC_OFF_T_C_HLPR2(Val,Suffix)
|
||||
# define CURL_OFF_T_C(Val) CURLINC_OFF_T_C_HLPR1(Val,CURL_SUFFIX_CURL_OFF_T)
|
||||
# define CURL_OFF_TU_C(Val) CURLINC_OFF_T_C_HLPR1(Val,CURL_SUFFIX_CURL_OFF_TU)
|
||||
#endif
|
||||
|
||||
#endif /* CURLINC_SYSTEM_H */
|
718
3rdparty/curl/include/curl/typecheck-gcc.h
vendored
Normal file
718
3rdparty/curl/include/curl/typecheck-gcc.h
vendored
Normal file
@ -0,0 +1,718 @@
|
||||
#ifndef CURLINC_TYPECHECK_GCC_H
|
||||
#define CURLINC_TYPECHECK_GCC_H
|
||||
/***************************************************************************
|
||||
* _ _ ____ _
|
||||
* Project ___| | | | _ \| |
|
||||
* / __| | | | |_) | |
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
*
|
||||
* This software is licensed as described in the file COPYING, which
|
||||
* you should have received as part of this distribution. The terms
|
||||
* are also available at https://curl.se/docs/copyright.html.
|
||||
*
|
||||
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
|
||||
* copies of the Software, and permit persons to whom the Software is
|
||||
* furnished to do so, under the terms of the COPYING file.
|
||||
*
|
||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||
* KIND, either express or implied.
|
||||
*
|
||||
* SPDX-License-Identifier: curl
|
||||
*
|
||||
***************************************************************************/
|
||||
|
||||
/* wraps curl_easy_setopt() with typechecking */
|
||||
|
||||
/* To add a new kind of warning, add an
|
||||
* if(curlcheck_sometype_option(_curl_opt))
|
||||
* if(!curlcheck_sometype(value))
|
||||
* _curl_easy_setopt_err_sometype();
|
||||
* block and define curlcheck_sometype_option, curlcheck_sometype and
|
||||
* _curl_easy_setopt_err_sometype below
|
||||
*
|
||||
* NOTE: We use two nested 'if' statements here instead of the && operator, in
|
||||
* order to work around gcc bug #32061. It affects only gcc 4.3.x/4.4.x
|
||||
* when compiling with -Wlogical-op.
|
||||
*
|
||||
* To add an option that uses the same type as an existing option, you will
|
||||
* just need to extend the appropriate _curl_*_option macro
|
||||
*/
|
||||
#define curl_easy_setopt(handle, option, value) \
|
||||
__extension__({ \
|
||||
CURLoption _curl_opt = (option); \
|
||||
if(__builtin_constant_p(_curl_opt)) { \
|
||||
CURL_IGNORE_DEPRECATION( \
|
||||
if(curlcheck_long_option(_curl_opt)) \
|
||||
if(!curlcheck_long(value)) \
|
||||
_curl_easy_setopt_err_long(); \
|
||||
if(curlcheck_off_t_option(_curl_opt)) \
|
||||
if(!curlcheck_off_t(value)) \
|
||||
_curl_easy_setopt_err_curl_off_t(); \
|
||||
if(curlcheck_string_option(_curl_opt)) \
|
||||
if(!curlcheck_string(value)) \
|
||||
_curl_easy_setopt_err_string(); \
|
||||
if(curlcheck_write_cb_option(_curl_opt)) \
|
||||
if(!curlcheck_write_cb(value)) \
|
||||
_curl_easy_setopt_err_write_callback(); \
|
||||
if((_curl_opt) == CURLOPT_RESOLVER_START_FUNCTION) \
|
||||
if(!curlcheck_resolver_start_callback(value)) \
|
||||
_curl_easy_setopt_err_resolver_start_callback(); \
|
||||
if((_curl_opt) == CURLOPT_READFUNCTION) \
|
||||
if(!curlcheck_read_cb(value)) \
|
||||
_curl_easy_setopt_err_read_cb(); \
|
||||
if((_curl_opt) == CURLOPT_IOCTLFUNCTION) \
|
||||
if(!curlcheck_ioctl_cb(value)) \
|
||||
_curl_easy_setopt_err_ioctl_cb(); \
|
||||
if((_curl_opt) == CURLOPT_SOCKOPTFUNCTION) \
|
||||
if(!curlcheck_sockopt_cb(value)) \
|
||||
_curl_easy_setopt_err_sockopt_cb(); \
|
||||
if((_curl_opt) == CURLOPT_OPENSOCKETFUNCTION) \
|
||||
if(!curlcheck_opensocket_cb(value)) \
|
||||
_curl_easy_setopt_err_opensocket_cb(); \
|
||||
if((_curl_opt) == CURLOPT_PROGRESSFUNCTION) \
|
||||
if(!curlcheck_progress_cb(value)) \
|
||||
_curl_easy_setopt_err_progress_cb(); \
|
||||
if((_curl_opt) == CURLOPT_DEBUGFUNCTION) \
|
||||
if(!curlcheck_debug_cb(value)) \
|
||||
_curl_easy_setopt_err_debug_cb(); \
|
||||
if((_curl_opt) == CURLOPT_SSL_CTX_FUNCTION) \
|
||||
if(!curlcheck_ssl_ctx_cb(value)) \
|
||||
_curl_easy_setopt_err_ssl_ctx_cb(); \
|
||||
if(curlcheck_conv_cb_option(_curl_opt)) \
|
||||
if(!curlcheck_conv_cb(value)) \
|
||||
_curl_easy_setopt_err_conv_cb(); \
|
||||
if((_curl_opt) == CURLOPT_SEEKFUNCTION) \
|
||||
if(!curlcheck_seek_cb(value)) \
|
||||
_curl_easy_setopt_err_seek_cb(); \
|
||||
if(curlcheck_cb_data_option(_curl_opt)) \
|
||||
if(!curlcheck_cb_data(value)) \
|
||||
_curl_easy_setopt_err_cb_data(); \
|
||||
if((_curl_opt) == CURLOPT_ERRORBUFFER) \
|
||||
if(!curlcheck_error_buffer(value)) \
|
||||
_curl_easy_setopt_err_error_buffer(); \
|
||||
if((_curl_opt) == CURLOPT_STDERR) \
|
||||
if(!curlcheck_FILE(value)) \
|
||||
_curl_easy_setopt_err_FILE(); \
|
||||
if(curlcheck_postfields_option(_curl_opt)) \
|
||||
if(!curlcheck_postfields(value)) \
|
||||
_curl_easy_setopt_err_postfields(); \
|
||||
if((_curl_opt) == CURLOPT_HTTPPOST) \
|
||||
if(!curlcheck_arr((value), struct curl_httppost)) \
|
||||
_curl_easy_setopt_err_curl_httpost(); \
|
||||
if((_curl_opt) == CURLOPT_MIMEPOST) \
|
||||
if(!curlcheck_ptr((value), curl_mime)) \
|
||||
_curl_easy_setopt_err_curl_mimepost(); \
|
||||
if(curlcheck_slist_option(_curl_opt)) \
|
||||
if(!curlcheck_arr((value), struct curl_slist)) \
|
||||
_curl_easy_setopt_err_curl_slist(); \
|
||||
if((_curl_opt) == CURLOPT_SHARE) \
|
||||
if(!curlcheck_ptr((value), CURLSH)) \
|
||||
_curl_easy_setopt_err_CURLSH(); \
|
||||
) \
|
||||
} \
|
||||
curl_easy_setopt(handle, _curl_opt, value); \
|
||||
})
|
||||
|
||||
/* wraps curl_easy_getinfo() with typechecking */
|
||||
#define curl_easy_getinfo(handle, info, arg) \
|
||||
__extension__({ \
|
||||
CURLINFO _curl_info = (info); \
|
||||
if(__builtin_constant_p(_curl_info)) { \
|
||||
CURL_IGNORE_DEPRECATION( \
|
||||
if(curlcheck_string_info(_curl_info)) \
|
||||
if(!curlcheck_arr((arg), char *)) \
|
||||
_curl_easy_getinfo_err_string(); \
|
||||
if(curlcheck_long_info(_curl_info)) \
|
||||
if(!curlcheck_arr((arg), long)) \
|
||||
_curl_easy_getinfo_err_long(); \
|
||||
if(curlcheck_double_info(_curl_info)) \
|
||||
if(!curlcheck_arr((arg), double)) \
|
||||
_curl_easy_getinfo_err_double(); \
|
||||
if(curlcheck_slist_info(_curl_info)) \
|
||||
if(!curlcheck_arr((arg), struct curl_slist *)) \
|
||||
_curl_easy_getinfo_err_curl_slist(); \
|
||||
if(curlcheck_tlssessioninfo_info(_curl_info)) \
|
||||
if(!curlcheck_arr((arg), struct curl_tlssessioninfo *)) \
|
||||
_curl_easy_getinfo_err_curl_tlssesssioninfo(); \
|
||||
if(curlcheck_certinfo_info(_curl_info)) \
|
||||
if(!curlcheck_arr((arg), struct curl_certinfo *)) \
|
||||
_curl_easy_getinfo_err_curl_certinfo(); \
|
||||
if(curlcheck_socket_info(_curl_info)) \
|
||||
if(!curlcheck_arr((arg), curl_socket_t)) \
|
||||
_curl_easy_getinfo_err_curl_socket(); \
|
||||
if(curlcheck_off_t_info(_curl_info)) \
|
||||
if(!curlcheck_arr((arg), curl_off_t)) \
|
||||
_curl_easy_getinfo_err_curl_off_t(); \
|
||||
) \
|
||||
} \
|
||||
curl_easy_getinfo(handle, _curl_info, arg); \
|
||||
})
|
||||
|
||||
/*
|
||||
* For now, just make sure that the functions are called with three arguments
|
||||
*/
|
||||
#define curl_share_setopt(share,opt,param) curl_share_setopt(share,opt,param)
|
||||
#define curl_multi_setopt(handle,opt,param) curl_multi_setopt(handle,opt,param)
|
||||
|
||||
|
||||
/* the actual warnings, triggered by calling the _curl_easy_setopt_err*
|
||||
* functions */
|
||||
|
||||
/* To define a new warning, use _CURL_WARNING(identifier, "message") */
|
||||
#define CURLWARNING(id, message) \
|
||||
static void __attribute__((__warning__(message))) \
|
||||
__attribute__((__unused__)) __attribute__((__noinline__)) \
|
||||
id(void) { __asm__(""); }
|
||||
|
||||
CURLWARNING(_curl_easy_setopt_err_long,
|
||||
"curl_easy_setopt expects a long argument for this option")
|
||||
CURLWARNING(_curl_easy_setopt_err_curl_off_t,
|
||||
"curl_easy_setopt expects a curl_off_t argument for this option")
|
||||
CURLWARNING(_curl_easy_setopt_err_string,
|
||||
"curl_easy_setopt expects a "
|
||||
"string ('char *' or char[]) argument for this option"
|
||||
)
|
||||
CURLWARNING(_curl_easy_setopt_err_write_callback,
|
||||
"curl_easy_setopt expects a curl_write_callback argument for this option")
|
||||
CURLWARNING(_curl_easy_setopt_err_resolver_start_callback,
|
||||
"curl_easy_setopt expects a "
|
||||
"curl_resolver_start_callback argument for this option"
|
||||
)
|
||||
CURLWARNING(_curl_easy_setopt_err_read_cb,
|
||||
"curl_easy_setopt expects a curl_read_callback argument for this option")
|
||||
CURLWARNING(_curl_easy_setopt_err_ioctl_cb,
|
||||
"curl_easy_setopt expects a curl_ioctl_callback argument for this option")
|
||||
CURLWARNING(_curl_easy_setopt_err_sockopt_cb,
|
||||
"curl_easy_setopt expects a curl_sockopt_callback argument for this option")
|
||||
CURLWARNING(_curl_easy_setopt_err_opensocket_cb,
|
||||
"curl_easy_setopt expects a "
|
||||
"curl_opensocket_callback argument for this option"
|
||||
)
|
||||
CURLWARNING(_curl_easy_setopt_err_progress_cb,
|
||||
"curl_easy_setopt expects a curl_progress_callback argument for this option")
|
||||
CURLWARNING(_curl_easy_setopt_err_debug_cb,
|
||||
"curl_easy_setopt expects a curl_debug_callback argument for this option")
|
||||
CURLWARNING(_curl_easy_setopt_err_ssl_ctx_cb,
|
||||
"curl_easy_setopt expects a curl_ssl_ctx_callback argument for this option")
|
||||
CURLWARNING(_curl_easy_setopt_err_conv_cb,
|
||||
"curl_easy_setopt expects a curl_conv_callback argument for this option")
|
||||
CURLWARNING(_curl_easy_setopt_err_seek_cb,
|
||||
"curl_easy_setopt expects a curl_seek_callback argument for this option")
|
||||
CURLWARNING(_curl_easy_setopt_err_cb_data,
|
||||
"curl_easy_setopt expects a "
|
||||
"private data pointer as argument for this option")
|
||||
CURLWARNING(_curl_easy_setopt_err_error_buffer,
|
||||
"curl_easy_setopt expects a "
|
||||
"char buffer of CURL_ERROR_SIZE as argument for this option")
|
||||
CURLWARNING(_curl_easy_setopt_err_FILE,
|
||||
"curl_easy_setopt expects a 'FILE *' argument for this option")
|
||||
CURLWARNING(_curl_easy_setopt_err_postfields,
|
||||
"curl_easy_setopt expects a 'void *' or 'char *' argument for this option")
|
||||
CURLWARNING(_curl_easy_setopt_err_curl_httpost,
|
||||
"curl_easy_setopt expects a 'struct curl_httppost *' "
|
||||
"argument for this option")
|
||||
CURLWARNING(_curl_easy_setopt_err_curl_mimepost,
|
||||
"curl_easy_setopt expects a 'curl_mime *' "
|
||||
"argument for this option")
|
||||
CURLWARNING(_curl_easy_setopt_err_curl_slist,
|
||||
"curl_easy_setopt expects a 'struct curl_slist *' argument for this option")
|
||||
CURLWARNING(_curl_easy_setopt_err_CURLSH,
|
||||
"curl_easy_setopt expects a CURLSH* argument for this option")
|
||||
|
||||
CURLWARNING(_curl_easy_getinfo_err_string,
|
||||
"curl_easy_getinfo expects a pointer to 'char *' for this info")
|
||||
CURLWARNING(_curl_easy_getinfo_err_long,
|
||||
"curl_easy_getinfo expects a pointer to long for this info")
|
||||
CURLWARNING(_curl_easy_getinfo_err_double,
|
||||
"curl_easy_getinfo expects a pointer to double for this info")
|
||||
CURLWARNING(_curl_easy_getinfo_err_curl_slist,
|
||||
"curl_easy_getinfo expects a pointer to 'struct curl_slist *' for this info")
|
||||
CURLWARNING(_curl_easy_getinfo_err_curl_tlssesssioninfo,
|
||||
"curl_easy_getinfo expects a pointer to "
|
||||
"'struct curl_tlssessioninfo *' for this info")
|
||||
CURLWARNING(_curl_easy_getinfo_err_curl_certinfo,
|
||||
"curl_easy_getinfo expects a pointer to "
|
||||
"'struct curl_certinfo *' for this info")
|
||||
CURLWARNING(_curl_easy_getinfo_err_curl_socket,
|
||||
"curl_easy_getinfo expects a pointer to curl_socket_t for this info")
|
||||
CURLWARNING(_curl_easy_getinfo_err_curl_off_t,
|
||||
"curl_easy_getinfo expects a pointer to curl_off_t for this info")
|
||||
|
||||
/* groups of curl_easy_setops options that take the same type of argument */
|
||||
|
||||
/* To add a new option to one of the groups, just add
|
||||
* (option) == CURLOPT_SOMETHING
|
||||
* to the or-expression. If the option takes a long or curl_off_t, you do not
|
||||
* have to do anything
|
||||
*/
|
||||
|
||||
/* evaluates to true if option takes a long argument */
|
||||
#define curlcheck_long_option(option) \
|
||||
(0 < (option) && (option) < CURLOPTTYPE_OBJECTPOINT)
|
||||
|
||||
#define curlcheck_off_t_option(option) \
|
||||
(((option) > CURLOPTTYPE_OFF_T) && ((option) < CURLOPTTYPE_BLOB))
|
||||
|
||||
/* evaluates to true if option takes a char* argument */
|
||||
#define curlcheck_string_option(option) \
|
||||
((option) == CURLOPT_ABSTRACT_UNIX_SOCKET || \
|
||||
(option) == CURLOPT_ACCEPT_ENCODING || \
|
||||
(option) == CURLOPT_ALTSVC || \
|
||||
(option) == CURLOPT_CAINFO || \
|
||||
(option) == CURLOPT_CAPATH || \
|
||||
(option) == CURLOPT_COOKIE || \
|
||||
(option) == CURLOPT_COOKIEFILE || \
|
||||
(option) == CURLOPT_COOKIEJAR || \
|
||||
(option) == CURLOPT_COOKIELIST || \
|
||||
(option) == CURLOPT_CRLFILE || \
|
||||
(option) == CURLOPT_CUSTOMREQUEST || \
|
||||
(option) == CURLOPT_DEFAULT_PROTOCOL || \
|
||||
(option) == CURLOPT_DNS_INTERFACE || \
|
||||
(option) == CURLOPT_DNS_LOCAL_IP4 || \
|
||||
(option) == CURLOPT_DNS_LOCAL_IP6 || \
|
||||
(option) == CURLOPT_DNS_SERVERS || \
|
||||
(option) == CURLOPT_DOH_URL || \
|
||||
(option) == CURLOPT_ECH || \
|
||||
(option) == CURLOPT_EGDSOCKET || \
|
||||
(option) == CURLOPT_FTP_ACCOUNT || \
|
||||
(option) == CURLOPT_FTP_ALTERNATIVE_TO_USER || \
|
||||
(option) == CURLOPT_FTPPORT || \
|
||||
(option) == CURLOPT_HSTS || \
|
||||
(option) == CURLOPT_HAPROXY_CLIENT_IP || \
|
||||
(option) == CURLOPT_INTERFACE || \
|
||||
(option) == CURLOPT_ISSUERCERT || \
|
||||
(option) == CURLOPT_KEYPASSWD || \
|
||||
(option) == CURLOPT_KRBLEVEL || \
|
||||
(option) == CURLOPT_LOGIN_OPTIONS || \
|
||||
(option) == CURLOPT_MAIL_AUTH || \
|
||||
(option) == CURLOPT_MAIL_FROM || \
|
||||
(option) == CURLOPT_NETRC_FILE || \
|
||||
(option) == CURLOPT_NOPROXY || \
|
||||
(option) == CURLOPT_PASSWORD || \
|
||||
(option) == CURLOPT_PINNEDPUBLICKEY || \
|
||||
(option) == CURLOPT_PRE_PROXY || \
|
||||
(option) == CURLOPT_PROTOCOLS_STR || \
|
||||
(option) == CURLOPT_PROXY || \
|
||||
(option) == CURLOPT_PROXY_CAINFO || \
|
||||
(option) == CURLOPT_PROXY_CAPATH || \
|
||||
(option) == CURLOPT_PROXY_CRLFILE || \
|
||||
(option) == CURLOPT_PROXY_ISSUERCERT || \
|
||||
(option) == CURLOPT_PROXY_KEYPASSWD || \
|
||||
(option) == CURLOPT_PROXY_PINNEDPUBLICKEY || \
|
||||
(option) == CURLOPT_PROXY_SERVICE_NAME || \
|
||||
(option) == CURLOPT_PROXY_SSL_CIPHER_LIST || \
|
||||
(option) == CURLOPT_PROXY_SSLCERT || \
|
||||
(option) == CURLOPT_PROXY_SSLCERTTYPE || \
|
||||
(option) == CURLOPT_PROXY_SSLKEY || \
|
||||
(option) == CURLOPT_PROXY_SSLKEYTYPE || \
|
||||
(option) == CURLOPT_PROXY_TLS13_CIPHERS || \
|
||||
(option) == CURLOPT_PROXY_TLSAUTH_PASSWORD || \
|
||||
(option) == CURLOPT_PROXY_TLSAUTH_TYPE || \
|
||||
(option) == CURLOPT_PROXY_TLSAUTH_USERNAME || \
|
||||
(option) == CURLOPT_PROXYPASSWORD || \
|
||||
(option) == CURLOPT_PROXYUSERNAME || \
|
||||
(option) == CURLOPT_PROXYUSERPWD || \
|
||||
(option) == CURLOPT_RANDOM_FILE || \
|
||||
(option) == CURLOPT_RANGE || \
|
||||
(option) == CURLOPT_REDIR_PROTOCOLS_STR || \
|
||||
(option) == CURLOPT_REFERER || \
|
||||
(option) == CURLOPT_REQUEST_TARGET || \
|
||||
(option) == CURLOPT_RTSP_SESSION_ID || \
|
||||
(option) == CURLOPT_RTSP_STREAM_URI || \
|
||||
(option) == CURLOPT_RTSP_TRANSPORT || \
|
||||
(option) == CURLOPT_SASL_AUTHZID || \
|
||||
(option) == CURLOPT_SERVICE_NAME || \
|
||||
(option) == CURLOPT_SOCKS5_GSSAPI_SERVICE || \
|
||||
(option) == CURLOPT_SSH_HOST_PUBLIC_KEY_MD5 || \
|
||||
(option) == CURLOPT_SSH_HOST_PUBLIC_KEY_SHA256 || \
|
||||
(option) == CURLOPT_SSH_KNOWNHOSTS || \
|
||||
(option) == CURLOPT_SSH_PRIVATE_KEYFILE || \
|
||||
(option) == CURLOPT_SSH_PUBLIC_KEYFILE || \
|
||||
(option) == CURLOPT_SSLCERT || \
|
||||
(option) == CURLOPT_SSLCERTTYPE || \
|
||||
(option) == CURLOPT_SSLENGINE || \
|
||||
(option) == CURLOPT_SSLKEY || \
|
||||
(option) == CURLOPT_SSLKEYTYPE || \
|
||||
(option) == CURLOPT_SSL_CIPHER_LIST || \
|
||||
(option) == CURLOPT_TLS13_CIPHERS || \
|
||||
(option) == CURLOPT_TLSAUTH_PASSWORD || \
|
||||
(option) == CURLOPT_TLSAUTH_TYPE || \
|
||||
(option) == CURLOPT_TLSAUTH_USERNAME || \
|
||||
(option) == CURLOPT_UNIX_SOCKET_PATH || \
|
||||
(option) == CURLOPT_URL || \
|
||||
(option) == CURLOPT_USERAGENT || \
|
||||
(option) == CURLOPT_USERNAME || \
|
||||
(option) == CURLOPT_AWS_SIGV4 || \
|
||||
(option) == CURLOPT_USERPWD || \
|
||||
(option) == CURLOPT_XOAUTH2_BEARER || \
|
||||
(option) == CURLOPT_SSL_EC_CURVES || \
|
||||
0)
|
||||
|
||||
/* evaluates to true if option takes a curl_write_callback argument */
|
||||
#define curlcheck_write_cb_option(option) \
|
||||
((option) == CURLOPT_HEADERFUNCTION || \
|
||||
(option) == CURLOPT_WRITEFUNCTION)
|
||||
|
||||
/* evaluates to true if option takes a curl_conv_callback argument */
|
||||
#define curlcheck_conv_cb_option(option) \
|
||||
((option) == CURLOPT_CONV_TO_NETWORK_FUNCTION || \
|
||||
(option) == CURLOPT_CONV_FROM_NETWORK_FUNCTION || \
|
||||
(option) == CURLOPT_CONV_FROM_UTF8_FUNCTION)
|
||||
|
||||
/* evaluates to true if option takes a data argument to pass to a callback */
|
||||
#define curlcheck_cb_data_option(option) \
|
||||
((option) == CURLOPT_CHUNK_DATA || \
|
||||
(option) == CURLOPT_CLOSESOCKETDATA || \
|
||||
(option) == CURLOPT_DEBUGDATA || \
|
||||
(option) == CURLOPT_FNMATCH_DATA || \
|
||||
(option) == CURLOPT_HEADERDATA || \
|
||||
(option) == CURLOPT_HSTSREADDATA || \
|
||||
(option) == CURLOPT_HSTSWRITEDATA || \
|
||||
(option) == CURLOPT_INTERLEAVEDATA || \
|
||||
(option) == CURLOPT_IOCTLDATA || \
|
||||
(option) == CURLOPT_OPENSOCKETDATA || \
|
||||
(option) == CURLOPT_PREREQDATA || \
|
||||
(option) == CURLOPT_PROGRESSDATA || \
|
||||
(option) == CURLOPT_READDATA || \
|
||||
(option) == CURLOPT_SEEKDATA || \
|
||||
(option) == CURLOPT_SOCKOPTDATA || \
|
||||
(option) == CURLOPT_SSH_KEYDATA || \
|
||||
(option) == CURLOPT_SSL_CTX_DATA || \
|
||||
(option) == CURLOPT_WRITEDATA || \
|
||||
(option) == CURLOPT_RESOLVER_START_DATA || \
|
||||
(option) == CURLOPT_TRAILERDATA || \
|
||||
(option) == CURLOPT_SSH_HOSTKEYDATA || \
|
||||
0)
|
||||
|
||||
/* evaluates to true if option takes a POST data argument (void* or char*) */
|
||||
#define curlcheck_postfields_option(option) \
|
||||
((option) == CURLOPT_POSTFIELDS || \
|
||||
(option) == CURLOPT_COPYPOSTFIELDS || \
|
||||
0)
|
||||
|
||||
/* evaluates to true if option takes a struct curl_slist * argument */
|
||||
#define curlcheck_slist_option(option) \
|
||||
((option) == CURLOPT_HTTP200ALIASES || \
|
||||
(option) == CURLOPT_HTTPHEADER || \
|
||||
(option) == CURLOPT_MAIL_RCPT || \
|
||||
(option) == CURLOPT_POSTQUOTE || \
|
||||
(option) == CURLOPT_PREQUOTE || \
|
||||
(option) == CURLOPT_PROXYHEADER || \
|
||||
(option) == CURLOPT_QUOTE || \
|
||||
(option) == CURLOPT_RESOLVE || \
|
||||
(option) == CURLOPT_TELNETOPTIONS || \
|
||||
(option) == CURLOPT_CONNECT_TO || \
|
||||
0)
|
||||
|
||||
/* groups of curl_easy_getinfo infos that take the same type of argument */
|
||||
|
||||
/* evaluates to true if info expects a pointer to char * argument */
|
||||
#define curlcheck_string_info(info) \
|
||||
(CURLINFO_STRING < (info) && (info) < CURLINFO_LONG && \
|
||||
(info) != CURLINFO_PRIVATE)
|
||||
|
||||
/* evaluates to true if info expects a pointer to long argument */
|
||||
#define curlcheck_long_info(info) \
|
||||
(CURLINFO_LONG < (info) && (info) < CURLINFO_DOUBLE)
|
||||
|
||||
/* evaluates to true if info expects a pointer to double argument */
|
||||
#define curlcheck_double_info(info) \
|
||||
(CURLINFO_DOUBLE < (info) && (info) < CURLINFO_SLIST)
|
||||
|
||||
/* true if info expects a pointer to struct curl_slist * argument */
|
||||
#define curlcheck_slist_info(info) \
|
||||
(((info) == CURLINFO_SSL_ENGINES) || ((info) == CURLINFO_COOKIELIST))
|
||||
|
||||
/* true if info expects a pointer to struct curl_tlssessioninfo * argument */
|
||||
#define curlcheck_tlssessioninfo_info(info) \
|
||||
(((info) == CURLINFO_TLS_SSL_PTR) || ((info) == CURLINFO_TLS_SESSION))
|
||||
|
||||
/* true if info expects a pointer to struct curl_certinfo * argument */
|
||||
#define curlcheck_certinfo_info(info) ((info) == CURLINFO_CERTINFO)
|
||||
|
||||
/* true if info expects a pointer to struct curl_socket_t argument */
|
||||
#define curlcheck_socket_info(info) \
|
||||
(CURLINFO_SOCKET < (info) && (info) < CURLINFO_OFF_T)
|
||||
|
||||
/* true if info expects a pointer to curl_off_t argument */
|
||||
#define curlcheck_off_t_info(info) \
|
||||
(CURLINFO_OFF_T < (info))
|
||||
|
||||
|
||||
/* typecheck helpers -- check whether given expression has requested type */
|
||||
|
||||
/* For pointers, you can use the curlcheck_ptr/curlcheck_arr macros,
|
||||
* otherwise define a new macro. Search for __builtin_types_compatible_p
|
||||
* in the GCC manual.
|
||||
* NOTE: these macros MUST NOT EVALUATE their arguments! The argument is
|
||||
* the actual expression passed to the curl_easy_setopt macro. This
|
||||
* means that you can only apply the sizeof and __typeof__ operators, no
|
||||
* == or whatsoever.
|
||||
*/
|
||||
|
||||
/* XXX: should evaluate to true if expr is a pointer */
|
||||
#define curlcheck_any_ptr(expr) \
|
||||
(sizeof(expr) == sizeof(void *))
|
||||
|
||||
/* evaluates to true if expr is NULL */
|
||||
/* XXX: must not evaluate expr, so this check is not accurate */
|
||||
#define curlcheck_NULL(expr) \
|
||||
(__builtin_types_compatible_p(__typeof__(expr), __typeof__(NULL)))
|
||||
|
||||
/* evaluates to true if expr is type*, const type* or NULL */
|
||||
#define curlcheck_ptr(expr, type) \
|
||||
(curlcheck_NULL(expr) || \
|
||||
__builtin_types_compatible_p(__typeof__(expr), type *) || \
|
||||
__builtin_types_compatible_p(__typeof__(expr), const type *))
|
||||
|
||||
/* evaluates to true if expr is one of type[], type*, NULL or const type* */
|
||||
#define curlcheck_arr(expr, type) \
|
||||
(curlcheck_ptr((expr), type) || \
|
||||
__builtin_types_compatible_p(__typeof__(expr), type []))
|
||||
|
||||
/* evaluates to true if expr is a string */
|
||||
#define curlcheck_string(expr) \
|
||||
(curlcheck_arr((expr), char) || \
|
||||
curlcheck_arr((expr), signed char) || \
|
||||
curlcheck_arr((expr), unsigned char))
|
||||
|
||||
/* evaluates to true if expr is a long (no matter the signedness)
|
||||
* XXX: for now, int is also accepted (and therefore short and char, which
|
||||
* are promoted to int when passed to a variadic function) */
|
||||
#define curlcheck_long(expr) \
|
||||
(__builtin_types_compatible_p(__typeof__(expr), long) || \
|
||||
__builtin_types_compatible_p(__typeof__(expr), signed long) || \
|
||||
__builtin_types_compatible_p(__typeof__(expr), unsigned long) || \
|
||||
__builtin_types_compatible_p(__typeof__(expr), int) || \
|
||||
__builtin_types_compatible_p(__typeof__(expr), signed int) || \
|
||||
__builtin_types_compatible_p(__typeof__(expr), unsigned int) || \
|
||||
__builtin_types_compatible_p(__typeof__(expr), short) || \
|
||||
__builtin_types_compatible_p(__typeof__(expr), signed short) || \
|
||||
__builtin_types_compatible_p(__typeof__(expr), unsigned short) || \
|
||||
__builtin_types_compatible_p(__typeof__(expr), char) || \
|
||||
__builtin_types_compatible_p(__typeof__(expr), signed char) || \
|
||||
__builtin_types_compatible_p(__typeof__(expr), unsigned char))
|
||||
|
||||
/* evaluates to true if expr is of type curl_off_t */
|
||||
#define curlcheck_off_t(expr) \
|
||||
(__builtin_types_compatible_p(__typeof__(expr), curl_off_t))
|
||||
|
||||
/* evaluates to true if expr is abuffer suitable for CURLOPT_ERRORBUFFER */
|
||||
/* XXX: also check size of an char[] array? */
|
||||
#define curlcheck_error_buffer(expr) \
|
||||
(curlcheck_NULL(expr) || \
|
||||
__builtin_types_compatible_p(__typeof__(expr), char *) || \
|
||||
__builtin_types_compatible_p(__typeof__(expr), char[]))
|
||||
|
||||
/* evaluates to true if expr is of type (const) void* or (const) FILE* */
|
||||
#if 0
|
||||
#define curlcheck_cb_data(expr) \
|
||||
(curlcheck_ptr((expr), void) || \
|
||||
curlcheck_ptr((expr), FILE))
|
||||
#else /* be less strict */
|
||||
#define curlcheck_cb_data(expr) \
|
||||
curlcheck_any_ptr(expr)
|
||||
#endif
|
||||
|
||||
/* evaluates to true if expr is of type FILE* */
|
||||
#define curlcheck_FILE(expr) \
|
||||
(curlcheck_NULL(expr) || \
|
||||
(__builtin_types_compatible_p(__typeof__(expr), FILE *)))
|
||||
|
||||
/* evaluates to true if expr can be passed as POST data (void* or char*) */
|
||||
#define curlcheck_postfields(expr) \
|
||||
(curlcheck_ptr((expr), void) || \
|
||||
curlcheck_arr((expr), char) || \
|
||||
curlcheck_arr((expr), unsigned char))
|
||||
|
||||
/* helper: __builtin_types_compatible_p distinguishes between functions and
|
||||
* function pointers, hide it */
|
||||
#define curlcheck_cb_compatible(func, type) \
|
||||
(__builtin_types_compatible_p(__typeof__(func), type) || \
|
||||
__builtin_types_compatible_p(__typeof__(func) *, type))
|
||||
|
||||
/* evaluates to true if expr is of type curl_resolver_start_callback */
|
||||
#define curlcheck_resolver_start_callback(expr) \
|
||||
(curlcheck_NULL(expr) || \
|
||||
curlcheck_cb_compatible((expr), curl_resolver_start_callback))
|
||||
|
||||
/* evaluates to true if expr is of type curl_read_callback or "similar" */
|
||||
#define curlcheck_read_cb(expr) \
|
||||
(curlcheck_NULL(expr) || \
|
||||
curlcheck_cb_compatible((expr), __typeof__(fread) *) || \
|
||||
curlcheck_cb_compatible((expr), curl_read_callback) || \
|
||||
curlcheck_cb_compatible((expr), _curl_read_callback1) || \
|
||||
curlcheck_cb_compatible((expr), _curl_read_callback2) || \
|
||||
curlcheck_cb_compatible((expr), _curl_read_callback3) || \
|
||||
curlcheck_cb_compatible((expr), _curl_read_callback4) || \
|
||||
curlcheck_cb_compatible((expr), _curl_read_callback5) || \
|
||||
curlcheck_cb_compatible((expr), _curl_read_callback6))
|
||||
typedef size_t (*_curl_read_callback1)(char *, size_t, size_t, void *);
|
||||
typedef size_t (*_curl_read_callback2)(char *, size_t, size_t, const void *);
|
||||
typedef size_t (*_curl_read_callback3)(char *, size_t, size_t, FILE *);
|
||||
typedef size_t (*_curl_read_callback4)(void *, size_t, size_t, void *);
|
||||
typedef size_t (*_curl_read_callback5)(void *, size_t, size_t, const void *);
|
||||
typedef size_t (*_curl_read_callback6)(void *, size_t, size_t, FILE *);
|
||||
|
||||
/* evaluates to true if expr is of type curl_write_callback or "similar" */
|
||||
#define curlcheck_write_cb(expr) \
|
||||
(curlcheck_read_cb(expr) || \
|
||||
curlcheck_cb_compatible((expr), __typeof__(fwrite) *) || \
|
||||
curlcheck_cb_compatible((expr), curl_write_callback) || \
|
||||
curlcheck_cb_compatible((expr), _curl_write_callback1) || \
|
||||
curlcheck_cb_compatible((expr), _curl_write_callback2) || \
|
||||
curlcheck_cb_compatible((expr), _curl_write_callback3) || \
|
||||
curlcheck_cb_compatible((expr), _curl_write_callback4) || \
|
||||
curlcheck_cb_compatible((expr), _curl_write_callback5) || \
|
||||
curlcheck_cb_compatible((expr), _curl_write_callback6))
|
||||
typedef size_t (*_curl_write_callback1)(const char *, size_t, size_t, void *);
|
||||
typedef size_t (*_curl_write_callback2)(const char *, size_t, size_t,
|
||||
const void *);
|
||||
typedef size_t (*_curl_write_callback3)(const char *, size_t, size_t, FILE *);
|
||||
typedef size_t (*_curl_write_callback4)(const void *, size_t, size_t, void *);
|
||||
typedef size_t (*_curl_write_callback5)(const void *, size_t, size_t,
|
||||
const void *);
|
||||
typedef size_t (*_curl_write_callback6)(const void *, size_t, size_t, FILE *);
|
||||
|
||||
/* evaluates to true if expr is of type curl_ioctl_callback or "similar" */
|
||||
#define curlcheck_ioctl_cb(expr) \
|
||||
(curlcheck_NULL(expr) || \
|
||||
curlcheck_cb_compatible((expr), curl_ioctl_callback) || \
|
||||
curlcheck_cb_compatible((expr), _curl_ioctl_callback1) || \
|
||||
curlcheck_cb_compatible((expr), _curl_ioctl_callback2) || \
|
||||
curlcheck_cb_compatible((expr), _curl_ioctl_callback3) || \
|
||||
curlcheck_cb_compatible((expr), _curl_ioctl_callback4))
|
||||
typedef curlioerr (*_curl_ioctl_callback1)(CURL *, int, void *);
|
||||
typedef curlioerr (*_curl_ioctl_callback2)(CURL *, int, const void *);
|
||||
typedef curlioerr (*_curl_ioctl_callback3)(CURL *, curliocmd, void *);
|
||||
typedef curlioerr (*_curl_ioctl_callback4)(CURL *, curliocmd, const void *);
|
||||
|
||||
/* evaluates to true if expr is of type curl_sockopt_callback or "similar" */
|
||||
#define curlcheck_sockopt_cb(expr) \
|
||||
(curlcheck_NULL(expr) || \
|
||||
curlcheck_cb_compatible((expr), curl_sockopt_callback) || \
|
||||
curlcheck_cb_compatible((expr), _curl_sockopt_callback1) || \
|
||||
curlcheck_cb_compatible((expr), _curl_sockopt_callback2))
|
||||
typedef int (*_curl_sockopt_callback1)(void *, curl_socket_t, curlsocktype);
|
||||
typedef int (*_curl_sockopt_callback2)(const void *, curl_socket_t,
|
||||
curlsocktype);
|
||||
|
||||
/* evaluates to true if expr is of type curl_opensocket_callback or
|
||||
"similar" */
|
||||
#define curlcheck_opensocket_cb(expr) \
|
||||
(curlcheck_NULL(expr) || \
|
||||
curlcheck_cb_compatible((expr), curl_opensocket_callback) || \
|
||||
curlcheck_cb_compatible((expr), _curl_opensocket_callback1) || \
|
||||
curlcheck_cb_compatible((expr), _curl_opensocket_callback2) || \
|
||||
curlcheck_cb_compatible((expr), _curl_opensocket_callback3) || \
|
||||
curlcheck_cb_compatible((expr), _curl_opensocket_callback4))
|
||||
typedef curl_socket_t (*_curl_opensocket_callback1)
|
||||
(void *, curlsocktype, struct curl_sockaddr *);
|
||||
typedef curl_socket_t (*_curl_opensocket_callback2)
|
||||
(void *, curlsocktype, const struct curl_sockaddr *);
|
||||
typedef curl_socket_t (*_curl_opensocket_callback3)
|
||||
(const void *, curlsocktype, struct curl_sockaddr *);
|
||||
typedef curl_socket_t (*_curl_opensocket_callback4)
|
||||
(const void *, curlsocktype, const struct curl_sockaddr *);
|
||||
|
||||
/* evaluates to true if expr is of type curl_progress_callback or "similar" */
|
||||
#define curlcheck_progress_cb(expr) \
|
||||
(curlcheck_NULL(expr) || \
|
||||
curlcheck_cb_compatible((expr), curl_progress_callback) || \
|
||||
curlcheck_cb_compatible((expr), _curl_progress_callback1) || \
|
||||
curlcheck_cb_compatible((expr), _curl_progress_callback2))
|
||||
typedef int (*_curl_progress_callback1)(void *,
|
||||
double, double, double, double);
|
||||
typedef int (*_curl_progress_callback2)(const void *,
|
||||
double, double, double, double);
|
||||
|
||||
/* evaluates to true if expr is of type curl_debug_callback or "similar" */
|
||||
#define curlcheck_debug_cb(expr) \
|
||||
(curlcheck_NULL(expr) || \
|
||||
curlcheck_cb_compatible((expr), curl_debug_callback) || \
|
||||
curlcheck_cb_compatible((expr), _curl_debug_callback1) || \
|
||||
curlcheck_cb_compatible((expr), _curl_debug_callback2) || \
|
||||
curlcheck_cb_compatible((expr), _curl_debug_callback3) || \
|
||||
curlcheck_cb_compatible((expr), _curl_debug_callback4) || \
|
||||
curlcheck_cb_compatible((expr), _curl_debug_callback5) || \
|
||||
curlcheck_cb_compatible((expr), _curl_debug_callback6) || \
|
||||
curlcheck_cb_compatible((expr), _curl_debug_callback7) || \
|
||||
curlcheck_cb_compatible((expr), _curl_debug_callback8))
|
||||
typedef int (*_curl_debug_callback1) (CURL *,
|
||||
curl_infotype, char *, size_t, void *);
|
||||
typedef int (*_curl_debug_callback2) (CURL *,
|
||||
curl_infotype, char *, size_t, const void *);
|
||||
typedef int (*_curl_debug_callback3) (CURL *,
|
||||
curl_infotype, const char *, size_t, void *);
|
||||
typedef int (*_curl_debug_callback4) (CURL *,
|
||||
curl_infotype, const char *, size_t, const void *);
|
||||
typedef int (*_curl_debug_callback5) (CURL *,
|
||||
curl_infotype, unsigned char *, size_t, void *);
|
||||
typedef int (*_curl_debug_callback6) (CURL *,
|
||||
curl_infotype, unsigned char *, size_t, const void *);
|
||||
typedef int (*_curl_debug_callback7) (CURL *,
|
||||
curl_infotype, const unsigned char *, size_t, void *);
|
||||
typedef int (*_curl_debug_callback8) (CURL *,
|
||||
curl_infotype, const unsigned char *, size_t, const void *);
|
||||
|
||||
/* evaluates to true if expr is of type curl_ssl_ctx_callback or "similar" */
|
||||
/* this is getting even messier... */
|
||||
#define curlcheck_ssl_ctx_cb(expr) \
|
||||
(curlcheck_NULL(expr) || \
|
||||
curlcheck_cb_compatible((expr), curl_ssl_ctx_callback) || \
|
||||
curlcheck_cb_compatible((expr), _curl_ssl_ctx_callback1) || \
|
||||
curlcheck_cb_compatible((expr), _curl_ssl_ctx_callback2) || \
|
||||
curlcheck_cb_compatible((expr), _curl_ssl_ctx_callback3) || \
|
||||
curlcheck_cb_compatible((expr), _curl_ssl_ctx_callback4) || \
|
||||
curlcheck_cb_compatible((expr), _curl_ssl_ctx_callback5) || \
|
||||
curlcheck_cb_compatible((expr), _curl_ssl_ctx_callback6) || \
|
||||
curlcheck_cb_compatible((expr), _curl_ssl_ctx_callback7) || \
|
||||
curlcheck_cb_compatible((expr), _curl_ssl_ctx_callback8))
|
||||
typedef CURLcode (*_curl_ssl_ctx_callback1)(CURL *, void *, void *);
|
||||
typedef CURLcode (*_curl_ssl_ctx_callback2)(CURL *, void *, const void *);
|
||||
typedef CURLcode (*_curl_ssl_ctx_callback3)(CURL *, const void *, void *);
|
||||
typedef CURLcode (*_curl_ssl_ctx_callback4)(CURL *, const void *,
|
||||
const void *);
|
||||
#ifdef HEADER_SSL_H
|
||||
/* hack: if we included OpenSSL's ssl.h, we know about SSL_CTX
|
||||
* this will of course break if we are included before OpenSSL headers...
|
||||
*/
|
||||
typedef CURLcode (*_curl_ssl_ctx_callback5)(CURL *, SSL_CTX *, void *);
|
||||
typedef CURLcode (*_curl_ssl_ctx_callback6)(CURL *, SSL_CTX *, const void *);
|
||||
typedef CURLcode (*_curl_ssl_ctx_callback7)(CURL *, const SSL_CTX *, void *);
|
||||
typedef CURLcode (*_curl_ssl_ctx_callback8)(CURL *, const SSL_CTX *,
|
||||
const void *);
|
||||
#else
|
||||
typedef _curl_ssl_ctx_callback1 _curl_ssl_ctx_callback5;
|
||||
typedef _curl_ssl_ctx_callback1 _curl_ssl_ctx_callback6;
|
||||
typedef _curl_ssl_ctx_callback1 _curl_ssl_ctx_callback7;
|
||||
typedef _curl_ssl_ctx_callback1 _curl_ssl_ctx_callback8;
|
||||
#endif
|
||||
|
||||
/* evaluates to true if expr is of type curl_conv_callback or "similar" */
|
||||
#define curlcheck_conv_cb(expr) \
|
||||
(curlcheck_NULL(expr) || \
|
||||
curlcheck_cb_compatible((expr), curl_conv_callback) || \
|
||||
curlcheck_cb_compatible((expr), _curl_conv_callback1) || \
|
||||
curlcheck_cb_compatible((expr), _curl_conv_callback2) || \
|
||||
curlcheck_cb_compatible((expr), _curl_conv_callback3) || \
|
||||
curlcheck_cb_compatible((expr), _curl_conv_callback4))
|
||||
typedef CURLcode (*_curl_conv_callback1)(char *, size_t length);
|
||||
typedef CURLcode (*_curl_conv_callback2)(const char *, size_t length);
|
||||
typedef CURLcode (*_curl_conv_callback3)(void *, size_t length);
|
||||
typedef CURLcode (*_curl_conv_callback4)(const void *, size_t length);
|
||||
|
||||
/* evaluates to true if expr is of type curl_seek_callback or "similar" */
|
||||
#define curlcheck_seek_cb(expr) \
|
||||
(curlcheck_NULL(expr) || \
|
||||
curlcheck_cb_compatible((expr), curl_seek_callback) || \
|
||||
curlcheck_cb_compatible((expr), _curl_seek_callback1) || \
|
||||
curlcheck_cb_compatible((expr), _curl_seek_callback2))
|
||||
typedef CURLcode (*_curl_seek_callback1)(void *, curl_off_t, int);
|
||||
typedef CURLcode (*_curl_seek_callback2)(const void *, curl_off_t, int);
|
||||
|
||||
|
||||
#endif /* CURLINC_TYPECHECK_GCC_H */
|
155
3rdparty/curl/include/curl/urlapi.h
vendored
Normal file
155
3rdparty/curl/include/curl/urlapi.h
vendored
Normal file
@ -0,0 +1,155 @@
|
||||
#ifndef CURLINC_URLAPI_H
|
||||
#define CURLINC_URLAPI_H
|
||||
/***************************************************************************
|
||||
* _ _ ____ _
|
||||
* Project ___| | | | _ \| |
|
||||
* / __| | | | |_) | |
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
*
|
||||
* This software is licensed as described in the file COPYING, which
|
||||
* you should have received as part of this distribution. The terms
|
||||
* are also available at https://curl.se/docs/copyright.html.
|
||||
*
|
||||
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
|
||||
* copies of the Software, and permit persons to whom the Software is
|
||||
* furnished to do so, under the terms of the COPYING file.
|
||||
*
|
||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||
* KIND, either express or implied.
|
||||
*
|
||||
* SPDX-License-Identifier: curl
|
||||
*
|
||||
***************************************************************************/
|
||||
|
||||
#include "curl.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* the error codes for the URL API */
|
||||
typedef enum {
|
||||
CURLUE_OK,
|
||||
CURLUE_BAD_HANDLE, /* 1 */
|
||||
CURLUE_BAD_PARTPOINTER, /* 2 */
|
||||
CURLUE_MALFORMED_INPUT, /* 3 */
|
||||
CURLUE_BAD_PORT_NUMBER, /* 4 */
|
||||
CURLUE_UNSUPPORTED_SCHEME, /* 5 */
|
||||
CURLUE_URLDECODE, /* 6 */
|
||||
CURLUE_OUT_OF_MEMORY, /* 7 */
|
||||
CURLUE_USER_NOT_ALLOWED, /* 8 */
|
||||
CURLUE_UNKNOWN_PART, /* 9 */
|
||||
CURLUE_NO_SCHEME, /* 10 */
|
||||
CURLUE_NO_USER, /* 11 */
|
||||
CURLUE_NO_PASSWORD, /* 12 */
|
||||
CURLUE_NO_OPTIONS, /* 13 */
|
||||
CURLUE_NO_HOST, /* 14 */
|
||||
CURLUE_NO_PORT, /* 15 */
|
||||
CURLUE_NO_QUERY, /* 16 */
|
||||
CURLUE_NO_FRAGMENT, /* 17 */
|
||||
CURLUE_NO_ZONEID, /* 18 */
|
||||
CURLUE_BAD_FILE_URL, /* 19 */
|
||||
CURLUE_BAD_FRAGMENT, /* 20 */
|
||||
CURLUE_BAD_HOSTNAME, /* 21 */
|
||||
CURLUE_BAD_IPV6, /* 22 */
|
||||
CURLUE_BAD_LOGIN, /* 23 */
|
||||
CURLUE_BAD_PASSWORD, /* 24 */
|
||||
CURLUE_BAD_PATH, /* 25 */
|
||||
CURLUE_BAD_QUERY, /* 26 */
|
||||
CURLUE_BAD_SCHEME, /* 27 */
|
||||
CURLUE_BAD_SLASHES, /* 28 */
|
||||
CURLUE_BAD_USER, /* 29 */
|
||||
CURLUE_LACKS_IDN, /* 30 */
|
||||
CURLUE_TOO_LARGE, /* 31 */
|
||||
CURLUE_LAST
|
||||
} CURLUcode;
|
||||
|
||||
typedef enum {
|
||||
CURLUPART_URL,
|
||||
CURLUPART_SCHEME,
|
||||
CURLUPART_USER,
|
||||
CURLUPART_PASSWORD,
|
||||
CURLUPART_OPTIONS,
|
||||
CURLUPART_HOST,
|
||||
CURLUPART_PORT,
|
||||
CURLUPART_PATH,
|
||||
CURLUPART_QUERY,
|
||||
CURLUPART_FRAGMENT,
|
||||
CURLUPART_ZONEID /* added in 7.65.0 */
|
||||
} CURLUPart;
|
||||
|
||||
#define CURLU_DEFAULT_PORT (1<<0) /* return default port number */
|
||||
#define CURLU_NO_DEFAULT_PORT (1<<1) /* act as if no port number was set,
|
||||
if the port number matches the
|
||||
default for the scheme */
|
||||
#define CURLU_DEFAULT_SCHEME (1<<2) /* return default scheme if
|
||||
missing */
|
||||
#define CURLU_NON_SUPPORT_SCHEME (1<<3) /* allow non-supported scheme */
|
||||
#define CURLU_PATH_AS_IS (1<<4) /* leave dot sequences */
|
||||
#define CURLU_DISALLOW_USER (1<<5) /* no user+password allowed */
|
||||
#define CURLU_URLDECODE (1<<6) /* URL decode on get */
|
||||
#define CURLU_URLENCODE (1<<7) /* URL encode on set */
|
||||
#define CURLU_APPENDQUERY (1<<8) /* append a form style part */
|
||||
#define CURLU_GUESS_SCHEME (1<<9) /* legacy curl-style guessing */
|
||||
#define CURLU_NO_AUTHORITY (1<<10) /* Allow empty authority when the
|
||||
scheme is unknown. */
|
||||
#define CURLU_ALLOW_SPACE (1<<11) /* Allow spaces in the URL */
|
||||
#define CURLU_PUNYCODE (1<<12) /* get the hostname in punycode */
|
||||
#define CURLU_PUNY2IDN (1<<13) /* punycode => IDN conversion */
|
||||
#define CURLU_GET_EMPTY (1<<14) /* allow empty queries and fragments
|
||||
when extracting the URL or the
|
||||
components */
|
||||
#define CURLU_NO_GUESS_SCHEME (1<<15) /* for get, do not accept a guess */
|
||||
|
||||
typedef struct Curl_URL CURLU;
|
||||
|
||||
/*
|
||||
* curl_url() creates a new CURLU handle and returns a pointer to it.
|
||||
* Must be freed with curl_url_cleanup().
|
||||
*/
|
||||
CURL_EXTERN CURLU *curl_url(void);
|
||||
|
||||
/*
|
||||
* curl_url_cleanup() frees the CURLU handle and related resources used for
|
||||
* the URL parsing. It will not free strings previously returned with the URL
|
||||
* API.
|
||||
*/
|
||||
CURL_EXTERN void curl_url_cleanup(CURLU *handle);
|
||||
|
||||
/*
|
||||
* curl_url_dup() duplicates a CURLU handle and returns a new copy. The new
|
||||
* handle must also be freed with curl_url_cleanup().
|
||||
*/
|
||||
CURL_EXTERN CURLU *curl_url_dup(const CURLU *in);
|
||||
|
||||
/*
|
||||
* curl_url_get() extracts a specific part of the URL from a CURLU
|
||||
* handle. Returns error code. The returned pointer MUST be freed with
|
||||
* curl_free() afterwards.
|
||||
*/
|
||||
CURL_EXTERN CURLUcode curl_url_get(const CURLU *handle, CURLUPart what,
|
||||
char **part, unsigned int flags);
|
||||
|
||||
/*
|
||||
* curl_url_set() sets a specific part of the URL in a CURLU handle. Returns
|
||||
* error code. The passed in string will be copied. Passing a NULL instead of
|
||||
* a part string, clears that part.
|
||||
*/
|
||||
CURL_EXTERN CURLUcode curl_url_set(CURLU *handle, CURLUPart what,
|
||||
const char *part, unsigned int flags);
|
||||
|
||||
/*
|
||||
* curl_url_strerror() turns a CURLUcode value into the equivalent human
|
||||
* readable error string. This is useful for printing meaningful error
|
||||
* messages.
|
||||
*/
|
||||
CURL_EXTERN const char *curl_url_strerror(CURLUcode);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* end of extern "C" */
|
||||
#endif
|
||||
|
||||
#endif /* CURLINC_URLAPI_H */
|
84
3rdparty/curl/include/curl/websockets.h
vendored
Normal file
84
3rdparty/curl/include/curl/websockets.h
vendored
Normal file
@ -0,0 +1,84 @@
|
||||
#ifndef CURLINC_WEBSOCKETS_H
|
||||
#define CURLINC_WEBSOCKETS_H
|
||||
/***************************************************************************
|
||||
* _ _ ____ _
|
||||
* Project ___| | | | _ \| |
|
||||
* / __| | | | |_) | |
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
*
|
||||
* This software is licensed as described in the file COPYING, which
|
||||
* you should have received as part of this distribution. The terms
|
||||
* are also available at https://curl.se/docs/copyright.html.
|
||||
*
|
||||
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
|
||||
* copies of the Software, and permit persons to whom the Software is
|
||||
* furnished to do so, under the terms of the COPYING file.
|
||||
*
|
||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||
* KIND, either express or implied.
|
||||
*
|
||||
* SPDX-License-Identifier: curl
|
||||
*
|
||||
***************************************************************************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct curl_ws_frame {
|
||||
int age; /* zero */
|
||||
int flags; /* See the CURLWS_* defines */
|
||||
curl_off_t offset; /* the offset of this data into the frame */
|
||||
curl_off_t bytesleft; /* number of pending bytes left of the payload */
|
||||
size_t len; /* size of the current data chunk */
|
||||
};
|
||||
|
||||
/* flag bits */
|
||||
#define CURLWS_TEXT (1<<0)
|
||||
#define CURLWS_BINARY (1<<1)
|
||||
#define CURLWS_CONT (1<<2)
|
||||
#define CURLWS_CLOSE (1<<3)
|
||||
#define CURLWS_PING (1<<4)
|
||||
#define CURLWS_OFFSET (1<<5)
|
||||
|
||||
/*
|
||||
* NAME curl_ws_recv()
|
||||
*
|
||||
* DESCRIPTION
|
||||
*
|
||||
* Receives data from the websocket connection. Use after successful
|
||||
* curl_easy_perform() with CURLOPT_CONNECT_ONLY option.
|
||||
*/
|
||||
CURL_EXTERN CURLcode curl_ws_recv(CURL *curl, void *buffer, size_t buflen,
|
||||
size_t *recv,
|
||||
const struct curl_ws_frame **metap);
|
||||
|
||||
/* flags for curl_ws_send() */
|
||||
#define CURLWS_PONG (1<<6)
|
||||
|
||||
/*
|
||||
* NAME curl_ws_send()
|
||||
*
|
||||
* DESCRIPTION
|
||||
*
|
||||
* Sends data over the websocket connection. Use after successful
|
||||
* curl_easy_perform() with CURLOPT_CONNECT_ONLY option.
|
||||
*/
|
||||
CURL_EXTERN CURLcode curl_ws_send(CURL *curl, const void *buffer,
|
||||
size_t buflen, size_t *sent,
|
||||
curl_off_t fragsize,
|
||||
unsigned int flags);
|
||||
|
||||
/* bits for the CURLOPT_WS_OPTIONS bitmask: */
|
||||
#define CURLWS_RAW_MODE (1<<0)
|
||||
|
||||
CURL_EXTERN const struct curl_ws_frame *curl_ws_meta(CURL *curl);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* CURLINC_WEBSOCKETS_H */
|
75
3rdparty/curl/lib/cmake/CURL/CURLConfig.cmake
vendored
Normal file
75
3rdparty/curl/lib/cmake/CURL/CURLConfig.cmake
vendored
Normal file
@ -0,0 +1,75 @@
|
||||
#***************************************************************************
|
||||
# _ _ ____ _
|
||||
# Project ___| | | | _ \| |
|
||||
# / __| | | | |_) | |
|
||||
# | (__| |_| | _ <| |___
|
||||
# \___|\___/|_| \_\_____|
|
||||
#
|
||||
# Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
#
|
||||
# This software is licensed as described in the file COPYING, which
|
||||
# you should have received as part of this distribution. The terms
|
||||
# are also available at https://curl.se/docs/copyright.html.
|
||||
#
|
||||
# You may opt to use, copy, modify, merge, publish, distribute and/or sell
|
||||
# copies of the Software, and permit persons to whom the Software is
|
||||
# furnished to do so, under the terms of the COPYING file.
|
||||
#
|
||||
# This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||
# KIND, either express or implied.
|
||||
#
|
||||
# SPDX-License-Identifier: curl
|
||||
#
|
||||
###########################################################################
|
||||
|
||||
####### Expanded from @PACKAGE_INIT@ by configure_package_config_file() #######
|
||||
####### Any changes to this file will be overwritten by the next CMake run ####
|
||||
####### The input file was curl-config.cmake.in ########
|
||||
|
||||
get_filename_component(PACKAGE_PREFIX_DIR "${CMAKE_CURRENT_LIST_DIR}/../../../" ABSOLUTE)
|
||||
|
||||
macro(set_and_check _var _file)
|
||||
set(${_var} "${_file}")
|
||||
if(NOT EXISTS "${_file}")
|
||||
message(FATAL_ERROR "File or directory ${_file} referenced by variable ${_var} does not exist !")
|
||||
endif()
|
||||
endmacro()
|
||||
|
||||
macro(check_required_components _NAME)
|
||||
foreach(comp ${${_NAME}_FIND_COMPONENTS})
|
||||
if(NOT ${_NAME}_${comp}_FOUND)
|
||||
if(${_NAME}_FIND_REQUIRED_${comp})
|
||||
set(${_NAME}_FOUND FALSE)
|
||||
endif()
|
||||
endif()
|
||||
endforeach()
|
||||
endmacro()
|
||||
|
||||
####################################################################################
|
||||
|
||||
if(UNIX OR VCPKG_TOOLCHAIN OR (MINGW AND NOT CMAKE_CROSSCOMPILING)) # Keep in sync with root CMakeLists.txt
|
||||
set(_curl_use_pkgconfig_default ON)
|
||||
else()
|
||||
set(_curl_use_pkgconfig_default OFF)
|
||||
endif()
|
||||
option(CURL_USE_PKGCONFIG "Enable pkg-config to detect CURL dependencies" ${_curl_use_pkgconfig_default})
|
||||
|
||||
include(CMakeFindDependencyMacro)
|
||||
if("ON")
|
||||
find_dependency(OpenSSL "3")
|
||||
endif()
|
||||
if("ON")
|
||||
find_dependency(ZLIB "1")
|
||||
endif()
|
||||
|
||||
include("${CMAKE_CURRENT_LIST_DIR}/CURLTargets.cmake")
|
||||
check_required_components("CURL")
|
||||
|
||||
# Alias for either shared or static library
|
||||
if(NOT TARGET CURL::libcurl)
|
||||
add_library(CURL::libcurl ALIAS CURL::libcurl_static)
|
||||
endif()
|
||||
|
||||
# For compatibility with CMake's FindCURL.cmake
|
||||
set(CURL_LIBRARIES CURL::libcurl)
|
||||
set_and_check(CURL_INCLUDE_DIRS "${PACKAGE_PREFIX_DIR}/include")
|
76
3rdparty/curl/lib/cmake/CURL/CURLConfigVersion.cmake
vendored
Normal file
76
3rdparty/curl/lib/cmake/CURL/CURLConfigVersion.cmake
vendored
Normal file
@ -0,0 +1,76 @@
|
||||
|
||||
if(NOT PACKAGE_FIND_VERSION_RANGE AND PACKAGE_FIND_VERSION_MAJOR STREQUAL "7")
|
||||
# Version 8 satisfies version 7... requirements
|
||||
set(PACKAGE_FIND_VERSION_MAJOR 8)
|
||||
set(PACKAGE_FIND_VERSION_COUNT 1)
|
||||
endif()
|
||||
# This is a basic version file for the Config-mode of find_package().
|
||||
# It is used by write_basic_package_version_file() as input file for configure_file()
|
||||
# to create a version-file which can be installed along a config.cmake file.
|
||||
#
|
||||
# The created file sets PACKAGE_VERSION_EXACT if the current version string and
|
||||
# the requested version string are exactly the same and it sets
|
||||
# PACKAGE_VERSION_COMPATIBLE if the current version is >= requested version,
|
||||
# but only if the requested major version is the same as the current one.
|
||||
# The variable CVF_VERSION must be set before calling configure_file().
|
||||
|
||||
|
||||
set(PACKAGE_VERSION "8.11.0-DEV")
|
||||
|
||||
if(PACKAGE_VERSION VERSION_LESS PACKAGE_FIND_VERSION)
|
||||
set(PACKAGE_VERSION_COMPATIBLE FALSE)
|
||||
else()
|
||||
|
||||
if("8.11.0-DEV" MATCHES "^([0-9]+)\\.")
|
||||
set(CVF_VERSION_MAJOR "${CMAKE_MATCH_1}")
|
||||
if(NOT CVF_VERSION_MAJOR VERSION_EQUAL 0)
|
||||
string(REGEX REPLACE "^0+" "" CVF_VERSION_MAJOR "${CVF_VERSION_MAJOR}")
|
||||
endif()
|
||||
else()
|
||||
set(CVF_VERSION_MAJOR "8.11.0-DEV")
|
||||
endif()
|
||||
|
||||
if(PACKAGE_FIND_VERSION_RANGE)
|
||||
# both endpoints of the range must have the expected major version
|
||||
math (EXPR CVF_VERSION_MAJOR_NEXT "${CVF_VERSION_MAJOR} + 1")
|
||||
if (NOT PACKAGE_FIND_VERSION_MIN_MAJOR STREQUAL CVF_VERSION_MAJOR
|
||||
OR ((PACKAGE_FIND_VERSION_RANGE_MAX STREQUAL "INCLUDE" AND NOT PACKAGE_FIND_VERSION_MAX_MAJOR STREQUAL CVF_VERSION_MAJOR)
|
||||
OR (PACKAGE_FIND_VERSION_RANGE_MAX STREQUAL "EXCLUDE" AND NOT PACKAGE_FIND_VERSION_MAX VERSION_LESS_EQUAL CVF_VERSION_MAJOR_NEXT)))
|
||||
set(PACKAGE_VERSION_COMPATIBLE FALSE)
|
||||
elseif(PACKAGE_FIND_VERSION_MIN_MAJOR STREQUAL CVF_VERSION_MAJOR
|
||||
AND ((PACKAGE_FIND_VERSION_RANGE_MAX STREQUAL "INCLUDE" AND PACKAGE_VERSION VERSION_LESS_EQUAL PACKAGE_FIND_VERSION_MAX)
|
||||
OR (PACKAGE_FIND_VERSION_RANGE_MAX STREQUAL "EXCLUDE" AND PACKAGE_VERSION VERSION_LESS PACKAGE_FIND_VERSION_MAX)))
|
||||
set(PACKAGE_VERSION_COMPATIBLE TRUE)
|
||||
else()
|
||||
set(PACKAGE_VERSION_COMPATIBLE FALSE)
|
||||
endif()
|
||||
else()
|
||||
if(PACKAGE_FIND_VERSION_MAJOR STREQUAL CVF_VERSION_MAJOR)
|
||||
set(PACKAGE_VERSION_COMPATIBLE TRUE)
|
||||
else()
|
||||
set(PACKAGE_VERSION_COMPATIBLE FALSE)
|
||||
endif()
|
||||
|
||||
if(PACKAGE_FIND_VERSION STREQUAL PACKAGE_VERSION)
|
||||
set(PACKAGE_VERSION_EXACT TRUE)
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
|
||||
# if the installed project requested no architecture check, don't perform the check
|
||||
if("FALSE")
|
||||
return()
|
||||
endif()
|
||||
|
||||
# if the installed or the using project don't have CMAKE_SIZEOF_VOID_P set, ignore it:
|
||||
if("${CMAKE_SIZEOF_VOID_P}" STREQUAL "" OR "8" STREQUAL "")
|
||||
return()
|
||||
endif()
|
||||
|
||||
# check that the installed version has the same 32/64bit-ness as the one which is currently searching:
|
||||
if(NOT CMAKE_SIZEOF_VOID_P STREQUAL "8")
|
||||
math(EXPR installedBits "8 * 8")
|
||||
set(PACKAGE_VERSION "${PACKAGE_VERSION} (${installedBits}bit)")
|
||||
set(PACKAGE_VERSION_UNSUITABLE TRUE)
|
||||
endif()
|
28
3rdparty/curl/lib/cmake/CURL/CURLTargets-release.cmake
vendored
Normal file
28
3rdparty/curl/lib/cmake/CURL/CURLTargets-release.cmake
vendored
Normal file
@ -0,0 +1,28 @@
|
||||
#----------------------------------------------------------------
|
||||
# Generated CMake target import file for configuration "Release".
|
||||
#----------------------------------------------------------------
|
||||
|
||||
# Commands may need to know the format version.
|
||||
set(CMAKE_IMPORT_FILE_VERSION 1)
|
||||
|
||||
# Import target "CURL::libcurl_static" for configuration "Release"
|
||||
set_property(TARGET CURL::libcurl_static APPEND PROPERTY IMPORTED_CONFIGURATIONS RELEASE)
|
||||
set_target_properties(CURL::libcurl_static PROPERTIES
|
||||
IMPORTED_LINK_INTERFACE_LANGUAGES_RELEASE "C"
|
||||
IMPORTED_LOCATION_RELEASE "${_IMPORT_PREFIX}/lib/libcurl.a"
|
||||
)
|
||||
|
||||
list(APPEND _cmake_import_check_targets CURL::libcurl_static )
|
||||
list(APPEND _cmake_import_check_files_for_CURL::libcurl_static "${_IMPORT_PREFIX}/lib/libcurl.a" )
|
||||
|
||||
# Import target "CURL::curl" for configuration "Release"
|
||||
set_property(TARGET CURL::curl APPEND PROPERTY IMPORTED_CONFIGURATIONS RELEASE)
|
||||
set_target_properties(CURL::curl PROPERTIES
|
||||
IMPORTED_LOCATION_RELEASE "${_IMPORT_PREFIX}/bin/curl.exe"
|
||||
)
|
||||
|
||||
list(APPEND _cmake_import_check_targets CURL::curl )
|
||||
list(APPEND _cmake_import_check_files_for_CURL::curl "${_IMPORT_PREFIX}/bin/curl.exe" )
|
||||
|
||||
# Commands beyond this point should not need to know the version.
|
||||
set(CMAKE_IMPORT_FILE_VERSION)
|
111
3rdparty/curl/lib/cmake/CURL/CURLTargets.cmake
vendored
Normal file
111
3rdparty/curl/lib/cmake/CURL/CURLTargets.cmake
vendored
Normal file
@ -0,0 +1,111 @@
|
||||
# Generated by CMake
|
||||
|
||||
if("${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}" LESS 2.8)
|
||||
message(FATAL_ERROR "CMake >= 2.8.0 required")
|
||||
endif()
|
||||
if(CMAKE_VERSION VERSION_LESS "2.8.3")
|
||||
message(FATAL_ERROR "CMake >= 2.8.3 required")
|
||||
endif()
|
||||
cmake_policy(PUSH)
|
||||
cmake_policy(VERSION 2.8.3...3.22)
|
||||
#----------------------------------------------------------------
|
||||
# Generated CMake target import file.
|
||||
#----------------------------------------------------------------
|
||||
|
||||
# Commands may need to know the format version.
|
||||
set(CMAKE_IMPORT_FILE_VERSION 1)
|
||||
|
||||
# Protect against multiple inclusion, which would fail when already imported targets are added once more.
|
||||
set(_cmake_targets_defined "")
|
||||
set(_cmake_targets_not_defined "")
|
||||
set(_cmake_expected_targets "")
|
||||
foreach(_cmake_expected_target IN ITEMS CURL::libcurl_static CURL::curl)
|
||||
list(APPEND _cmake_expected_targets "${_cmake_expected_target}")
|
||||
if(TARGET "${_cmake_expected_target}")
|
||||
list(APPEND _cmake_targets_defined "${_cmake_expected_target}")
|
||||
else()
|
||||
list(APPEND _cmake_targets_not_defined "${_cmake_expected_target}")
|
||||
endif()
|
||||
endforeach()
|
||||
unset(_cmake_expected_target)
|
||||
if(_cmake_targets_defined STREQUAL _cmake_expected_targets)
|
||||
unset(_cmake_targets_defined)
|
||||
unset(_cmake_targets_not_defined)
|
||||
unset(_cmake_expected_targets)
|
||||
unset(CMAKE_IMPORT_FILE_VERSION)
|
||||
cmake_policy(POP)
|
||||
return()
|
||||
endif()
|
||||
if(NOT _cmake_targets_defined STREQUAL "")
|
||||
string(REPLACE ";" ", " _cmake_targets_defined_text "${_cmake_targets_defined}")
|
||||
string(REPLACE ";" ", " _cmake_targets_not_defined_text "${_cmake_targets_not_defined}")
|
||||
message(FATAL_ERROR "Some (but not all) targets in this export set were already defined.\nTargets Defined: ${_cmake_targets_defined_text}\nTargets not yet defined: ${_cmake_targets_not_defined_text}\n")
|
||||
endif()
|
||||
unset(_cmake_targets_defined)
|
||||
unset(_cmake_targets_not_defined)
|
||||
unset(_cmake_expected_targets)
|
||||
|
||||
|
||||
# Compute the installation prefix relative to this file.
|
||||
get_filename_component(_IMPORT_PREFIX "${CMAKE_CURRENT_LIST_FILE}" PATH)
|
||||
get_filename_component(_IMPORT_PREFIX "${_IMPORT_PREFIX}" PATH)
|
||||
get_filename_component(_IMPORT_PREFIX "${_IMPORT_PREFIX}" PATH)
|
||||
get_filename_component(_IMPORT_PREFIX "${_IMPORT_PREFIX}" PATH)
|
||||
if(_IMPORT_PREFIX STREQUAL "/")
|
||||
set(_IMPORT_PREFIX "")
|
||||
endif()
|
||||
|
||||
# Create imported target CURL::libcurl_static
|
||||
add_library(CURL::libcurl_static STATIC IMPORTED)
|
||||
|
||||
set_target_properties(CURL::libcurl_static PROPERTIES
|
||||
INTERFACE_COMPILE_DEFINITIONS "CURL_STATICLIB"
|
||||
INTERFACE_INCLUDE_DIRECTORIES "${_IMPORT_PREFIX}/include"
|
||||
INTERFACE_LINK_LIBRARIES "\$<LINK_ONLY:idn2>;\$<LINK_ONLY:ws2_32>;\$<LINK_ONLY:bcrypt>;\$<LINK_ONLY:OpenSSL::SSL>;\$<LINK_ONLY:OpenSSL::Crypto>;\$<LINK_ONLY:ZLIB::ZLIB>;D:/Dev/msys64/mingw64/lib/libzstd.dll.a;D:/Dev/msys64/mingw64/lib/libnghttp2.dll.a;D:/Dev/msys64/mingw64/lib/libnghttp3.dll.a;\$<LINK_ONLY:wldap32>;D:/Dev/msys64/mingw64/lib/libpsl.dll.a;D:/Dev/msys64/mingw64/lib/libssh2.dll.a;\$<LINK_ONLY:advapi32>;\$<LINK_ONLY:crypt32>"
|
||||
)
|
||||
|
||||
# Create imported target CURL::curl
|
||||
add_executable(CURL::curl IMPORTED)
|
||||
|
||||
if(CMAKE_VERSION VERSION_LESS 2.8.12)
|
||||
message(FATAL_ERROR "This file relies on consumers using CMake 2.8.12 or greater.")
|
||||
endif()
|
||||
|
||||
# Load information for each installed configuration.
|
||||
file(GLOB _cmake_config_files "${CMAKE_CURRENT_LIST_DIR}/CURLTargets-*.cmake")
|
||||
foreach(_cmake_config_file IN LISTS _cmake_config_files)
|
||||
include("${_cmake_config_file}")
|
||||
endforeach()
|
||||
unset(_cmake_config_file)
|
||||
unset(_cmake_config_files)
|
||||
|
||||
# Cleanup temporary variables.
|
||||
set(_IMPORT_PREFIX)
|
||||
|
||||
# Loop over all imported files and verify that they actually exist
|
||||
foreach(_cmake_target IN LISTS _cmake_import_check_targets)
|
||||
foreach(_cmake_file IN LISTS "_cmake_import_check_files_for_${_cmake_target}")
|
||||
if(NOT EXISTS "${_cmake_file}")
|
||||
message(FATAL_ERROR "The imported target \"${_cmake_target}\" references the file
|
||||
\"${_cmake_file}\"
|
||||
but this file does not exist. Possible reasons include:
|
||||
* The file was deleted, renamed, or moved to another location.
|
||||
* An install or uninstall procedure did not complete successfully.
|
||||
* The installation package was faulty and contained
|
||||
\"${CMAKE_CURRENT_LIST_FILE}\"
|
||||
but not all the files it references.
|
||||
")
|
||||
endif()
|
||||
endforeach()
|
||||
unset(_cmake_file)
|
||||
unset("_cmake_import_check_files_for_${_cmake_target}")
|
||||
endforeach()
|
||||
unset(_cmake_target)
|
||||
unset(_cmake_import_check_targets)
|
||||
|
||||
# This file does not depend on other imported targets which have
|
||||
# been exported from the same project but in a separate export set.
|
||||
|
||||
# Commands beyond this point should not need to know the version.
|
||||
set(CMAKE_IMPORT_FILE_VERSION)
|
||||
cmake_policy(POP)
|
BIN
3rdparty/curl/lib/libcurl.a
vendored
Normal file
BIN
3rdparty/curl/lib/libcurl.a
vendored
Normal file
Binary file not shown.
41
3rdparty/curl/lib/pkgconfig/libcurl.pc
vendored
Normal file
41
3rdparty/curl/lib/pkgconfig/libcurl.pc
vendored
Normal file
@ -0,0 +1,41 @@
|
||||
#***************************************************************************
|
||||
# _ _ ____ _
|
||||
# Project ___| | | | _ \| |
|
||||
# / __| | | | |_) | |
|
||||
# | (__| |_| | _ <| |___
|
||||
# \___|\___/|_| \_\_____|
|
||||
#
|
||||
# Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
#
|
||||
# This software is licensed as described in the file COPYING, which
|
||||
# you should have received as part of this distribution. The terms
|
||||
# are also available at https://curl.se/docs/copyright.html.
|
||||
#
|
||||
# You may opt to use, copy, modify, merge, publish, distribute and/or sell
|
||||
# copies of the Software, and permit persons to whom the Software is
|
||||
# furnished to do so, under the terms of the COPYING file.
|
||||
#
|
||||
# This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||
# KIND, either express or implied.
|
||||
#
|
||||
# SPDX-License-Identifier: curl
|
||||
#
|
||||
###########################################################################
|
||||
|
||||
prefix=F:\SourceCode\curl\build\curl
|
||||
exec_prefix=${prefix}
|
||||
libdir=${exec_prefix}/lib
|
||||
includedir=${prefix}/include
|
||||
supported_protocols="DICT FILE FTP FTPS GOPHER GOPHERS HTTP HTTPS IMAP IMAPS IPFS IPNS LDAP LDAPS MQTT POP3 POP3S RTSP SCP SFTP SMB SMBS SMTP SMTPS TELNET TFTP"
|
||||
supported_features="alt-svc AsynchDNS HSTS HTTP2 HTTP3 HTTPS-proxy IDN IPv6 Largefile libz NTLM PSL SSL threadsafe TLS-SRP UnixSockets zstd"
|
||||
|
||||
Name: libcurl
|
||||
URL: https://curl.se/
|
||||
Description: Library to transfer files with HTTP, FTP, etc.
|
||||
Version: 8.11.0-DEV
|
||||
Requires: libidn2,openssl,zlib,libzstd,libnghttp2,libnghttp3,libpsl,libssh2
|
||||
Requires.private: libidn2,openssl,zlib,libzstd,libnghttp2,libnghttp3,libpsl,libssh2
|
||||
Libs: -L${libdir} -lcurl -lidn2 -lws2_32 -lbcrypt -lssl -lcrypto -lz -lzstd -lnghttp2 -lnghttp3 -lwldap32 -lpsl -lssh2 -ladvapi32 -lcrypt32
|
||||
Libs.private: -LD:/Dev/msys64/mingw64/bin/../lib -LD:/Dev/msys64/mingw64/lib -lidn2 -lws2_32 -lbcrypt -lssl -lcrypto -lz -lzstd -lnghttp2 -lnghttp3 -lwldap32 -lpsl -lssh2 -ladvapi32 -lcrypt32
|
||||
Cflags: -I${includedir} -DCURL_STATICLIB
|
||||
Cflags.private: -DCURL_STATICLIB
|
6523
3rdparty/curl/share/man/man1/curl.1
vendored
Normal file
6523
3rdparty/curl/share/man/man1/curl.1
vendored
Normal file
File diff suppressed because it is too large
Load Diff
22875
3rdparty/json/json.hpp
vendored
Normal file
22875
3rdparty/json/json.hpp
vendored
Normal file
File diff suppressed because it is too large
Load Diff
74
3rdparty/libgit2/include/git2.h
vendored
Normal file
74
3rdparty/libgit2/include/git2.h
vendored
Normal file
@ -0,0 +1,74 @@
|
||||
/*
|
||||
* Copyright (C) the libgit2 contributors. All rights reserved.
|
||||
*
|
||||
* This file is part of libgit2, distributed under the GNU GPL v2 with
|
||||
* a Linking Exception. For full terms see the included COPYING file.
|
||||
*/
|
||||
|
||||
#ifndef INCLUDE_git_git_h__
|
||||
#define INCLUDE_git_git_h__
|
||||
|
||||
#include "git2/annotated_commit.h"
|
||||
#include "git2/apply.h"
|
||||
#include "git2/attr.h"
|
||||
#include "git2/blob.h"
|
||||
#include "git2/blame.h"
|
||||
#include "git2/branch.h"
|
||||
#include "git2/buffer.h"
|
||||
#include "git2/cert.h"
|
||||
#include "git2/checkout.h"
|
||||
#include "git2/cherrypick.h"
|
||||
#include "git2/clone.h"
|
||||
#include "git2/commit.h"
|
||||
#include "git2/common.h"
|
||||
#include "git2/config.h"
|
||||
#include "git2/credential.h"
|
||||
#include "git2/deprecated.h"
|
||||
#include "git2/describe.h"
|
||||
#include "git2/diff.h"
|
||||
#include "git2/email.h"
|
||||
#include "git2/errors.h"
|
||||
#include "git2/experimental.h"
|
||||
#include "git2/filter.h"
|
||||
#include "git2/global.h"
|
||||
#include "git2/graph.h"
|
||||
#include "git2/ignore.h"
|
||||
#include "git2/index.h"
|
||||
#include "git2/indexer.h"
|
||||
#include "git2/mailmap.h"
|
||||
#include "git2/merge.h"
|
||||
#include "git2/message.h"
|
||||
#include "git2/net.h"
|
||||
#include "git2/notes.h"
|
||||
#include "git2/object.h"
|
||||
#include "git2/odb.h"
|
||||
#include "git2/odb_backend.h"
|
||||
#include "git2/oid.h"
|
||||
#include "git2/pack.h"
|
||||
#include "git2/patch.h"
|
||||
#include "git2/pathspec.h"
|
||||
#include "git2/proxy.h"
|
||||
#include "git2/rebase.h"
|
||||
#include "git2/refdb.h"
|
||||
#include "git2/reflog.h"
|
||||
#include "git2/refs.h"
|
||||
#include "git2/refspec.h"
|
||||
#include "git2/remote.h"
|
||||
#include "git2/repository.h"
|
||||
#include "git2/reset.h"
|
||||
#include "git2/revert.h"
|
||||
#include "git2/revparse.h"
|
||||
#include "git2/revwalk.h"
|
||||
#include "git2/signature.h"
|
||||
#include "git2/stash.h"
|
||||
#include "git2/status.h"
|
||||
#include "git2/submodule.h"
|
||||
#include "git2/tag.h"
|
||||
#include "git2/transport.h"
|
||||
#include "git2/transaction.h"
|
||||
#include "git2/tree.h"
|
||||
#include "git2/types.h"
|
||||
#include "git2/version.h"
|
||||
#include "git2/worktree.h"
|
||||
|
||||
#endif
|
125
3rdparty/libgit2/include/git2/annotated_commit.h
vendored
Normal file
125
3rdparty/libgit2/include/git2/annotated_commit.h
vendored
Normal file
@ -0,0 +1,125 @@
|
||||
/*
|
||||
* Copyright (C) the libgit2 contributors. All rights reserved.
|
||||
*
|
||||
* This file is part of libgit2, distributed under the GNU GPL v2 with
|
||||
* a Linking Exception. For full terms see the included COPYING file.
|
||||
*/
|
||||
#ifndef INCLUDE_git_annotated_commit_h__
|
||||
#define INCLUDE_git_annotated_commit_h__
|
||||
|
||||
#include "common.h"
|
||||
#include "repository.h"
|
||||
#include "types.h"
|
||||
|
||||
/**
|
||||
* @file git2/annotated_commit.h
|
||||
* @brief Git annotated commit routines
|
||||
* @defgroup git_annotated_commit Git annotated commit routines
|
||||
* @ingroup Git
|
||||
* @{
|
||||
*/
|
||||
GIT_BEGIN_DECL
|
||||
|
||||
/**
|
||||
* Creates a `git_annotated_commit` from the given reference.
|
||||
* The resulting git_annotated_commit must be freed with
|
||||
* `git_annotated_commit_free`.
|
||||
*
|
||||
* @param out pointer to store the git_annotated_commit result in
|
||||
* @param repo repository that contains the given reference
|
||||
* @param ref reference to use to lookup the git_annotated_commit
|
||||
* @return 0 on success or error code
|
||||
*/
|
||||
GIT_EXTERN(int) git_annotated_commit_from_ref(
|
||||
git_annotated_commit **out,
|
||||
git_repository *repo,
|
||||
const git_reference *ref);
|
||||
|
||||
/**
|
||||
* Creates a `git_annotated_commit` from the given fetch head data.
|
||||
* The resulting git_annotated_commit must be freed with
|
||||
* `git_annotated_commit_free`.
|
||||
*
|
||||
* @param out pointer to store the git_annotated_commit result in
|
||||
* @param repo repository that contains the given commit
|
||||
* @param branch_name name of the (remote) branch
|
||||
* @param remote_url url of the remote
|
||||
* @param id the commit object id of the remote branch
|
||||
* @return 0 on success or error code
|
||||
*/
|
||||
GIT_EXTERN(int) git_annotated_commit_from_fetchhead(
|
||||
git_annotated_commit **out,
|
||||
git_repository *repo,
|
||||
const char *branch_name,
|
||||
const char *remote_url,
|
||||
const git_oid *id);
|
||||
|
||||
/**
|
||||
* Creates a `git_annotated_commit` from the given commit id.
|
||||
* The resulting git_annotated_commit must be freed with
|
||||
* `git_annotated_commit_free`.
|
||||
*
|
||||
* An annotated commit contains information about how it was
|
||||
* looked up, which may be useful for functions like merge or
|
||||
* rebase to provide context to the operation. For example,
|
||||
* conflict files will include the name of the source or target
|
||||
* branches being merged. It is therefore preferable to use the
|
||||
* most specific function (eg `git_annotated_commit_from_ref`)
|
||||
* instead of this one when that data is known.
|
||||
*
|
||||
* @param out pointer to store the git_annotated_commit result in
|
||||
* @param repo repository that contains the given commit
|
||||
* @param id the commit object id to lookup
|
||||
* @return 0 on success or error code
|
||||
*/
|
||||
GIT_EXTERN(int) git_annotated_commit_lookup(
|
||||
git_annotated_commit **out,
|
||||
git_repository *repo,
|
||||
const git_oid *id);
|
||||
|
||||
/**
|
||||
* Creates a `git_annotated_commit` from a revision string.
|
||||
*
|
||||
* See `man gitrevisions`, or
|
||||
* http://git-scm.com/docs/git-rev-parse.html#_specifying_revisions for
|
||||
* information on the syntax accepted.
|
||||
*
|
||||
* @param out pointer to store the git_annotated_commit result in
|
||||
* @param repo repository that contains the given commit
|
||||
* @param revspec the extended sha syntax string to use to lookup the commit
|
||||
* @return 0 on success or error code
|
||||
*/
|
||||
GIT_EXTERN(int) git_annotated_commit_from_revspec(
|
||||
git_annotated_commit **out,
|
||||
git_repository *repo,
|
||||
const char *revspec);
|
||||
|
||||
/**
|
||||
* Gets the commit ID that the given `git_annotated_commit` refers to.
|
||||
*
|
||||
* @param commit the given annotated commit
|
||||
* @return commit id
|
||||
*/
|
||||
GIT_EXTERN(const git_oid *) git_annotated_commit_id(
|
||||
const git_annotated_commit *commit);
|
||||
|
||||
/**
|
||||
* Get the refname that the given `git_annotated_commit` refers to.
|
||||
*
|
||||
* @param commit the given annotated commit
|
||||
* @return ref name.
|
||||
*/
|
||||
GIT_EXTERN(const char *) git_annotated_commit_ref(
|
||||
const git_annotated_commit *commit);
|
||||
|
||||
/**
|
||||
* Frees a `git_annotated_commit`.
|
||||
*
|
||||
* @param commit annotated commit to free
|
||||
*/
|
||||
GIT_EXTERN(void) git_annotated_commit_free(
|
||||
git_annotated_commit *commit);
|
||||
|
||||
/** @} */
|
||||
GIT_END_DECL
|
||||
#endif
|
165
3rdparty/libgit2/include/git2/apply.h
vendored
Normal file
165
3rdparty/libgit2/include/git2/apply.h
vendored
Normal file
@ -0,0 +1,165 @@
|
||||
/*
|
||||
* Copyright (C) the libgit2 contributors. All rights reserved.
|
||||
*
|
||||
* This file is part of libgit2, distributed under the GNU GPL v2 with
|
||||
* a Linking Exception. For full terms see the included COPYING file.
|
||||
*/
|
||||
#ifndef INCLUDE_git_apply_h__
|
||||
#define INCLUDE_git_apply_h__
|
||||
|
||||
#include "common.h"
|
||||
#include "types.h"
|
||||
#include "oid.h"
|
||||
#include "diff.h"
|
||||
|
||||
/**
|
||||
* @file git2/apply.h
|
||||
* @brief Git patch application routines
|
||||
* @defgroup git_apply Git patch application routines
|
||||
* @ingroup Git
|
||||
* @{
|
||||
*/
|
||||
GIT_BEGIN_DECL
|
||||
|
||||
/**
|
||||
* When applying a patch, callback that will be made per delta (file).
|
||||
*
|
||||
* When the callback:
|
||||
* - returns < 0, the apply process will be aborted.
|
||||
* - returns > 0, the delta will not be applied, but the apply process
|
||||
* continues
|
||||
* - returns 0, the delta is applied, and the apply process continues.
|
||||
*
|
||||
* @param delta The delta to be applied
|
||||
* @param payload User-specified payload
|
||||
* @return 0 if the delta is applied, < 0 if the apply process will be aborted
|
||||
* or > 0 if the delta will not be applied.
|
||||
*/
|
||||
typedef int GIT_CALLBACK(git_apply_delta_cb)(
|
||||
const git_diff_delta *delta,
|
||||
void *payload);
|
||||
|
||||
/**
|
||||
* When applying a patch, callback that will be made per hunk.
|
||||
*
|
||||
* When the callback:
|
||||
* - returns < 0, the apply process will be aborted.
|
||||
* - returns > 0, the hunk will not be applied, but the apply process
|
||||
* continues
|
||||
* - returns 0, the hunk is applied, and the apply process continues.
|
||||
*
|
||||
* @param hunk The hunk to be applied
|
||||
* @param payload User-specified payload
|
||||
* @return 0 if the hunk is applied, < 0 if the apply process will be aborted
|
||||
* or > 0 if the hunk will not be applied.
|
||||
*/
|
||||
typedef int GIT_CALLBACK(git_apply_hunk_cb)(
|
||||
const git_diff_hunk *hunk,
|
||||
void *payload);
|
||||
|
||||
/** Flags controlling the behavior of git_apply */
|
||||
typedef enum {
|
||||
/**
|
||||
* Don't actually make changes, just test that the patch applies.
|
||||
* This is the equivalent of `git apply --check`.
|
||||
*/
|
||||
GIT_APPLY_CHECK = (1 << 0)
|
||||
} git_apply_flags_t;
|
||||
|
||||
/**
|
||||
* Apply options structure
|
||||
*
|
||||
* Initialize with `GIT_APPLY_OPTIONS_INIT`. Alternatively, you can
|
||||
* use `git_apply_options_init`.
|
||||
*
|
||||
* @see git_apply_to_tree, git_apply
|
||||
*/
|
||||
typedef struct {
|
||||
unsigned int version; /**< The version */
|
||||
|
||||
/** When applying a patch, callback that will be made per delta (file). */
|
||||
git_apply_delta_cb delta_cb;
|
||||
|
||||
/** When applying a patch, callback that will be made per hunk. */
|
||||
git_apply_hunk_cb hunk_cb;
|
||||
|
||||
/** Payload passed to both delta_cb & hunk_cb. */
|
||||
void *payload;
|
||||
|
||||
/** Bitmask of git_apply_flags_t */
|
||||
unsigned int flags;
|
||||
} git_apply_options;
|
||||
|
||||
#define GIT_APPLY_OPTIONS_VERSION 1
|
||||
#define GIT_APPLY_OPTIONS_INIT {GIT_APPLY_OPTIONS_VERSION}
|
||||
|
||||
/**
|
||||
* Initialize git_apply_options structure
|
||||
*
|
||||
* Initialize a `git_apply_options` with default values. Equivalent to creating
|
||||
* an instance with GIT_APPLY_OPTIONS_INIT.
|
||||
*
|
||||
* @param opts The `git_apply_options` struct to initialize.
|
||||
* @param version The struct version; pass `GIT_APPLY_OPTIONS_VERSION`
|
||||
* @return 0 on success or -1 on failure.
|
||||
*/
|
||||
GIT_EXTERN(int) git_apply_options_init(git_apply_options *opts, unsigned int version);
|
||||
|
||||
/**
|
||||
* Apply a `git_diff` to a `git_tree`, and return the resulting image
|
||||
* as an index.
|
||||
*
|
||||
* @param out the postimage of the application
|
||||
* @param repo the repository to apply
|
||||
* @param preimage the tree to apply the diff to
|
||||
* @param diff the diff to apply
|
||||
* @param options the options for the apply (or null for defaults)
|
||||
* @return 0 or an error code
|
||||
*/
|
||||
GIT_EXTERN(int) git_apply_to_tree(
|
||||
git_index **out,
|
||||
git_repository *repo,
|
||||
git_tree *preimage,
|
||||
git_diff *diff,
|
||||
const git_apply_options *options);
|
||||
|
||||
/** Possible application locations for git_apply */
|
||||
typedef enum {
|
||||
/**
|
||||
* Apply the patch to the workdir, leaving the index untouched.
|
||||
* This is the equivalent of `git apply` with no location argument.
|
||||
*/
|
||||
GIT_APPLY_LOCATION_WORKDIR = 0,
|
||||
|
||||
/**
|
||||
* Apply the patch to the index, leaving the working directory
|
||||
* untouched. This is the equivalent of `git apply --cached`.
|
||||
*/
|
||||
GIT_APPLY_LOCATION_INDEX = 1,
|
||||
|
||||
/**
|
||||
* Apply the patch to both the working directory and the index.
|
||||
* This is the equivalent of `git apply --index`.
|
||||
*/
|
||||
GIT_APPLY_LOCATION_BOTH = 2
|
||||
} git_apply_location_t;
|
||||
|
||||
/**
|
||||
* Apply a `git_diff` to the given repository, making changes directly
|
||||
* in the working directory, the index, or both.
|
||||
*
|
||||
* @param repo the repository to apply to
|
||||
* @param diff the diff to apply
|
||||
* @param location the location to apply (workdir, index or both)
|
||||
* @param options the options for the apply (or null for defaults)
|
||||
* @return 0 or an error code
|
||||
*/
|
||||
GIT_EXTERN(int) git_apply(
|
||||
git_repository *repo,
|
||||
git_diff *diff,
|
||||
git_apply_location_t location,
|
||||
const git_apply_options *options);
|
||||
|
||||
/** @} */
|
||||
GIT_END_DECL
|
||||
#endif
|
368
3rdparty/libgit2/include/git2/attr.h
vendored
Normal file
368
3rdparty/libgit2/include/git2/attr.h
vendored
Normal file
@ -0,0 +1,368 @@
|
||||
/*
|
||||
* Copyright (C) the libgit2 contributors. All rights reserved.
|
||||
*
|
||||
* This file is part of libgit2, distributed under the GNU GPL v2 with
|
||||
* a Linking Exception. For full terms see the included COPYING file.
|
||||
*/
|
||||
#ifndef INCLUDE_git_attr_h__
|
||||
#define INCLUDE_git_attr_h__
|
||||
|
||||
#include "common.h"
|
||||
#include "types.h"
|
||||
|
||||
/**
|
||||
* @file git2/attr.h
|
||||
* @brief Git attribute management routines
|
||||
* @defgroup git_attr Git attribute management routines
|
||||
* @ingroup Git
|
||||
* @{
|
||||
*/
|
||||
GIT_BEGIN_DECL
|
||||
|
||||
/**
|
||||
* GIT_ATTR_TRUE checks if an attribute is set on. In core git
|
||||
* parlance, this the value for "Set" attributes.
|
||||
*
|
||||
* For example, if the attribute file contains:
|
||||
*
|
||||
* *.c foo
|
||||
*
|
||||
* Then for file `xyz.c` looking up attribute "foo" gives a value for
|
||||
* which `GIT_ATTR_TRUE(value)` is true.
|
||||
*/
|
||||
#define GIT_ATTR_IS_TRUE(attr) (git_attr_value(attr) == GIT_ATTR_VALUE_TRUE)
|
||||
|
||||
/**
|
||||
* GIT_ATTR_FALSE checks if an attribute is set off. In core git
|
||||
* parlance, this is the value for attributes that are "Unset" (not to
|
||||
* be confused with values that a "Unspecified").
|
||||
*
|
||||
* For example, if the attribute file contains:
|
||||
*
|
||||
* *.h -foo
|
||||
*
|
||||
* Then for file `zyx.h` looking up attribute "foo" gives a value for
|
||||
* which `GIT_ATTR_FALSE(value)` is true.
|
||||
*/
|
||||
#define GIT_ATTR_IS_FALSE(attr) (git_attr_value(attr) == GIT_ATTR_VALUE_FALSE)
|
||||
|
||||
/**
|
||||
* GIT_ATTR_UNSPECIFIED checks if an attribute is unspecified. This
|
||||
* may be due to the attribute not being mentioned at all or because
|
||||
* the attribute was explicitly set unspecified via the `!` operator.
|
||||
*
|
||||
* For example, if the attribute file contains:
|
||||
*
|
||||
* *.c foo
|
||||
* *.h -foo
|
||||
* onefile.c !foo
|
||||
*
|
||||
* Then for `onefile.c` looking up attribute "foo" yields a value with
|
||||
* `GIT_ATTR_UNSPECIFIED(value)` of true. Also, looking up "foo" on
|
||||
* file `onefile.rb` or looking up "bar" on any file will all give
|
||||
* `GIT_ATTR_UNSPECIFIED(value)` of true.
|
||||
*/
|
||||
#define GIT_ATTR_IS_UNSPECIFIED(attr) (git_attr_value(attr) == GIT_ATTR_VALUE_UNSPECIFIED)
|
||||
|
||||
/**
|
||||
* GIT_ATTR_HAS_VALUE checks if an attribute is set to a value (as
|
||||
* opposed to TRUE, FALSE or UNSPECIFIED). This would be the case if
|
||||
* for a file with something like:
|
||||
*
|
||||
* *.txt eol=lf
|
||||
*
|
||||
* Given this, looking up "eol" for `onefile.txt` will give back the
|
||||
* string "lf" and `GIT_ATTR_SET_TO_VALUE(attr)` will return true.
|
||||
*/
|
||||
#define GIT_ATTR_HAS_VALUE(attr) (git_attr_value(attr) == GIT_ATTR_VALUE_STRING)
|
||||
|
||||
/**
|
||||
* Possible states for an attribute
|
||||
*/
|
||||
typedef enum {
|
||||
GIT_ATTR_VALUE_UNSPECIFIED = 0, /**< The attribute has been left unspecified */
|
||||
GIT_ATTR_VALUE_TRUE, /**< The attribute has been set */
|
||||
GIT_ATTR_VALUE_FALSE, /**< The attribute has been unset */
|
||||
GIT_ATTR_VALUE_STRING /**< This attribute has a value */
|
||||
} git_attr_value_t;
|
||||
|
||||
/**
|
||||
* Return the value type for a given attribute.
|
||||
*
|
||||
* This can be either `TRUE`, `FALSE`, `UNSPECIFIED` (if the attribute
|
||||
* was not set at all), or `VALUE`, if the attribute was set to an
|
||||
* actual string.
|
||||
*
|
||||
* If the attribute has a `VALUE` string, it can be accessed normally
|
||||
* as a NULL-terminated C string.
|
||||
*
|
||||
* @param attr The attribute
|
||||
* @return the value type for the attribute
|
||||
*/
|
||||
GIT_EXTERN(git_attr_value_t) git_attr_value(const char *attr);
|
||||
|
||||
/**
|
||||
* Check attribute flags: Reading values from index and working directory.
|
||||
*
|
||||
* When checking attributes, it is possible to check attribute files
|
||||
* in both the working directory (if there is one) and the index (if
|
||||
* there is one). You can explicitly choose where to check and in
|
||||
* which order using the following flags.
|
||||
*
|
||||
* Core git usually checks the working directory then the index,
|
||||
* except during a checkout when it checks the index first. It will
|
||||
* use index only for creating archives or for a bare repo (if an
|
||||
* index has been specified for the bare repo).
|
||||
*/
|
||||
#define GIT_ATTR_CHECK_FILE_THEN_INDEX 0
|
||||
#define GIT_ATTR_CHECK_INDEX_THEN_FILE 1
|
||||
#define GIT_ATTR_CHECK_INDEX_ONLY 2
|
||||
|
||||
/**
|
||||
* Check attribute flags: controlling extended attribute behavior.
|
||||
*
|
||||
* Normally, attribute checks include looking in the /etc (or system
|
||||
* equivalent) directory for a `gitattributes` file. Passing the
|
||||
* `GIT_ATTR_CHECK_NO_SYSTEM` flag will cause attribute checks to
|
||||
* ignore that file.
|
||||
*
|
||||
* Passing the `GIT_ATTR_CHECK_INCLUDE_HEAD` flag will use attributes
|
||||
* from a `.gitattributes` file in the repository at the HEAD revision.
|
||||
*
|
||||
* Passing the `GIT_ATTR_CHECK_INCLUDE_COMMIT` flag will use attributes
|
||||
* from a `.gitattributes` file in a specific commit.
|
||||
*/
|
||||
#define GIT_ATTR_CHECK_NO_SYSTEM (1 << 2)
|
||||
#define GIT_ATTR_CHECK_INCLUDE_HEAD (1 << 3)
|
||||
#define GIT_ATTR_CHECK_INCLUDE_COMMIT (1 << 4)
|
||||
|
||||
/**
|
||||
* An options structure for querying attributes.
|
||||
*/
|
||||
typedef struct {
|
||||
unsigned int version;
|
||||
|
||||
/** A combination of GIT_ATTR_CHECK flags */
|
||||
unsigned int flags;
|
||||
|
||||
#ifdef GIT_DEPRECATE_HARD
|
||||
void *reserved;
|
||||
#else
|
||||
git_oid *commit_id;
|
||||
#endif
|
||||
|
||||
/**
|
||||
* The commit to load attributes from, when
|
||||
* `GIT_ATTR_CHECK_INCLUDE_COMMIT` is specified.
|
||||
*/
|
||||
git_oid attr_commit_id;
|
||||
} git_attr_options;
|
||||
|
||||
#define GIT_ATTR_OPTIONS_VERSION 1
|
||||
#define GIT_ATTR_OPTIONS_INIT {GIT_ATTR_OPTIONS_VERSION}
|
||||
|
||||
/**
|
||||
* Look up the value of one git attribute for path.
|
||||
*
|
||||
* @param value_out Output of the value of the attribute. Use the GIT_ATTR_...
|
||||
* macros to test for TRUE, FALSE, UNSPECIFIED, etc. or just
|
||||
* use the string value for attributes set to a value. You
|
||||
* should NOT modify or free this value.
|
||||
* @param repo The repository containing the path.
|
||||
* @param flags A combination of GIT_ATTR_CHECK... flags.
|
||||
* @param path The path to check for attributes. Relative paths are
|
||||
* interpreted relative to the repo root. The file does
|
||||
* not have to exist, but if it does not, then it will be
|
||||
* treated as a plain file (not a directory).
|
||||
* @param name The name of the attribute to look up.
|
||||
* @return 0 or an error code.
|
||||
*/
|
||||
GIT_EXTERN(int) git_attr_get(
|
||||
const char **value_out,
|
||||
git_repository *repo,
|
||||
uint32_t flags,
|
||||
const char *path,
|
||||
const char *name);
|
||||
|
||||
/**
|
||||
* Look up the value of one git attribute for path with extended options.
|
||||
*
|
||||
* @param value_out Output of the value of the attribute. Use the GIT_ATTR_...
|
||||
* macros to test for TRUE, FALSE, UNSPECIFIED, etc. or just
|
||||
* use the string value for attributes set to a value. You
|
||||
* should NOT modify or free this value.
|
||||
* @param repo The repository containing the path.
|
||||
* @param opts The `git_attr_options` to use when querying these attributes.
|
||||
* @param path The path to check for attributes. Relative paths are
|
||||
* interpreted relative to the repo root. The file does
|
||||
* not have to exist, but if it does not, then it will be
|
||||
* treated as a plain file (not a directory).
|
||||
* @param name The name of the attribute to look up.
|
||||
* @return 0 or an error code.
|
||||
*/
|
||||
GIT_EXTERN(int) git_attr_get_ext(
|
||||
const char **value_out,
|
||||
git_repository *repo,
|
||||
git_attr_options *opts,
|
||||
const char *path,
|
||||
const char *name);
|
||||
|
||||
/**
|
||||
* Look up a list of git attributes for path.
|
||||
*
|
||||
* Use this if you have a known list of attributes that you want to
|
||||
* look up in a single call. This is somewhat more efficient than
|
||||
* calling `git_attr_get()` multiple times.
|
||||
*
|
||||
* For example, you might write:
|
||||
*
|
||||
* const char *attrs[] = { "crlf", "diff", "foo" };
|
||||
* const char **values[3];
|
||||
* git_attr_get_many(values, repo, 0, "my/fun/file.c", 3, attrs);
|
||||
*
|
||||
* Then you could loop through the 3 values to get the settings for
|
||||
* the three attributes you asked about.
|
||||
*
|
||||
* @param values_out An array of num_attr entries that will have string
|
||||
* pointers written into it for the values of the attributes.
|
||||
* You should not modify or free the values that are written
|
||||
* into this array (although of course, you should free the
|
||||
* array itself if you allocated it).
|
||||
* @param repo The repository containing the path.
|
||||
* @param flags A combination of GIT_ATTR_CHECK... flags.
|
||||
* @param path The path inside the repo to check attributes. This
|
||||
* does not have to exist, but if it does not, then
|
||||
* it will be treated as a plain file (i.e. not a directory).
|
||||
* @param num_attr The number of attributes being looked up
|
||||
* @param names An array of num_attr strings containing attribute names.
|
||||
* @return 0 or an error code.
|
||||
*/
|
||||
GIT_EXTERN(int) git_attr_get_many(
|
||||
const char **values_out,
|
||||
git_repository *repo,
|
||||
uint32_t flags,
|
||||
const char *path,
|
||||
size_t num_attr,
|
||||
const char **names);
|
||||
|
||||
/**
|
||||
* Look up a list of git attributes for path with extended options.
|
||||
*
|
||||
* @param values_out An array of num_attr entries that will have string
|
||||
* pointers written into it for the values of the attributes.
|
||||
* You should not modify or free the values that are written
|
||||
* into this array (although of course, you should free the
|
||||
* array itself if you allocated it).
|
||||
* @param repo The repository containing the path.
|
||||
* @param opts The `git_attr_options` to use when querying these attributes.
|
||||
* @param path The path inside the repo to check attributes. This
|
||||
* does not have to exist, but if it does not, then
|
||||
* it will be treated as a plain file (i.e. not a directory).
|
||||
* @param num_attr The number of attributes being looked up
|
||||
* @param names An array of num_attr strings containing attribute names.
|
||||
* @return 0 or an error code.
|
||||
*/
|
||||
GIT_EXTERN(int) git_attr_get_many_ext(
|
||||
const char **values_out,
|
||||
git_repository *repo,
|
||||
git_attr_options *opts,
|
||||
const char *path,
|
||||
size_t num_attr,
|
||||
const char **names);
|
||||
|
||||
/**
|
||||
* The callback used with git_attr_foreach.
|
||||
*
|
||||
* This callback will be invoked only once per attribute name, even if there
|
||||
* are multiple rules for a given file. The highest priority rule will be
|
||||
* used.
|
||||
*
|
||||
* @see git_attr_foreach.
|
||||
*
|
||||
* @param name The attribute name.
|
||||
* @param value The attribute value. May be NULL if the attribute is explicitly
|
||||
* set to UNSPECIFIED using the '!' sign.
|
||||
* @param payload A user-specified pointer.
|
||||
* @return 0 to continue looping, non-zero to stop. This value will be returned
|
||||
* from git_attr_foreach.
|
||||
*/
|
||||
typedef int GIT_CALLBACK(git_attr_foreach_cb)(const char *name, const char *value, void *payload);
|
||||
|
||||
/**
|
||||
* Loop over all the git attributes for a path.
|
||||
*
|
||||
* @param repo The repository containing the path.
|
||||
* @param flags A combination of GIT_ATTR_CHECK... flags.
|
||||
* @param path Path inside the repo to check attributes. This does not have
|
||||
* to exist, but if it does not, then it will be treated as a
|
||||
* plain file (i.e. not a directory).
|
||||
* @param callback Function to invoke on each attribute name and value.
|
||||
* See git_attr_foreach_cb.
|
||||
* @param payload Passed on as extra parameter to callback function.
|
||||
* @return 0 on success, non-zero callback return value, or error code
|
||||
*/
|
||||
GIT_EXTERN(int) git_attr_foreach(
|
||||
git_repository *repo,
|
||||
uint32_t flags,
|
||||
const char *path,
|
||||
git_attr_foreach_cb callback,
|
||||
void *payload);
|
||||
|
||||
/**
|
||||
* Loop over all the git attributes for a path with extended options.
|
||||
*
|
||||
* @param repo The repository containing the path.
|
||||
* @param opts The `git_attr_options` to use when querying these attributes.
|
||||
* @param path Path inside the repo to check attributes. This does not have
|
||||
* to exist, but if it does not, then it will be treated as a
|
||||
* plain file (i.e. not a directory).
|
||||
* @param callback Function to invoke on each attribute name and value.
|
||||
* See git_attr_foreach_cb.
|
||||
* @param payload Passed on as extra parameter to callback function.
|
||||
* @return 0 on success, non-zero callback return value, or error code
|
||||
*/
|
||||
GIT_EXTERN(int) git_attr_foreach_ext(
|
||||
git_repository *repo,
|
||||
git_attr_options *opts,
|
||||
const char *path,
|
||||
git_attr_foreach_cb callback,
|
||||
void *payload);
|
||||
|
||||
/**
|
||||
* Flush the gitattributes cache.
|
||||
*
|
||||
* Call this if you have reason to believe that the attributes files on
|
||||
* disk no longer match the cached contents of memory. This will cause
|
||||
* the attributes files to be reloaded the next time that an attribute
|
||||
* access function is called.
|
||||
*
|
||||
* @param repo The repository containing the gitattributes cache
|
||||
* @return 0 on success, or an error code
|
||||
*/
|
||||
GIT_EXTERN(int) git_attr_cache_flush(
|
||||
git_repository *repo);
|
||||
|
||||
/**
|
||||
* Add a macro definition.
|
||||
*
|
||||
* Macros will automatically be loaded from the top level `.gitattributes`
|
||||
* file of the repository (plus the built-in "binary" macro). This
|
||||
* function allows you to add others. For example, to add the default
|
||||
* macro, you would call:
|
||||
*
|
||||
* git_attr_add_macro(repo, "binary", "-diff -crlf");
|
||||
*
|
||||
* @param repo The repository to add the macro in.
|
||||
* @param name The name of the macro.
|
||||
* @param values The value for the macro.
|
||||
* @return 0 or an error code.
|
||||
*/
|
||||
GIT_EXTERN(int) git_attr_add_macro(
|
||||
git_repository *repo,
|
||||
const char *name,
|
||||
const char *values);
|
||||
|
||||
/** @} */
|
||||
GIT_END_DECL
|
||||
#endif
|
||||
|
285
3rdparty/libgit2/include/git2/blame.h
vendored
Normal file
285
3rdparty/libgit2/include/git2/blame.h
vendored
Normal file
@ -0,0 +1,285 @@
|
||||
/*
|
||||
* Copyright (C) the libgit2 contributors. All rights reserved.
|
||||
*
|
||||
* This file is part of libgit2, distributed under the GNU GPL v2 with
|
||||
* a Linking Exception. For full terms see the included COPYING file.
|
||||
*/
|
||||
|
||||
#ifndef INCLUDE_git_blame_h__
|
||||
#define INCLUDE_git_blame_h__
|
||||
|
||||
#include "common.h"
|
||||
#include "oid.h"
|
||||
|
||||
/**
|
||||
* @file git2/blame.h
|
||||
* @brief Git blame routines
|
||||
* @defgroup git_blame Git blame routines
|
||||
* @ingroup Git
|
||||
* @{
|
||||
*/
|
||||
GIT_BEGIN_DECL
|
||||
|
||||
/**
|
||||
* Flags for indicating option behavior for git_blame APIs.
|
||||
*/
|
||||
typedef enum {
|
||||
/** Normal blame, the default */
|
||||
GIT_BLAME_NORMAL = 0,
|
||||
|
||||
/**
|
||||
* Track lines that have moved within a file (like `git blame -M`).
|
||||
*
|
||||
* This is not yet implemented and reserved for future use.
|
||||
*/
|
||||
GIT_BLAME_TRACK_COPIES_SAME_FILE = (1<<0),
|
||||
|
||||
/**
|
||||
* Track lines that have moved across files in the same commit
|
||||
* (like `git blame -C`).
|
||||
*
|
||||
* This is not yet implemented and reserved for future use.
|
||||
*/
|
||||
GIT_BLAME_TRACK_COPIES_SAME_COMMIT_MOVES = (1<<1),
|
||||
|
||||
/**
|
||||
* Track lines that have been copied from another file that exists
|
||||
* in the same commit (like `git blame -CC`). Implies SAME_FILE.
|
||||
*
|
||||
* This is not yet implemented and reserved for future use.
|
||||
*/
|
||||
GIT_BLAME_TRACK_COPIES_SAME_COMMIT_COPIES = (1<<2),
|
||||
|
||||
/**
|
||||
* Track lines that have been copied from another file that exists in
|
||||
* *any* commit (like `git blame -CCC`). Implies SAME_COMMIT_COPIES.
|
||||
*
|
||||
* This is not yet implemented and reserved for future use.
|
||||
*/
|
||||
GIT_BLAME_TRACK_COPIES_ANY_COMMIT_COPIES = (1<<3),
|
||||
|
||||
/**
|
||||
* Restrict the search of commits to those reachable following only
|
||||
* the first parents.
|
||||
*/
|
||||
GIT_BLAME_FIRST_PARENT = (1<<4),
|
||||
|
||||
/**
|
||||
* Use mailmap file to map author and committer names and email
|
||||
* addresses to canonical real names and email addresses. The
|
||||
* mailmap will be read from the working directory, or HEAD in a
|
||||
* bare repository.
|
||||
*/
|
||||
GIT_BLAME_USE_MAILMAP = (1<<5),
|
||||
|
||||
/** Ignore whitespace differences */
|
||||
GIT_BLAME_IGNORE_WHITESPACE = (1<<6)
|
||||
} git_blame_flag_t;
|
||||
|
||||
/**
|
||||
* Blame options structure
|
||||
*
|
||||
* Initialize with `GIT_BLAME_OPTIONS_INIT`. Alternatively, you can
|
||||
* use `git_blame_options_init`.
|
||||
*
|
||||
*/
|
||||
typedef struct git_blame_options {
|
||||
unsigned int version;
|
||||
|
||||
/** A combination of `git_blame_flag_t` */
|
||||
uint32_t flags;
|
||||
|
||||
/**
|
||||
* The lower bound on the number of alphanumeric characters that
|
||||
* must be detected as moving/copying within a file for it to
|
||||
* associate those lines with the parent commit. The default value
|
||||
* is 20.
|
||||
*
|
||||
* This value only takes effect if any of the `GIT_BLAME_TRACK_COPIES_*`
|
||||
* flags are specified.
|
||||
*/
|
||||
uint16_t min_match_characters;
|
||||
|
||||
/** The id of the newest commit to consider. The default is HEAD. */
|
||||
git_oid newest_commit;
|
||||
|
||||
/**
|
||||
* The id of the oldest commit to consider.
|
||||
* The default is the first commit encountered with a NULL parent.
|
||||
*/
|
||||
git_oid oldest_commit;
|
||||
|
||||
/**
|
||||
* The first line in the file to blame.
|
||||
* The default is 1 (line numbers start with 1).
|
||||
*/
|
||||
size_t min_line;
|
||||
|
||||
/**
|
||||
* The last line in the file to blame.
|
||||
* The default is the last line of the file.
|
||||
*/
|
||||
size_t max_line;
|
||||
} git_blame_options;
|
||||
|
||||
#define GIT_BLAME_OPTIONS_VERSION 1
|
||||
#define GIT_BLAME_OPTIONS_INIT {GIT_BLAME_OPTIONS_VERSION}
|
||||
|
||||
/**
|
||||
* Initialize git_blame_options structure
|
||||
*
|
||||
* Initializes a `git_blame_options` with default values. Equivalent to creating
|
||||
* an instance with GIT_BLAME_OPTIONS_INIT.
|
||||
*
|
||||
* @param opts The `git_blame_options` struct to initialize.
|
||||
* @param version The struct version; pass `GIT_BLAME_OPTIONS_VERSION`.
|
||||
* @return Zero on success; -1 on failure.
|
||||
*/
|
||||
GIT_EXTERN(int) git_blame_options_init(
|
||||
git_blame_options *opts,
|
||||
unsigned int version);
|
||||
|
||||
/**
|
||||
* Structure that represents a blame hunk.
|
||||
*/
|
||||
typedef struct git_blame_hunk {
|
||||
/**
|
||||
* The number of lines in this hunk.
|
||||
*/
|
||||
size_t lines_in_hunk;
|
||||
|
||||
/**
|
||||
* The OID of the commit where this line was last changed.
|
||||
*/
|
||||
git_oid final_commit_id;
|
||||
|
||||
/**
|
||||
* The 1-based line number where this hunk begins, in the final version
|
||||
* of the file.
|
||||
*/
|
||||
size_t final_start_line_number;
|
||||
|
||||
/**
|
||||
* The author of `final_commit_id`. If `GIT_BLAME_USE_MAILMAP` has been
|
||||
* specified, it will contain the canonical real name and email address.
|
||||
*/
|
||||
git_signature *final_signature;
|
||||
|
||||
/**
|
||||
* The OID of the commit where this hunk was found.
|
||||
* This will usually be the same as `final_commit_id`, except when
|
||||
* `GIT_BLAME_TRACK_COPIES_ANY_COMMIT_COPIES` has been specified.
|
||||
*/
|
||||
git_oid orig_commit_id;
|
||||
|
||||
/**
|
||||
* The path to the file where this hunk originated, as of the commit
|
||||
* specified by `orig_commit_id`.
|
||||
*/
|
||||
const char *orig_path;
|
||||
|
||||
/**
|
||||
* The 1-based line number where this hunk begins in the file named by
|
||||
* `orig_path` in the commit specified by `orig_commit_id`.
|
||||
*/
|
||||
size_t orig_start_line_number;
|
||||
|
||||
/**
|
||||
* The author of `orig_commit_id`. If `GIT_BLAME_USE_MAILMAP` has been
|
||||
* specified, it will contain the canonical real name and email address.
|
||||
*/
|
||||
git_signature *orig_signature;
|
||||
|
||||
/**
|
||||
* The 1 iff the hunk has been tracked to a boundary commit (the root,
|
||||
* or the commit specified in git_blame_options.oldest_commit)
|
||||
*/
|
||||
char boundary;
|
||||
} git_blame_hunk;
|
||||
|
||||
|
||||
/** Opaque structure to hold blame results */
|
||||
typedef struct git_blame git_blame;
|
||||
|
||||
/**
|
||||
* Gets the number of hunks that exist in the blame structure.
|
||||
*
|
||||
* @param blame The blame structure to query.
|
||||
* @return The number of hunks.
|
||||
*/
|
||||
GIT_EXTERN(uint32_t) git_blame_get_hunk_count(git_blame *blame);
|
||||
|
||||
/**
|
||||
* Gets the blame hunk at the given index.
|
||||
*
|
||||
* @param blame the blame structure to query
|
||||
* @param index index of the hunk to retrieve
|
||||
* @return the hunk at the given index, or NULL on error
|
||||
*/
|
||||
GIT_EXTERN(const git_blame_hunk*) git_blame_get_hunk_byindex(
|
||||
git_blame *blame,
|
||||
uint32_t index);
|
||||
|
||||
/**
|
||||
* Gets the hunk that relates to the given line number in the newest commit.
|
||||
*
|
||||
* @param blame the blame structure to query
|
||||
* @param lineno the (1-based) line number to find a hunk for
|
||||
* @return the hunk that contains the given line, or NULL on error
|
||||
*/
|
||||
GIT_EXTERN(const git_blame_hunk*) git_blame_get_hunk_byline(
|
||||
git_blame *blame,
|
||||
size_t lineno);
|
||||
|
||||
/**
|
||||
* Get the blame for a single file.
|
||||
*
|
||||
* @param out pointer that will receive the blame object
|
||||
* @param repo repository whose history is to be walked
|
||||
* @param path path to file to consider
|
||||
* @param options options for the blame operation. If NULL, this is treated as
|
||||
* though GIT_BLAME_OPTIONS_INIT were passed.
|
||||
* @return 0 on success, or an error code. (use git_error_last for information
|
||||
* about the error.)
|
||||
*/
|
||||
GIT_EXTERN(int) git_blame_file(
|
||||
git_blame **out,
|
||||
git_repository *repo,
|
||||
const char *path,
|
||||
git_blame_options *options);
|
||||
|
||||
|
||||
/**
|
||||
* Get blame data for a file that has been modified in memory. The `reference`
|
||||
* parameter is a pre-calculated blame for the in-odb history of the file. This
|
||||
* means that once a file blame is completed (which can be expensive), updating
|
||||
* the buffer blame is very fast.
|
||||
*
|
||||
* Lines that differ between the buffer and the committed version are marked as
|
||||
* having a zero OID for their final_commit_id.
|
||||
*
|
||||
* @param out pointer that will receive the resulting blame data
|
||||
* @param reference cached blame from the history of the file (usually the output
|
||||
* from git_blame_file)
|
||||
* @param buffer the (possibly) modified contents of the file
|
||||
* @param buffer_len number of valid bytes in the buffer
|
||||
* @return 0 on success, or an error code. (use git_error_last for information
|
||||
* about the error)
|
||||
*/
|
||||
GIT_EXTERN(int) git_blame_buffer(
|
||||
git_blame **out,
|
||||
git_blame *reference,
|
||||
const char *buffer,
|
||||
size_t buffer_len);
|
||||
|
||||
/**
|
||||
* Free memory allocated by git_blame_file or git_blame_buffer.
|
||||
*
|
||||
* @param blame the blame structure to free
|
||||
*/
|
||||
GIT_EXTERN(void) git_blame_free(git_blame *blame);
|
||||
|
||||
/** @} */
|
||||
GIT_END_DECL
|
||||
#endif
|
||||
|
311
3rdparty/libgit2/include/git2/blob.h
vendored
Normal file
311
3rdparty/libgit2/include/git2/blob.h
vendored
Normal file
@ -0,0 +1,311 @@
|
||||
/*
|
||||
* Copyright (C) the libgit2 contributors. All rights reserved.
|
||||
*
|
||||
* This file is part of libgit2, distributed under the GNU GPL v2 with
|
||||
* a Linking Exception. For full terms see the included COPYING file.
|
||||
*/
|
||||
#ifndef INCLUDE_git_blob_h__
|
||||
#define INCLUDE_git_blob_h__
|
||||
|
||||
#include "common.h"
|
||||
#include "types.h"
|
||||
#include "oid.h"
|
||||
#include "object.h"
|
||||
#include "buffer.h"
|
||||
|
||||
/**
|
||||
* @file git2/blob.h
|
||||
* @brief Git blob load and write routines
|
||||
* @defgroup git_blob Git blob load and write routines
|
||||
* @ingroup Git
|
||||
* @{
|
||||
*/
|
||||
GIT_BEGIN_DECL
|
||||
|
||||
/**
|
||||
* Lookup a blob object from a repository.
|
||||
*
|
||||
* @param blob pointer to the looked up blob
|
||||
* @param repo the repo to use when locating the blob.
|
||||
* @param id identity of the blob to locate.
|
||||
* @return 0 or an error code
|
||||
*/
|
||||
GIT_EXTERN(int) git_blob_lookup(git_blob **blob, git_repository *repo, const git_oid *id);
|
||||
|
||||
/**
|
||||
* Lookup a blob object from a repository,
|
||||
* given a prefix of its identifier (short id).
|
||||
*
|
||||
* @see git_object_lookup_prefix
|
||||
*
|
||||
* @param blob pointer to the looked up blob
|
||||
* @param repo the repo to use when locating the blob.
|
||||
* @param id identity of the blob to locate.
|
||||
* @param len the length of the short identifier
|
||||
* @return 0 or an error code
|
||||
*/
|
||||
GIT_EXTERN(int) git_blob_lookup_prefix(git_blob **blob, git_repository *repo, const git_oid *id, size_t len);
|
||||
|
||||
/**
|
||||
* Close an open blob
|
||||
*
|
||||
* This is a wrapper around git_object_free()
|
||||
*
|
||||
* IMPORTANT:
|
||||
* It *is* necessary to call this method when you stop
|
||||
* using a blob. Failure to do so will cause a memory leak.
|
||||
*
|
||||
* @param blob the blob to close
|
||||
*/
|
||||
GIT_EXTERN(void) git_blob_free(git_blob *blob);
|
||||
|
||||
/**
|
||||
* Get the id of a blob.
|
||||
*
|
||||
* @param blob a previously loaded blob.
|
||||
* @return SHA1 hash for this blob.
|
||||
*/
|
||||
GIT_EXTERN(const git_oid *) git_blob_id(const git_blob *blob);
|
||||
|
||||
/**
|
||||
* Get the repository that contains the blob.
|
||||
*
|
||||
* @param blob A previously loaded blob.
|
||||
* @return Repository that contains this blob.
|
||||
*/
|
||||
GIT_EXTERN(git_repository *) git_blob_owner(const git_blob *blob);
|
||||
|
||||
/**
|
||||
* Get a read-only buffer with the raw content of a blob.
|
||||
*
|
||||
* A pointer to the raw content of a blob is returned;
|
||||
* this pointer is owned internally by the object and shall
|
||||
* not be free'd. The pointer may be invalidated at a later
|
||||
* time.
|
||||
*
|
||||
* @param blob pointer to the blob
|
||||
* @return the pointer, or NULL on error
|
||||
*/
|
||||
GIT_EXTERN(const void *) git_blob_rawcontent(const git_blob *blob);
|
||||
|
||||
/**
|
||||
* Get the size in bytes of the contents of a blob
|
||||
*
|
||||
* @param blob pointer to the blob
|
||||
* @return size on bytes
|
||||
*/
|
||||
GIT_EXTERN(git_object_size_t) git_blob_rawsize(const git_blob *blob);
|
||||
|
||||
/**
|
||||
* Flags to control the functionality of `git_blob_filter`.
|
||||
*/
|
||||
typedef enum {
|
||||
/** When set, filters will not be applied to binary files. */
|
||||
GIT_BLOB_FILTER_CHECK_FOR_BINARY = (1 << 0),
|
||||
|
||||
/**
|
||||
* When set, filters will not load configuration from the
|
||||
* system-wide `gitattributes` in `/etc` (or system equivalent).
|
||||
*/
|
||||
GIT_BLOB_FILTER_NO_SYSTEM_ATTRIBUTES = (1 << 1),
|
||||
|
||||
/**
|
||||
* When set, filters will be loaded from a `.gitattributes` file
|
||||
* in the HEAD commit.
|
||||
*/
|
||||
GIT_BLOB_FILTER_ATTRIBUTES_FROM_HEAD = (1 << 2),
|
||||
|
||||
/**
|
||||
* When set, filters will be loaded from a `.gitattributes` file
|
||||
* in the specified commit.
|
||||
*/
|
||||
GIT_BLOB_FILTER_ATTRIBUTES_FROM_COMMIT = (1 << 3)
|
||||
} git_blob_filter_flag_t;
|
||||
|
||||
/**
|
||||
* The options used when applying filter options to a file.
|
||||
*
|
||||
* Initialize with `GIT_BLOB_FILTER_OPTIONS_INIT`. Alternatively, you can
|
||||
* use `git_blob_filter_options_init`.
|
||||
*
|
||||
*/
|
||||
typedef struct {
|
||||
int version;
|
||||
|
||||
/** Flags to control the filtering process, see `git_blob_filter_flag_t` above */
|
||||
uint32_t flags;
|
||||
|
||||
#ifdef GIT_DEPRECATE_HARD
|
||||
void *reserved;
|
||||
#else
|
||||
git_oid *commit_id;
|
||||
#endif
|
||||
|
||||
/**
|
||||
* The commit to load attributes from, when
|
||||
* `GIT_BLOB_FILTER_ATTRIBUTES_FROM_COMMIT` is specified.
|
||||
*/
|
||||
git_oid attr_commit_id;
|
||||
} git_blob_filter_options;
|
||||
|
||||
#define GIT_BLOB_FILTER_OPTIONS_VERSION 1
|
||||
#define GIT_BLOB_FILTER_OPTIONS_INIT {GIT_BLOB_FILTER_OPTIONS_VERSION, GIT_BLOB_FILTER_CHECK_FOR_BINARY}
|
||||
|
||||
/**
|
||||
* Initialize git_blob_filter_options structure
|
||||
*
|
||||
* Initializes a `git_blob_filter_options` with default values. Equivalent
|
||||
* to creating an instance with `GIT_BLOB_FILTER_OPTIONS_INIT`.
|
||||
*
|
||||
* @param opts The `git_blob_filter_options` struct to initialize.
|
||||
* @param version The struct version; pass `GIT_BLOB_FILTER_OPTIONS_VERSION`.
|
||||
* @return Zero on success; -1 on failure.
|
||||
*/
|
||||
GIT_EXTERN(int) git_blob_filter_options_init(git_blob_filter_options *opts, unsigned int version);
|
||||
|
||||
/**
|
||||
* Get a buffer with the filtered content of a blob.
|
||||
*
|
||||
* This applies filters as if the blob was being checked out to the
|
||||
* working directory under the specified filename. This may apply
|
||||
* CRLF filtering or other types of changes depending on the file
|
||||
* attributes set for the blob and the content detected in it.
|
||||
*
|
||||
* The output is written into a `git_buf` which the caller must free
|
||||
* when done (via `git_buf_dispose`).
|
||||
*
|
||||
* If no filters need to be applied, then the `out` buffer will just
|
||||
* be populated with a pointer to the raw content of the blob. In
|
||||
* that case, be careful to *not* free the blob until done with the
|
||||
* buffer or copy it into memory you own.
|
||||
*
|
||||
* @param out The git_buf to be filled in
|
||||
* @param blob Pointer to the blob
|
||||
* @param as_path Path used for file attribute lookups, etc.
|
||||
* @param opts Options to use for filtering the blob
|
||||
* @return 0 on success or an error code
|
||||
*/
|
||||
GIT_EXTERN(int) git_blob_filter(
|
||||
git_buf *out,
|
||||
git_blob *blob,
|
||||
const char *as_path,
|
||||
git_blob_filter_options *opts);
|
||||
|
||||
/**
|
||||
* Read a file from the working folder of a repository
|
||||
* and write it to the Object Database as a loose blob
|
||||
*
|
||||
* @param id return the id of the written blob
|
||||
* @param repo repository where the blob will be written.
|
||||
* this repository cannot be bare
|
||||
* @param relative_path file from which the blob will be created,
|
||||
* relative to the repository's working dir
|
||||
* @return 0 or an error code
|
||||
*/
|
||||
GIT_EXTERN(int) git_blob_create_from_workdir(git_oid *id, git_repository *repo, const char *relative_path);
|
||||
|
||||
/**
|
||||
* Read a file from the filesystem and write its content
|
||||
* to the Object Database as a loose blob
|
||||
*
|
||||
* @param id return the id of the written blob
|
||||
* @param repo repository where the blob will be written.
|
||||
* this repository can be bare or not
|
||||
* @param path file from which the blob will be created
|
||||
* @return 0 or an error code
|
||||
*/
|
||||
GIT_EXTERN(int) git_blob_create_from_disk(git_oid *id, git_repository *repo, const char *path);
|
||||
|
||||
/**
|
||||
* Create a stream to write a new blob into the object db
|
||||
*
|
||||
* This function may need to buffer the data on disk and will in
|
||||
* general not be the right choice if you know the size of the data
|
||||
* to write. If you have data in memory, use
|
||||
* `git_blob_create_from_buffer()`. If you do not, but know the size of
|
||||
* the contents (and don't want/need to perform filtering), use
|
||||
* `git_odb_open_wstream()`.
|
||||
*
|
||||
* Don't close this stream yourself but pass it to
|
||||
* `git_blob_create_from_stream_commit()` to commit the write to the
|
||||
* object db and get the object id.
|
||||
*
|
||||
* If the `hintpath` parameter is filled, it will be used to determine
|
||||
* what git filters should be applied to the object before it is written
|
||||
* to the object database.
|
||||
*
|
||||
* @param out the stream into which to write
|
||||
* @param repo Repository where the blob will be written.
|
||||
* This repository can be bare or not.
|
||||
* @param hintpath If not NULL, will be used to select data filters
|
||||
* to apply onto the content of the blob to be created.
|
||||
* @return 0 or error code
|
||||
*/
|
||||
GIT_EXTERN(int) git_blob_create_from_stream(
|
||||
git_writestream **out,
|
||||
git_repository *repo,
|
||||
const char *hintpath);
|
||||
|
||||
/**
|
||||
* Close the stream and write the blob to the object db
|
||||
*
|
||||
* The stream will be closed and freed.
|
||||
*
|
||||
* @param out the id of the new blob
|
||||
* @param stream the stream to close
|
||||
* @return 0 or an error code
|
||||
*/
|
||||
GIT_EXTERN(int) git_blob_create_from_stream_commit(
|
||||
git_oid *out,
|
||||
git_writestream *stream);
|
||||
|
||||
/**
|
||||
* Write an in-memory buffer to the ODB as a blob
|
||||
*
|
||||
* @param id return the id of the written blob
|
||||
* @param repo repository where the blob will be written
|
||||
* @param buffer data to be written into the blob
|
||||
* @param len length of the data
|
||||
* @return 0 or an error code
|
||||
*/
|
||||
GIT_EXTERN(int) git_blob_create_from_buffer(
|
||||
git_oid *id, git_repository *repo, const void *buffer, size_t len);
|
||||
|
||||
/**
|
||||
* Determine if the blob content is most certainly binary or not.
|
||||
*
|
||||
* The heuristic used to guess if a file is binary is taken from core git:
|
||||
* Searching for NUL bytes and looking for a reasonable ratio of printable
|
||||
* to non-printable characters among the first 8000 bytes.
|
||||
*
|
||||
* @param blob The blob which content should be analyzed
|
||||
* @return 1 if the content of the blob is detected
|
||||
* as binary; 0 otherwise.
|
||||
*/
|
||||
GIT_EXTERN(int) git_blob_is_binary(const git_blob *blob);
|
||||
|
||||
/**
|
||||
* Determine if the given content is most certainly binary or not;
|
||||
* this is the same mechanism used by `git_blob_is_binary` but only
|
||||
* looking at raw data.
|
||||
*
|
||||
* @param data The blob data which content should be analyzed
|
||||
* @param len The length of the data
|
||||
* @return 1 if the content of the blob is detected
|
||||
* as binary; 0 otherwise.
|
||||
*/
|
||||
GIT_EXTERN(int) git_blob_data_is_binary(const char *data, size_t len);
|
||||
|
||||
/**
|
||||
* Create an in-memory copy of a blob. The copy must be explicitly
|
||||
* free'd or it will leak.
|
||||
*
|
||||
* @param out Pointer to store the copy of the object
|
||||
* @param source Original object to copy
|
||||
* @return 0.
|
||||
*/
|
||||
GIT_EXTERN(int) git_blob_dup(git_blob **out, git_blob *source);
|
||||
|
||||
/** @} */
|
||||
GIT_END_DECL
|
||||
#endif
|
336
3rdparty/libgit2/include/git2/branch.h
vendored
Normal file
336
3rdparty/libgit2/include/git2/branch.h
vendored
Normal file
@ -0,0 +1,336 @@
|
||||
/*
|
||||
* Copyright (C) the libgit2 contributors. All rights reserved.
|
||||
*
|
||||
* This file is part of libgit2, distributed under the GNU GPL v2 with
|
||||
* a Linking Exception. For full terms see the included COPYING file.
|
||||
*/
|
||||
#ifndef INCLUDE_git_branch_h__
|
||||
#define INCLUDE_git_branch_h__
|
||||
|
||||
#include "common.h"
|
||||
#include "oid.h"
|
||||
#include "types.h"
|
||||
|
||||
/**
|
||||
* @file git2/branch.h
|
||||
* @brief Git branch parsing routines
|
||||
* @defgroup git_branch Git branch management
|
||||
* @ingroup Git
|
||||
* @{
|
||||
*/
|
||||
GIT_BEGIN_DECL
|
||||
|
||||
/**
|
||||
* Create a new branch pointing at a target commit
|
||||
*
|
||||
* A new direct reference will be created pointing to
|
||||
* this target commit. If `force` is true and a reference
|
||||
* already exists with the given name, it'll be replaced.
|
||||
*
|
||||
* The returned reference must be freed by the user.
|
||||
*
|
||||
* The branch name will be checked for validity.
|
||||
* See `git_tag_create()` for rules about valid names.
|
||||
*
|
||||
* @param out Pointer where to store the underlying reference.
|
||||
*
|
||||
* @param repo the repository to create the branch in.
|
||||
*
|
||||
* @param branch_name Name for the branch; this name is
|
||||
* validated for consistency. It should also not conflict with
|
||||
* an already existing branch name.
|
||||
*
|
||||
* @param target Commit to which this branch should point. This object
|
||||
* must belong to the given `repo`.
|
||||
*
|
||||
* @param force Overwrite existing branch.
|
||||
*
|
||||
* @return 0, GIT_EINVALIDSPEC or an error code.
|
||||
* A proper reference is written in the refs/heads namespace
|
||||
* pointing to the provided target commit.
|
||||
*/
|
||||
GIT_EXTERN(int) git_branch_create(
|
||||
git_reference **out,
|
||||
git_repository *repo,
|
||||
const char *branch_name,
|
||||
const git_commit *target,
|
||||
int force);
|
||||
|
||||
/**
|
||||
* Create a new branch pointing at a target commit
|
||||
*
|
||||
* This behaves like `git_branch_create()` but takes an annotated
|
||||
* commit, which lets you specify which extended sha syntax string was
|
||||
* specified by a user, allowing for more exact reflog messages.
|
||||
*
|
||||
* See the documentation for `git_branch_create()`.
|
||||
*
|
||||
* @see git_branch_create
|
||||
*/
|
||||
GIT_EXTERN(int) git_branch_create_from_annotated(
|
||||
git_reference **ref_out,
|
||||
git_repository *repository,
|
||||
const char *branch_name,
|
||||
const git_annotated_commit *commit,
|
||||
int force);
|
||||
|
||||
/**
|
||||
* Delete an existing branch reference.
|
||||
*
|
||||
* Note that if the deletion succeeds, the reference object will not
|
||||
* be valid anymore, and should be freed immediately by the user using
|
||||
* `git_reference_free()`.
|
||||
*
|
||||
* @param branch A valid reference representing a branch
|
||||
* @return 0 on success, or an error code.
|
||||
*/
|
||||
GIT_EXTERN(int) git_branch_delete(git_reference *branch);
|
||||
|
||||
/** Iterator type for branches */
|
||||
typedef struct git_branch_iterator git_branch_iterator;
|
||||
|
||||
/**
|
||||
* Create an iterator which loops over the requested branches.
|
||||
*
|
||||
* @param out the iterator
|
||||
* @param repo Repository where to find the branches.
|
||||
* @param list_flags Filtering flags for the branch
|
||||
* listing. Valid values are GIT_BRANCH_LOCAL, GIT_BRANCH_REMOTE
|
||||
* or GIT_BRANCH_ALL.
|
||||
*
|
||||
* @return 0 on success or an error code
|
||||
*/
|
||||
GIT_EXTERN(int) git_branch_iterator_new(
|
||||
git_branch_iterator **out,
|
||||
git_repository *repo,
|
||||
git_branch_t list_flags);
|
||||
|
||||
/**
|
||||
* Retrieve the next branch from the iterator
|
||||
*
|
||||
* @param out the reference
|
||||
* @param out_type the type of branch (local or remote-tracking)
|
||||
* @param iter the branch iterator
|
||||
* @return 0 on success, GIT_ITEROVER if there are no more branches or an error code.
|
||||
*/
|
||||
GIT_EXTERN(int) git_branch_next(git_reference **out, git_branch_t *out_type, git_branch_iterator *iter);
|
||||
|
||||
/**
|
||||
* Free a branch iterator
|
||||
*
|
||||
* @param iter the iterator to free
|
||||
*/
|
||||
GIT_EXTERN(void) git_branch_iterator_free(git_branch_iterator *iter);
|
||||
|
||||
/**
|
||||
* Move/rename an existing local branch reference.
|
||||
*
|
||||
* The new branch name will be checked for validity.
|
||||
* See `git_tag_create()` for rules about valid names.
|
||||
*
|
||||
* Note that if the move succeeds, the old reference object will not
|
||||
* be valid anymore, and should be freed immediately by the user using
|
||||
* `git_reference_free()`.
|
||||
*
|
||||
* @param out New reference object for the updated name.
|
||||
*
|
||||
* @param branch Current underlying reference of the branch.
|
||||
*
|
||||
* @param new_branch_name Target name of the branch once the move
|
||||
* is performed; this name is validated for consistency.
|
||||
*
|
||||
* @param force Overwrite existing branch.
|
||||
*
|
||||
* @return 0 on success, GIT_EINVALIDSPEC or an error code.
|
||||
*/
|
||||
GIT_EXTERN(int) git_branch_move(
|
||||
git_reference **out,
|
||||
git_reference *branch,
|
||||
const char *new_branch_name,
|
||||
int force);
|
||||
|
||||
/**
|
||||
* Lookup a branch by its name in a repository.
|
||||
*
|
||||
* The generated reference must be freed by the user.
|
||||
* The branch name will be checked for validity.
|
||||
*
|
||||
* @see git_tag_create for rules about valid names.
|
||||
*
|
||||
* @param out pointer to the looked-up branch reference
|
||||
* @param repo the repository to look up the branch
|
||||
* @param branch_name Name of the branch to be looked-up;
|
||||
* this name is validated for consistency.
|
||||
* @param branch_type Type of the considered branch. This should
|
||||
* be valued with either GIT_BRANCH_LOCAL or GIT_BRANCH_REMOTE.
|
||||
*
|
||||
* @return 0 on success; GIT_ENOTFOUND when no matching branch
|
||||
* exists, GIT_EINVALIDSPEC, otherwise an error code.
|
||||
*/
|
||||
GIT_EXTERN(int) git_branch_lookup(
|
||||
git_reference **out,
|
||||
git_repository *repo,
|
||||
const char *branch_name,
|
||||
git_branch_t branch_type);
|
||||
|
||||
/**
|
||||
* Get the branch name
|
||||
*
|
||||
* Given a reference object, this will check that it really is a branch (ie.
|
||||
* it lives under "refs/heads/" or "refs/remotes/"), and return the branch part
|
||||
* of it.
|
||||
*
|
||||
* @param out Pointer to the abbreviated reference name.
|
||||
* Owned by ref, do not free.
|
||||
*
|
||||
* @param ref A reference object, ideally pointing to a branch
|
||||
*
|
||||
* @return 0 on success; GIT_EINVALID if the reference isn't either a local or
|
||||
* remote branch, otherwise an error code.
|
||||
*/
|
||||
GIT_EXTERN(int) git_branch_name(
|
||||
const char **out,
|
||||
const git_reference *ref);
|
||||
|
||||
/**
|
||||
* Get the upstream of a branch
|
||||
*
|
||||
* Given a reference, this will return a new reference object corresponding
|
||||
* to its remote tracking branch. The reference must be a local branch.
|
||||
*
|
||||
* @see git_branch_upstream_name for details on the resolution.
|
||||
*
|
||||
* @param out Pointer where to store the retrieved reference.
|
||||
* @param branch Current underlying reference of the branch.
|
||||
*
|
||||
* @return 0 on success; GIT_ENOTFOUND when no remote tracking
|
||||
* reference exists, otherwise an error code.
|
||||
*/
|
||||
GIT_EXTERN(int) git_branch_upstream(
|
||||
git_reference **out,
|
||||
const git_reference *branch);
|
||||
|
||||
/**
|
||||
* Set a branch's upstream branch
|
||||
*
|
||||
* This will update the configuration to set the branch named `branch_name` as the upstream of `branch`.
|
||||
* Pass a NULL name to unset the upstream information.
|
||||
*
|
||||
* @note the actual tracking reference must have been already created for the
|
||||
* operation to succeed.
|
||||
*
|
||||
* @param branch the branch to configure
|
||||
* @param branch_name remote-tracking or local branch to set as upstream.
|
||||
*
|
||||
* @return 0 on success; GIT_ENOTFOUND if there's no branch named `branch_name`
|
||||
* or an error code
|
||||
*/
|
||||
GIT_EXTERN(int) git_branch_set_upstream(
|
||||
git_reference *branch,
|
||||
const char *branch_name);
|
||||
|
||||
/**
|
||||
* Get the upstream name of a branch
|
||||
*
|
||||
* Given a local branch, this will return its remote-tracking branch information,
|
||||
* as a full reference name, ie. "feature/nice" would become
|
||||
* "refs/remote/origin/feature/nice", depending on that branch's configuration.
|
||||
*
|
||||
* @param out the buffer into which the name will be written.
|
||||
* @param repo the repository where the branches live.
|
||||
* @param refname reference name of the local branch.
|
||||
*
|
||||
* @return 0 on success, GIT_ENOTFOUND when no remote tracking reference exists,
|
||||
* or an error code.
|
||||
*/
|
||||
GIT_EXTERN(int) git_branch_upstream_name(
|
||||
git_buf *out,
|
||||
git_repository *repo,
|
||||
const char *refname);
|
||||
|
||||
/**
|
||||
* Determine if HEAD points to the given branch
|
||||
*
|
||||
* @param branch A reference to a local branch.
|
||||
*
|
||||
* @return 1 if HEAD points at the branch, 0 if it isn't, or a negative value
|
||||
* as an error code.
|
||||
*/
|
||||
GIT_EXTERN(int) git_branch_is_head(
|
||||
const git_reference *branch);
|
||||
|
||||
/**
|
||||
* Determine if any HEAD points to the current branch
|
||||
*
|
||||
* This will iterate over all known linked repositories (usually in the form of
|
||||
* worktrees) and report whether any HEAD is pointing at the current branch.
|
||||
*
|
||||
* @param branch A reference to a local branch.
|
||||
*
|
||||
* @return 1 if branch is checked out, 0 if it isn't, an error code otherwise.
|
||||
*/
|
||||
GIT_EXTERN(int) git_branch_is_checked_out(
|
||||
const git_reference *branch);
|
||||
|
||||
/**
|
||||
* Find the remote name of a remote-tracking branch
|
||||
*
|
||||
* This will return the name of the remote whose fetch refspec is matching
|
||||
* the given branch. E.g. given a branch "refs/remotes/test/master", it will
|
||||
* extract the "test" part. If refspecs from multiple remotes match,
|
||||
* the function will return GIT_EAMBIGUOUS.
|
||||
*
|
||||
* @param out The buffer into which the name will be written.
|
||||
* @param repo The repository where the branch lives.
|
||||
* @param refname complete name of the remote tracking branch.
|
||||
*
|
||||
* @return 0 on success, GIT_ENOTFOUND when no matching remote was found,
|
||||
* GIT_EAMBIGUOUS when the branch maps to several remotes,
|
||||
* otherwise an error code.
|
||||
*/
|
||||
GIT_EXTERN(int) git_branch_remote_name(
|
||||
git_buf *out,
|
||||
git_repository *repo,
|
||||
const char *refname);
|
||||
|
||||
/**
|
||||
* Retrieve the upstream remote of a local branch
|
||||
*
|
||||
* This will return the currently configured "branch.*.remote" for a given
|
||||
* branch. This branch must be local.
|
||||
*
|
||||
* @param buf the buffer into which to write the name
|
||||
* @param repo the repository in which to look
|
||||
* @param refname the full name of the branch
|
||||
* @return 0 or an error code
|
||||
*/
|
||||
GIT_EXTERN(int) git_branch_upstream_remote(git_buf *buf, git_repository *repo, const char *refname);
|
||||
|
||||
/**
|
||||
* Retrieve the upstream merge of a local branch
|
||||
*
|
||||
* This will return the currently configured "branch.*.merge" for a given
|
||||
* branch. This branch must be local.
|
||||
*
|
||||
* @param buf the buffer into which to write the name
|
||||
* @param repo the repository in which to look
|
||||
* @param refname the full name of the branch
|
||||
* @return 0 or an error code
|
||||
*/
|
||||
GIT_EXTERN(int) git_branch_upstream_merge(git_buf *buf, git_repository *repo, const char *refname);
|
||||
|
||||
/**
|
||||
* Determine whether a branch name is valid, meaning that (when prefixed
|
||||
* with `refs/heads/`) that it is a valid reference name, and that any
|
||||
* additional branch name restrictions are imposed (eg, it cannot start
|
||||
* with a `-`).
|
||||
*
|
||||
* @param valid output pointer to set with validity of given branch name
|
||||
* @param name a branch name to test
|
||||
* @return 0 on success or an error code
|
||||
*/
|
||||
GIT_EXTERN(int) git_branch_name_is_valid(int *valid, const char *name);
|
||||
|
||||
/** @} */
|
||||
GIT_END_DECL
|
||||
#endif
|
74
3rdparty/libgit2/include/git2/buffer.h
vendored
Normal file
74
3rdparty/libgit2/include/git2/buffer.h
vendored
Normal file
@ -0,0 +1,74 @@
|
||||
/*
|
||||
* Copyright (C) the libgit2 contributors. All rights reserved.
|
||||
*
|
||||
* This file is part of libgit2, distributed under the GNU GPL v2 with
|
||||
* a Linking Exception. For full terms see the included COPYING file.
|
||||
*/
|
||||
#ifndef INCLUDE_git_buf_h__
|
||||
#define INCLUDE_git_buf_h__
|
||||
|
||||
#include "common.h"
|
||||
|
||||
/**
|
||||
* @file git2/buffer.h
|
||||
* @brief Buffer export structure
|
||||
*
|
||||
* @ingroup Git
|
||||
* @{
|
||||
*/
|
||||
GIT_BEGIN_DECL
|
||||
|
||||
/**
|
||||
* A data buffer for exporting data from libgit2
|
||||
*
|
||||
* Sometimes libgit2 wants to return an allocated data buffer to the
|
||||
* caller and have the caller take responsibility for freeing that memory.
|
||||
* To make ownership clear in these cases, libgit2 uses `git_buf` to
|
||||
* return this data. Callers should use `git_buf_dispose()` to release
|
||||
* the memory when they are done.
|
||||
*
|
||||
* A `git_buf` contains a pointer to a NUL-terminated C string, and
|
||||
* the length of the string (not including the NUL terminator).
|
||||
*/
|
||||
typedef struct {
|
||||
/**
|
||||
* The buffer contents. `ptr` points to the start of the buffer
|
||||
* being returned. The buffer's length (in bytes) is specified
|
||||
* by the `size` member of the structure, and contains a NUL
|
||||
* terminator at position `(size + 1)`.
|
||||
*/
|
||||
char *ptr;
|
||||
|
||||
/**
|
||||
* This field is reserved and unused.
|
||||
*/
|
||||
size_t reserved;
|
||||
|
||||
/**
|
||||
* The length (in bytes) of the buffer pointed to by `ptr`,
|
||||
* not including a NUL terminator.
|
||||
*/
|
||||
size_t size;
|
||||
} git_buf;
|
||||
|
||||
/**
|
||||
* Use to initialize a `git_buf` before passing it to a function that
|
||||
* will populate it.
|
||||
*/
|
||||
#define GIT_BUF_INIT { NULL, 0, 0 }
|
||||
|
||||
/**
|
||||
* Free the memory referred to by the git_buf.
|
||||
*
|
||||
* Note that this does not free the `git_buf` itself, just the memory
|
||||
* pointed to by `buffer->ptr`.
|
||||
*
|
||||
* @param buffer The buffer to deallocate
|
||||
*/
|
||||
GIT_EXTERN(void) git_buf_dispose(git_buf *buffer);
|
||||
|
||||
GIT_END_DECL
|
||||
|
||||
/** @} */
|
||||
|
||||
#endif
|
172
3rdparty/libgit2/include/git2/cert.h
vendored
Normal file
172
3rdparty/libgit2/include/git2/cert.h
vendored
Normal file
@ -0,0 +1,172 @@
|
||||
/*
|
||||
* Copyright (C) the libgit2 contributors. All rights reserved.
|
||||
*
|
||||
* This file is part of libgit2, distributed under the GNU GPL v2 with
|
||||
* a Linking Exception. For full terms see the included COPYING file.
|
||||
*/
|
||||
#ifndef INCLUDE_git_cert_h__
|
||||
#define INCLUDE_git_cert_h__
|
||||
|
||||
#include "common.h"
|
||||
#include "types.h"
|
||||
|
||||
/**
|
||||
* @file git2/cert.h
|
||||
* @brief Git certificate objects
|
||||
* @defgroup git_cert Certificate objects
|
||||
* @ingroup Git
|
||||
* @{
|
||||
*/
|
||||
GIT_BEGIN_DECL
|
||||
|
||||
/**
|
||||
* Type of host certificate structure that is passed to the check callback
|
||||
*/
|
||||
typedef enum git_cert_t {
|
||||
/**
|
||||
* No information about the certificate is available. This may
|
||||
* happen when using curl.
|
||||
*/
|
||||
GIT_CERT_NONE,
|
||||
/**
|
||||
* The `data` argument to the callback will be a pointer to
|
||||
* the DER-encoded data.
|
||||
*/
|
||||
GIT_CERT_X509,
|
||||
/**
|
||||
* The `data` argument to the callback will be a pointer to a
|
||||
* `git_cert_hostkey` structure.
|
||||
*/
|
||||
GIT_CERT_HOSTKEY_LIBSSH2,
|
||||
/**
|
||||
* The `data` argument to the callback will be a pointer to a
|
||||
* `git_strarray` with `name:content` strings containing
|
||||
* information about the certificate. This is used when using
|
||||
* curl.
|
||||
*/
|
||||
GIT_CERT_STRARRAY
|
||||
} git_cert_t;
|
||||
|
||||
/**
|
||||
* Parent type for `git_cert_hostkey` and `git_cert_x509`.
|
||||
*/
|
||||
struct git_cert {
|
||||
/**
|
||||
* Type of certificate. A `GIT_CERT_` value.
|
||||
*/
|
||||
git_cert_t cert_type;
|
||||
};
|
||||
|
||||
/**
|
||||
* Callback for the user's custom certificate checks.
|
||||
*
|
||||
* @param cert The host certificate
|
||||
* @param valid Whether the libgit2 checks (OpenSSL or WinHTTP) think
|
||||
* this certificate is valid
|
||||
* @param host Hostname of the host libgit2 connected to
|
||||
* @param payload Payload provided by the caller
|
||||
* @return 0 to proceed with the connection, < 0 to fail the connection
|
||||
* or > 0 to indicate that the callback refused to act and that
|
||||
* the existing validity determination should be honored
|
||||
*/
|
||||
typedef int GIT_CALLBACK(git_transport_certificate_check_cb)(git_cert *cert, int valid, const char *host, void *payload);
|
||||
|
||||
/**
|
||||
* Type of SSH host fingerprint
|
||||
*/
|
||||
typedef enum {
|
||||
/** MD5 is available */
|
||||
GIT_CERT_SSH_MD5 = (1 << 0),
|
||||
/** SHA-1 is available */
|
||||
GIT_CERT_SSH_SHA1 = (1 << 1),
|
||||
/** SHA-256 is available */
|
||||
GIT_CERT_SSH_SHA256 = (1 << 2),
|
||||
/** Raw hostkey is available */
|
||||
GIT_CERT_SSH_RAW = (1 << 3)
|
||||
} git_cert_ssh_t;
|
||||
|
||||
typedef enum {
|
||||
/** The raw key is of an unknown type. */
|
||||
GIT_CERT_SSH_RAW_TYPE_UNKNOWN = 0,
|
||||
/** The raw key is an RSA key. */
|
||||
GIT_CERT_SSH_RAW_TYPE_RSA = 1,
|
||||
/** The raw key is a DSS key. */
|
||||
GIT_CERT_SSH_RAW_TYPE_DSS = 2,
|
||||
/** The raw key is a ECDSA 256 key. */
|
||||
GIT_CERT_SSH_RAW_TYPE_KEY_ECDSA_256 = 3,
|
||||
/** The raw key is a ECDSA 384 key. */
|
||||
GIT_CERT_SSH_RAW_TYPE_KEY_ECDSA_384 = 4,
|
||||
/** The raw key is a ECDSA 521 key. */
|
||||
GIT_CERT_SSH_RAW_TYPE_KEY_ECDSA_521 = 5,
|
||||
/** The raw key is a ED25519 key. */
|
||||
GIT_CERT_SSH_RAW_TYPE_KEY_ED25519 = 6
|
||||
} git_cert_ssh_raw_type_t;
|
||||
|
||||
/**
|
||||
* Hostkey information taken from libssh2
|
||||
*/
|
||||
typedef struct {
|
||||
git_cert parent; /**< The parent cert */
|
||||
|
||||
/**
|
||||
* A bitmask containing the available fields.
|
||||
*/
|
||||
git_cert_ssh_t type;
|
||||
|
||||
/**
|
||||
* Hostkey hash. If `type` has `GIT_CERT_SSH_MD5` set, this will
|
||||
* have the MD5 hash of the hostkey.
|
||||
*/
|
||||
unsigned char hash_md5[16];
|
||||
|
||||
/**
|
||||
* Hostkey hash. If `type` has `GIT_CERT_SSH_SHA1` set, this will
|
||||
* have the SHA-1 hash of the hostkey.
|
||||
*/
|
||||
unsigned char hash_sha1[20];
|
||||
|
||||
/**
|
||||
* Hostkey hash. If `type` has `GIT_CERT_SSH_SHA256` set, this will
|
||||
* have the SHA-256 hash of the hostkey.
|
||||
*/
|
||||
unsigned char hash_sha256[32];
|
||||
|
||||
/**
|
||||
* Raw hostkey type. If `type` has `GIT_CERT_SSH_RAW` set, this will
|
||||
* have the type of the raw hostkey.
|
||||
*/
|
||||
git_cert_ssh_raw_type_t raw_type;
|
||||
|
||||
/**
|
||||
* Pointer to the raw hostkey. If `type` has `GIT_CERT_SSH_RAW` set,
|
||||
* this will have the raw contents of the hostkey.
|
||||
*/
|
||||
const char *hostkey;
|
||||
|
||||
/**
|
||||
* Raw hostkey length. If `type` has `GIT_CERT_SSH_RAW` set, this will
|
||||
* have the length of the raw contents of the hostkey.
|
||||
*/
|
||||
size_t hostkey_len;
|
||||
} git_cert_hostkey;
|
||||
|
||||
/**
|
||||
* X.509 certificate information
|
||||
*/
|
||||
typedef struct {
|
||||
git_cert parent; /**< The parent cert */
|
||||
|
||||
/**
|
||||
* Pointer to the X.509 certificate data
|
||||
*/
|
||||
void *data;
|
||||
|
||||
/**
|
||||
* Length of the memory block pointed to by `data`.
|
||||
*/
|
||||
size_t len;
|
||||
} git_cert_x509;
|
||||
|
||||
/** @} */
|
||||
GIT_END_DECL
|
||||
#endif
|
417
3rdparty/libgit2/include/git2/checkout.h
vendored
Normal file
417
3rdparty/libgit2/include/git2/checkout.h
vendored
Normal file
@ -0,0 +1,417 @@
|
||||
/*
|
||||
* Copyright (C) the libgit2 contributors. All rights reserved.
|
||||
*
|
||||
* This file is part of libgit2, distributed under the GNU GPL v2 with
|
||||
* a Linking Exception. For full terms see the included COPYING file.
|
||||
*/
|
||||
#ifndef INCLUDE_git_checkout_h__
|
||||
#define INCLUDE_git_checkout_h__
|
||||
|
||||
#include "common.h"
|
||||
#include "types.h"
|
||||
#include "diff.h"
|
||||
|
||||
/**
|
||||
* @file git2/checkout.h
|
||||
* @brief Git checkout routines
|
||||
* @defgroup git_checkout Git checkout routines
|
||||
* @ingroup Git
|
||||
* @{
|
||||
*/
|
||||
GIT_BEGIN_DECL
|
||||
|
||||
/**
|
||||
* Checkout behavior flags
|
||||
*
|
||||
* In libgit2, checkout is used to update the working directory and index
|
||||
* to match a target tree. Unlike git checkout, it does not move the HEAD
|
||||
* commit for you - use `git_repository_set_head` or the like to do that.
|
||||
*
|
||||
* Checkout looks at (up to) four things: the "target" tree you want to
|
||||
* check out, the "baseline" tree of what was checked out previously, the
|
||||
* working directory for actual files, and the index for staged changes.
|
||||
*
|
||||
* You give checkout one of three strategies for update:
|
||||
*
|
||||
* - `GIT_CHECKOUT_NONE` is a dry-run strategy that checks for conflicts,
|
||||
* etc., but doesn't make any actual changes.
|
||||
*
|
||||
* - `GIT_CHECKOUT_FORCE` is at the opposite extreme, taking any action to
|
||||
* make the working directory match the target (including potentially
|
||||
* discarding modified files).
|
||||
*
|
||||
* - `GIT_CHECKOUT_SAFE` is between these two options, it will only make
|
||||
* modifications that will not lose changes.
|
||||
*
|
||||
* | target == baseline | target != baseline |
|
||||
* ---------------------|-----------------------|----------------------|
|
||||
* workdir == baseline | no action | create, update, or |
|
||||
* | | delete file |
|
||||
* ---------------------|-----------------------|----------------------|
|
||||
* workdir exists and | no action | conflict (notify |
|
||||
* is != baseline | notify dirty MODIFIED | and cancel checkout) |
|
||||
* ---------------------|-----------------------|----------------------|
|
||||
* workdir missing, | notify dirty DELETED | create file |
|
||||
* baseline present | | |
|
||||
* ---------------------|-----------------------|----------------------|
|
||||
*
|
||||
* To emulate `git checkout`, use `GIT_CHECKOUT_SAFE` with a checkout
|
||||
* notification callback (see below) that displays information about dirty
|
||||
* files. The default behavior will cancel checkout on conflicts.
|
||||
*
|
||||
* To emulate `git checkout-index`, use `GIT_CHECKOUT_SAFE` with a
|
||||
* notification callback that cancels the operation if a dirty-but-existing
|
||||
* file is found in the working directory. This core git command isn't
|
||||
* quite "force" but is sensitive about some types of changes.
|
||||
*
|
||||
* To emulate `git checkout -f`, use `GIT_CHECKOUT_FORCE`.
|
||||
*
|
||||
*
|
||||
* There are some additional flags to modify the behavior of checkout:
|
||||
*
|
||||
* - GIT_CHECKOUT_ALLOW_CONFLICTS makes SAFE mode apply safe file updates
|
||||
* even if there are conflicts (instead of cancelling the checkout).
|
||||
*
|
||||
* - GIT_CHECKOUT_REMOVE_UNTRACKED means remove untracked files (i.e. not
|
||||
* in target, baseline, or index, and not ignored) from the working dir.
|
||||
*
|
||||
* - GIT_CHECKOUT_REMOVE_IGNORED means remove ignored files (that are also
|
||||
* untracked) from the working directory as well.
|
||||
*
|
||||
* - GIT_CHECKOUT_UPDATE_ONLY means to only update the content of files that
|
||||
* already exist. Files will not be created nor deleted. This just skips
|
||||
* applying adds, deletes, and typechanges.
|
||||
*
|
||||
* - GIT_CHECKOUT_DONT_UPDATE_INDEX prevents checkout from writing the
|
||||
* updated files' information to the index.
|
||||
*
|
||||
* - Normally, checkout will reload the index and git attributes from disk
|
||||
* before any operations. GIT_CHECKOUT_NO_REFRESH prevents this reload.
|
||||
*
|
||||
* - Unmerged index entries are conflicts. GIT_CHECKOUT_SKIP_UNMERGED skips
|
||||
* files with unmerged index entries instead. GIT_CHECKOUT_USE_OURS and
|
||||
* GIT_CHECKOUT_USE_THEIRS to proceed with the checkout using either the
|
||||
* stage 2 ("ours") or stage 3 ("theirs") version of files in the index.
|
||||
*
|
||||
* - GIT_CHECKOUT_DONT_OVERWRITE_IGNORED prevents ignored files from being
|
||||
* overwritten. Normally, files that are ignored in the working directory
|
||||
* are not considered "precious" and may be overwritten if the checkout
|
||||
* target contains that file.
|
||||
*
|
||||
* - GIT_CHECKOUT_DONT_REMOVE_EXISTING prevents checkout from removing
|
||||
* files or folders that fold to the same name on case insensitive
|
||||
* filesystems. This can cause files to retain their existing names
|
||||
* and write through existing symbolic links.
|
||||
*/
|
||||
typedef enum {
|
||||
GIT_CHECKOUT_NONE = 0, /**< default is a dry run, no actual updates */
|
||||
|
||||
/**
|
||||
* Allow safe updates that cannot overwrite uncommitted data.
|
||||
* If the uncommitted changes don't conflict with the checked out files,
|
||||
* the checkout will still proceed, leaving the changes intact.
|
||||
*
|
||||
* Mutually exclusive with GIT_CHECKOUT_FORCE.
|
||||
* GIT_CHECKOUT_FORCE takes precedence over GIT_CHECKOUT_SAFE.
|
||||
*/
|
||||
GIT_CHECKOUT_SAFE = (1u << 0),
|
||||
|
||||
/**
|
||||
* Allow all updates to force working directory to look like index.
|
||||
*
|
||||
* Mutually exclusive with GIT_CHECKOUT_SAFE.
|
||||
* GIT_CHECKOUT_FORCE takes precedence over GIT_CHECKOUT_SAFE.
|
||||
*/
|
||||
GIT_CHECKOUT_FORCE = (1u << 1),
|
||||
|
||||
|
||||
/** Allow checkout to recreate missing files */
|
||||
GIT_CHECKOUT_RECREATE_MISSING = (1u << 2),
|
||||
|
||||
/** Allow checkout to make safe updates even if conflicts are found */
|
||||
GIT_CHECKOUT_ALLOW_CONFLICTS = (1u << 4),
|
||||
|
||||
/** Remove untracked files not in index (that are not ignored) */
|
||||
GIT_CHECKOUT_REMOVE_UNTRACKED = (1u << 5),
|
||||
|
||||
/** Remove ignored files not in index */
|
||||
GIT_CHECKOUT_REMOVE_IGNORED = (1u << 6),
|
||||
|
||||
/** Only update existing files, don't create new ones */
|
||||
GIT_CHECKOUT_UPDATE_ONLY = (1u << 7),
|
||||
|
||||
/**
|
||||
* Normally checkout updates index entries as it goes; this stops that.
|
||||
* Implies `GIT_CHECKOUT_DONT_WRITE_INDEX`.
|
||||
*/
|
||||
GIT_CHECKOUT_DONT_UPDATE_INDEX = (1u << 8),
|
||||
|
||||
/** Don't refresh index/config/etc before doing checkout */
|
||||
GIT_CHECKOUT_NO_REFRESH = (1u << 9),
|
||||
|
||||
/** Allow checkout to skip unmerged files */
|
||||
GIT_CHECKOUT_SKIP_UNMERGED = (1u << 10),
|
||||
/** For unmerged files, checkout stage 2 from index */
|
||||
GIT_CHECKOUT_USE_OURS = (1u << 11),
|
||||
/** For unmerged files, checkout stage 3 from index */
|
||||
GIT_CHECKOUT_USE_THEIRS = (1u << 12),
|
||||
|
||||
/** Treat pathspec as simple list of exact match file paths */
|
||||
GIT_CHECKOUT_DISABLE_PATHSPEC_MATCH = (1u << 13),
|
||||
|
||||
/** Ignore directories in use, they will be left empty */
|
||||
GIT_CHECKOUT_SKIP_LOCKED_DIRECTORIES = (1u << 18),
|
||||
|
||||
/** Don't overwrite ignored files that exist in the checkout target */
|
||||
GIT_CHECKOUT_DONT_OVERWRITE_IGNORED = (1u << 19),
|
||||
|
||||
/** Write normal merge files for conflicts */
|
||||
GIT_CHECKOUT_CONFLICT_STYLE_MERGE = (1u << 20),
|
||||
|
||||
/** Include common ancestor data in diff3 format files for conflicts */
|
||||
GIT_CHECKOUT_CONFLICT_STYLE_DIFF3 = (1u << 21),
|
||||
|
||||
/** Don't overwrite existing files or folders */
|
||||
GIT_CHECKOUT_DONT_REMOVE_EXISTING = (1u << 22),
|
||||
|
||||
/** Normally checkout writes the index upon completion; this prevents that. */
|
||||
GIT_CHECKOUT_DONT_WRITE_INDEX = (1u << 23),
|
||||
|
||||
/**
|
||||
* Show what would be done by a checkout. Stop after sending
|
||||
* notifications; don't update the working directory or index.
|
||||
*/
|
||||
GIT_CHECKOUT_DRY_RUN = (1u << 24),
|
||||
|
||||
/** Include common ancestor data in zdiff3 format for conflicts */
|
||||
GIT_CHECKOUT_CONFLICT_STYLE_ZDIFF3 = (1u << 25),
|
||||
|
||||
/**
|
||||
* THE FOLLOWING OPTIONS ARE NOT YET IMPLEMENTED
|
||||
*/
|
||||
|
||||
/** Recursively checkout submodules with same options (NOT IMPLEMENTED) */
|
||||
GIT_CHECKOUT_UPDATE_SUBMODULES = (1u << 16),
|
||||
/** Recursively checkout submodules if HEAD moved in super repo (NOT IMPLEMENTED) */
|
||||
GIT_CHECKOUT_UPDATE_SUBMODULES_IF_CHANGED = (1u << 17)
|
||||
|
||||
} git_checkout_strategy_t;
|
||||
|
||||
/**
|
||||
* Checkout notification flags
|
||||
*
|
||||
* Checkout will invoke an options notification callback (`notify_cb`) for
|
||||
* certain cases - you pick which ones via `notify_flags`:
|
||||
*
|
||||
* Returning a non-zero value from this callback will cancel the checkout.
|
||||
* The non-zero return value will be propagated back and returned by the
|
||||
* git_checkout_... call.
|
||||
*
|
||||
* Notification callbacks are made prior to modifying any files on disk,
|
||||
* so canceling on any notification will still happen prior to any files
|
||||
* being modified.
|
||||
*/
|
||||
typedef enum {
|
||||
GIT_CHECKOUT_NOTIFY_NONE = 0,
|
||||
|
||||
/**
|
||||
* Invokes checkout on conflicting paths.
|
||||
*/
|
||||
GIT_CHECKOUT_NOTIFY_CONFLICT = (1u << 0),
|
||||
|
||||
/**
|
||||
* Notifies about "dirty" files, i.e. those that do not need an update
|
||||
* but no longer match the baseline. Core git displays these files when
|
||||
* checkout runs, but won't stop the checkout.
|
||||
*/
|
||||
GIT_CHECKOUT_NOTIFY_DIRTY = (1u << 1),
|
||||
|
||||
/**
|
||||
* Sends notification for any file changed.
|
||||
*/
|
||||
GIT_CHECKOUT_NOTIFY_UPDATED = (1u << 2),
|
||||
|
||||
/**
|
||||
* Notifies about untracked files.
|
||||
*/
|
||||
GIT_CHECKOUT_NOTIFY_UNTRACKED = (1u << 3),
|
||||
|
||||
/**
|
||||
* Notifies about ignored files.
|
||||
*/
|
||||
GIT_CHECKOUT_NOTIFY_IGNORED = (1u << 4),
|
||||
|
||||
GIT_CHECKOUT_NOTIFY_ALL = 0x0FFFFu
|
||||
} git_checkout_notify_t;
|
||||
|
||||
/** Checkout performance-reporting structure */
|
||||
typedef struct {
|
||||
size_t mkdir_calls;
|
||||
size_t stat_calls;
|
||||
size_t chmod_calls;
|
||||
} git_checkout_perfdata;
|
||||
|
||||
/** Checkout notification callback function */
|
||||
typedef int GIT_CALLBACK(git_checkout_notify_cb)(
|
||||
git_checkout_notify_t why,
|
||||
const char *path,
|
||||
const git_diff_file *baseline,
|
||||
const git_diff_file *target,
|
||||
const git_diff_file *workdir,
|
||||
void *payload);
|
||||
|
||||
/** Checkout progress notification function */
|
||||
typedef void GIT_CALLBACK(git_checkout_progress_cb)(
|
||||
const char *path,
|
||||
size_t completed_steps,
|
||||
size_t total_steps,
|
||||
void *payload);
|
||||
|
||||
/** Checkout perfdata notification function */
|
||||
typedef void GIT_CALLBACK(git_checkout_perfdata_cb)(
|
||||
const git_checkout_perfdata *perfdata,
|
||||
void *payload);
|
||||
|
||||
/**
|
||||
* Checkout options structure
|
||||
*
|
||||
* Initialize with `GIT_CHECKOUT_OPTIONS_INIT`. Alternatively, you can
|
||||
* use `git_checkout_options_init`.
|
||||
*
|
||||
*/
|
||||
typedef struct git_checkout_options {
|
||||
unsigned int version; /**< The version */
|
||||
|
||||
unsigned int checkout_strategy; /**< default will be a safe checkout */
|
||||
|
||||
int disable_filters; /**< don't apply filters like CRLF conversion */
|
||||
unsigned int dir_mode; /**< default is 0755 */
|
||||
unsigned int file_mode; /**< default is 0644 or 0755 as dictated by blob */
|
||||
int file_open_flags; /**< default is O_CREAT | O_TRUNC | O_WRONLY */
|
||||
|
||||
unsigned int notify_flags; /**< see `git_checkout_notify_t` above */
|
||||
|
||||
/**
|
||||
* Optional callback to get notifications on specific file states.
|
||||
* @see git_checkout_notify_t
|
||||
*/
|
||||
git_checkout_notify_cb notify_cb;
|
||||
|
||||
/** Payload passed to notify_cb */
|
||||
void *notify_payload;
|
||||
|
||||
/** Optional callback to notify the consumer of checkout progress. */
|
||||
git_checkout_progress_cb progress_cb;
|
||||
|
||||
/** Payload passed to progress_cb */
|
||||
void *progress_payload;
|
||||
|
||||
/**
|
||||
* A list of wildmatch patterns or paths.
|
||||
*
|
||||
* By default, all paths are processed. If you pass an array of wildmatch
|
||||
* patterns, those will be used to filter which paths should be taken into
|
||||
* account.
|
||||
*
|
||||
* Use GIT_CHECKOUT_DISABLE_PATHSPEC_MATCH to treat as a simple list.
|
||||
*/
|
||||
git_strarray paths;
|
||||
|
||||
/**
|
||||
* The expected content of the working directory; defaults to HEAD.
|
||||
*
|
||||
* If the working directory does not match this baseline information,
|
||||
* that will produce a checkout conflict.
|
||||
*/
|
||||
git_tree *baseline;
|
||||
|
||||
/**
|
||||
* Like `baseline` above, though expressed as an index. This
|
||||
* option overrides `baseline`.
|
||||
*/
|
||||
git_index *baseline_index;
|
||||
|
||||
const char *target_directory; /**< alternative checkout path to workdir */
|
||||
|
||||
const char *ancestor_label; /**< the name of the common ancestor side of conflicts */
|
||||
const char *our_label; /**< the name of the "our" side of conflicts */
|
||||
const char *their_label; /**< the name of the "their" side of conflicts */
|
||||
|
||||
/** Optional callback to notify the consumer of performance data. */
|
||||
git_checkout_perfdata_cb perfdata_cb;
|
||||
|
||||
/** Payload passed to perfdata_cb */
|
||||
void *perfdata_payload;
|
||||
} git_checkout_options;
|
||||
|
||||
#define GIT_CHECKOUT_OPTIONS_VERSION 1
|
||||
#define GIT_CHECKOUT_OPTIONS_INIT {GIT_CHECKOUT_OPTIONS_VERSION, GIT_CHECKOUT_SAFE}
|
||||
|
||||
/**
|
||||
* Initialize git_checkout_options structure
|
||||
*
|
||||
* Initializes a `git_checkout_options` with default values. Equivalent to creating
|
||||
* an instance with GIT_CHECKOUT_OPTIONS_INIT.
|
||||
*
|
||||
* @param opts The `git_checkout_options` struct to initialize.
|
||||
* @param version The struct version; pass `GIT_CHECKOUT_OPTIONS_VERSION`.
|
||||
* @return Zero on success; -1 on failure.
|
||||
*/
|
||||
GIT_EXTERN(int) git_checkout_options_init(
|
||||
git_checkout_options *opts,
|
||||
unsigned int version);
|
||||
|
||||
/**
|
||||
* Updates files in the index and the working tree to match the content of
|
||||
* the commit pointed at by HEAD.
|
||||
*
|
||||
* Note that this is _not_ the correct mechanism used to switch branches;
|
||||
* do not change your `HEAD` and then call this method, that would leave
|
||||
* you with checkout conflicts since your working directory would then
|
||||
* appear to be dirty. Instead, checkout the target of the branch and
|
||||
* then update `HEAD` using `git_repository_set_head` to point to the
|
||||
* branch you checked out.
|
||||
*
|
||||
* @param repo repository to check out (must be non-bare)
|
||||
* @param opts specifies checkout options (may be NULL)
|
||||
* @return 0 on success, GIT_EUNBORNBRANCH if HEAD points to a non
|
||||
* existing branch, non-zero value returned by `notify_cb`, or
|
||||
* other error code < 0 (use git_error_last for error details)
|
||||
*/
|
||||
GIT_EXTERN(int) git_checkout_head(
|
||||
git_repository *repo,
|
||||
const git_checkout_options *opts);
|
||||
|
||||
/**
|
||||
* Updates files in the working tree to match the content of the index.
|
||||
*
|
||||
* @param repo repository into which to check out (must be non-bare)
|
||||
* @param index index to be checked out (or NULL to use repository index)
|
||||
* @param opts specifies checkout options (may be NULL)
|
||||
* @return 0 on success, non-zero return value from `notify_cb`, or error
|
||||
* code < 0 (use git_error_last for error details)
|
||||
*/
|
||||
GIT_EXTERN(int) git_checkout_index(
|
||||
git_repository *repo,
|
||||
git_index *index,
|
||||
const git_checkout_options *opts);
|
||||
|
||||
/**
|
||||
* Updates files in the index and working tree to match the content of the
|
||||
* tree pointed at by the treeish.
|
||||
*
|
||||
* @param repo repository to check out (must be non-bare)
|
||||
* @param treeish a commit, tag or tree which content will be used to update
|
||||
* the working directory (or NULL to use HEAD)
|
||||
* @param opts specifies checkout options (may be NULL)
|
||||
* @return 0 on success, non-zero return value from `notify_cb`, or error
|
||||
* code < 0 (use git_error_last for error details)
|
||||
*/
|
||||
GIT_EXTERN(int) git_checkout_tree(
|
||||
git_repository *repo,
|
||||
const git_object *treeish,
|
||||
const git_checkout_options *opts);
|
||||
|
||||
/** @} */
|
||||
GIT_END_DECL
|
||||
#endif
|
92
3rdparty/libgit2/include/git2/cherrypick.h
vendored
Normal file
92
3rdparty/libgit2/include/git2/cherrypick.h
vendored
Normal file
@ -0,0 +1,92 @@
|
||||
/*
|
||||
* Copyright (C) the libgit2 contributors. All rights reserved.
|
||||
*
|
||||
* This file is part of libgit2, distributed under the GNU GPL v2 with
|
||||
* a Linking Exception. For full terms see the included COPYING file.
|
||||
*/
|
||||
#ifndef INCLUDE_git_cherrypick_h__
|
||||
#define INCLUDE_git_cherrypick_h__
|
||||
|
||||
#include "common.h"
|
||||
#include "types.h"
|
||||
#include "merge.h"
|
||||
|
||||
/**
|
||||
* @file git2/cherrypick.h
|
||||
* @brief Git cherry-pick routines
|
||||
* @defgroup git_cherrypick Git cherry-pick routines
|
||||
* @ingroup Git
|
||||
* @{
|
||||
*/
|
||||
GIT_BEGIN_DECL
|
||||
|
||||
/**
|
||||
* Cherry-pick options
|
||||
*/
|
||||
typedef struct {
|
||||
unsigned int version;
|
||||
|
||||
/** For merge commits, the "mainline" is treated as the parent. */
|
||||
unsigned int mainline;
|
||||
|
||||
git_merge_options merge_opts; /**< Options for the merging */
|
||||
git_checkout_options checkout_opts; /**< Options for the checkout */
|
||||
} git_cherrypick_options;
|
||||
|
||||
#define GIT_CHERRYPICK_OPTIONS_VERSION 1
|
||||
#define GIT_CHERRYPICK_OPTIONS_INIT {GIT_CHERRYPICK_OPTIONS_VERSION, 0, GIT_MERGE_OPTIONS_INIT, GIT_CHECKOUT_OPTIONS_INIT}
|
||||
|
||||
/**
|
||||
* Initialize git_cherrypick_options structure
|
||||
*
|
||||
* Initializes a `git_cherrypick_options` with default values. Equivalent to creating
|
||||
* an instance with GIT_CHERRYPICK_OPTIONS_INIT.
|
||||
*
|
||||
* @param opts The `git_cherrypick_options` struct to initialize.
|
||||
* @param version The struct version; pass `GIT_CHERRYPICK_OPTIONS_VERSION`.
|
||||
* @return Zero on success; -1 on failure.
|
||||
*/
|
||||
GIT_EXTERN(int) git_cherrypick_options_init(
|
||||
git_cherrypick_options *opts,
|
||||
unsigned int version);
|
||||
|
||||
/**
|
||||
* Cherry-picks the given commit against the given "our" commit, producing an
|
||||
* index that reflects the result of the cherry-pick.
|
||||
*
|
||||
* The returned index must be freed explicitly with `git_index_free`.
|
||||
*
|
||||
* @param out pointer to store the index result in
|
||||
* @param repo the repository that contains the given commits
|
||||
* @param cherrypick_commit the commit to cherry-pick
|
||||
* @param our_commit the commit to cherry-pick against (eg, HEAD)
|
||||
* @param mainline the parent of the `cherrypick_commit`, if it is a merge
|
||||
* @param merge_options the merge options (or null for defaults)
|
||||
* @return zero on success, -1 on failure.
|
||||
*/
|
||||
GIT_EXTERN(int) git_cherrypick_commit(
|
||||
git_index **out,
|
||||
git_repository *repo,
|
||||
git_commit *cherrypick_commit,
|
||||
git_commit *our_commit,
|
||||
unsigned int mainline,
|
||||
const git_merge_options *merge_options);
|
||||
|
||||
/**
|
||||
* Cherry-pick the given commit, producing changes in the index and working directory.
|
||||
*
|
||||
* @param repo the repository to cherry-pick
|
||||
* @param commit the commit to cherry-pick
|
||||
* @param cherrypick_options the cherry-pick options (or null for defaults)
|
||||
* @return zero on success, -1 on failure.
|
||||
*/
|
||||
GIT_EXTERN(int) git_cherrypick(
|
||||
git_repository *repo,
|
||||
git_commit *commit,
|
||||
const git_cherrypick_options *cherrypick_options);
|
||||
|
||||
/** @} */
|
||||
GIT_END_DECL
|
||||
|
||||
#endif
|
||||
|
209
3rdparty/libgit2/include/git2/clone.h
vendored
Normal file
209
3rdparty/libgit2/include/git2/clone.h
vendored
Normal file
@ -0,0 +1,209 @@
|
||||
/*
|
||||
* Copyright (C) the libgit2 contributors. All rights reserved.
|
||||
*
|
||||
* This file is part of libgit2, distributed under the GNU GPL v2 with
|
||||
* a Linking Exception. For full terms see the included COPYING file.
|
||||
*/
|
||||
#ifndef INCLUDE_git_clone_h__
|
||||
#define INCLUDE_git_clone_h__
|
||||
|
||||
#include "common.h"
|
||||
#include "types.h"
|
||||
#include "indexer.h"
|
||||
#include "checkout.h"
|
||||
#include "remote.h"
|
||||
#include "transport.h"
|
||||
|
||||
|
||||
/**
|
||||
* @file git2/clone.h
|
||||
* @brief Git cloning routines
|
||||
* @defgroup git_clone Git cloning routines
|
||||
* @ingroup Git
|
||||
* @{
|
||||
*/
|
||||
GIT_BEGIN_DECL
|
||||
|
||||
/**
|
||||
* Options for bypassing the git-aware transport on clone. Bypassing
|
||||
* it means that instead of a fetch, libgit2 will copy the object
|
||||
* database directory instead of figuring out what it needs, which is
|
||||
* faster. If possible, it will hardlink the files to save space.
|
||||
*/
|
||||
typedef enum {
|
||||
/**
|
||||
* Auto-detect (default), libgit2 will bypass the git-aware
|
||||
* transport for local paths, but use a normal fetch for
|
||||
* `file://` urls.
|
||||
*/
|
||||
GIT_CLONE_LOCAL_AUTO,
|
||||
/**
|
||||
* Bypass the git-aware transport even for a `file://` url.
|
||||
*/
|
||||
GIT_CLONE_LOCAL,
|
||||
/**
|
||||
* Do no bypass the git-aware transport
|
||||
*/
|
||||
GIT_CLONE_NO_LOCAL,
|
||||
/**
|
||||
* Bypass the git-aware transport, but do not try to use
|
||||
* hardlinks.
|
||||
*/
|
||||
GIT_CLONE_LOCAL_NO_LINKS
|
||||
} git_clone_local_t;
|
||||
|
||||
/**
|
||||
* The signature of a function matching git_remote_create, with an additional
|
||||
* void* as a callback payload.
|
||||
*
|
||||
* Callers of git_clone may provide a function matching this signature to override
|
||||
* the remote creation and customization process during a clone operation.
|
||||
*
|
||||
* @param out the resulting remote
|
||||
* @param repo the repository in which to create the remote
|
||||
* @param name the remote's name
|
||||
* @param url the remote's url
|
||||
* @param payload an opaque payload
|
||||
* @return 0, GIT_EINVALIDSPEC, GIT_EEXISTS or an error code
|
||||
*/
|
||||
typedef int GIT_CALLBACK(git_remote_create_cb)(
|
||||
git_remote **out,
|
||||
git_repository *repo,
|
||||
const char *name,
|
||||
const char *url,
|
||||
void *payload);
|
||||
|
||||
/**
|
||||
* The signature of a function matching git_repository_init, with an
|
||||
* additional void * as callback payload.
|
||||
*
|
||||
* Callers of git_clone my provide a function matching this signature
|
||||
* to override the repository creation and customization process
|
||||
* during a clone operation.
|
||||
*
|
||||
* @param out the resulting repository
|
||||
* @param path path in which to create the repository
|
||||
* @param bare whether the repository is bare. This is the value from the clone options
|
||||
* @param payload payload specified by the options
|
||||
* @return 0, or a negative value to indicate error
|
||||
*/
|
||||
typedef int GIT_CALLBACK(git_repository_create_cb)(
|
||||
git_repository **out,
|
||||
const char *path,
|
||||
int bare,
|
||||
void *payload);
|
||||
|
||||
/**
|
||||
* Clone options structure
|
||||
*
|
||||
* Initialize with `GIT_CLONE_OPTIONS_INIT`. Alternatively, you can
|
||||
* use `git_clone_options_init`.
|
||||
*
|
||||
*/
|
||||
typedef struct git_clone_options {
|
||||
unsigned int version;
|
||||
|
||||
/**
|
||||
* These options are passed to the checkout step. To disable
|
||||
* checkout, set the `checkout_strategy` to
|
||||
* `GIT_CHECKOUT_NONE`.
|
||||
*/
|
||||
git_checkout_options checkout_opts;
|
||||
|
||||
/**
|
||||
* Options which control the fetch, including callbacks.
|
||||
*
|
||||
* The callbacks are used for reporting fetch progress, and for acquiring
|
||||
* credentials in the event they are needed.
|
||||
*/
|
||||
git_fetch_options fetch_opts;
|
||||
|
||||
/**
|
||||
* Set to zero (false) to create a standard repo, or non-zero
|
||||
* for a bare repo
|
||||
*/
|
||||
int bare;
|
||||
|
||||
/**
|
||||
* Whether to use a fetch or copy the object database.
|
||||
*/
|
||||
git_clone_local_t local;
|
||||
|
||||
/**
|
||||
* The name of the branch to checkout. NULL means use the
|
||||
* remote's default branch.
|
||||
*/
|
||||
const char *checkout_branch;
|
||||
|
||||
/**
|
||||
* A callback used to create the new repository into which to
|
||||
* clone. If NULL, the 'bare' field will be used to determine
|
||||
* whether to create a bare repository.
|
||||
*/
|
||||
git_repository_create_cb repository_cb;
|
||||
|
||||
/**
|
||||
* An opaque payload to pass to the git_repository creation callback.
|
||||
* This parameter is ignored unless repository_cb is non-NULL.
|
||||
*/
|
||||
void *repository_cb_payload;
|
||||
|
||||
/**
|
||||
* A callback used to create the git_remote, prior to its being
|
||||
* used to perform the clone operation. See the documentation for
|
||||
* git_remote_create_cb for details. This parameter may be NULL,
|
||||
* indicating that git_clone should provide default behavior.
|
||||
*/
|
||||
git_remote_create_cb remote_cb;
|
||||
|
||||
/**
|
||||
* An opaque payload to pass to the git_remote creation callback.
|
||||
* This parameter is ignored unless remote_cb is non-NULL.
|
||||
*/
|
||||
void *remote_cb_payload;
|
||||
} git_clone_options;
|
||||
|
||||
#define GIT_CLONE_OPTIONS_VERSION 1
|
||||
#define GIT_CLONE_OPTIONS_INIT { GIT_CLONE_OPTIONS_VERSION, \
|
||||
{ GIT_CHECKOUT_OPTIONS_VERSION, GIT_CHECKOUT_SAFE }, \
|
||||
GIT_FETCH_OPTIONS_INIT }
|
||||
|
||||
/**
|
||||
* Initialize git_clone_options structure
|
||||
*
|
||||
* Initializes a `git_clone_options` with default values. Equivalent to creating
|
||||
* an instance with GIT_CLONE_OPTIONS_INIT.
|
||||
*
|
||||
* @param opts The `git_clone_options` struct to initialize.
|
||||
* @param version The struct version; pass `GIT_CLONE_OPTIONS_VERSION`.
|
||||
* @return Zero on success; -1 on failure.
|
||||
*/
|
||||
GIT_EXTERN(int) git_clone_options_init(
|
||||
git_clone_options *opts,
|
||||
unsigned int version);
|
||||
|
||||
/**
|
||||
* Clone a remote repository.
|
||||
*
|
||||
* By default this creates its repository and initial remote to match
|
||||
* git's defaults. You can use the options in the callback to
|
||||
* customize how these are created.
|
||||
*
|
||||
* @param out pointer that will receive the resulting repository object
|
||||
* @param url the remote repository to clone
|
||||
* @param local_path local directory to clone to
|
||||
* @param options configuration options for the clone. If NULL, the
|
||||
* function works as though GIT_OPTIONS_INIT were passed.
|
||||
* @return 0 on success, any non-zero return value from a callback
|
||||
* function, or a negative value to indicate an error (use
|
||||
* `git_error_last` for a detailed error message)
|
||||
*/
|
||||
GIT_EXTERN(int) git_clone(
|
||||
git_repository **out,
|
||||
const char *url,
|
||||
const char *local_path,
|
||||
const git_clone_options *options);
|
||||
|
||||
/** @} */
|
||||
GIT_END_DECL
|
||||
#endif
|
607
3rdparty/libgit2/include/git2/commit.h
vendored
Normal file
607
3rdparty/libgit2/include/git2/commit.h
vendored
Normal file
@ -0,0 +1,607 @@
|
||||
/*
|
||||
* Copyright (C) the libgit2 contributors. All rights reserved.
|
||||
*
|
||||
* This file is part of libgit2, distributed under the GNU GPL v2 with
|
||||
* a Linking Exception. For full terms see the included COPYING file.
|
||||
*/
|
||||
#ifndef INCLUDE_git_commit_h__
|
||||
#define INCLUDE_git_commit_h__
|
||||
|
||||
#include "common.h"
|
||||
#include "types.h"
|
||||
#include "oid.h"
|
||||
#include "object.h"
|
||||
|
||||
/**
|
||||
* @file git2/commit.h
|
||||
* @brief Git commit parsing, formatting routines
|
||||
* @defgroup git_commit Git commit parsing, formatting routines
|
||||
* @ingroup Git
|
||||
* @{
|
||||
*/
|
||||
GIT_BEGIN_DECL
|
||||
|
||||
/**
|
||||
* Lookup a commit object from a repository.
|
||||
*
|
||||
* The returned object should be released with `git_commit_free` when no
|
||||
* longer needed.
|
||||
*
|
||||
* @param commit pointer to the looked up commit
|
||||
* @param repo the repo to use when locating the commit.
|
||||
* @param id identity of the commit to locate. If the object is
|
||||
* an annotated tag it will be peeled back to the commit.
|
||||
* @return 0 or an error code
|
||||
*/
|
||||
GIT_EXTERN(int) git_commit_lookup(
|
||||
git_commit **commit, git_repository *repo, const git_oid *id);
|
||||
|
||||
/**
|
||||
* Lookup a commit object from a repository, given a prefix of its
|
||||
* identifier (short id).
|
||||
*
|
||||
* The returned object should be released with `git_commit_free` when no
|
||||
* longer needed.
|
||||
*
|
||||
* @see git_object_lookup_prefix
|
||||
*
|
||||
* @param commit pointer to the looked up commit
|
||||
* @param repo the repo to use when locating the commit.
|
||||
* @param id identity of the commit to locate. If the object is
|
||||
* an annotated tag it will be peeled back to the commit.
|
||||
* @param len the length of the short identifier
|
||||
* @return 0 or an error code
|
||||
*/
|
||||
GIT_EXTERN(int) git_commit_lookup_prefix(
|
||||
git_commit **commit, git_repository *repo, const git_oid *id, size_t len);
|
||||
|
||||
/**
|
||||
* Close an open commit
|
||||
*
|
||||
* This is a wrapper around git_object_free()
|
||||
*
|
||||
* IMPORTANT:
|
||||
* It *is* necessary to call this method when you stop
|
||||
* using a commit. Failure to do so will cause a memory leak.
|
||||
*
|
||||
* @param commit the commit to close
|
||||
*/
|
||||
|
||||
GIT_EXTERN(void) git_commit_free(git_commit *commit);
|
||||
|
||||
/**
|
||||
* Get the id of a commit.
|
||||
*
|
||||
* @param commit a previously loaded commit.
|
||||
* @return object identity for the commit.
|
||||
*/
|
||||
GIT_EXTERN(const git_oid *) git_commit_id(const git_commit *commit);
|
||||
|
||||
/**
|
||||
* Get the repository that contains the commit.
|
||||
*
|
||||
* @param commit A previously loaded commit.
|
||||
* @return Repository that contains this commit.
|
||||
*/
|
||||
GIT_EXTERN(git_repository *) git_commit_owner(const git_commit *commit);
|
||||
|
||||
/**
|
||||
* Get the encoding for the message of a commit,
|
||||
* as a string representing a standard encoding name.
|
||||
*
|
||||
* The encoding may be NULL if the `encoding` header
|
||||
* in the commit is missing; in that case UTF-8 is assumed.
|
||||
*
|
||||
* @param commit a previously loaded commit.
|
||||
* @return NULL, or the encoding
|
||||
*/
|
||||
GIT_EXTERN(const char *) git_commit_message_encoding(const git_commit *commit);
|
||||
|
||||
/**
|
||||
* Get the full message of a commit.
|
||||
*
|
||||
* The returned message will be slightly prettified by removing any
|
||||
* potential leading newlines.
|
||||
*
|
||||
* @param commit a previously loaded commit.
|
||||
* @return the message of a commit
|
||||
*/
|
||||
GIT_EXTERN(const char *) git_commit_message(const git_commit *commit);
|
||||
|
||||
/**
|
||||
* Get the full raw message of a commit.
|
||||
*
|
||||
* @param commit a previously loaded commit.
|
||||
* @return the raw message of a commit
|
||||
*/
|
||||
GIT_EXTERN(const char *) git_commit_message_raw(const git_commit *commit);
|
||||
|
||||
/**
|
||||
* Get the short "summary" of the git commit message.
|
||||
*
|
||||
* The returned message is the summary of the commit, comprising the
|
||||
* first paragraph of the message with whitespace trimmed and squashed.
|
||||
*
|
||||
* @param commit a previously loaded commit.
|
||||
* @return the summary of a commit or NULL on error
|
||||
*/
|
||||
GIT_EXTERN(const char *) git_commit_summary(git_commit *commit);
|
||||
|
||||
/**
|
||||
* Get the long "body" of the git commit message.
|
||||
*
|
||||
* The returned message is the body of the commit, comprising
|
||||
* everything but the first paragraph of the message. Leading and
|
||||
* trailing whitespaces are trimmed.
|
||||
*
|
||||
* @param commit a previously loaded commit.
|
||||
* @return the body of a commit or NULL when no the message only
|
||||
* consists of a summary
|
||||
*/
|
||||
GIT_EXTERN(const char *) git_commit_body(git_commit *commit);
|
||||
|
||||
/**
|
||||
* Get the commit time (i.e. committer time) of a commit.
|
||||
*
|
||||
* @param commit a previously loaded commit.
|
||||
* @return the time of a commit
|
||||
*/
|
||||
GIT_EXTERN(git_time_t) git_commit_time(const git_commit *commit);
|
||||
|
||||
/**
|
||||
* Get the commit timezone offset (i.e. committer's preferred timezone) of a commit.
|
||||
*
|
||||
* @param commit a previously loaded commit.
|
||||
* @return positive or negative timezone offset, in minutes from UTC
|
||||
*/
|
||||
GIT_EXTERN(int) git_commit_time_offset(const git_commit *commit);
|
||||
|
||||
/**
|
||||
* Get the committer of a commit.
|
||||
*
|
||||
* @param commit a previously loaded commit.
|
||||
* @return the committer of a commit
|
||||
*/
|
||||
GIT_EXTERN(const git_signature *) git_commit_committer(const git_commit *commit);
|
||||
|
||||
/**
|
||||
* Get the author of a commit.
|
||||
*
|
||||
* @param commit a previously loaded commit.
|
||||
* @return the author of a commit
|
||||
*/
|
||||
GIT_EXTERN(const git_signature *) git_commit_author(const git_commit *commit);
|
||||
|
||||
/**
|
||||
* Get the committer of a commit, using the mailmap to map names and email
|
||||
* addresses to canonical real names and email addresses.
|
||||
*
|
||||
* Call `git_signature_free` to free the signature.
|
||||
*
|
||||
* @param out a pointer to store the resolved signature.
|
||||
* @param commit a previously loaded commit.
|
||||
* @param mailmap the mailmap to resolve with. (may be NULL)
|
||||
* @return 0 or an error code
|
||||
*/
|
||||
GIT_EXTERN(int) git_commit_committer_with_mailmap(
|
||||
git_signature **out, const git_commit *commit, const git_mailmap *mailmap);
|
||||
|
||||
/**
|
||||
* Get the author of a commit, using the mailmap to map names and email
|
||||
* addresses to canonical real names and email addresses.
|
||||
*
|
||||
* Call `git_signature_free` to free the signature.
|
||||
*
|
||||
* @param out a pointer to store the resolved signature.
|
||||
* @param commit a previously loaded commit.
|
||||
* @param mailmap the mailmap to resolve with. (may be NULL)
|
||||
* @return 0 or an error code
|
||||
*/
|
||||
GIT_EXTERN(int) git_commit_author_with_mailmap(
|
||||
git_signature **out, const git_commit *commit, const git_mailmap *mailmap);
|
||||
|
||||
/**
|
||||
* Get the full raw text of the commit header.
|
||||
*
|
||||
* @param commit a previously loaded commit
|
||||
* @return the header text of the commit
|
||||
*/
|
||||
GIT_EXTERN(const char *) git_commit_raw_header(const git_commit *commit);
|
||||
|
||||
/**
|
||||
* Get the tree pointed to by a commit.
|
||||
*
|
||||
* @param tree_out pointer where to store the tree object
|
||||
* @param commit a previously loaded commit.
|
||||
* @return 0 or an error code
|
||||
*/
|
||||
GIT_EXTERN(int) git_commit_tree(git_tree **tree_out, const git_commit *commit);
|
||||
|
||||
/**
|
||||
* Get the id of the tree pointed to by a commit. This differs from
|
||||
* `git_commit_tree` in that no attempts are made to fetch an object
|
||||
* from the ODB.
|
||||
*
|
||||
* @param commit a previously loaded commit.
|
||||
* @return the id of tree pointed to by commit.
|
||||
*/
|
||||
GIT_EXTERN(const git_oid *) git_commit_tree_id(const git_commit *commit);
|
||||
|
||||
/**
|
||||
* Get the number of parents of this commit
|
||||
*
|
||||
* @param commit a previously loaded commit.
|
||||
* @return integer of count of parents
|
||||
*/
|
||||
GIT_EXTERN(unsigned int) git_commit_parentcount(const git_commit *commit);
|
||||
|
||||
/**
|
||||
* Get the specified parent of the commit.
|
||||
*
|
||||
* @param out Pointer where to store the parent commit
|
||||
* @param commit a previously loaded commit.
|
||||
* @param n the position of the parent (from 0 to `parentcount`)
|
||||
* @return 0 or an error code
|
||||
*/
|
||||
GIT_EXTERN(int) git_commit_parent(
|
||||
git_commit **out,
|
||||
const git_commit *commit,
|
||||
unsigned int n);
|
||||
|
||||
/**
|
||||
* Get the oid of a specified parent for a commit. This is different from
|
||||
* `git_commit_parent`, which will attempt to load the parent commit from
|
||||
* the ODB.
|
||||
*
|
||||
* @param commit a previously loaded commit.
|
||||
* @param n the position of the parent (from 0 to `parentcount`)
|
||||
* @return the id of the parent, NULL on error.
|
||||
*/
|
||||
GIT_EXTERN(const git_oid *) git_commit_parent_id(
|
||||
const git_commit *commit,
|
||||
unsigned int n);
|
||||
|
||||
/**
|
||||
* Get the commit object that is the <n>th generation ancestor
|
||||
* of the named commit object, following only the first parents.
|
||||
* The returned commit has to be freed by the caller.
|
||||
*
|
||||
* Passing `0` as the generation number returns another instance of the
|
||||
* base commit itself.
|
||||
*
|
||||
* @param ancestor Pointer where to store the ancestor commit
|
||||
* @param commit a previously loaded commit.
|
||||
* @param n the requested generation
|
||||
* @return 0 on success; GIT_ENOTFOUND if no matching ancestor exists
|
||||
* or an error code
|
||||
*/
|
||||
GIT_EXTERN(int) git_commit_nth_gen_ancestor(
|
||||
git_commit **ancestor,
|
||||
const git_commit *commit,
|
||||
unsigned int n);
|
||||
|
||||
/**
|
||||
* Get an arbitrary header field
|
||||
*
|
||||
* @param out the buffer to fill; existing content will be
|
||||
* overwritten
|
||||
* @param commit the commit to look in
|
||||
* @param field the header field to return
|
||||
* @return 0 on succeess, GIT_ENOTFOUND if the field does not exist,
|
||||
* or an error code
|
||||
*/
|
||||
GIT_EXTERN(int) git_commit_header_field(git_buf *out, const git_commit *commit, const char *field);
|
||||
|
||||
/**
|
||||
* Extract the signature from a commit
|
||||
*
|
||||
* If the id is not for a commit, the error class will be
|
||||
* `GIT_ERROR_INVALID`. If the commit does not have a signature, the
|
||||
* error class will be `GIT_ERROR_OBJECT`.
|
||||
*
|
||||
* @param signature the signature block; existing content will be
|
||||
* overwritten
|
||||
* @param signed_data signed data; this is the commit contents minus the signature block;
|
||||
* existing content will be overwritten
|
||||
* @param repo the repository in which the commit exists
|
||||
* @param commit_id the commit from which to extract the data
|
||||
* @param field the name of the header field containing the signature
|
||||
* block; pass `NULL` to extract the default 'gpgsig'
|
||||
* @return 0 on success, GIT_ENOTFOUND if the id is not for a commit
|
||||
* or the commit does not have a signature.
|
||||
*/
|
||||
GIT_EXTERN(int) git_commit_extract_signature(git_buf *signature, git_buf *signed_data, git_repository *repo, git_oid *commit_id, const char *field);
|
||||
|
||||
/**
|
||||
* Create new commit in the repository from a list of `git_object` pointers
|
||||
*
|
||||
* The message will **not** be cleaned up automatically. You can do that
|
||||
* with the `git_message_prettify()` function.
|
||||
*
|
||||
* @param id Pointer in which to store the OID of the newly created commit
|
||||
*
|
||||
* @param repo Repository where to store the commit
|
||||
*
|
||||
* @param update_ref If not NULL, name of the reference that
|
||||
* will be updated to point to this commit. If the reference
|
||||
* is not direct, it will be resolved to a direct reference.
|
||||
* Use "HEAD" to update the HEAD of the current branch and
|
||||
* make it point to this commit. If the reference doesn't
|
||||
* exist yet, it will be created. If it does exist, the first
|
||||
* parent must be the tip of this branch.
|
||||
*
|
||||
* @param author Signature with author and author time of commit
|
||||
*
|
||||
* @param committer Signature with committer and * commit time of commit
|
||||
*
|
||||
* @param message_encoding The encoding for the message in the
|
||||
* commit, represented with a standard encoding name.
|
||||
* E.g. "UTF-8". If NULL, no encoding header is written and
|
||||
* UTF-8 is assumed.
|
||||
*
|
||||
* @param message Full message for this commit
|
||||
*
|
||||
* @param tree An instance of a `git_tree` object that will
|
||||
* be used as the tree for the commit. This tree object must
|
||||
* also be owned by the given `repo`.
|
||||
*
|
||||
* @param parent_count Number of parents for this commit
|
||||
*
|
||||
* @param parents Array of `parent_count` pointers to `git_commit`
|
||||
* objects that will be used as the parents for this commit. This
|
||||
* array may be NULL if `parent_count` is 0 (root commit). All the
|
||||
* given commits must be owned by the `repo`.
|
||||
*
|
||||
* @return 0 or an error code
|
||||
* The created commit will be written to the Object Database and
|
||||
* the given reference will be updated to point to it
|
||||
*/
|
||||
GIT_EXTERN(int) git_commit_create(
|
||||
git_oid *id,
|
||||
git_repository *repo,
|
||||
const char *update_ref,
|
||||
const git_signature *author,
|
||||
const git_signature *committer,
|
||||
const char *message_encoding,
|
||||
const char *message,
|
||||
const git_tree *tree,
|
||||
size_t parent_count,
|
||||
git_commit * const parents[]);
|
||||
|
||||
/**
|
||||
* Create new commit in the repository using a variable argument list.
|
||||
*
|
||||
* The message will **not** be cleaned up automatically. You can do that
|
||||
* with the `git_message_prettify()` function.
|
||||
*
|
||||
* The parents for the commit are specified as a variable list of pointers
|
||||
* to `const git_commit *`. Note that this is a convenience method which may
|
||||
* not be safe to export for certain languages or compilers
|
||||
*
|
||||
* All other parameters remain the same as `git_commit_create()`.
|
||||
*
|
||||
* @see git_commit_create
|
||||
*/
|
||||
GIT_EXTERN(int) git_commit_create_v(
|
||||
git_oid *id,
|
||||
git_repository *repo,
|
||||
const char *update_ref,
|
||||
const git_signature *author,
|
||||
const git_signature *committer,
|
||||
const char *message_encoding,
|
||||
const char *message,
|
||||
const git_tree *tree,
|
||||
size_t parent_count,
|
||||
...);
|
||||
|
||||
typedef struct {
|
||||
unsigned int version;
|
||||
|
||||
/**
|
||||
* Flags for creating the commit.
|
||||
*
|
||||
* If `allow_empty_commit` is specified, a commit with no changes
|
||||
* from the prior commit (and "empty" commit) is allowed. Otherwise,
|
||||
* commit creation will be stopped.
|
||||
*/
|
||||
unsigned int allow_empty_commit : 1;
|
||||
|
||||
/** The commit author, or NULL for the default. */
|
||||
const git_signature *author;
|
||||
|
||||
/** The committer, or NULL for the default. */
|
||||
const git_signature *committer;
|
||||
|
||||
/** Encoding for the commit message; leave NULL for default. */
|
||||
const char *message_encoding;
|
||||
} git_commit_create_options;
|
||||
|
||||
#define GIT_COMMIT_CREATE_OPTIONS_VERSION 1
|
||||
#define GIT_COMMIT_CREATE_OPTIONS_INIT { GIT_COMMIT_CREATE_OPTIONS_VERSION }
|
||||
|
||||
/**
|
||||
* Commits the staged changes in the repository; this is a near analog to
|
||||
* `git commit -m message`.
|
||||
*
|
||||
* By default, empty commits are not allowed.
|
||||
*
|
||||
* @param id pointer to store the new commit's object id
|
||||
* @param repo repository to commit changes in
|
||||
* @param message the commit message
|
||||
* @param opts options for creating the commit
|
||||
* @return 0 on success, GIT_EUNCHANGED if there were no changes to commit, or an error code
|
||||
*/
|
||||
GIT_EXTERN(int) git_commit_create_from_stage(
|
||||
git_oid *id,
|
||||
git_repository *repo,
|
||||
const char *message,
|
||||
const git_commit_create_options *opts);
|
||||
|
||||
/**
|
||||
* Amend an existing commit by replacing only non-NULL values.
|
||||
*
|
||||
* This creates a new commit that is exactly the same as the old commit,
|
||||
* except that any non-NULL values will be updated. The new commit has
|
||||
* the same parents as the old commit.
|
||||
*
|
||||
* The `update_ref` value works as in the regular `git_commit_create()`,
|
||||
* updating the ref to point to the newly rewritten commit. If you want
|
||||
* to amend a commit that is not currently the tip of the branch and then
|
||||
* rewrite the following commits to reach a ref, pass this as NULL and
|
||||
* update the rest of the commit chain and ref separately.
|
||||
*
|
||||
* Unlike `git_commit_create()`, the `author`, `committer`, `message`,
|
||||
* `message_encoding`, and `tree` parameters can be NULL in which case this
|
||||
* will use the values from the original `commit_to_amend`.
|
||||
*
|
||||
* All parameters have the same meanings as in `git_commit_create()`.
|
||||
*
|
||||
* @see git_commit_create
|
||||
*/
|
||||
GIT_EXTERN(int) git_commit_amend(
|
||||
git_oid *id,
|
||||
const git_commit *commit_to_amend,
|
||||
const char *update_ref,
|
||||
const git_signature *author,
|
||||
const git_signature *committer,
|
||||
const char *message_encoding,
|
||||
const char *message,
|
||||
const git_tree *tree);
|
||||
|
||||
/**
|
||||
* Create a commit and write it into a buffer
|
||||
*
|
||||
* Create a commit as with `git_commit_create()` but instead of
|
||||
* writing it to the objectdb, write the contents of the object into a
|
||||
* buffer.
|
||||
*
|
||||
* @param out the buffer into which to write the commit object content
|
||||
*
|
||||
* @param repo Repository where the referenced tree and parents live
|
||||
*
|
||||
* @param author Signature with author and author time of commit
|
||||
*
|
||||
* @param committer Signature with committer and * commit time of commit
|
||||
*
|
||||
* @param message_encoding The encoding for the message in the
|
||||
* commit, represented with a standard encoding name.
|
||||
* E.g. "UTF-8". If NULL, no encoding header is written and
|
||||
* UTF-8 is assumed.
|
||||
*
|
||||
* @param message Full message for this commit
|
||||
*
|
||||
* @param tree An instance of a `git_tree` object that will
|
||||
* be used as the tree for the commit. This tree object must
|
||||
* also be owned by the given `repo`.
|
||||
*
|
||||
* @param parent_count Number of parents for this commit
|
||||
*
|
||||
* @param parents Array of `parent_count` pointers to `git_commit`
|
||||
* objects that will be used as the parents for this commit. This
|
||||
* array may be NULL if `parent_count` is 0 (root commit). All the
|
||||
* given commits must be owned by the `repo`.
|
||||
*
|
||||
* @return 0 or an error code
|
||||
*/
|
||||
GIT_EXTERN(int) git_commit_create_buffer(
|
||||
git_buf *out,
|
||||
git_repository *repo,
|
||||
const git_signature *author,
|
||||
const git_signature *committer,
|
||||
const char *message_encoding,
|
||||
const char *message,
|
||||
const git_tree *tree,
|
||||
size_t parent_count,
|
||||
git_commit * const parents[]);
|
||||
|
||||
/**
|
||||
* Create a commit object from the given buffer and signature
|
||||
*
|
||||
* Given the unsigned commit object's contents, its signature and the
|
||||
* header field in which to store the signature, attach the signature
|
||||
* to the commit and write it into the given repository.
|
||||
*
|
||||
* @param out the resulting commit id
|
||||
* @param repo the repository to create the commit in.
|
||||
* @param commit_content the content of the unsigned commit object
|
||||
* @param signature the signature to add to the commit. Leave `NULL`
|
||||
* to create a commit without adding a signature field.
|
||||
* @param signature_field which header field should contain this
|
||||
* signature. Leave `NULL` for the default of "gpgsig"
|
||||
* @return 0 or an error code
|
||||
*/
|
||||
GIT_EXTERN(int) git_commit_create_with_signature(
|
||||
git_oid *out,
|
||||
git_repository *repo,
|
||||
const char *commit_content,
|
||||
const char *signature,
|
||||
const char *signature_field);
|
||||
|
||||
/**
|
||||
* Create an in-memory copy of a commit. The copy must be explicitly
|
||||
* free'd or it will leak.
|
||||
*
|
||||
* @param out Pointer to store the copy of the commit
|
||||
* @param source Original commit to copy
|
||||
* @return 0
|
||||
*/
|
||||
GIT_EXTERN(int) git_commit_dup(git_commit **out, git_commit *source);
|
||||
|
||||
/**
|
||||
* Commit creation callback: used when a function is going to create
|
||||
* commits (for example, in `git_rebase_commit`) to allow callers to
|
||||
* override the commit creation behavior. For example, users may
|
||||
* wish to sign commits by providing this information to
|
||||
* `git_commit_create_buffer`, signing that buffer, then calling
|
||||
* `git_commit_create_with_signature`. The resultant commit id
|
||||
* should be set in the `out` object id parameter.
|
||||
*
|
||||
* @param out pointer that this callback will populate with the object
|
||||
* id of the commit that is created
|
||||
* @param author the author name and time of the commit
|
||||
* @param committer the committer name and time of the commit
|
||||
* @param message_encoding the encoding of the given message, or NULL
|
||||
* to assume UTF8
|
||||
* @param message the commit message
|
||||
* @param tree the tree to be committed
|
||||
* @param parent_count the number of parents for this commit
|
||||
* @param parents the commit parents
|
||||
* @param payload the payload pointer in the rebase options
|
||||
* @return 0 if this callback has created the commit and populated the out
|
||||
* parameter, GIT_PASSTHROUGH if the callback has not created a
|
||||
* commit and wants the calling function to create the commit as
|
||||
* if no callback had been specified, any other value to stop
|
||||
* and return a failure
|
||||
*/
|
||||
typedef int (*git_commit_create_cb)(
|
||||
git_oid *out,
|
||||
const git_signature *author,
|
||||
const git_signature *committer,
|
||||
const char *message_encoding,
|
||||
const char *message,
|
||||
const git_tree *tree,
|
||||
size_t parent_count,
|
||||
git_commit * const parents[],
|
||||
void *payload);
|
||||
|
||||
/** An array of commits returned from the library */
|
||||
typedef struct git_commitarray {
|
||||
git_commit *const *commits;
|
||||
size_t count;
|
||||
} git_commitarray;
|
||||
|
||||
/**
|
||||
* Free the commits contained in a commit array. This method should
|
||||
* be called on `git_commitarray` objects that were provided by the
|
||||
* library. Not doing so will result in a memory leak.
|
||||
*
|
||||
* This does not free the `git_commitarray` itself, since the library
|
||||
* will never allocate that object directly itself.
|
||||
*
|
||||
* @param array The git_commitarray that contains commits to free
|
||||
*/
|
||||
GIT_EXTERN(void) git_commitarray_dispose(git_commitarray *array);
|
||||
|
||||
/** @} */
|
||||
GIT_END_DECL
|
||||
#endif
|
514
3rdparty/libgit2/include/git2/common.h
vendored
Normal file
514
3rdparty/libgit2/include/git2/common.h
vendored
Normal file
@ -0,0 +1,514 @@
|
||||
/*
|
||||
* Copyright (C) the libgit2 contributors. All rights reserved.
|
||||
*
|
||||
* This file is part of libgit2, distributed under the GNU GPL v2 with
|
||||
* a Linking Exception. For full terms see the included COPYING file.
|
||||
*/
|
||||
#ifndef INCLUDE_git_common_h__
|
||||
#define INCLUDE_git_common_h__
|
||||
|
||||
#include <time.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
# define GIT_BEGIN_DECL extern "C" {
|
||||
# define GIT_END_DECL }
|
||||
#else
|
||||
/** Start declarations in C mode */
|
||||
# define GIT_BEGIN_DECL /* empty */
|
||||
/** End declarations in C mode */
|
||||
# define GIT_END_DECL /* empty */
|
||||
#endif
|
||||
|
||||
#if defined(_MSC_VER) && _MSC_VER < 1800
|
||||
# include <stdint.h>
|
||||
#elif !defined(__CLANG_INTTYPES_H)
|
||||
# include <inttypes.h>
|
||||
#endif
|
||||
|
||||
#ifdef DOCURIUM
|
||||
/*
|
||||
* This is so clang's doc parser acknowledges comments on functions
|
||||
* with size_t parameters.
|
||||
*/
|
||||
typedef size_t size_t;
|
||||
#endif
|
||||
|
||||
/** Declare a public function exported for application use. */
|
||||
#if __GNUC__ >= 4
|
||||
# define GIT_EXTERN(type) extern \
|
||||
__attribute__((visibility("default"))) \
|
||||
type
|
||||
#elif defined(_MSC_VER)
|
||||
# define GIT_EXTERN(type) __declspec(dllexport) type __cdecl
|
||||
#else
|
||||
# define GIT_EXTERN(type) extern type
|
||||
#endif
|
||||
|
||||
/** Declare a callback function for application use. */
|
||||
#if defined(_MSC_VER)
|
||||
# define GIT_CALLBACK(name) (__cdecl *name)
|
||||
#else
|
||||
# define GIT_CALLBACK(name) (*name)
|
||||
#endif
|
||||
|
||||
/** Declare a function as deprecated. */
|
||||
#if defined(__GNUC__)
|
||||
# define GIT_DEPRECATED(func) \
|
||||
__attribute__((deprecated)) \
|
||||
__attribute__((used)) \
|
||||
func
|
||||
#elif defined(_MSC_VER)
|
||||
# define GIT_DEPRECATED(func) __declspec(deprecated) func
|
||||
#else
|
||||
# define GIT_DEPRECATED(func) func
|
||||
#endif
|
||||
|
||||
/** Declare a function's takes printf style arguments. */
|
||||
#ifdef __GNUC__
|
||||
# define GIT_FORMAT_PRINTF(a,b) __attribute__((format (printf, a, b)))
|
||||
#else
|
||||
# define GIT_FORMAT_PRINTF(a,b) /* empty */
|
||||
#endif
|
||||
|
||||
#if (defined(_WIN32)) && !defined(__CYGWIN__)
|
||||
#define GIT_WIN32 1
|
||||
#endif
|
||||
|
||||
#ifdef __amigaos4__
|
||||
#include <netinet/in.h>
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @file git2/common.h
|
||||
* @brief Git common platform definitions
|
||||
* @defgroup git_common Git common platform definitions
|
||||
* @ingroup Git
|
||||
* @{
|
||||
*/
|
||||
|
||||
GIT_BEGIN_DECL
|
||||
|
||||
/**
|
||||
* The separator used in path list strings (ie like in the PATH
|
||||
* environment variable). A semi-colon ";" is used on Windows and
|
||||
* AmigaOS, and a colon ":" for all other systems.
|
||||
*/
|
||||
#if defined(GIT_WIN32) || defined(AMIGA)
|
||||
#define GIT_PATH_LIST_SEPARATOR ';'
|
||||
#else
|
||||
#define GIT_PATH_LIST_SEPARATOR ':'
|
||||
#endif
|
||||
|
||||
/**
|
||||
* The maximum length of a valid git path.
|
||||
*/
|
||||
#define GIT_PATH_MAX 4096
|
||||
|
||||
/**
|
||||
* Return the version of the libgit2 library
|
||||
* being currently used.
|
||||
*
|
||||
* @param major Store the major version number
|
||||
* @param minor Store the minor version number
|
||||
* @param rev Store the revision (patch) number
|
||||
* @return 0 on success or an error code on failure
|
||||
*/
|
||||
GIT_EXTERN(int) git_libgit2_version(int *major, int *minor, int *rev);
|
||||
|
||||
/**
|
||||
* Return the prerelease state of the libgit2 library currently being
|
||||
* used. For nightly builds during active development, this will be
|
||||
* "alpha". Releases may have a "beta" or release candidate ("rc1",
|
||||
* "rc2", etc) prerelease. For a final release, this function returns
|
||||
* NULL.
|
||||
*
|
||||
* @return the name of the prerelease state or NULL
|
||||
*/
|
||||
GIT_EXTERN(const char *) git_libgit2_prerelease(void);
|
||||
|
||||
/**
|
||||
* Combinations of these values describe the features with which libgit2
|
||||
* was compiled
|
||||
*/
|
||||
typedef enum {
|
||||
/**
|
||||
* If set, libgit2 was built thread-aware and can be safely used from multiple
|
||||
* threads.
|
||||
*/
|
||||
GIT_FEATURE_THREADS = (1 << 0),
|
||||
/**
|
||||
* If set, libgit2 was built with and linked against a TLS implementation.
|
||||
* Custom TLS streams may still be added by the user to support HTTPS
|
||||
* regardless of this.
|
||||
*/
|
||||
GIT_FEATURE_HTTPS = (1 << 1),
|
||||
/**
|
||||
* If set, libgit2 was built with and linked against libssh2. A custom
|
||||
* transport may still be added by the user to support libssh2 regardless of
|
||||
* this.
|
||||
*/
|
||||
GIT_FEATURE_SSH = (1 << 2),
|
||||
/**
|
||||
* If set, libgit2 was built with support for sub-second resolution in file
|
||||
* modification times.
|
||||
*/
|
||||
GIT_FEATURE_NSEC = (1 << 3)
|
||||
} git_feature_t;
|
||||
|
||||
/**
|
||||
* Query compile time options for libgit2.
|
||||
*
|
||||
* @return A combination of GIT_FEATURE_* values.
|
||||
*
|
||||
* - GIT_FEATURE_THREADS
|
||||
* Libgit2 was compiled with thread support. Note that thread support is
|
||||
* still to be seen as a 'work in progress' - basic object lookups are
|
||||
* believed to be threadsafe, but other operations may not be.
|
||||
*
|
||||
* - GIT_FEATURE_HTTPS
|
||||
* Libgit2 supports the https:// protocol. This requires the openssl
|
||||
* library to be found when compiling libgit2.
|
||||
*
|
||||
* - GIT_FEATURE_SSH
|
||||
* Libgit2 supports the SSH protocol for network operations. This requires
|
||||
* the libssh2 library to be found when compiling libgit2
|
||||
*
|
||||
* - GIT_FEATURE_NSEC
|
||||
* Libgit2 supports the sub-second resolution in file modification times.
|
||||
*/
|
||||
GIT_EXTERN(int) git_libgit2_features(void);
|
||||
|
||||
/**
|
||||
* Global library options
|
||||
*
|
||||
* These are used to select which global option to set or get and are
|
||||
* used in `git_libgit2_opts()`.
|
||||
*/
|
||||
typedef enum {
|
||||
GIT_OPT_GET_MWINDOW_SIZE,
|
||||
GIT_OPT_SET_MWINDOW_SIZE,
|
||||
GIT_OPT_GET_MWINDOW_MAPPED_LIMIT,
|
||||
GIT_OPT_SET_MWINDOW_MAPPED_LIMIT,
|
||||
GIT_OPT_GET_SEARCH_PATH,
|
||||
GIT_OPT_SET_SEARCH_PATH,
|
||||
GIT_OPT_SET_CACHE_OBJECT_LIMIT,
|
||||
GIT_OPT_SET_CACHE_MAX_SIZE,
|
||||
GIT_OPT_ENABLE_CACHING,
|
||||
GIT_OPT_GET_CACHED_MEMORY,
|
||||
GIT_OPT_GET_TEMPLATE_PATH,
|
||||
GIT_OPT_SET_TEMPLATE_PATH,
|
||||
GIT_OPT_SET_SSL_CERT_LOCATIONS,
|
||||
GIT_OPT_SET_USER_AGENT,
|
||||
GIT_OPT_ENABLE_STRICT_OBJECT_CREATION,
|
||||
GIT_OPT_ENABLE_STRICT_SYMBOLIC_REF_CREATION,
|
||||
GIT_OPT_SET_SSL_CIPHERS,
|
||||
GIT_OPT_GET_USER_AGENT,
|
||||
GIT_OPT_ENABLE_OFS_DELTA,
|
||||
GIT_OPT_ENABLE_FSYNC_GITDIR,
|
||||
GIT_OPT_GET_WINDOWS_SHAREMODE,
|
||||
GIT_OPT_SET_WINDOWS_SHAREMODE,
|
||||
GIT_OPT_ENABLE_STRICT_HASH_VERIFICATION,
|
||||
GIT_OPT_SET_ALLOCATOR,
|
||||
GIT_OPT_ENABLE_UNSAVED_INDEX_SAFETY,
|
||||
GIT_OPT_GET_PACK_MAX_OBJECTS,
|
||||
GIT_OPT_SET_PACK_MAX_OBJECTS,
|
||||
GIT_OPT_DISABLE_PACK_KEEP_FILE_CHECKS,
|
||||
GIT_OPT_ENABLE_HTTP_EXPECT_CONTINUE,
|
||||
GIT_OPT_GET_MWINDOW_FILE_LIMIT,
|
||||
GIT_OPT_SET_MWINDOW_FILE_LIMIT,
|
||||
GIT_OPT_SET_ODB_PACKED_PRIORITY,
|
||||
GIT_OPT_SET_ODB_LOOSE_PRIORITY,
|
||||
GIT_OPT_GET_EXTENSIONS,
|
||||
GIT_OPT_SET_EXTENSIONS,
|
||||
GIT_OPT_GET_OWNER_VALIDATION,
|
||||
GIT_OPT_SET_OWNER_VALIDATION,
|
||||
GIT_OPT_GET_HOMEDIR,
|
||||
GIT_OPT_SET_HOMEDIR,
|
||||
GIT_OPT_SET_SERVER_CONNECT_TIMEOUT,
|
||||
GIT_OPT_GET_SERVER_CONNECT_TIMEOUT,
|
||||
GIT_OPT_SET_SERVER_TIMEOUT,
|
||||
GIT_OPT_GET_SERVER_TIMEOUT
|
||||
} git_libgit2_opt_t;
|
||||
|
||||
/**
|
||||
* Set or query a library global option
|
||||
*
|
||||
* Available options:
|
||||
*
|
||||
* * opts(GIT_OPT_GET_MWINDOW_SIZE, size_t *):
|
||||
*
|
||||
* > Get the maximum mmap window size
|
||||
*
|
||||
* * opts(GIT_OPT_SET_MWINDOW_SIZE, size_t):
|
||||
*
|
||||
* > Set the maximum mmap window size
|
||||
*
|
||||
* * opts(GIT_OPT_GET_MWINDOW_MAPPED_LIMIT, size_t *):
|
||||
*
|
||||
* > Get the maximum memory that will be mapped in total by the library
|
||||
*
|
||||
* * opts(GIT_OPT_SET_MWINDOW_MAPPED_LIMIT, size_t):
|
||||
*
|
||||
* > Set the maximum amount of memory that can be mapped at any time
|
||||
* > by the library
|
||||
*
|
||||
* * opts(GIT_OPT_GET_MWINDOW_FILE_LIMIT, size_t *):
|
||||
*
|
||||
* > Get the maximum number of files that will be mapped at any time by the
|
||||
* > library
|
||||
*
|
||||
* * opts(GIT_OPT_SET_MWINDOW_FILE_LIMIT, size_t):
|
||||
*
|
||||
* > Set the maximum number of files that can be mapped at any time
|
||||
* > by the library. The default (0) is unlimited.
|
||||
*
|
||||
* * opts(GIT_OPT_GET_SEARCH_PATH, int level, git_buf *buf)
|
||||
*
|
||||
* > Get the search path for a given level of config data. "level" must
|
||||
* > be one of `GIT_CONFIG_LEVEL_SYSTEM`, `GIT_CONFIG_LEVEL_GLOBAL`,
|
||||
* > `GIT_CONFIG_LEVEL_XDG`, or `GIT_CONFIG_LEVEL_PROGRAMDATA`.
|
||||
* > The search path is written to the `out` buffer.
|
||||
*
|
||||
* * opts(GIT_OPT_SET_SEARCH_PATH, int level, const char *path)
|
||||
*
|
||||
* > Set the search path for a level of config data. The search path
|
||||
* > applied to shared attributes and ignore files, too.
|
||||
* >
|
||||
* > - `path` lists directories delimited by GIT_PATH_LIST_SEPARATOR.
|
||||
* > Pass NULL to reset to the default (generally based on environment
|
||||
* > variables). Use magic path `$PATH` to include the old value
|
||||
* > of the path (if you want to prepend or append, for instance).
|
||||
* >
|
||||
* > - `level` must be `GIT_CONFIG_LEVEL_SYSTEM`,
|
||||
* > `GIT_CONFIG_LEVEL_GLOBAL`, `GIT_CONFIG_LEVEL_XDG`, or
|
||||
* > `GIT_CONFIG_LEVEL_PROGRAMDATA`.
|
||||
*
|
||||
* * opts(GIT_OPT_SET_CACHE_OBJECT_LIMIT, git_object_t type, size_t size)
|
||||
*
|
||||
* > Set the maximum data size for the given type of object to be
|
||||
* > considered eligible for caching in memory. Setting to value to
|
||||
* > zero means that that type of object will not be cached.
|
||||
* > Defaults to 0 for GIT_OBJECT_BLOB (i.e. won't cache blobs) and 4k
|
||||
* > for GIT_OBJECT_COMMIT, GIT_OBJECT_TREE, and GIT_OBJECT_TAG.
|
||||
*
|
||||
* * opts(GIT_OPT_SET_CACHE_MAX_SIZE, ssize_t max_storage_bytes)
|
||||
*
|
||||
* > Set the maximum total data size that will be cached in memory
|
||||
* > across all repositories before libgit2 starts evicting objects
|
||||
* > from the cache. This is a soft limit, in that the library might
|
||||
* > briefly exceed it, but will start aggressively evicting objects
|
||||
* > from cache when that happens. The default cache size is 256MB.
|
||||
*
|
||||
* * opts(GIT_OPT_ENABLE_CACHING, int enabled)
|
||||
*
|
||||
* > Enable or disable caching completely.
|
||||
* >
|
||||
* > Because caches are repository-specific, disabling the cache
|
||||
* > cannot immediately clear all cached objects, but each cache will
|
||||
* > be cleared on the next attempt to update anything in it.
|
||||
*
|
||||
* * opts(GIT_OPT_GET_CACHED_MEMORY, ssize_t *current, ssize_t *allowed)
|
||||
*
|
||||
* > Get the current bytes in cache and the maximum that would be
|
||||
* > allowed in the cache.
|
||||
*
|
||||
* * opts(GIT_OPT_GET_TEMPLATE_PATH, git_buf *out)
|
||||
*
|
||||
* > Get the default template path.
|
||||
* > The path is written to the `out` buffer.
|
||||
*
|
||||
* * opts(GIT_OPT_SET_TEMPLATE_PATH, const char *path)
|
||||
*
|
||||
* > Set the default template path.
|
||||
* >
|
||||
* > - `path` directory of template.
|
||||
*
|
||||
* * opts(GIT_OPT_SET_SSL_CERT_LOCATIONS, const char *file, const char *path)
|
||||
*
|
||||
* > Set the SSL certificate-authority locations.
|
||||
* >
|
||||
* > - `file` is the location of a file containing several
|
||||
* > certificates concatenated together.
|
||||
* > - `path` is the location of a directory holding several
|
||||
* > certificates, one per file.
|
||||
* >
|
||||
* > Either parameter may be `NULL`, but not both.
|
||||
*
|
||||
* * opts(GIT_OPT_SET_USER_AGENT, const char *user_agent)
|
||||
*
|
||||
* > Set the value of the User-Agent header. This value will be
|
||||
* > appended to "git/1.0", for compatibility with other git clients.
|
||||
* >
|
||||
* > - `user_agent` is the value that will be delivered as the
|
||||
* > User-Agent header on HTTP requests.
|
||||
*
|
||||
* * opts(GIT_OPT_SET_WINDOWS_SHAREMODE, unsigned long value)
|
||||
*
|
||||
* > Set the share mode used when opening files on Windows.
|
||||
* > For more information, see the documentation for CreateFile.
|
||||
* > The default is: FILE_SHARE_READ | FILE_SHARE_WRITE. This is
|
||||
* > ignored and unused on non-Windows platforms.
|
||||
*
|
||||
* * opts(GIT_OPT_GET_WINDOWS_SHAREMODE, unsigned long *value)
|
||||
*
|
||||
* > Get the share mode used when opening files on Windows.
|
||||
*
|
||||
* * opts(GIT_OPT_ENABLE_STRICT_OBJECT_CREATION, int enabled)
|
||||
*
|
||||
* > Enable strict input validation when creating new objects
|
||||
* > to ensure that all inputs to the new objects are valid. For
|
||||
* > example, when this is enabled, the parent(s) and tree inputs
|
||||
* > will be validated when creating a new commit. This defaults
|
||||
* > to enabled.
|
||||
*
|
||||
* * opts(GIT_OPT_ENABLE_STRICT_SYMBOLIC_REF_CREATION, int enabled)
|
||||
*
|
||||
* > Validate the target of a symbolic ref when creating it. For
|
||||
* > example, `foobar` is not a valid ref, therefore `foobar` is
|
||||
* > not a valid target for a symbolic ref by default, whereas
|
||||
* > `refs/heads/foobar` is. Disabling this bypasses validation
|
||||
* > so that an arbitrary strings such as `foobar` can be used
|
||||
* > for a symbolic ref target. This defaults to enabled.
|
||||
*
|
||||
* * opts(GIT_OPT_SET_SSL_CIPHERS, const char *ciphers)
|
||||
*
|
||||
* > Set the SSL ciphers use for HTTPS connections.
|
||||
* >
|
||||
* > - `ciphers` is the list of ciphers that are eanbled.
|
||||
*
|
||||
* * opts(GIT_OPT_GET_USER_AGENT, git_buf *out)
|
||||
*
|
||||
* > Get the value of the User-Agent header.
|
||||
* > The User-Agent is written to the `out` buffer.
|
||||
*
|
||||
* * opts(GIT_OPT_ENABLE_OFS_DELTA, int enabled)
|
||||
*
|
||||
* > Enable or disable the use of "offset deltas" when creating packfiles,
|
||||
* > and the negotiation of them when talking to a remote server.
|
||||
* > Offset deltas store a delta base location as an offset into the
|
||||
* > packfile from the current location, which provides a shorter encoding
|
||||
* > and thus smaller resultant packfiles.
|
||||
* > Packfiles containing offset deltas can still be read.
|
||||
* > This defaults to enabled.
|
||||
*
|
||||
* * opts(GIT_OPT_ENABLE_FSYNC_GITDIR, int enabled)
|
||||
*
|
||||
* > Enable synchronized writes of files in the gitdir using `fsync`
|
||||
* > (or the platform equivalent) to ensure that new object data
|
||||
* > is written to permanent storage, not simply cached. This
|
||||
* > defaults to disabled.
|
||||
*
|
||||
* opts(GIT_OPT_ENABLE_STRICT_HASH_VERIFICATION, int enabled)
|
||||
*
|
||||
* > Enable strict verification of object hashsums when reading
|
||||
* > objects from disk. This may impact performance due to an
|
||||
* > additional checksum calculation on each object. This defaults
|
||||
* > to enabled.
|
||||
*
|
||||
* opts(GIT_OPT_SET_ALLOCATOR, git_allocator *allocator)
|
||||
*
|
||||
* > Set the memory allocator to a different memory allocator. This
|
||||
* > allocator will then be used to make all memory allocations for
|
||||
* > libgit2 operations. If the given `allocator` is NULL, then the
|
||||
* > system default will be restored.
|
||||
*
|
||||
* opts(GIT_OPT_ENABLE_UNSAVED_INDEX_SAFETY, int enabled)
|
||||
*
|
||||
* > Ensure that there are no unsaved changes in the index before
|
||||
* > beginning any operation that reloads the index from disk (eg,
|
||||
* > checkout). If there are unsaved changes, the instruction will
|
||||
* > fail. (Using the FORCE flag to checkout will still overwrite
|
||||
* > these changes.)
|
||||
*
|
||||
* opts(GIT_OPT_GET_PACK_MAX_OBJECTS, size_t *out)
|
||||
*
|
||||
* > Get the maximum number of objects libgit2 will allow in a pack
|
||||
* > file when downloading a pack file from a remote. This can be
|
||||
* > used to limit maximum memory usage when fetching from an untrusted
|
||||
* > remote.
|
||||
*
|
||||
* opts(GIT_OPT_SET_PACK_MAX_OBJECTS, size_t objects)
|
||||
*
|
||||
* > Set the maximum number of objects libgit2 will allow in a pack
|
||||
* > file when downloading a pack file from a remote.
|
||||
*
|
||||
* opts(GIT_OPT_DISABLE_PACK_KEEP_FILE_CHECKS, int enabled)
|
||||
* > This will cause .keep file existence checks to be skipped when
|
||||
* > accessing packfiles, which can help performance with remote filesystems.
|
||||
*
|
||||
* opts(GIT_OPT_ENABLE_HTTP_EXPECT_CONTINUE, int enabled)
|
||||
* > When connecting to a server using NTLM or Negotiate
|
||||
* > authentication, use expect/continue when POSTing data.
|
||||
* > This option is not available on Windows.
|
||||
*
|
||||
* opts(GIT_OPT_SET_ODB_PACKED_PRIORITY, int priority)
|
||||
* > Override the default priority of the packed ODB backend which
|
||||
* > is added when default backends are assigned to a repository
|
||||
*
|
||||
* opts(GIT_OPT_SET_ODB_LOOSE_PRIORITY, int priority)
|
||||
* > Override the default priority of the loose ODB backend which
|
||||
* > is added when default backends are assigned to a repository
|
||||
*
|
||||
* opts(GIT_OPT_GET_EXTENSIONS, git_strarray *out)
|
||||
* > Returns the list of git extensions that are supported. This
|
||||
* > is the list of built-in extensions supported by libgit2 and
|
||||
* > custom extensions that have been added with
|
||||
* > `GIT_OPT_SET_EXTENSIONS`. Extensions that have been negated
|
||||
* > will not be returned. The returned list should be released
|
||||
* > with `git_strarray_dispose`.
|
||||
*
|
||||
* opts(GIT_OPT_SET_EXTENSIONS, const char **extensions, size_t len)
|
||||
* > Set that the given git extensions are supported by the caller.
|
||||
* > Extensions supported by libgit2 may be negated by prefixing
|
||||
* > them with a `!`. For example: setting extensions to
|
||||
* > { "!noop", "newext" } indicates that the caller does not want
|
||||
* > to support repositories with the `noop` extension but does want
|
||||
* > to support repositories with the `newext` extension.
|
||||
*
|
||||
* opts(GIT_OPT_GET_OWNER_VALIDATION, int *enabled)
|
||||
* > Gets the owner validation setting for repository
|
||||
* > directories.
|
||||
*
|
||||
* opts(GIT_OPT_SET_OWNER_VALIDATION, int enabled)
|
||||
* > Set that repository directories should be owned by the current
|
||||
* > user. The default is to validate ownership.
|
||||
*
|
||||
* opts(GIT_OPT_GET_HOMEDIR, git_buf *out)
|
||||
* > Gets the current user's home directory, as it will be used
|
||||
* > for file lookups. The path is written to the `out` buffer.
|
||||
*
|
||||
* opts(GIT_OPT_SET_HOMEDIR, const char *path)
|
||||
* > Sets the directory used as the current user's home directory,
|
||||
* > for file lookups.
|
||||
* >
|
||||
* > - `path` directory of home directory.
|
||||
*
|
||||
* opts(GIT_OPT_GET_SERVER_CONNECT_TIMEOUT, int *timeout)
|
||||
* > Gets the timeout (in milliseconds) to attempt connections to
|
||||
* > a remote server.
|
||||
*
|
||||
* opts(GIT_OPT_SET_SERVER_CONNECT_TIMEOUT, int timeout)
|
||||
* > Sets the timeout (in milliseconds) to attempt connections to
|
||||
* > a remote server. Set to 0 to use the system default. Note that
|
||||
* > this may not be able to be configured longer than the system
|
||||
* > default, typically 75 seconds.
|
||||
*
|
||||
* opts(GIT_OPT_GET_SERVER_TIMEOUT, int *timeout)
|
||||
* > Gets the timeout (in milliseconds) for reading from and writing
|
||||
* > to a remote server.
|
||||
*
|
||||
* opts(GIT_OPT_SET_SERVER_TIMEOUT, int timeout)
|
||||
* > Sets the timeout (in milliseconds) for reading from and writing
|
||||
* > to a remote server. Set to 0 to use the system default.
|
||||
*
|
||||
* @param option Option key
|
||||
* @param ... value to set the option
|
||||
* @return 0 on success, <0 on failure
|
||||
*/
|
||||
GIT_EXTERN(int) git_libgit2_opts(int option, ...);
|
||||
|
||||
/** @} */
|
||||
GIT_END_DECL
|
||||
|
||||
#endif
|
822
3rdparty/libgit2/include/git2/config.h
vendored
Normal file
822
3rdparty/libgit2/include/git2/config.h
vendored
Normal file
@ -0,0 +1,822 @@
|
||||
/*
|
||||
* Copyright (C) the libgit2 contributors. All rights reserved.
|
||||
*
|
||||
* This file is part of libgit2, distributed under the GNU GPL v2 with
|
||||
* a Linking Exception. For full terms see the included COPYING file.
|
||||
*/
|
||||
#ifndef INCLUDE_git_config_h__
|
||||
#define INCLUDE_git_config_h__
|
||||
|
||||
#include "common.h"
|
||||
#include "types.h"
|
||||
#include "buffer.h"
|
||||
|
||||
/**
|
||||
* @file git2/config.h
|
||||
* @brief Git config management routines
|
||||
* @defgroup git_config Git config management routines
|
||||
* @ingroup Git
|
||||
* @{
|
||||
*/
|
||||
GIT_BEGIN_DECL
|
||||
|
||||
/**
|
||||
* Priority level of a config file.
|
||||
*
|
||||
* These priority levels correspond to the natural escalation logic
|
||||
* (from higher to lower) when reading or searching for config entries
|
||||
* in git.git. Meaning that for the same key, the configuration in
|
||||
* the local configuration is preferred over the configuration in
|
||||
* the system configuration file.
|
||||
*
|
||||
* Callers can add their own custom configuration, beginning at the
|
||||
* `GIT_CONFIG_LEVEL_APP` level.
|
||||
*
|
||||
* Writes, by default, occur in the highest priority level backend
|
||||
* that is writable. This ordering can be overridden with
|
||||
* `git_config_set_writeorder`.
|
||||
*
|
||||
* git_config_open_default() and git_repository_config() honor those
|
||||
* priority levels as well.
|
||||
*/
|
||||
typedef enum {
|
||||
/** System-wide on Windows, for compatibility with portable git */
|
||||
GIT_CONFIG_LEVEL_PROGRAMDATA = 1,
|
||||
|
||||
/** System-wide configuration file; /etc/gitconfig on Linux systems */
|
||||
GIT_CONFIG_LEVEL_SYSTEM = 2,
|
||||
|
||||
/** XDG compatible configuration file; typically ~/.config/git/config */
|
||||
GIT_CONFIG_LEVEL_XDG = 3,
|
||||
|
||||
/** User-specific configuration file (also called Global configuration
|
||||
* file); typically ~/.gitconfig
|
||||
*/
|
||||
GIT_CONFIG_LEVEL_GLOBAL = 4,
|
||||
|
||||
/** Repository specific configuration file; $WORK_DIR/.git/config on
|
||||
* non-bare repos
|
||||
*/
|
||||
GIT_CONFIG_LEVEL_LOCAL = 5,
|
||||
|
||||
/** Worktree specific configuration file; $GIT_DIR/config.worktree
|
||||
*/
|
||||
GIT_CONFIG_LEVEL_WORKTREE = 6,
|
||||
|
||||
/** Application specific configuration file; freely defined by applications
|
||||
*/
|
||||
GIT_CONFIG_LEVEL_APP = 7,
|
||||
|
||||
/** Represents the highest level available config file (i.e. the most
|
||||
* specific config file available that actually is loaded)
|
||||
*/
|
||||
GIT_CONFIG_HIGHEST_LEVEL = -1
|
||||
} git_config_level_t;
|
||||
|
||||
/**
|
||||
* An entry in a configuration file
|
||||
*/
|
||||
typedef struct git_config_entry {
|
||||
/** Name of the configuration entry (normalized) */
|
||||
const char *name;
|
||||
|
||||
/** Literal (string) value of the entry */
|
||||
const char *value;
|
||||
|
||||
/** The type of backend that this entry exists in (eg, "file") */
|
||||
const char *backend_type;
|
||||
|
||||
/**
|
||||
* The path to the origin of this entry. For config files, this is
|
||||
* the path to the file.
|
||||
*/
|
||||
const char *origin_path;
|
||||
|
||||
/** Depth of includes where this variable was found */
|
||||
unsigned int include_depth;
|
||||
|
||||
/** Configuration level for the file this was found in */
|
||||
git_config_level_t level;
|
||||
|
||||
/**
|
||||
* Free function for this entry; for internal purposes. Callers
|
||||
* should call `git_config_entry_free` to free data.
|
||||
*/
|
||||
void GIT_CALLBACK(free)(struct git_config_entry *entry);
|
||||
} git_config_entry;
|
||||
|
||||
/**
|
||||
* Free a config entry
|
||||
*
|
||||
* @param entry The entry to free.
|
||||
*/
|
||||
GIT_EXTERN(void) git_config_entry_free(git_config_entry *entry);
|
||||
|
||||
/**
|
||||
* A config enumeration callback
|
||||
*
|
||||
* @param entry the entry currently being enumerated
|
||||
* @param payload a user-specified pointer
|
||||
* @return non-zero to terminate the iteration.
|
||||
*/
|
||||
typedef int GIT_CALLBACK(git_config_foreach_cb)(const git_config_entry *entry, void *payload);
|
||||
|
||||
/**
|
||||
* An opaque structure for a configuration iterator
|
||||
*/
|
||||
typedef struct git_config_iterator git_config_iterator;
|
||||
|
||||
/**
|
||||
* Config var type
|
||||
*/
|
||||
typedef enum {
|
||||
GIT_CONFIGMAP_FALSE = 0,
|
||||
GIT_CONFIGMAP_TRUE = 1,
|
||||
GIT_CONFIGMAP_INT32,
|
||||
GIT_CONFIGMAP_STRING
|
||||
} git_configmap_t;
|
||||
|
||||
/**
|
||||
* Mapping from config variables to values.
|
||||
*/
|
||||
typedef struct {
|
||||
git_configmap_t type;
|
||||
const char *str_match;
|
||||
int map_value;
|
||||
} git_configmap;
|
||||
|
||||
/**
|
||||
* Locate the path to the global configuration file
|
||||
*
|
||||
* The user or global configuration file is usually
|
||||
* located in `$HOME/.gitconfig`.
|
||||
*
|
||||
* This method will try to guess the full path to that
|
||||
* file, if the file exists. The returned path
|
||||
* may be used on any `git_config` call to load the
|
||||
* global configuration file.
|
||||
*
|
||||
* This method will not guess the path to the xdg compatible
|
||||
* config file (`.config/git/config`).
|
||||
*
|
||||
* @param out Pointer to a user-allocated git_buf in which to store the path
|
||||
* @return 0 if a global configuration file has been found. Its path will be stored in `out`.
|
||||
*/
|
||||
GIT_EXTERN(int) git_config_find_global(git_buf *out);
|
||||
|
||||
/**
|
||||
* Locate the path to the global xdg compatible configuration file
|
||||
*
|
||||
* The xdg compatible configuration file is usually
|
||||
* located in `$HOME/.config/git/config`.
|
||||
*
|
||||
* This method will try to guess the full path to that
|
||||
* file, if the file exists. The returned path
|
||||
* may be used on any `git_config` call to load the
|
||||
* xdg compatible configuration file.
|
||||
*
|
||||
* @param out Pointer to a user-allocated git_buf in which to store the path
|
||||
* @return 0 if a xdg compatible configuration file has been
|
||||
* found. Its path will be stored in `out`.
|
||||
*/
|
||||
GIT_EXTERN(int) git_config_find_xdg(git_buf *out);
|
||||
|
||||
/**
|
||||
* Locate the path to the system configuration file
|
||||
*
|
||||
* If `/etc/gitconfig` doesn't exist, it will look for
|
||||
* `%PROGRAMFILES%\Git\etc\gitconfig`.
|
||||
*
|
||||
* @param out Pointer to a user-allocated git_buf in which to store the path
|
||||
* @return 0 if a system configuration file has been
|
||||
* found. Its path will be stored in `out`.
|
||||
*/
|
||||
GIT_EXTERN(int) git_config_find_system(git_buf *out);
|
||||
|
||||
/**
|
||||
* Locate the path to the configuration file in ProgramData
|
||||
*
|
||||
* Look for the file in `%PROGRAMDATA%\Git\config` used by portable git.
|
||||
*
|
||||
* @param out Pointer to a user-allocated git_buf in which to store the path
|
||||
* @return 0 if a ProgramData configuration file has been
|
||||
* found. Its path will be stored in `out`.
|
||||
*/
|
||||
GIT_EXTERN(int) git_config_find_programdata(git_buf *out);
|
||||
|
||||
/**
|
||||
* Open the global, XDG and system configuration files
|
||||
*
|
||||
* Utility wrapper that finds the global, XDG and system configuration files
|
||||
* and opens them into a single prioritized config object that can be
|
||||
* used when accessing default config data outside a repository.
|
||||
*
|
||||
* @param out Pointer to store the config instance
|
||||
* @return 0 or an error code
|
||||
*/
|
||||
GIT_EXTERN(int) git_config_open_default(git_config **out);
|
||||
|
||||
/**
|
||||
* Allocate a new configuration object
|
||||
*
|
||||
* This object is empty, so you have to add a file to it before you
|
||||
* can do anything with it.
|
||||
*
|
||||
* @param out pointer to the new configuration
|
||||
* @return 0 or an error code
|
||||
*/
|
||||
GIT_EXTERN(int) git_config_new(git_config **out);
|
||||
|
||||
/**
|
||||
* Add an on-disk config file instance to an existing config
|
||||
*
|
||||
* The on-disk file pointed at by `path` will be opened and
|
||||
* parsed; it's expected to be a native Git config file following
|
||||
* the default Git config syntax (see man git-config).
|
||||
*
|
||||
* If the file does not exist, the file will still be added and it
|
||||
* will be created the first time we write to it.
|
||||
*
|
||||
* Note that the configuration object will free the file
|
||||
* automatically.
|
||||
*
|
||||
* Further queries on this config object will access each
|
||||
* of the config file instances in order (instances with
|
||||
* a higher priority level will be accessed first).
|
||||
*
|
||||
* @param cfg the configuration to add the file to
|
||||
* @param path path to the configuration file to add
|
||||
* @param level the priority level of the backend
|
||||
* @param force replace config file at the given priority level
|
||||
* @param repo optional repository to allow parsing of
|
||||
* conditional includes
|
||||
* @return 0 on success, GIT_EEXISTS when adding more than one file
|
||||
* for a given priority level (and force_replace set to 0),
|
||||
* GIT_ENOTFOUND when the file doesn't exist or error code
|
||||
*/
|
||||
GIT_EXTERN(int) git_config_add_file_ondisk(
|
||||
git_config *cfg,
|
||||
const char *path,
|
||||
git_config_level_t level,
|
||||
const git_repository *repo,
|
||||
int force);
|
||||
|
||||
/**
|
||||
* Create a new config instance containing a single on-disk file
|
||||
*
|
||||
* This method is a simple utility wrapper for the following sequence
|
||||
* of calls:
|
||||
* - git_config_new
|
||||
* - git_config_add_file_ondisk
|
||||
*
|
||||
* @param out The configuration instance to create
|
||||
* @param path Path to the on-disk file to open
|
||||
* @return 0 on success, or an error code
|
||||
*/
|
||||
GIT_EXTERN(int) git_config_open_ondisk(git_config **out, const char *path);
|
||||
|
||||
/**
|
||||
* Build a single-level focused config object from a multi-level one.
|
||||
*
|
||||
* The returned config object can be used to perform get/set/delete operations
|
||||
* on a single specific level.
|
||||
*
|
||||
* Getting several times the same level from the same parent multi-level config
|
||||
* will return different config instances, but containing the same config_file
|
||||
* instance.
|
||||
*
|
||||
* @param out The configuration instance to create
|
||||
* @param parent Multi-level config to search for the given level
|
||||
* @param level Configuration level to search for
|
||||
* @return 0, GIT_ENOTFOUND if the passed level cannot be found in the
|
||||
* multi-level parent config, or an error code
|
||||
*/
|
||||
GIT_EXTERN(int) git_config_open_level(
|
||||
git_config **out,
|
||||
const git_config *parent,
|
||||
git_config_level_t level);
|
||||
|
||||
/**
|
||||
* Open the global/XDG configuration file according to git's rules
|
||||
*
|
||||
* Git allows you to store your global configuration at
|
||||
* `$HOME/.gitconfig` or `$XDG_CONFIG_HOME/git/config`. For backwards
|
||||
* compatibility, the XDG file shouldn't be used unless the use has
|
||||
* created it explicitly. With this function you'll open the correct
|
||||
* one to write to.
|
||||
*
|
||||
* @param out pointer in which to store the config object
|
||||
* @param config the config object in which to look
|
||||
* @return 0 or an error code.
|
||||
*/
|
||||
GIT_EXTERN(int) git_config_open_global(git_config **out, git_config *config);
|
||||
|
||||
GIT_EXTERN(int) git_config_set_writeorder(
|
||||
git_config *cfg,
|
||||
git_config_level_t *levels,
|
||||
size_t len);
|
||||
|
||||
/**
|
||||
* Create a snapshot of the configuration
|
||||
*
|
||||
* Create a snapshot of the current state of a configuration, which
|
||||
* allows you to look into a consistent view of the configuration for
|
||||
* looking up complex values (e.g. a remote, submodule).
|
||||
*
|
||||
* The string returned when querying such a config object is valid
|
||||
* until it is freed.
|
||||
*
|
||||
* @param out pointer in which to store the snapshot config object
|
||||
* @param config configuration to snapshot
|
||||
* @return 0 or an error code
|
||||
*/
|
||||
GIT_EXTERN(int) git_config_snapshot(git_config **out, git_config *config);
|
||||
|
||||
/**
|
||||
* Free the configuration and its associated memory and files
|
||||
*
|
||||
* @param cfg the configuration to free
|
||||
*/
|
||||
GIT_EXTERN(void) git_config_free(git_config *cfg);
|
||||
|
||||
/**
|
||||
* Get the git_config_entry of a config variable.
|
||||
*
|
||||
* Free the git_config_entry after use with `git_config_entry_free()`.
|
||||
*
|
||||
* @param out pointer to the variable git_config_entry
|
||||
* @param cfg where to look for the variable
|
||||
* @param name the variable's name
|
||||
* @return 0 or an error code
|
||||
*/
|
||||
GIT_EXTERN(int) git_config_get_entry(
|
||||
git_config_entry **out,
|
||||
const git_config *cfg,
|
||||
const char *name);
|
||||
|
||||
/**
|
||||
* Get the value of an integer config variable.
|
||||
*
|
||||
* All config files will be looked into, in the order of their
|
||||
* defined level. A higher level means a higher priority. The
|
||||
* first occurrence of the variable will be returned here.
|
||||
*
|
||||
* @param out pointer to the variable where the value should be stored
|
||||
* @param cfg where to look for the variable
|
||||
* @param name the variable's name
|
||||
* @return 0 or an error code
|
||||
*/
|
||||
GIT_EXTERN(int) git_config_get_int32(int32_t *out, const git_config *cfg, const char *name);
|
||||
|
||||
/**
|
||||
* Get the value of a long integer config variable.
|
||||
*
|
||||
* All config files will be looked into, in the order of their
|
||||
* defined level. A higher level means a higher priority. The
|
||||
* first occurrence of the variable will be returned here.
|
||||
*
|
||||
* @param out pointer to the variable where the value should be stored
|
||||
* @param cfg where to look for the variable
|
||||
* @param name the variable's name
|
||||
* @return 0 or an error code
|
||||
*/
|
||||
GIT_EXTERN(int) git_config_get_int64(int64_t *out, const git_config *cfg, const char *name);
|
||||
|
||||
/**
|
||||
* Get the value of a boolean config variable.
|
||||
*
|
||||
* This function uses the usual C convention of 0 being false and
|
||||
* anything else true.
|
||||
*
|
||||
* All config files will be looked into, in the order of their
|
||||
* defined level. A higher level means a higher priority. The
|
||||
* first occurrence of the variable will be returned here.
|
||||
*
|
||||
* @param out pointer to the variable where the value should be stored
|
||||
* @param cfg where to look for the variable
|
||||
* @param name the variable's name
|
||||
* @return 0 or an error code
|
||||
*/
|
||||
GIT_EXTERN(int) git_config_get_bool(int *out, const git_config *cfg, const char *name);
|
||||
|
||||
/**
|
||||
* Get the value of a path config variable.
|
||||
*
|
||||
* A leading '~' will be expanded to the global search path (which
|
||||
* defaults to the user's home directory but can be overridden via
|
||||
* `git_libgit2_opts()`.
|
||||
*
|
||||
* All config files will be looked into, in the order of their
|
||||
* defined level. A higher level means a higher priority. The
|
||||
* first occurrence of the variable will be returned here.
|
||||
*
|
||||
* @param out the buffer in which to store the result
|
||||
* @param cfg where to look for the variable
|
||||
* @param name the variable's name
|
||||
* @return 0 or an error code
|
||||
*/
|
||||
GIT_EXTERN(int) git_config_get_path(git_buf *out, const git_config *cfg, const char *name);
|
||||
|
||||
/**
|
||||
* Get the value of a string config variable.
|
||||
*
|
||||
* This function can only be used on snapshot config objects. The
|
||||
* string is owned by the config and should not be freed by the
|
||||
* user. The pointer will be valid until the config is freed.
|
||||
*
|
||||
* All config files will be looked into, in the order of their
|
||||
* defined level. A higher level means a higher priority. The
|
||||
* first occurrence of the variable will be returned here.
|
||||
*
|
||||
* @param out pointer to the string
|
||||
* @param cfg where to look for the variable
|
||||
* @param name the variable's name
|
||||
* @return 0 or an error code
|
||||
*/
|
||||
GIT_EXTERN(int) git_config_get_string(const char **out, const git_config *cfg, const char *name);
|
||||
|
||||
/**
|
||||
* Get the value of a string config variable.
|
||||
*
|
||||
* The value of the config will be copied into the buffer.
|
||||
*
|
||||
* All config files will be looked into, in the order of their
|
||||
* defined level. A higher level means a higher priority. The
|
||||
* first occurrence of the variable will be returned here.
|
||||
*
|
||||
* @param out buffer in which to store the string
|
||||
* @param cfg where to look for the variable
|
||||
* @param name the variable's name
|
||||
* @return 0 or an error code
|
||||
*/
|
||||
GIT_EXTERN(int) git_config_get_string_buf(git_buf *out, const git_config *cfg, const char *name);
|
||||
|
||||
/**
|
||||
* Get each value of a multivar in a foreach callback
|
||||
*
|
||||
* The callback will be called on each variable found
|
||||
*
|
||||
* The regular expression is applied case-sensitively on the normalized form of
|
||||
* the variable name: the section and variable parts are lower-cased. The
|
||||
* subsection is left unchanged.
|
||||
*
|
||||
* @param cfg where to look for the variable
|
||||
* @param name the variable's name
|
||||
* @param regexp regular expression to filter which variables we're
|
||||
* interested in. Use NULL to indicate all
|
||||
* @param callback the function to be called on each value of the variable
|
||||
* @param payload opaque pointer to pass to the callback
|
||||
* @return 0 or an error code.
|
||||
*/
|
||||
GIT_EXTERN(int) git_config_get_multivar_foreach(const git_config *cfg, const char *name, const char *regexp, git_config_foreach_cb callback, void *payload);
|
||||
|
||||
/**
|
||||
* Get each value of a multivar
|
||||
*
|
||||
* The regular expression is applied case-sensitively on the normalized form of
|
||||
* the variable name: the section and variable parts are lower-cased. The
|
||||
* subsection is left unchanged.
|
||||
*
|
||||
* @param out pointer to store the iterator
|
||||
* @param cfg where to look for the variable
|
||||
* @param name the variable's name
|
||||
* @param regexp regular expression to filter which variables we're
|
||||
* interested in. Use NULL to indicate all
|
||||
* @return 0 or an error code.
|
||||
*/
|
||||
GIT_EXTERN(int) git_config_multivar_iterator_new(git_config_iterator **out, const git_config *cfg, const char *name, const char *regexp);
|
||||
|
||||
/**
|
||||
* Return the current entry and advance the iterator
|
||||
*
|
||||
* The pointers returned by this function are valid until the next call
|
||||
* to `git_config_next` or until the iterator is freed.
|
||||
*
|
||||
* @param entry pointer to store the entry
|
||||
* @param iter the iterator
|
||||
* @return 0 or an error code. GIT_ITEROVER if the iteration has completed
|
||||
*/
|
||||
GIT_EXTERN(int) git_config_next(git_config_entry **entry, git_config_iterator *iter);
|
||||
|
||||
/**
|
||||
* Free a config iterator
|
||||
*
|
||||
* @param iter the iterator to free
|
||||
*/
|
||||
GIT_EXTERN(void) git_config_iterator_free(git_config_iterator *iter);
|
||||
|
||||
/**
|
||||
* Set the value of an integer config variable in the config file
|
||||
* with the highest level (usually the local one).
|
||||
*
|
||||
* @param cfg where to look for the variable
|
||||
* @param name the variable's name
|
||||
* @param value Integer value for the variable
|
||||
* @return 0 or an error code
|
||||
*/
|
||||
GIT_EXTERN(int) git_config_set_int32(git_config *cfg, const char *name, int32_t value);
|
||||
|
||||
/**
|
||||
* Set the value of a long integer config variable in the config file
|
||||
* with the highest level (usually the local one).
|
||||
*
|
||||
* @param cfg where to look for the variable
|
||||
* @param name the variable's name
|
||||
* @param value Long integer value for the variable
|
||||
* @return 0 or an error code
|
||||
*/
|
||||
GIT_EXTERN(int) git_config_set_int64(git_config *cfg, const char *name, int64_t value);
|
||||
|
||||
/**
|
||||
* Set the value of a boolean config variable in the config file
|
||||
* with the highest level (usually the local one).
|
||||
*
|
||||
* @param cfg where to look for the variable
|
||||
* @param name the variable's name
|
||||
* @param value the value to store
|
||||
* @return 0 or an error code
|
||||
*/
|
||||
GIT_EXTERN(int) git_config_set_bool(git_config *cfg, const char *name, int value);
|
||||
|
||||
/**
|
||||
* Set the value of a string config variable in the config file
|
||||
* with the highest level (usually the local one).
|
||||
*
|
||||
* A copy of the string is made and the user is free to use it
|
||||
* afterwards.
|
||||
*
|
||||
* @param cfg where to look for the variable
|
||||
* @param name the variable's name
|
||||
* @param value the string to store.
|
||||
* @return 0 or an error code
|
||||
*/
|
||||
GIT_EXTERN(int) git_config_set_string(git_config *cfg, const char *name, const char *value);
|
||||
|
||||
/**
|
||||
* Set a multivar in the local config file.
|
||||
*
|
||||
* The regular expression is applied case-sensitively on the value.
|
||||
*
|
||||
* @param cfg where to look for the variable
|
||||
* @param name the variable's name
|
||||
* @param regexp a regular expression to indicate which values to replace
|
||||
* @param value the new value.
|
||||
* @return 0 or an error code.
|
||||
*/
|
||||
GIT_EXTERN(int) git_config_set_multivar(git_config *cfg, const char *name, const char *regexp, const char *value);
|
||||
|
||||
/**
|
||||
* Delete a config variable from the config file
|
||||
* with the highest level (usually the local one).
|
||||
*
|
||||
* @param cfg the configuration
|
||||
* @param name the variable to delete
|
||||
* @return 0 or an error code.
|
||||
*/
|
||||
GIT_EXTERN(int) git_config_delete_entry(git_config *cfg, const char *name);
|
||||
|
||||
/**
|
||||
* Deletes one or several entries from a multivar in the local config file.
|
||||
*
|
||||
* The regular expression is applied case-sensitively on the value.
|
||||
*
|
||||
* @param cfg where to look for the variables
|
||||
* @param name the variable's name
|
||||
* @param regexp a regular expression to indicate which values to delete
|
||||
*
|
||||
* @return 0 or an error code
|
||||
*/
|
||||
GIT_EXTERN(int) git_config_delete_multivar(git_config *cfg, const char *name, const char *regexp);
|
||||
|
||||
/**
|
||||
* Perform an operation on each config variable.
|
||||
*
|
||||
* The callback receives the normalized name and value of each variable
|
||||
* in the config backend, and the data pointer passed to this function.
|
||||
* If the callback returns a non-zero value, the function stops iterating
|
||||
* and returns that value to the caller.
|
||||
*
|
||||
* The pointers passed to the callback are only valid as long as the
|
||||
* iteration is ongoing.
|
||||
*
|
||||
* @param cfg where to get the variables from
|
||||
* @param callback the function to call on each variable
|
||||
* @param payload the data to pass to the callback
|
||||
* @return 0 on success, non-zero callback return value, or error code
|
||||
*/
|
||||
GIT_EXTERN(int) git_config_foreach(
|
||||
const git_config *cfg,
|
||||
git_config_foreach_cb callback,
|
||||
void *payload);
|
||||
|
||||
/**
|
||||
* Iterate over all the config variables
|
||||
*
|
||||
* Use `git_config_next` to advance the iteration and
|
||||
* `git_config_iterator_free` when done.
|
||||
*
|
||||
* @param out pointer to store the iterator
|
||||
* @param cfg where to get the variables from
|
||||
* @return 0 or an error code.
|
||||
*/
|
||||
GIT_EXTERN(int) git_config_iterator_new(git_config_iterator **out, const git_config *cfg);
|
||||
|
||||
/**
|
||||
* Iterate over all the config variables whose name matches a pattern
|
||||
*
|
||||
* Use `git_config_next` to advance the iteration and
|
||||
* `git_config_iterator_free` when done.
|
||||
*
|
||||
* The regular expression is applied case-sensitively on the normalized form of
|
||||
* the variable name: the section and variable parts are lower-cased. The
|
||||
* subsection is left unchanged.
|
||||
*
|
||||
* @param out pointer to store the iterator
|
||||
* @param cfg where to ge the variables from
|
||||
* @param regexp regular expression to match the names
|
||||
* @return 0 or an error code.
|
||||
*/
|
||||
GIT_EXTERN(int) git_config_iterator_glob_new(git_config_iterator **out, const git_config *cfg, const char *regexp);
|
||||
|
||||
/**
|
||||
* Perform an operation on each config variable matching a regular expression.
|
||||
*
|
||||
* This behaves like `git_config_foreach` with an additional filter of a
|
||||
* regular expression that filters which config keys are passed to the
|
||||
* callback.
|
||||
*
|
||||
* The regular expression is applied case-sensitively on the normalized form of
|
||||
* the variable name: the section and variable parts are lower-cased. The
|
||||
* subsection is left unchanged.
|
||||
*
|
||||
* The regular expression is applied case-sensitively on the normalized form of
|
||||
* the variable name: the case-insensitive parts are lower-case.
|
||||
*
|
||||
* @param cfg where to get the variables from
|
||||
* @param regexp regular expression to match against config names
|
||||
* @param callback the function to call on each variable
|
||||
* @param payload the data to pass to the callback
|
||||
* @return 0 or the return value of the callback which didn't return 0
|
||||
*/
|
||||
GIT_EXTERN(int) git_config_foreach_match(
|
||||
const git_config *cfg,
|
||||
const char *regexp,
|
||||
git_config_foreach_cb callback,
|
||||
void *payload);
|
||||
|
||||
/**
|
||||
* Query the value of a config variable and return it mapped to
|
||||
* an integer constant.
|
||||
*
|
||||
* This is a helper method to easily map different possible values
|
||||
* to a variable to integer constants that easily identify them.
|
||||
*
|
||||
* A mapping array looks as follows:
|
||||
*
|
||||
* git_configmap autocrlf_mapping[] = {
|
||||
* {GIT_CVAR_FALSE, NULL, GIT_AUTO_CRLF_FALSE},
|
||||
* {GIT_CVAR_TRUE, NULL, GIT_AUTO_CRLF_TRUE},
|
||||
* {GIT_CVAR_STRING, "input", GIT_AUTO_CRLF_INPUT},
|
||||
* {GIT_CVAR_STRING, "default", GIT_AUTO_CRLF_DEFAULT}};
|
||||
*
|
||||
* On any "false" value for the variable (e.g. "false", "FALSE", "no"), the
|
||||
* mapping will store `GIT_AUTO_CRLF_FALSE` in the `out` parameter.
|
||||
*
|
||||
* The same thing applies for any "true" value such as "true", "yes" or "1", storing
|
||||
* the `GIT_AUTO_CRLF_TRUE` variable.
|
||||
*
|
||||
* Otherwise, if the value matches the string "input" (with case insensitive comparison),
|
||||
* the given constant will be stored in `out`, and likewise for "default".
|
||||
*
|
||||
* If not a single match can be made to store in `out`, an error code will be
|
||||
* returned.
|
||||
*
|
||||
* @param out place to store the result of the mapping
|
||||
* @param cfg config file to get the variables from
|
||||
* @param name name of the config variable to lookup
|
||||
* @param maps array of `git_configmap` objects specifying the possible mappings
|
||||
* @param map_n number of mapping objects in `maps`
|
||||
* @return 0 on success, error code otherwise
|
||||
*/
|
||||
GIT_EXTERN(int) git_config_get_mapped(
|
||||
int *out,
|
||||
const git_config *cfg,
|
||||
const char *name,
|
||||
const git_configmap *maps,
|
||||
size_t map_n);
|
||||
|
||||
/**
|
||||
* Maps a string value to an integer constant
|
||||
*
|
||||
* @param out place to store the result of the parsing
|
||||
* @param maps array of `git_configmap` objects specifying the possible mappings
|
||||
* @param map_n number of mapping objects in `maps`
|
||||
* @param value value to parse
|
||||
* @return 0 or an error code.
|
||||
*/
|
||||
GIT_EXTERN(int) git_config_lookup_map_value(
|
||||
int *out,
|
||||
const git_configmap *maps,
|
||||
size_t map_n,
|
||||
const char *value);
|
||||
|
||||
/**
|
||||
* Parse a string value as a bool.
|
||||
*
|
||||
* Valid values for true are: 'true', 'yes', 'on', 1 or any
|
||||
* number different from 0
|
||||
* Valid values for false are: 'false', 'no', 'off', 0
|
||||
*
|
||||
* @param out place to store the result of the parsing
|
||||
* @param value value to parse
|
||||
* @return 0 or an error code.
|
||||
*/
|
||||
GIT_EXTERN(int) git_config_parse_bool(int *out, const char *value);
|
||||
|
||||
/**
|
||||
* Parse a string value as an int32.
|
||||
*
|
||||
* An optional value suffix of 'k', 'm', or 'g' will
|
||||
* cause the value to be multiplied by 1024, 1048576,
|
||||
* or 1073741824 prior to output.
|
||||
*
|
||||
* @param out place to store the result of the parsing
|
||||
* @param value value to parse
|
||||
* @return 0 or an error code.
|
||||
*/
|
||||
GIT_EXTERN(int) git_config_parse_int32(int32_t *out, const char *value);
|
||||
|
||||
/**
|
||||
* Parse a string value as an int64.
|
||||
*
|
||||
* An optional value suffix of 'k', 'm', or 'g' will
|
||||
* cause the value to be multiplied by 1024, 1048576,
|
||||
* or 1073741824 prior to output.
|
||||
*
|
||||
* @param out place to store the result of the parsing
|
||||
* @param value value to parse
|
||||
* @return 0 or an error code.
|
||||
*/
|
||||
GIT_EXTERN(int) git_config_parse_int64(int64_t *out, const char *value);
|
||||
|
||||
/**
|
||||
* Parse a string value as a path.
|
||||
*
|
||||
* A leading '~' will be expanded to the global search path (which
|
||||
* defaults to the user's home directory but can be overridden via
|
||||
* `git_libgit2_opts()`.
|
||||
*
|
||||
* If the value does not begin with a tilde, the input will be
|
||||
* returned.
|
||||
*
|
||||
* @param out placae to store the result of parsing
|
||||
* @param value the path to evaluate
|
||||
* @return 0 or an error code.
|
||||
*/
|
||||
GIT_EXTERN(int) git_config_parse_path(git_buf *out, const char *value);
|
||||
|
||||
/**
|
||||
* Perform an operation on each config variable in a given config backend,
|
||||
* matching a regular expression.
|
||||
*
|
||||
* This behaves like `git_config_foreach_match` except that only config
|
||||
* entries from the given backend entry are enumerated.
|
||||
*
|
||||
* The regular expression is applied case-sensitively on the normalized form of
|
||||
* the variable name: the section and variable parts are lower-cased. The
|
||||
* subsection is left unchanged.
|
||||
*
|
||||
* @param backend where to get the variables from
|
||||
* @param regexp regular expression to match against config names (can be NULL)
|
||||
* @param callback the function to call on each variable
|
||||
* @param payload the data to pass to the callback
|
||||
* @return 0 or an error code.
|
||||
*/
|
||||
GIT_EXTERN(int) git_config_backend_foreach_match(
|
||||
git_config_backend *backend,
|
||||
const char *regexp,
|
||||
git_config_foreach_cb callback,
|
||||
void *payload);
|
||||
|
||||
|
||||
/**
|
||||
* Lock the backend with the highest priority
|
||||
*
|
||||
* Locking disallows anybody else from writing to that backend. Any
|
||||
* updates made after locking will not be visible to a reader until
|
||||
* the file is unlocked.
|
||||
*
|
||||
* You can apply the changes by calling `git_transaction_commit()`
|
||||
* before freeing the transaction. Either of these actions will unlock
|
||||
* the config.
|
||||
*
|
||||
* @param tx the resulting transaction, use this to commit or undo the
|
||||
* changes
|
||||
* @param cfg the configuration in which to lock
|
||||
* @return 0 or an error code
|
||||
*/
|
||||
GIT_EXTERN(int) git_config_lock(git_transaction **tx, git_config *cfg);
|
||||
|
||||
/** @} */
|
||||
GIT_END_DECL
|
||||
#endif
|
15
3rdparty/libgit2/include/git2/cred_helpers.h
vendored
Normal file
15
3rdparty/libgit2/include/git2/cred_helpers.h
vendored
Normal file
@ -0,0 +1,15 @@
|
||||
/*
|
||||
* Copyright (C) the libgit2 contributors. All rights reserved.
|
||||
*
|
||||
* This file is part of libgit2, distributed under the GNU GPL v2 with
|
||||
* a Linking Exception. For full terms see the included COPYING file.
|
||||
*/
|
||||
#ifndef INCLUDE_git_cred_helpers_h__
|
||||
#define INCLUDE_git_cred_helpers_h__
|
||||
|
||||
/* These declarations have moved. */
|
||||
#ifndef GIT_DEPRECATE_HARD
|
||||
# include "git2/credential_helpers.h"
|
||||
#endif
|
||||
|
||||
#endif
|
315
3rdparty/libgit2/include/git2/credential.h
vendored
Normal file
315
3rdparty/libgit2/include/git2/credential.h
vendored
Normal file
@ -0,0 +1,315 @@
|
||||
/*
|
||||
* Copyright (C) the libgit2 contributors. All rights reserved.
|
||||
*
|
||||
* This file is part of libgit2, distributed under the GNU GPL v2 with
|
||||
* a Linking Exception. For full terms see the included COPYING file.
|
||||
*/
|
||||
#ifndef INCLUDE_git_credential_h__
|
||||
#define INCLUDE_git_credential_h__
|
||||
|
||||
#include "common.h"
|
||||
|
||||
/**
|
||||
* @file git2/credential.h
|
||||
* @brief Git authentication & credential management
|
||||
* @defgroup git_credential Authentication & credential management
|
||||
* @ingroup Git
|
||||
* @{
|
||||
*/
|
||||
GIT_BEGIN_DECL
|
||||
|
||||
/**
|
||||
* Supported credential types
|
||||
*
|
||||
* This represents the various types of authentication methods supported by
|
||||
* the library.
|
||||
*/
|
||||
typedef enum {
|
||||
/**
|
||||
* A vanilla user/password request
|
||||
* @see git_credential_userpass_plaintext_new
|
||||
*/
|
||||
GIT_CREDENTIAL_USERPASS_PLAINTEXT = (1u << 0),
|
||||
|
||||
/**
|
||||
* An SSH key-based authentication request
|
||||
* @see git_credential_ssh_key_new
|
||||
*/
|
||||
GIT_CREDENTIAL_SSH_KEY = (1u << 1),
|
||||
|
||||
/**
|
||||
* An SSH key-based authentication request, with a custom signature
|
||||
* @see git_credential_ssh_custom_new
|
||||
*/
|
||||
GIT_CREDENTIAL_SSH_CUSTOM = (1u << 2),
|
||||
|
||||
/**
|
||||
* An NTLM/Negotiate-based authentication request.
|
||||
* @see git_credential_default
|
||||
*/
|
||||
GIT_CREDENTIAL_DEFAULT = (1u << 3),
|
||||
|
||||
/**
|
||||
* An SSH interactive authentication request
|
||||
* @see git_credential_ssh_interactive_new
|
||||
*/
|
||||
GIT_CREDENTIAL_SSH_INTERACTIVE = (1u << 4),
|
||||
|
||||
/**
|
||||
* Username-only authentication request
|
||||
*
|
||||
* Used as a pre-authentication step if the underlying transport
|
||||
* (eg. SSH, with no username in its URL) does not know which username
|
||||
* to use.
|
||||
*
|
||||
* @see git_credential_username_new
|
||||
*/
|
||||
GIT_CREDENTIAL_USERNAME = (1u << 5),
|
||||
|
||||
/**
|
||||
* An SSH key-based authentication request
|
||||
*
|
||||
* Allows credentials to be read from memory instead of files.
|
||||
* Note that because of differences in crypto backend support, it might
|
||||
* not be functional.
|
||||
*
|
||||
* @see git_credential_ssh_key_memory_new
|
||||
*/
|
||||
GIT_CREDENTIAL_SSH_MEMORY = (1u << 6)
|
||||
} git_credential_t;
|
||||
|
||||
/**
|
||||
* The base structure for all credential types
|
||||
*/
|
||||
typedef struct git_credential git_credential;
|
||||
|
||||
typedef struct git_credential_userpass_plaintext git_credential_userpass_plaintext;
|
||||
|
||||
/** Username-only credential information */
|
||||
typedef struct git_credential_username git_credential_username;
|
||||
|
||||
/** A key for NTLM/Kerberos "default" credentials */
|
||||
typedef struct git_credential git_credential_default;
|
||||
|
||||
/**
|
||||
* A ssh key from disk
|
||||
*/
|
||||
typedef struct git_credential_ssh_key git_credential_ssh_key;
|
||||
|
||||
/**
|
||||
* Keyboard-interactive based ssh authentication
|
||||
*/
|
||||
typedef struct git_credential_ssh_interactive git_credential_ssh_interactive;
|
||||
|
||||
/**
|
||||
* A key with a custom signature function
|
||||
*/
|
||||
typedef struct git_credential_ssh_custom git_credential_ssh_custom;
|
||||
|
||||
/**
|
||||
* Credential acquisition callback.
|
||||
*
|
||||
* This callback is usually involved any time another system might need
|
||||
* authentication. As such, you are expected to provide a valid
|
||||
* git_credential object back, depending on allowed_types (a
|
||||
* git_credential_t bitmask).
|
||||
*
|
||||
* Note that most authentication details are your responsibility - this
|
||||
* callback will be called until the authentication succeeds, or you report
|
||||
* an error. As such, it's easy to get in a loop if you fail to stop providing
|
||||
* the same incorrect credentials.
|
||||
*
|
||||
* @param out The newly created credential object.
|
||||
* @param url The resource for which we are demanding a credential.
|
||||
* @param username_from_url The username that was embedded in a "user\@host"
|
||||
* remote url, or NULL if not included.
|
||||
* @param allowed_types A bitmask stating which credential types are OK to return.
|
||||
* @param payload The payload provided when specifying this callback.
|
||||
* @return 0 for success, < 0 to indicate an error, > 0 to indicate
|
||||
* no credential was acquired
|
||||
*/
|
||||
typedef int GIT_CALLBACK(git_credential_acquire_cb)(
|
||||
git_credential **out,
|
||||
const char *url,
|
||||
const char *username_from_url,
|
||||
unsigned int allowed_types,
|
||||
void *payload);
|
||||
|
||||
/**
|
||||
* Free a credential.
|
||||
*
|
||||
* This is only necessary if you own the object; that is, if you are a
|
||||
* transport.
|
||||
*
|
||||
* @param cred the object to free
|
||||
*/
|
||||
GIT_EXTERN(void) git_credential_free(git_credential *cred);
|
||||
|
||||
/**
|
||||
* Check whether a credential object contains username information.
|
||||
*
|
||||
* @param cred object to check
|
||||
* @return 1 if the credential object has non-NULL username, 0 otherwise
|
||||
*/
|
||||
GIT_EXTERN(int) git_credential_has_username(git_credential *cred);
|
||||
|
||||
/**
|
||||
* Return the username associated with a credential object.
|
||||
*
|
||||
* @param cred object to check
|
||||
* @return the credential username, or NULL if not applicable
|
||||
*/
|
||||
GIT_EXTERN(const char *) git_credential_get_username(git_credential *cred);
|
||||
|
||||
/**
|
||||
* Create a new plain-text username and password credential object.
|
||||
* The supplied credential parameter will be internally duplicated.
|
||||
*
|
||||
* @param out The newly created credential object.
|
||||
* @param username The username of the credential.
|
||||
* @param password The password of the credential.
|
||||
* @return 0 for success or an error code for failure
|
||||
*/
|
||||
GIT_EXTERN(int) git_credential_userpass_plaintext_new(
|
||||
git_credential **out,
|
||||
const char *username,
|
||||
const char *password);
|
||||
|
||||
/**
|
||||
* Create a "default" credential usable for Negotiate mechanisms like NTLM
|
||||
* or Kerberos authentication.
|
||||
*
|
||||
* @param out The newly created credential object.
|
||||
* @return 0 for success or an error code for failure
|
||||
*/
|
||||
GIT_EXTERN(int) git_credential_default_new(git_credential **out);
|
||||
|
||||
/**
|
||||
* Create a credential to specify a username.
|
||||
*
|
||||
* This is used with ssh authentication to query for the username if
|
||||
* none is specified in the url.
|
||||
*
|
||||
* @param out The newly created credential object.
|
||||
* @param username The username to authenticate with
|
||||
* @return 0 for success or an error code for failure
|
||||
*/
|
||||
GIT_EXTERN(int) git_credential_username_new(git_credential **out, const char *username);
|
||||
|
||||
/**
|
||||
* Create a new passphrase-protected ssh key credential object.
|
||||
* The supplied credential parameter will be internally duplicated.
|
||||
*
|
||||
* @param out The newly created credential object.
|
||||
* @param username username to use to authenticate
|
||||
* @param publickey The path to the public key of the credential.
|
||||
* @param privatekey The path to the private key of the credential.
|
||||
* @param passphrase The passphrase of the credential.
|
||||
* @return 0 for success or an error code for failure
|
||||
*/
|
||||
GIT_EXTERN(int) git_credential_ssh_key_new(
|
||||
git_credential **out,
|
||||
const char *username,
|
||||
const char *publickey,
|
||||
const char *privatekey,
|
||||
const char *passphrase);
|
||||
|
||||
/**
|
||||
* Create a new ssh key credential object reading the keys from memory.
|
||||
*
|
||||
* @param out The newly created credential object.
|
||||
* @param username username to use to authenticate.
|
||||
* @param publickey The public key of the credential.
|
||||
* @param privatekey The private key of the credential.
|
||||
* @param passphrase The passphrase of the credential.
|
||||
* @return 0 for success or an error code for failure
|
||||
*/
|
||||
GIT_EXTERN(int) git_credential_ssh_key_memory_new(
|
||||
git_credential **out,
|
||||
const char *username,
|
||||
const char *publickey,
|
||||
const char *privatekey,
|
||||
const char *passphrase);
|
||||
|
||||
/*
|
||||
* If the user hasn't included libssh2.h before git2.h, we need to
|
||||
* define a few types for the callback signatures.
|
||||
*/
|
||||
#ifndef LIBSSH2_VERSION
|
||||
typedef struct _LIBSSH2_SESSION LIBSSH2_SESSION;
|
||||
typedef struct _LIBSSH2_USERAUTH_KBDINT_PROMPT LIBSSH2_USERAUTH_KBDINT_PROMPT;
|
||||
typedef struct _LIBSSH2_USERAUTH_KBDINT_RESPONSE LIBSSH2_USERAUTH_KBDINT_RESPONSE;
|
||||
#endif
|
||||
|
||||
typedef void GIT_CALLBACK(git_credential_ssh_interactive_cb)(
|
||||
const char *name,
|
||||
int name_len,
|
||||
const char *instruction, int instruction_len,
|
||||
int num_prompts, const LIBSSH2_USERAUTH_KBDINT_PROMPT *prompts,
|
||||
LIBSSH2_USERAUTH_KBDINT_RESPONSE *responses,
|
||||
void **abstract);
|
||||
|
||||
|
||||
/**
|
||||
* Create a new ssh keyboard-interactive based credential object.
|
||||
* The supplied credential parameter will be internally duplicated.
|
||||
*
|
||||
* @param out The newly created credential object.
|
||||
* @param username Username to use to authenticate.
|
||||
* @param prompt_callback The callback method used for prompts.
|
||||
* @param payload Additional data to pass to the callback.
|
||||
* @return 0 for success or an error code for failure.
|
||||
*/
|
||||
GIT_EXTERN(int) git_credential_ssh_interactive_new(
|
||||
git_credential **out,
|
||||
const char *username,
|
||||
git_credential_ssh_interactive_cb prompt_callback,
|
||||
void *payload);
|
||||
|
||||
/**
|
||||
* Create a new ssh key credential object used for querying an ssh-agent.
|
||||
* The supplied credential parameter will be internally duplicated.
|
||||
*
|
||||
* @param out The newly created credential object.
|
||||
* @param username username to use to authenticate
|
||||
* @return 0 for success or an error code for failure
|
||||
*/
|
||||
GIT_EXTERN(int) git_credential_ssh_key_from_agent(
|
||||
git_credential **out,
|
||||
const char *username);
|
||||
|
||||
typedef int GIT_CALLBACK(git_credential_sign_cb)(
|
||||
LIBSSH2_SESSION *session,
|
||||
unsigned char **sig, size_t *sig_len,
|
||||
const unsigned char *data, size_t data_len,
|
||||
void **abstract);
|
||||
|
||||
/**
|
||||
* Create an ssh key credential with a custom signing function.
|
||||
*
|
||||
* This lets you use your own function to sign the challenge.
|
||||
*
|
||||
* This function and its credential type is provided for completeness
|
||||
* and wraps `libssh2_userauth_publickey()`, which is undocumented.
|
||||
*
|
||||
* The supplied credential parameter will be internally duplicated.
|
||||
*
|
||||
* @param out The newly created credential object.
|
||||
* @param username username to use to authenticate
|
||||
* @param publickey The bytes of the public key.
|
||||
* @param publickey_len The length of the public key in bytes.
|
||||
* @param sign_callback The callback method to sign the data during the challenge.
|
||||
* @param payload Additional data to pass to the callback.
|
||||
* @return 0 for success or an error code for failure
|
||||
*/
|
||||
GIT_EXTERN(int) git_credential_ssh_custom_new(
|
||||
git_credential **out,
|
||||
const char *username,
|
||||
const char *publickey,
|
||||
size_t publickey_len,
|
||||
git_credential_sign_cb sign_callback,
|
||||
void *payload);
|
||||
|
||||
/** @} */
|
||||
GIT_END_DECL
|
||||
#endif
|
53
3rdparty/libgit2/include/git2/credential_helpers.h
vendored
Normal file
53
3rdparty/libgit2/include/git2/credential_helpers.h
vendored
Normal file
@ -0,0 +1,53 @@
|
||||
/*
|
||||
* Copyright (C) the libgit2 contributors. All rights reserved.
|
||||
*
|
||||
* This file is part of libgit2, distributed under the GNU GPL v2 with
|
||||
* a Linking Exception. For full terms see the included COPYING file.
|
||||
*/
|
||||
#ifndef INCLUDE_git_credential_helpers_h__
|
||||
#define INCLUDE_git_credential_helpers_h__
|
||||
|
||||
#include "transport.h"
|
||||
|
||||
/**
|
||||
* @file git2/credential_helpers.h
|
||||
* @brief Utility functions for credential management
|
||||
* @defgroup git_credential_helpers credential management helpers
|
||||
* @ingroup Git
|
||||
* @{
|
||||
*/
|
||||
GIT_BEGIN_DECL
|
||||
|
||||
/**
|
||||
* Payload for git_credential_userpass_plaintext.
|
||||
*/
|
||||
typedef struct git_credential_userpass_payload {
|
||||
const char *username;
|
||||
const char *password;
|
||||
} git_credential_userpass_payload;
|
||||
|
||||
|
||||
/**
|
||||
* Stock callback usable as a git_credential_acquire_cb. This calls
|
||||
* git_cred_userpass_plaintext_new unless the protocol has not specified
|
||||
* `GIT_CREDENTIAL_USERPASS_PLAINTEXT` as an allowed type.
|
||||
*
|
||||
* @param out The newly created credential object.
|
||||
* @param url The resource for which we are demanding a credential.
|
||||
* @param user_from_url The username that was embedded in a "user\@host"
|
||||
* remote url, or NULL if not included.
|
||||
* @param allowed_types A bitmask stating which credential types are OK to return.
|
||||
* @param payload The payload provided when specifying this callback. (This is
|
||||
* interpreted as a `git_credential_userpass_payload*`.)
|
||||
* @return 0 or an error code.
|
||||
*/
|
||||
GIT_EXTERN(int) git_credential_userpass(
|
||||
git_credential **out,
|
||||
const char *url,
|
||||
const char *user_from_url,
|
||||
unsigned int allowed_types,
|
||||
void *payload);
|
||||
|
||||
/** @} */
|
||||
GIT_END_DECL
|
||||
#endif
|
939
3rdparty/libgit2/include/git2/deprecated.h
vendored
Normal file
939
3rdparty/libgit2/include/git2/deprecated.h
vendored
Normal file
@ -0,0 +1,939 @@
|
||||
/*
|
||||
* Copyright (C) the libgit2 contributors. All rights reserved.
|
||||
*
|
||||
* This file is part of libgit2, distributed under the GNU GPL v2 with
|
||||
* a Linking Exception. For full terms see the included COPYING file.
|
||||
*/
|
||||
#ifndef INCLUDE_git_deprecated_h__
|
||||
#define INCLUDE_git_deprecated_h__
|
||||
|
||||
#include "attr.h"
|
||||
#include "config.h"
|
||||
#include "common.h"
|
||||
#include "blame.h"
|
||||
#include "buffer.h"
|
||||
#include "checkout.h"
|
||||
#include "cherrypick.h"
|
||||
#include "clone.h"
|
||||
#include "describe.h"
|
||||
#include "diff.h"
|
||||
#include "errors.h"
|
||||
#include "filter.h"
|
||||
#include "index.h"
|
||||
#include "indexer.h"
|
||||
#include "merge.h"
|
||||
#include "object.h"
|
||||
#include "proxy.h"
|
||||
#include "refs.h"
|
||||
#include "rebase.h"
|
||||
#include "remote.h"
|
||||
#include "trace.h"
|
||||
#include "repository.h"
|
||||
#include "revert.h"
|
||||
#include "revparse.h"
|
||||
#include "stash.h"
|
||||
#include "status.h"
|
||||
#include "submodule.h"
|
||||
#include "worktree.h"
|
||||
#include "credential.h"
|
||||
#include "credential_helpers.h"
|
||||
|
||||
/*
|
||||
* Users can avoid deprecated functions by defining `GIT_DEPRECATE_HARD`.
|
||||
*/
|
||||
#ifndef GIT_DEPRECATE_HARD
|
||||
|
||||
/*
|
||||
* The credential structures are now opaque by default, and their
|
||||
* definition has moved into the `sys/credential.h` header; include
|
||||
* them here for backward compatibility.
|
||||
*/
|
||||
#include "sys/credential.h"
|
||||
|
||||
/**
|
||||
* @file git2/deprecated.h
|
||||
* @brief libgit2 deprecated functions and values
|
||||
* @ingroup Git
|
||||
* @{
|
||||
*/
|
||||
GIT_BEGIN_DECL
|
||||
|
||||
/** @name Deprecated Attribute Constants
|
||||
*
|
||||
* These enumeration values are retained for backward compatibility.
|
||||
* The newer versions of these functions should be preferred in all
|
||||
* new code.
|
||||
*
|
||||
* There is no plan to remove these backward compatibility values at
|
||||
* this time.
|
||||
*/
|
||||
/**@{*/
|
||||
|
||||
#define GIT_ATTR_UNSPECIFIED_T GIT_ATTR_VALUE_UNSPECIFIED
|
||||
#define GIT_ATTR_TRUE_T GIT_ATTR_VALUE_TRUE
|
||||
#define GIT_ATTR_FALSE_T GIT_ATTR_VALUE_FALSE
|
||||
#define GIT_ATTR_VALUE_T GIT_ATTR_VALUE_STRING
|
||||
|
||||
#define GIT_ATTR_TRUE(attr) GIT_ATTR_IS_TRUE(attr)
|
||||
#define GIT_ATTR_FALSE(attr) GIT_ATTR_IS_FALSE(attr)
|
||||
#define GIT_ATTR_UNSPECIFIED(attr) GIT_ATTR_IS_UNSPECIFIED(attr)
|
||||
|
||||
typedef git_attr_value_t git_attr_t;
|
||||
|
||||
/**@}*/
|
||||
|
||||
/** @name Deprecated Blob Functions and Constants
|
||||
*
|
||||
* These functions and enumeration values are retained for backward
|
||||
* compatibility. The newer versions of these functions and values
|
||||
* should be preferred in all new code.
|
||||
*
|
||||
* There is no plan to remove these backward compatibility values at
|
||||
* this time.
|
||||
*/
|
||||
/**@{*/
|
||||
|
||||
#define GIT_BLOB_FILTER_ATTTRIBUTES_FROM_HEAD GIT_BLOB_FILTER_ATTRIBUTES_FROM_HEAD
|
||||
|
||||
GIT_EXTERN(int) git_blob_create_fromworkdir(git_oid *id, git_repository *repo, const char *relative_path);
|
||||
GIT_EXTERN(int) git_blob_create_fromdisk(git_oid *id, git_repository *repo, const char *path);
|
||||
GIT_EXTERN(int) git_blob_create_fromstream(
|
||||
git_writestream **out,
|
||||
git_repository *repo,
|
||||
const char *hintpath);
|
||||
GIT_EXTERN(int) git_blob_create_fromstream_commit(
|
||||
git_oid *out,
|
||||
git_writestream *stream);
|
||||
GIT_EXTERN(int) git_blob_create_frombuffer(
|
||||
git_oid *id, git_repository *repo, const void *buffer, size_t len);
|
||||
|
||||
/** Deprecated in favor of `git_blob_filter`.
|
||||
*
|
||||
* @deprecated Use git_blob_filter
|
||||
* @see git_blob_filter
|
||||
*/
|
||||
GIT_EXTERN(int) git_blob_filtered_content(
|
||||
git_buf *out,
|
||||
git_blob *blob,
|
||||
const char *as_path,
|
||||
int check_for_binary_data);
|
||||
|
||||
/**@}*/
|
||||
|
||||
/** @name Deprecated Filter Functions
|
||||
*
|
||||
* These functions are retained for backward compatibility. The
|
||||
* newer versions of these functions should be preferred in all
|
||||
* new code.
|
||||
*
|
||||
* There is no plan to remove these backward compatibility values at
|
||||
* this time.
|
||||
*/
|
||||
/**@{*/
|
||||
|
||||
/** Deprecated in favor of `git_filter_list_stream_buffer`.
|
||||
*
|
||||
* @deprecated Use git_filter_list_stream_buffer
|
||||
* @see Use git_filter_list_stream_buffer
|
||||
*/
|
||||
GIT_EXTERN(int) git_filter_list_stream_data(
|
||||
git_filter_list *filters,
|
||||
git_buf *data,
|
||||
git_writestream *target);
|
||||
|
||||
/** Deprecated in favor of `git_filter_list_apply_to_buffer`.
|
||||
*
|
||||
* @deprecated Use git_filter_list_apply_to_buffer
|
||||
* @see Use git_filter_list_apply_to_buffer
|
||||
*/
|
||||
GIT_EXTERN(int) git_filter_list_apply_to_data(
|
||||
git_buf *out,
|
||||
git_filter_list *filters,
|
||||
git_buf *in);
|
||||
|
||||
/**@}*/
|
||||
|
||||
/** @name Deprecated Tree Functions
|
||||
*
|
||||
* These functions are retained for backward compatibility. The
|
||||
* newer versions of these functions and values should be preferred
|
||||
* in all new code.
|
||||
*
|
||||
* There is no plan to remove these backward compatibility values at
|
||||
* this time.
|
||||
*/
|
||||
/**@{*/
|
||||
|
||||
/**
|
||||
* Write the contents of the tree builder as a tree object.
|
||||
* This is an alias of `git_treebuilder_write` and is preserved
|
||||
* for backward compatibility.
|
||||
*
|
||||
* This function is deprecated, but there is no plan to remove this
|
||||
* function at this time.
|
||||
*
|
||||
* @deprecated Use git_treebuilder_write
|
||||
* @see git_treebuilder_write
|
||||
*/
|
||||
GIT_EXTERN(int) git_treebuilder_write_with_buffer(
|
||||
git_oid *oid, git_treebuilder *bld, git_buf *tree);
|
||||
|
||||
/**@}*/
|
||||
|
||||
/** @name Deprecated Buffer Functions
|
||||
*
|
||||
* These functions and enumeration values are retained for backward
|
||||
* compatibility. The newer versions of these functions should be
|
||||
* preferred in all new code.
|
||||
*
|
||||
* There is no plan to remove these backward compatibility values at
|
||||
* this time.
|
||||
*/
|
||||
/**@{*/
|
||||
|
||||
/**
|
||||
* Static initializer for git_buf from static buffer
|
||||
*/
|
||||
#define GIT_BUF_INIT_CONST(STR,LEN) { (char *)(STR), 0, (size_t)(LEN) }
|
||||
|
||||
/**
|
||||
* Resize the buffer allocation to make more space.
|
||||
*
|
||||
* This will attempt to grow the buffer to accommodate the target size.
|
||||
*
|
||||
* If the buffer refers to memory that was not allocated by libgit2 (i.e.
|
||||
* the `asize` field is zero), then `ptr` will be replaced with a newly
|
||||
* allocated block of data. Be careful so that memory allocated by the
|
||||
* caller is not lost. As a special variant, if you pass `target_size` as
|
||||
* 0 and the memory is not allocated by libgit2, this will allocate a new
|
||||
* buffer of size `size` and copy the external data into it.
|
||||
*
|
||||
* Currently, this will never shrink a buffer, only expand it.
|
||||
*
|
||||
* If the allocation fails, this will return an error and the buffer will be
|
||||
* marked as invalid for future operations, invaliding the contents.
|
||||
*
|
||||
* @param buffer The buffer to be resized; may or may not be allocated yet
|
||||
* @param target_size The desired available size
|
||||
* @return 0 on success, -1 on allocation failure
|
||||
*/
|
||||
GIT_EXTERN(int) git_buf_grow(git_buf *buffer, size_t target_size);
|
||||
|
||||
/**
|
||||
* Set buffer to a copy of some raw data.
|
||||
*
|
||||
* @param buffer The buffer to set
|
||||
* @param data The data to copy into the buffer
|
||||
* @param datalen The length of the data to copy into the buffer
|
||||
* @return 0 on success, -1 on allocation failure
|
||||
*/
|
||||
GIT_EXTERN(int) git_buf_set(
|
||||
git_buf *buffer, const void *data, size_t datalen);
|
||||
|
||||
/**
|
||||
* Check quickly if buffer looks like it contains binary data
|
||||
*
|
||||
* @param buf Buffer to check
|
||||
* @return 1 if buffer looks like non-text data
|
||||
*/
|
||||
GIT_EXTERN(int) git_buf_is_binary(const git_buf *buf);
|
||||
|
||||
/**
|
||||
* Check quickly if buffer contains a NUL byte
|
||||
*
|
||||
* @param buf Buffer to check
|
||||
* @return 1 if buffer contains a NUL byte
|
||||
*/
|
||||
GIT_EXTERN(int) git_buf_contains_nul(const git_buf *buf);
|
||||
|
||||
/**
|
||||
* Free the memory referred to by the git_buf. This is an alias of
|
||||
* `git_buf_dispose` and is preserved for backward compatibility.
|
||||
*
|
||||
* This function is deprecated, but there is no plan to remove this
|
||||
* function at this time.
|
||||
*
|
||||
* @deprecated Use git_buf_dispose
|
||||
* @see git_buf_dispose
|
||||
*/
|
||||
GIT_EXTERN(void) git_buf_free(git_buf *buffer);
|
||||
|
||||
/**@}*/
|
||||
|
||||
/** @name Deprecated Commit Definitions
|
||||
*/
|
||||
/**@{*/
|
||||
|
||||
/**
|
||||
* Provide a commit signature during commit creation.
|
||||
*
|
||||
* Callers should instead define a `git_commit_create_cb` that
|
||||
* generates a commit buffer using `git_commit_create_buffer`, sign
|
||||
* that buffer and call `git_commit_create_with_signature`.
|
||||
*
|
||||
* @deprecated use a `git_commit_create_cb` instead
|
||||
*/
|
||||
typedef int (*git_commit_signing_cb)(
|
||||
git_buf *signature,
|
||||
git_buf *signature_field,
|
||||
const char *commit_content,
|
||||
void *payload);
|
||||
|
||||
/**@}*/
|
||||
|
||||
/** @name Deprecated Config Functions and Constants
|
||||
*/
|
||||
/**@{*/
|
||||
|
||||
#define GIT_CVAR_FALSE GIT_CONFIGMAP_FALSE
|
||||
#define GIT_CVAR_TRUE GIT_CONFIGMAP_TRUE
|
||||
#define GIT_CVAR_INT32 GIT_CONFIGMAP_INT32
|
||||
#define GIT_CVAR_STRING GIT_CONFIGMAP_STRING
|
||||
|
||||
typedef git_configmap git_cvar_map;
|
||||
|
||||
/**@}*/
|
||||
|
||||
/** @name Deprecated Diff Functions and Constants
|
||||
*
|
||||
* These functions and enumeration values are retained for backward
|
||||
* compatibility. The newer versions of these functions and values
|
||||
* should be preferred in all new code.
|
||||
*
|
||||
* There is no plan to remove these backward compatibility values at
|
||||
* this time.
|
||||
*/
|
||||
/**@{*/
|
||||
|
||||
/**
|
||||
* Formatting options for diff e-mail generation
|
||||
*/
|
||||
typedef enum {
|
||||
/** Normal patch, the default */
|
||||
GIT_DIFF_FORMAT_EMAIL_NONE = 0,
|
||||
|
||||
/** Don't insert "[PATCH]" in the subject header*/
|
||||
GIT_DIFF_FORMAT_EMAIL_EXCLUDE_SUBJECT_PATCH_MARKER = (1 << 0)
|
||||
|
||||
} git_diff_format_email_flags_t;
|
||||
|
||||
/**
|
||||
* Options for controlling the formatting of the generated e-mail.
|
||||
*/
|
||||
typedef struct {
|
||||
unsigned int version;
|
||||
|
||||
/** see `git_diff_format_email_flags_t` above */
|
||||
uint32_t flags;
|
||||
|
||||
/** This patch number */
|
||||
size_t patch_no;
|
||||
|
||||
/** Total number of patches in this series */
|
||||
size_t total_patches;
|
||||
|
||||
/** id to use for the commit */
|
||||
const git_oid *id;
|
||||
|
||||
/** Summary of the change */
|
||||
const char *summary;
|
||||
|
||||
/** Commit message's body */
|
||||
const char *body;
|
||||
|
||||
/** Author of the change */
|
||||
const git_signature *author;
|
||||
} git_diff_format_email_options;
|
||||
|
||||
#define GIT_DIFF_FORMAT_EMAIL_OPTIONS_VERSION 1
|
||||
#define GIT_DIFF_FORMAT_EMAIL_OPTIONS_INIT {GIT_DIFF_FORMAT_EMAIL_OPTIONS_VERSION, 0, 1, 1, NULL, NULL, NULL, NULL}
|
||||
|
||||
/**
|
||||
* Create an e-mail ready patch from a diff.
|
||||
*
|
||||
* @deprecated git_email_create_from_diff
|
||||
* @see git_email_create_from_diff
|
||||
*/
|
||||
GIT_EXTERN(int) git_diff_format_email(
|
||||
git_buf *out,
|
||||
git_diff *diff,
|
||||
const git_diff_format_email_options *opts);
|
||||
|
||||
/**
|
||||
* Create an e-mail ready patch for a commit.
|
||||
*
|
||||
* @deprecated git_email_create_from_commit
|
||||
* @see git_email_create_from_commit
|
||||
*/
|
||||
GIT_EXTERN(int) git_diff_commit_as_email(
|
||||
git_buf *out,
|
||||
git_repository *repo,
|
||||
git_commit *commit,
|
||||
size_t patch_no,
|
||||
size_t total_patches,
|
||||
uint32_t flags,
|
||||
const git_diff_options *diff_opts);
|
||||
|
||||
/**
|
||||
* Initialize git_diff_format_email_options structure
|
||||
*
|
||||
* Initializes a `git_diff_format_email_options` with default values. Equivalent
|
||||
* to creating an instance with GIT_DIFF_FORMAT_EMAIL_OPTIONS_INIT.
|
||||
*
|
||||
* @param opts The `git_blame_options` struct to initialize.
|
||||
* @param version The struct version; pass `GIT_DIFF_FORMAT_EMAIL_OPTIONS_VERSION`.
|
||||
* @return Zero on success; -1 on failure.
|
||||
*/
|
||||
GIT_EXTERN(int) git_diff_format_email_options_init(
|
||||
git_diff_format_email_options *opts,
|
||||
unsigned int version);
|
||||
|
||||
/**@}*/
|
||||
|
||||
/** @name Deprecated Error Functions and Constants
|
||||
*
|
||||
* These functions and enumeration values are retained for backward
|
||||
* compatibility. The newer versions of these functions and values
|
||||
* should be preferred in all new code.
|
||||
*
|
||||
* There is no plan to remove these backward compatibility values at
|
||||
* this time.
|
||||
*/
|
||||
/**@{*/
|
||||
|
||||
#define GITERR_NONE GIT_ERROR_NONE
|
||||
#define GITERR_NOMEMORY GIT_ERROR_NOMEMORY
|
||||
#define GITERR_OS GIT_ERROR_OS
|
||||
#define GITERR_INVALID GIT_ERROR_INVALID
|
||||
#define GITERR_REFERENCE GIT_ERROR_REFERENCE
|
||||
#define GITERR_ZLIB GIT_ERROR_ZLIB
|
||||
#define GITERR_REPOSITORY GIT_ERROR_REPOSITORY
|
||||
#define GITERR_CONFIG GIT_ERROR_CONFIG
|
||||
#define GITERR_REGEX GIT_ERROR_REGEX
|
||||
#define GITERR_ODB GIT_ERROR_ODB
|
||||
#define GITERR_INDEX GIT_ERROR_INDEX
|
||||
#define GITERR_OBJECT GIT_ERROR_OBJECT
|
||||
#define GITERR_NET GIT_ERROR_NET
|
||||
#define GITERR_TAG GIT_ERROR_TAG
|
||||
#define GITERR_TREE GIT_ERROR_TREE
|
||||
#define GITERR_INDEXER GIT_ERROR_INDEXER
|
||||
#define GITERR_SSL GIT_ERROR_SSL
|
||||
#define GITERR_SUBMODULE GIT_ERROR_SUBMODULE
|
||||
#define GITERR_THREAD GIT_ERROR_THREAD
|
||||
#define GITERR_STASH GIT_ERROR_STASH
|
||||
#define GITERR_CHECKOUT GIT_ERROR_CHECKOUT
|
||||
#define GITERR_FETCHHEAD GIT_ERROR_FETCHHEAD
|
||||
#define GITERR_MERGE GIT_ERROR_MERGE
|
||||
#define GITERR_SSH GIT_ERROR_SSH
|
||||
#define GITERR_FILTER GIT_ERROR_FILTER
|
||||
#define GITERR_REVERT GIT_ERROR_REVERT
|
||||
#define GITERR_CALLBACK GIT_ERROR_CALLBACK
|
||||
#define GITERR_CHERRYPICK GIT_ERROR_CHERRYPICK
|
||||
#define GITERR_DESCRIBE GIT_ERROR_DESCRIBE
|
||||
#define GITERR_REBASE GIT_ERROR_REBASE
|
||||
#define GITERR_FILESYSTEM GIT_ERROR_FILESYSTEM
|
||||
#define GITERR_PATCH GIT_ERROR_PATCH
|
||||
#define GITERR_WORKTREE GIT_ERROR_WORKTREE
|
||||
#define GITERR_SHA1 GIT_ERROR_SHA1
|
||||
|
||||
#define GIT_ERROR_SHA1 GIT_ERROR_SHA
|
||||
|
||||
/**
|
||||
* Return the last `git_error` object that was generated for the
|
||||
* current thread. This is an alias of `git_error_last` and is
|
||||
* preserved for backward compatibility.
|
||||
*
|
||||
* This function is deprecated, but there is no plan to remove this
|
||||
* function at this time.
|
||||
*
|
||||
* @deprecated Use git_error_last
|
||||
* @see git_error_last
|
||||
*/
|
||||
GIT_EXTERN(const git_error *) giterr_last(void);
|
||||
|
||||
/**
|
||||
* Clear the last error. This is an alias of `git_error_last` and is
|
||||
* preserved for backward compatibility.
|
||||
*
|
||||
* This function is deprecated, but there is no plan to remove this
|
||||
* function at this time.
|
||||
*
|
||||
* @deprecated Use git_error_clear
|
||||
* @see git_error_clear
|
||||
*/
|
||||
GIT_EXTERN(void) giterr_clear(void);
|
||||
|
||||
/**
|
||||
* Sets the error message to the given string. This is an alias of
|
||||
* `git_error_set_str` and is preserved for backward compatibility.
|
||||
*
|
||||
* This function is deprecated, but there is no plan to remove this
|
||||
* function at this time.
|
||||
*
|
||||
* @deprecated Use git_error_set_str
|
||||
* @see git_error_set_str
|
||||
*/
|
||||
GIT_EXTERN(void) giterr_set_str(int error_class, const char *string);
|
||||
|
||||
/**
|
||||
* Indicates that an out-of-memory situation occurred. This is an alias
|
||||
* of `git_error_set_oom` and is preserved for backward compatibility.
|
||||
*
|
||||
* This function is deprecated, but there is no plan to remove this
|
||||
* function at this time.
|
||||
*
|
||||
* @deprecated Use git_error_set_oom
|
||||
* @see git_error_set_oom
|
||||
*/
|
||||
GIT_EXTERN(void) giterr_set_oom(void);
|
||||
|
||||
/**@}*/
|
||||
|
||||
/** @name Deprecated Index Functions and Constants
|
||||
*
|
||||
* These functions and enumeration values are retained for backward
|
||||
* compatibility. The newer versions of these values should be
|
||||
* preferred in all new code.
|
||||
*
|
||||
* There is no plan to remove these backward compatibility values at
|
||||
* this time.
|
||||
*/
|
||||
/**@{*/
|
||||
|
||||
#define GIT_IDXENTRY_NAMEMASK GIT_INDEX_ENTRY_NAMEMASK
|
||||
#define GIT_IDXENTRY_STAGEMASK GIT_INDEX_ENTRY_STAGEMASK
|
||||
#define GIT_IDXENTRY_STAGESHIFT GIT_INDEX_ENTRY_STAGESHIFT
|
||||
|
||||
/* The git_indxentry_flag_t enum */
|
||||
#define GIT_IDXENTRY_EXTENDED GIT_INDEX_ENTRY_EXTENDED
|
||||
#define GIT_IDXENTRY_VALID GIT_INDEX_ENTRY_VALID
|
||||
|
||||
#define GIT_IDXENTRY_STAGE(E) GIT_INDEX_ENTRY_STAGE(E)
|
||||
#define GIT_IDXENTRY_STAGE_SET(E,S) GIT_INDEX_ENTRY_STAGE_SET(E,S)
|
||||
|
||||
/* The git_idxentry_extended_flag_t enum */
|
||||
#define GIT_IDXENTRY_INTENT_TO_ADD GIT_INDEX_ENTRY_INTENT_TO_ADD
|
||||
#define GIT_IDXENTRY_SKIP_WORKTREE GIT_INDEX_ENTRY_SKIP_WORKTREE
|
||||
#define GIT_IDXENTRY_EXTENDED_FLAGS (GIT_INDEX_ENTRY_INTENT_TO_ADD | GIT_INDEX_ENTRY_SKIP_WORKTREE)
|
||||
#define GIT_IDXENTRY_EXTENDED2 (1 << 15)
|
||||
#define GIT_IDXENTRY_UPDATE (1 << 0)
|
||||
#define GIT_IDXENTRY_REMOVE (1 << 1)
|
||||
#define GIT_IDXENTRY_UPTODATE (1 << 2)
|
||||
#define GIT_IDXENTRY_ADDED (1 << 3)
|
||||
#define GIT_IDXENTRY_HASHED (1 << 4)
|
||||
#define GIT_IDXENTRY_UNHASHED (1 << 5)
|
||||
#define GIT_IDXENTRY_WT_REMOVE (1 << 6)
|
||||
#define GIT_IDXENTRY_CONFLICTED (1 << 7)
|
||||
#define GIT_IDXENTRY_UNPACKED (1 << 8)
|
||||
#define GIT_IDXENTRY_NEW_SKIP_WORKTREE (1 << 9)
|
||||
|
||||
/* The git_index_capability_t enum */
|
||||
#define GIT_INDEXCAP_IGNORE_CASE GIT_INDEX_CAPABILITY_IGNORE_CASE
|
||||
#define GIT_INDEXCAP_NO_FILEMODE GIT_INDEX_CAPABILITY_NO_FILEMODE
|
||||
#define GIT_INDEXCAP_NO_SYMLINKS GIT_INDEX_CAPABILITY_NO_SYMLINKS
|
||||
#define GIT_INDEXCAP_FROM_OWNER GIT_INDEX_CAPABILITY_FROM_OWNER
|
||||
|
||||
GIT_EXTERN(int) git_index_add_frombuffer(
|
||||
git_index *index,
|
||||
const git_index_entry *entry,
|
||||
const void *buffer, size_t len);
|
||||
|
||||
/**@}*/
|
||||
|
||||
/** @name Deprecated Object Constants
|
||||
*
|
||||
* These enumeration values are retained for backward compatibility. The
|
||||
* newer versions of these values should be preferred in all new code.
|
||||
*
|
||||
* There is no plan to remove these backward compatibility values at
|
||||
* this time.
|
||||
*/
|
||||
/**@{*/
|
||||
|
||||
#define git_otype git_object_t
|
||||
|
||||
#define GIT_OBJ_ANY GIT_OBJECT_ANY
|
||||
#define GIT_OBJ_BAD GIT_OBJECT_INVALID
|
||||
#define GIT_OBJ__EXT1 0
|
||||
#define GIT_OBJ_COMMIT GIT_OBJECT_COMMIT
|
||||
#define GIT_OBJ_TREE GIT_OBJECT_TREE
|
||||
#define GIT_OBJ_BLOB GIT_OBJECT_BLOB
|
||||
#define GIT_OBJ_TAG GIT_OBJECT_TAG
|
||||
#define GIT_OBJ__EXT2 5
|
||||
#define GIT_OBJ_OFS_DELTA GIT_OBJECT_OFS_DELTA
|
||||
#define GIT_OBJ_REF_DELTA GIT_OBJECT_REF_DELTA
|
||||
|
||||
/**
|
||||
* Get the size in bytes for the structure which
|
||||
* acts as an in-memory representation of any given
|
||||
* object type.
|
||||
*
|
||||
* For all the core types, this would the equivalent
|
||||
* of calling `sizeof(git_commit)` if the core types
|
||||
* were not opaque on the external API.
|
||||
*
|
||||
* @param type object type to get its size
|
||||
* @return size in bytes of the object
|
||||
*/
|
||||
GIT_EXTERN(size_t) git_object__size(git_object_t type);
|
||||
|
||||
/**@}*/
|
||||
|
||||
/** @name Deprecated Remote Functions
|
||||
*
|
||||
* These functions are retained for backward compatibility. The newer
|
||||
* versions of these functions should be preferred in all new code.
|
||||
*
|
||||
* There is no plan to remove these backward compatibility functions at
|
||||
* this time.
|
||||
*/
|
||||
/**@{*/
|
||||
|
||||
/**
|
||||
* Ensure the remote name is well-formed.
|
||||
*
|
||||
* @deprecated Use git_remote_name_is_valid
|
||||
* @param remote_name name to be checked.
|
||||
* @return 1 if the reference name is acceptable; 0 if it isn't
|
||||
*/
|
||||
GIT_EXTERN(int) git_remote_is_valid_name(const char *remote_name);
|
||||
|
||||
/**@}*/
|
||||
|
||||
/** @name Deprecated Reference Functions and Constants
|
||||
*
|
||||
* These functions and enumeration values are retained for backward
|
||||
* compatibility. The newer versions of these values should be
|
||||
* preferred in all new code.
|
||||
*
|
||||
* There is no plan to remove these backward compatibility values at
|
||||
* this time.
|
||||
*/
|
||||
/**@{*/
|
||||
|
||||
/** Basic type of any Git reference. */
|
||||
#define git_ref_t git_reference_t
|
||||
#define git_reference_normalize_t git_reference_format_t
|
||||
|
||||
#define GIT_REF_INVALID GIT_REFERENCE_INVALID
|
||||
#define GIT_REF_OID GIT_REFERENCE_DIRECT
|
||||
#define GIT_REF_SYMBOLIC GIT_REFERENCE_SYMBOLIC
|
||||
#define GIT_REF_LISTALL GIT_REFERENCE_ALL
|
||||
|
||||
#define GIT_REF_FORMAT_NORMAL GIT_REFERENCE_FORMAT_NORMAL
|
||||
#define GIT_REF_FORMAT_ALLOW_ONELEVEL GIT_REFERENCE_FORMAT_ALLOW_ONELEVEL
|
||||
#define GIT_REF_FORMAT_REFSPEC_PATTERN GIT_REFERENCE_FORMAT_REFSPEC_PATTERN
|
||||
#define GIT_REF_FORMAT_REFSPEC_SHORTHAND GIT_REFERENCE_FORMAT_REFSPEC_SHORTHAND
|
||||
|
||||
/**
|
||||
* Ensure the reference name is well-formed.
|
||||
*
|
||||
* Valid reference names must follow one of two patterns:
|
||||
*
|
||||
* 1. Top-level names must contain only capital letters and underscores,
|
||||
* and must begin and end with a letter. (e.g. "HEAD", "ORIG_HEAD").
|
||||
* 2. Names prefixed with "refs/" can be almost anything. You must avoid
|
||||
* the characters '~', '^', ':', '\\', '?', '[', and '*', and the
|
||||
* sequences ".." and "@{" which have special meaning to revparse.
|
||||
*
|
||||
* @deprecated Use git_reference_name_is_valid
|
||||
* @param refname name to be checked.
|
||||
* @return 1 if the reference name is acceptable; 0 if it isn't
|
||||
*/
|
||||
GIT_EXTERN(int) git_reference_is_valid_name(const char *refname);
|
||||
|
||||
GIT_EXTERN(int) git_tag_create_frombuffer(
|
||||
git_oid *oid,
|
||||
git_repository *repo,
|
||||
const char *buffer,
|
||||
int force);
|
||||
|
||||
/**@}*/
|
||||
|
||||
/** @name Deprecated Revspec Constants
|
||||
*
|
||||
* These enumeration values are retained for backward compatibility.
|
||||
* The newer versions of these values should be preferred in all new
|
||||
* code.
|
||||
*
|
||||
* There is no plan to remove these backward compatibility values at
|
||||
* this time.
|
||||
*/
|
||||
/**@{*/
|
||||
|
||||
typedef git_revspec_t git_revparse_mode_t;
|
||||
|
||||
#define GIT_REVPARSE_SINGLE GIT_REVSPEC_SINGLE
|
||||
#define GIT_REVPARSE_RANGE GIT_REVSPEC_RANGE
|
||||
#define GIT_REVPARSE_MERGE_BASE GIT_REVSPEC_MERGE_BASE
|
||||
|
||||
/**@}*/
|
||||
|
||||
/** @name Deprecated Credential Types
|
||||
*
|
||||
* These types are retained for backward compatibility. The newer
|
||||
* versions of these values should be preferred in all new code.
|
||||
*
|
||||
* There is no plan to remove these backward compatibility values at
|
||||
* this time.
|
||||
*/
|
||||
/**@{*/
|
||||
|
||||
typedef git_credential git_cred;
|
||||
typedef git_credential_userpass_plaintext git_cred_userpass_plaintext;
|
||||
typedef git_credential_username git_cred_username;
|
||||
typedef git_credential_default git_cred_default;
|
||||
typedef git_credential_ssh_key git_cred_ssh_key;
|
||||
typedef git_credential_ssh_interactive git_cred_ssh_interactive;
|
||||
typedef git_credential_ssh_custom git_cred_ssh_custom;
|
||||
|
||||
typedef git_credential_acquire_cb git_cred_acquire_cb;
|
||||
typedef git_credential_sign_cb git_cred_sign_callback;
|
||||
typedef git_credential_sign_cb git_cred_sign_cb;
|
||||
typedef git_credential_ssh_interactive_cb git_cred_ssh_interactive_callback;
|
||||
typedef git_credential_ssh_interactive_cb git_cred_ssh_interactive_cb;
|
||||
|
||||
#define git_credtype_t git_credential_t
|
||||
|
||||
#define GIT_CREDTYPE_USERPASS_PLAINTEXT GIT_CREDENTIAL_USERPASS_PLAINTEXT
|
||||
#define GIT_CREDTYPE_SSH_KEY GIT_CREDENTIAL_SSH_KEY
|
||||
#define GIT_CREDTYPE_SSH_CUSTOM GIT_CREDENTIAL_SSH_CUSTOM
|
||||
#define GIT_CREDTYPE_DEFAULT GIT_CREDENTIAL_DEFAULT
|
||||
#define GIT_CREDTYPE_SSH_INTERACTIVE GIT_CREDENTIAL_SSH_INTERACTIVE
|
||||
#define GIT_CREDTYPE_USERNAME GIT_CREDENTIAL_USERNAME
|
||||
#define GIT_CREDTYPE_SSH_MEMORY GIT_CREDENTIAL_SSH_MEMORY
|
||||
|
||||
GIT_EXTERN(void) git_cred_free(git_credential *cred);
|
||||
GIT_EXTERN(int) git_cred_has_username(git_credential *cred);
|
||||
GIT_EXTERN(const char *) git_cred_get_username(git_credential *cred);
|
||||
GIT_EXTERN(int) git_cred_userpass_plaintext_new(
|
||||
git_credential **out,
|
||||
const char *username,
|
||||
const char *password);
|
||||
GIT_EXTERN(int) git_cred_default_new(git_credential **out);
|
||||
GIT_EXTERN(int) git_cred_username_new(git_credential **out, const char *username);
|
||||
GIT_EXTERN(int) git_cred_ssh_key_new(
|
||||
git_credential **out,
|
||||
const char *username,
|
||||
const char *publickey,
|
||||
const char *privatekey,
|
||||
const char *passphrase);
|
||||
GIT_EXTERN(int) git_cred_ssh_key_memory_new(
|
||||
git_credential **out,
|
||||
const char *username,
|
||||
const char *publickey,
|
||||
const char *privatekey,
|
||||
const char *passphrase);
|
||||
GIT_EXTERN(int) git_cred_ssh_interactive_new(
|
||||
git_credential **out,
|
||||
const char *username,
|
||||
git_credential_ssh_interactive_cb prompt_callback,
|
||||
void *payload);
|
||||
GIT_EXTERN(int) git_cred_ssh_key_from_agent(
|
||||
git_credential **out,
|
||||
const char *username);
|
||||
GIT_EXTERN(int) git_cred_ssh_custom_new(
|
||||
git_credential **out,
|
||||
const char *username,
|
||||
const char *publickey,
|
||||
size_t publickey_len,
|
||||
git_credential_sign_cb sign_callback,
|
||||
void *payload);
|
||||
|
||||
/* Deprecated Credential Helper Types */
|
||||
|
||||
typedef git_credential_userpass_payload git_cred_userpass_payload;
|
||||
|
||||
GIT_EXTERN(int) git_cred_userpass(
|
||||
git_credential **out,
|
||||
const char *url,
|
||||
const char *user_from_url,
|
||||
unsigned int allowed_types,
|
||||
void *payload);
|
||||
|
||||
/**@}*/
|
||||
|
||||
/** @name Deprecated Trace Callback Types
|
||||
*
|
||||
* These types are retained for backward compatibility. The newer
|
||||
* versions of these values should be preferred in all new code.
|
||||
*
|
||||
* There is no plan to remove these backward compatibility values at
|
||||
* this time.
|
||||
*/
|
||||
/**@{*/
|
||||
|
||||
typedef git_trace_cb git_trace_callback;
|
||||
|
||||
/**@}*/
|
||||
|
||||
/** @name Deprecated Object ID Types
|
||||
*
|
||||
* These types are retained for backward compatibility. The newer
|
||||
* versions of these values should be preferred in all new code.
|
||||
*
|
||||
* There is no plan to remove these backward compatibility values at
|
||||
* this time.
|
||||
*/
|
||||
/**@{*/
|
||||
|
||||
#ifndef GIT_EXPERIMENTAL_SHA256
|
||||
# define GIT_OID_RAWSZ GIT_OID_SHA1_SIZE
|
||||
# define GIT_OID_HEXSZ GIT_OID_SHA1_HEXSIZE
|
||||
# define GIT_OID_HEX_ZERO GIT_OID_SHA1_HEXZERO
|
||||
#endif
|
||||
|
||||
GIT_EXTERN(int) git_oid_iszero(const git_oid *id);
|
||||
|
||||
/**@}*/
|
||||
|
||||
/** @name Deprecated OID Array Functions
|
||||
*
|
||||
* These types are retained for backward compatibility. The newer
|
||||
* versions of these values should be preferred in all new code.
|
||||
*
|
||||
* There is no plan to remove these backward compatibility values at
|
||||
* this time.
|
||||
*/
|
||||
/**@{*/
|
||||
|
||||
/**
|
||||
* Free the memory referred to by the git_oidarray. This is an alias of
|
||||
* `git_oidarray_dispose` and is preserved for backward compatibility.
|
||||
*
|
||||
* This function is deprecated, but there is no plan to remove this
|
||||
* function at this time.
|
||||
*
|
||||
* @deprecated Use git_oidarray_dispose
|
||||
* @see git_oidarray_dispose
|
||||
*/
|
||||
GIT_EXTERN(void) git_oidarray_free(git_oidarray *array);
|
||||
|
||||
/**@}*/
|
||||
|
||||
/** @name Deprecated Transfer Progress Types
|
||||
*
|
||||
* These types are retained for backward compatibility. The newer
|
||||
* versions of these values should be preferred in all new code.
|
||||
*
|
||||
* There is no plan to remove these backward compatibility values at
|
||||
* this time.
|
||||
*/
|
||||
/**@{*/
|
||||
|
||||
/**
|
||||
* This structure is used to provide callers information about the
|
||||
* progress of indexing a packfile.
|
||||
*
|
||||
* This type is deprecated, but there is no plan to remove this
|
||||
* type definition at this time.
|
||||
*/
|
||||
typedef git_indexer_progress git_transfer_progress;
|
||||
|
||||
/**
|
||||
* Type definition for progress callbacks during indexing.
|
||||
*
|
||||
* This type is deprecated, but there is no plan to remove this
|
||||
* type definition at this time.
|
||||
*/
|
||||
typedef git_indexer_progress_cb git_transfer_progress_cb;
|
||||
|
||||
/**
|
||||
* Type definition for push transfer progress callbacks.
|
||||
*
|
||||
* This type is deprecated, but there is no plan to remove this
|
||||
* type definition at this time.
|
||||
*/
|
||||
typedef git_push_transfer_progress_cb git_push_transfer_progress;
|
||||
|
||||
/** The type of a remote completion event */
|
||||
#define git_remote_completion_type git_remote_completion_t
|
||||
|
||||
/**
|
||||
* Callback for listing the remote heads
|
||||
*/
|
||||
typedef int GIT_CALLBACK(git_headlist_cb)(git_remote_head *rhead, void *payload);
|
||||
|
||||
/**@}*/
|
||||
|
||||
/** @name Deprecated String Array Functions
|
||||
*
|
||||
* These types are retained for backward compatibility. The newer
|
||||
* versions of these values should be preferred in all new code.
|
||||
*
|
||||
* There is no plan to remove these backward compatibility values at
|
||||
* this time.
|
||||
*/
|
||||
/**@{*/
|
||||
|
||||
/**
|
||||
* Copy a string array object from source to target.
|
||||
*
|
||||
* This function is deprecated, but there is no plan to remove this
|
||||
* function at this time.
|
||||
*
|
||||
* @param tgt target
|
||||
* @param src source
|
||||
* @return 0 on success, < 0 on allocation failure
|
||||
*/
|
||||
GIT_EXTERN(int) git_strarray_copy(git_strarray *tgt, const git_strarray *src);
|
||||
|
||||
/**
|
||||
* Free the memory referred to by the git_strarray. This is an alias of
|
||||
* `git_strarray_dispose` and is preserved for backward compatibility.
|
||||
*
|
||||
* This function is deprecated, but there is no plan to remove this
|
||||
* function at this time.
|
||||
*
|
||||
* @deprecated Use git_strarray_dispose
|
||||
* @see git_strarray_dispose
|
||||
*/
|
||||
GIT_EXTERN(void) git_strarray_free(git_strarray *array);
|
||||
|
||||
/**@}*/
|
||||
|
||||
/** @name Deprecated Options Initialization Functions
|
||||
*
|
||||
* These functions are retained for backward compatibility. The newer
|
||||
* versions of these functions should be preferred in all new code.
|
||||
*
|
||||
* There is no plan to remove these backward compatibility functions at
|
||||
* this time.
|
||||
*/
|
||||
/**@{*/
|
||||
|
||||
GIT_EXTERN(int) git_blame_init_options(git_blame_options *opts, unsigned int version);
|
||||
GIT_EXTERN(int) git_checkout_init_options(git_checkout_options *opts, unsigned int version);
|
||||
GIT_EXTERN(int) git_cherrypick_init_options(git_cherrypick_options *opts, unsigned int version);
|
||||
GIT_EXTERN(int) git_clone_init_options(git_clone_options *opts, unsigned int version);
|
||||
GIT_EXTERN(int) git_describe_init_options(git_describe_options *opts, unsigned int version);
|
||||
GIT_EXTERN(int) git_describe_init_format_options(git_describe_format_options *opts, unsigned int version);
|
||||
GIT_EXTERN(int) git_diff_init_options(git_diff_options *opts, unsigned int version);
|
||||
GIT_EXTERN(int) git_diff_find_init_options(git_diff_find_options *opts, unsigned int version);
|
||||
GIT_EXTERN(int) git_diff_format_email_init_options(git_diff_format_email_options *opts, unsigned int version);
|
||||
GIT_EXTERN(int) git_diff_patchid_init_options(git_diff_patchid_options *opts, unsigned int version);
|
||||
GIT_EXTERN(int) git_fetch_init_options(git_fetch_options *opts, unsigned int version);
|
||||
GIT_EXTERN(int) git_indexer_init_options(git_indexer_options *opts, unsigned int version);
|
||||
GIT_EXTERN(int) git_merge_init_options(git_merge_options *opts, unsigned int version);
|
||||
GIT_EXTERN(int) git_merge_file_init_input(git_merge_file_input *input, unsigned int version);
|
||||
GIT_EXTERN(int) git_merge_file_init_options(git_merge_file_options *opts, unsigned int version);
|
||||
GIT_EXTERN(int) git_proxy_init_options(git_proxy_options *opts, unsigned int version);
|
||||
GIT_EXTERN(int) git_push_init_options(git_push_options *opts, unsigned int version);
|
||||
GIT_EXTERN(int) git_rebase_init_options(git_rebase_options *opts, unsigned int version);
|
||||
GIT_EXTERN(int) git_remote_create_init_options(git_remote_create_options *opts, unsigned int version);
|
||||
GIT_EXTERN(int) git_repository_init_init_options(git_repository_init_options *opts, unsigned int version);
|
||||
GIT_EXTERN(int) git_revert_init_options(git_revert_options *opts, unsigned int version);
|
||||
GIT_EXTERN(int) git_stash_apply_init_options(git_stash_apply_options *opts, unsigned int version);
|
||||
GIT_EXTERN(int) git_status_init_options(git_status_options *opts, unsigned int version);
|
||||
GIT_EXTERN(int) git_submodule_update_init_options(git_submodule_update_options *opts, unsigned int version);
|
||||
GIT_EXTERN(int) git_worktree_add_init_options(git_worktree_add_options *opts, unsigned int version);
|
||||
GIT_EXTERN(int) git_worktree_prune_init_options(git_worktree_prune_options *opts, unsigned int version);
|
||||
|
||||
/**@}*/
|
||||
|
||||
/** @} */
|
||||
GIT_END_DECL
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
194
3rdparty/libgit2/include/git2/describe.h
vendored
Normal file
194
3rdparty/libgit2/include/git2/describe.h
vendored
Normal file
@ -0,0 +1,194 @@
|
||||
/*
|
||||
* Copyright (C) the libgit2 contributors. All rights reserved.
|
||||
*
|
||||
* This file is part of libgit2, distributed under the GNU GPL v2 with
|
||||
* a Linking Exception. For full terms see the included COPYING file.
|
||||
*/
|
||||
#ifndef INCLUDE_git_describe_h__
|
||||
#define INCLUDE_git_describe_h__
|
||||
|
||||
#include "common.h"
|
||||
#include "types.h"
|
||||
#include "buffer.h"
|
||||
|
||||
/**
|
||||
* @file git2/describe.h
|
||||
* @brief Git describing routines
|
||||
* @defgroup git_describe Git describing routines
|
||||
* @ingroup Git
|
||||
* @{
|
||||
*/
|
||||
GIT_BEGIN_DECL
|
||||
|
||||
/**
|
||||
* Reference lookup strategy
|
||||
*
|
||||
* These behave like the --tags and --all options to git-describe,
|
||||
* namely they say to look for any reference in either refs/tags/ or
|
||||
* refs/ respectively.
|
||||
*/
|
||||
typedef enum {
|
||||
GIT_DESCRIBE_DEFAULT,
|
||||
GIT_DESCRIBE_TAGS,
|
||||
GIT_DESCRIBE_ALL
|
||||
} git_describe_strategy_t;
|
||||
|
||||
/**
|
||||
* Describe options structure
|
||||
*
|
||||
* Initialize with `GIT_DESCRIBE_OPTIONS_INIT`. Alternatively, you can
|
||||
* use `git_describe_options_init`.
|
||||
*
|
||||
*/
|
||||
typedef struct git_describe_options {
|
||||
unsigned int version;
|
||||
|
||||
unsigned int max_candidates_tags; /**< default: 10 */
|
||||
unsigned int describe_strategy; /**< default: GIT_DESCRIBE_DEFAULT */
|
||||
const char *pattern;
|
||||
/**
|
||||
* When calculating the distance from the matching tag or
|
||||
* reference, only walk down the first-parent ancestry.
|
||||
*/
|
||||
int only_follow_first_parent;
|
||||
/**
|
||||
* If no matching tag or reference is found, the describe
|
||||
* operation would normally fail. If this option is set, it
|
||||
* will instead fall back to showing the full id of the
|
||||
* commit.
|
||||
*/
|
||||
int show_commit_oid_as_fallback;
|
||||
} git_describe_options;
|
||||
|
||||
#define GIT_DESCRIBE_DEFAULT_MAX_CANDIDATES_TAGS 10
|
||||
#define GIT_DESCRIBE_DEFAULT_ABBREVIATED_SIZE 7
|
||||
|
||||
#define GIT_DESCRIBE_OPTIONS_VERSION 1
|
||||
#define GIT_DESCRIBE_OPTIONS_INIT { \
|
||||
GIT_DESCRIBE_OPTIONS_VERSION, \
|
||||
GIT_DESCRIBE_DEFAULT_MAX_CANDIDATES_TAGS, \
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize git_describe_options structure
|
||||
*
|
||||
* Initializes a `git_describe_options` with default values. Equivalent to creating
|
||||
* an instance with GIT_DESCRIBE_OPTIONS_INIT.
|
||||
*
|
||||
* @param opts The `git_describe_options` struct to initialize.
|
||||
* @param version The struct version; pass `GIT_DESCRIBE_OPTIONS_VERSION`.
|
||||
* @return Zero on success; -1 on failure.
|
||||
*/
|
||||
GIT_EXTERN(int) git_describe_options_init(git_describe_options *opts, unsigned int version);
|
||||
|
||||
/**
|
||||
* Describe format options structure
|
||||
*
|
||||
* Initialize with `GIT_DESCRIBE_FORMAT_OPTIONS_INIT`. Alternatively, you can
|
||||
* use `git_describe_format_options_init`.
|
||||
*
|
||||
*/
|
||||
typedef struct {
|
||||
unsigned int version;
|
||||
|
||||
/**
|
||||
* Size of the abbreviated commit id to use. This value is the
|
||||
* lower bound for the length of the abbreviated string. The
|
||||
* default is 7.
|
||||
*/
|
||||
unsigned int abbreviated_size;
|
||||
|
||||
/**
|
||||
* Set to use the long format even when a shorter name could be used.
|
||||
*/
|
||||
int always_use_long_format;
|
||||
|
||||
/**
|
||||
* If the workdir is dirty and this is set, this string will
|
||||
* be appended to the description string.
|
||||
*/
|
||||
const char *dirty_suffix;
|
||||
} git_describe_format_options;
|
||||
|
||||
#define GIT_DESCRIBE_FORMAT_OPTIONS_VERSION 1
|
||||
#define GIT_DESCRIBE_FORMAT_OPTIONS_INIT { \
|
||||
GIT_DESCRIBE_FORMAT_OPTIONS_VERSION, \
|
||||
GIT_DESCRIBE_DEFAULT_ABBREVIATED_SIZE, \
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize git_describe_format_options structure
|
||||
*
|
||||
* Initializes a `git_describe_format_options` with default values. Equivalent to creating
|
||||
* an instance with GIT_DESCRIBE_FORMAT_OPTIONS_INIT.
|
||||
*
|
||||
* @param opts The `git_describe_format_options` struct to initialize.
|
||||
* @param version The struct version; pass `GIT_DESCRIBE_FORMAT_OPTIONS_VERSION`.
|
||||
* @return Zero on success; -1 on failure.
|
||||
*/
|
||||
GIT_EXTERN(int) git_describe_format_options_init(git_describe_format_options *opts, unsigned int version);
|
||||
|
||||
/**
|
||||
* A struct that stores the result of a describe operation.
|
||||
*/
|
||||
typedef struct git_describe_result git_describe_result;
|
||||
|
||||
/**
|
||||
* Describe a commit
|
||||
*
|
||||
* Perform the describe operation on the given committish object.
|
||||
*
|
||||
* @param result pointer to store the result. You must free this once
|
||||
* you're done with it.
|
||||
* @param committish a committish to describe
|
||||
* @param opts the lookup options (or NULL for defaults)
|
||||
* @return 0 or an error code.
|
||||
*/
|
||||
GIT_EXTERN(int) git_describe_commit(
|
||||
git_describe_result **result,
|
||||
git_object *committish,
|
||||
git_describe_options *opts);
|
||||
|
||||
/**
|
||||
* Describe a commit
|
||||
*
|
||||
* Perform the describe operation on the current commit and the
|
||||
* worktree. After performing describe on HEAD, a status is run and the
|
||||
* description is considered to be dirty if there are.
|
||||
*
|
||||
* @param out pointer to store the result. You must free this once
|
||||
* you're done with it.
|
||||
* @param repo the repository in which to perform the describe
|
||||
* @param opts the lookup options (or NULL for defaults)
|
||||
* @return 0 or an error code.
|
||||
*/
|
||||
GIT_EXTERN(int) git_describe_workdir(
|
||||
git_describe_result **out,
|
||||
git_repository *repo,
|
||||
git_describe_options *opts);
|
||||
|
||||
/**
|
||||
* Print the describe result to a buffer
|
||||
*
|
||||
* @param out The buffer to store the result
|
||||
* @param result the result from `git_describe_commit()` or
|
||||
* `git_describe_workdir()`.
|
||||
* @param opts the formatting options (or NULL for defaults)
|
||||
* @return 0 or an error code.
|
||||
*/
|
||||
GIT_EXTERN(int) git_describe_format(
|
||||
git_buf *out,
|
||||
const git_describe_result *result,
|
||||
const git_describe_format_options *opts);
|
||||
|
||||
/**
|
||||
* Free the describe result.
|
||||
*
|
||||
* @param result The result to free.
|
||||
*/
|
||||
GIT_EXTERN(void) git_describe_result_free(git_describe_result *result);
|
||||
|
||||
/** @} */
|
||||
GIT_END_DECL
|
||||
|
||||
#endif
|
1477
3rdparty/libgit2/include/git2/diff.h
vendored
Normal file
1477
3rdparty/libgit2/include/git2/diff.h
vendored
Normal file
File diff suppressed because it is too large
Load Diff
127
3rdparty/libgit2/include/git2/email.h
vendored
Normal file
127
3rdparty/libgit2/include/git2/email.h
vendored
Normal file
@ -0,0 +1,127 @@
|
||||
/*
|
||||
* Copyright (C) the libgit2 contributors. All rights reserved.
|
||||
*
|
||||
* This file is part of libgit2, distributed under the GNU GPL v2 with
|
||||
* a Linking Exception. For full terms see the included COPYING file.
|
||||
*/
|
||||
#ifndef INCLUDE_git_email_h__
|
||||
#define INCLUDE_git_email_h__
|
||||
|
||||
#include "common.h"
|
||||
|
||||
/**
|
||||
* @file git2/email.h
|
||||
* @brief Git email formatting and application routines.
|
||||
* @ingroup Git
|
||||
* @{
|
||||
*/
|
||||
GIT_BEGIN_DECL
|
||||
|
||||
/**
|
||||
* Formatting options for diff e-mail generation
|
||||
*/
|
||||
typedef enum {
|
||||
/** Normal patch, the default */
|
||||
GIT_EMAIL_CREATE_DEFAULT = 0,
|
||||
|
||||
/** Do not include patch numbers in the subject prefix. */
|
||||
GIT_EMAIL_CREATE_OMIT_NUMBERS = (1u << 0),
|
||||
|
||||
/**
|
||||
* Include numbers in the subject prefix even when the
|
||||
* patch is for a single commit (1/1).
|
||||
*/
|
||||
GIT_EMAIL_CREATE_ALWAYS_NUMBER = (1u << 1),
|
||||
|
||||
/** Do not perform rename or similarity detection. */
|
||||
GIT_EMAIL_CREATE_NO_RENAMES = (1u << 2)
|
||||
} git_email_create_flags_t;
|
||||
|
||||
/**
|
||||
* Options for controlling the formatting of the generated e-mail.
|
||||
*/
|
||||
typedef struct {
|
||||
unsigned int version;
|
||||
|
||||
/** see `git_email_create_flags_t` above */
|
||||
uint32_t flags;
|
||||
|
||||
/** Options to use when creating diffs */
|
||||
git_diff_options diff_opts;
|
||||
|
||||
/** Options for finding similarities within diffs */
|
||||
git_diff_find_options diff_find_opts;
|
||||
|
||||
/**
|
||||
* The subject prefix, by default "PATCH". If set to an empty
|
||||
* string ("") then only the patch numbers will be shown in the
|
||||
* prefix. If the subject_prefix is empty and patch numbers
|
||||
* are not being shown, the prefix will be omitted entirely.
|
||||
*/
|
||||
const char *subject_prefix;
|
||||
|
||||
/**
|
||||
* The starting patch number; this cannot be 0. By default,
|
||||
* this is 1.
|
||||
*/
|
||||
size_t start_number;
|
||||
|
||||
/** The "re-roll" number. By default, there is no re-roll. */
|
||||
size_t reroll_number;
|
||||
} git_email_create_options;
|
||||
|
||||
/*
|
||||
* By default, our options include rename detection and binary
|
||||
* diffs to match `git format-patch`.
|
||||
*/
|
||||
#define GIT_EMAIL_CREATE_OPTIONS_VERSION 1
|
||||
#define GIT_EMAIL_CREATE_OPTIONS_INIT \
|
||||
{ \
|
||||
GIT_EMAIL_CREATE_OPTIONS_VERSION, \
|
||||
GIT_EMAIL_CREATE_DEFAULT, \
|
||||
{ GIT_DIFF_OPTIONS_VERSION, GIT_DIFF_SHOW_BINARY, GIT_SUBMODULE_IGNORE_UNSPECIFIED, {NULL,0}, NULL, NULL, NULL, 3 }, \
|
||||
GIT_DIFF_FIND_OPTIONS_INIT \
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a diff for a commit in mbox format for sending via email.
|
||||
*
|
||||
* @param out buffer to store the e-mail patch in
|
||||
* @param diff the changes to include in the email
|
||||
* @param patch_idx the patch index
|
||||
* @param patch_count the total number of patches that will be included
|
||||
* @param commit_id the commit id for this change
|
||||
* @param summary the commit message for this change
|
||||
* @param body optional text to include above the diffstat
|
||||
* @param author the person who authored this commit
|
||||
* @param opts email creation options
|
||||
*/
|
||||
GIT_EXTERN(int) git_email_create_from_diff(
|
||||
git_buf *out,
|
||||
git_diff *diff,
|
||||
size_t patch_idx,
|
||||
size_t patch_count,
|
||||
const git_oid *commit_id,
|
||||
const char *summary,
|
||||
const char *body,
|
||||
const git_signature *author,
|
||||
const git_email_create_options *opts);
|
||||
|
||||
/**
|
||||
* Create a diff for a commit in mbox format for sending via email.
|
||||
* The commit must not be a merge commit.
|
||||
*
|
||||
* @param out buffer to store the e-mail patch in
|
||||
* @param commit commit to create a patch for
|
||||
* @param opts email creation options
|
||||
*/
|
||||
GIT_EXTERN(int) git_email_create_from_commit(
|
||||
git_buf *out,
|
||||
git_commit *commit,
|
||||
const git_email_create_options *opts);
|
||||
|
||||
GIT_END_DECL
|
||||
|
||||
/** @} */
|
||||
|
||||
#endif
|
143
3rdparty/libgit2/include/git2/errors.h
vendored
Normal file
143
3rdparty/libgit2/include/git2/errors.h
vendored
Normal file
@ -0,0 +1,143 @@
|
||||
/*
|
||||
* Copyright (C) the libgit2 contributors. All rights reserved.
|
||||
*
|
||||
* This file is part of libgit2, distributed under the GNU GPL v2 with
|
||||
* a Linking Exception. For full terms see the included COPYING file.
|
||||
*/
|
||||
#ifndef INCLUDE_git_errors_h__
|
||||
#define INCLUDE_git_errors_h__
|
||||
|
||||
#include "common.h"
|
||||
|
||||
/**
|
||||
* @file git2/errors.h
|
||||
* @brief Git error handling routines and variables
|
||||
* @ingroup Git
|
||||
* @{
|
||||
*/
|
||||
GIT_BEGIN_DECL
|
||||
|
||||
/** Generic return codes */
|
||||
typedef enum {
|
||||
GIT_OK = 0, /**< No error */
|
||||
|
||||
GIT_ERROR = -1, /**< Generic error */
|
||||
GIT_ENOTFOUND = -3, /**< Requested object could not be found */
|
||||
GIT_EEXISTS = -4, /**< Object exists preventing operation */
|
||||
GIT_EAMBIGUOUS = -5, /**< More than one object matches */
|
||||
GIT_EBUFS = -6, /**< Output buffer too short to hold data */
|
||||
|
||||
/**
|
||||
* GIT_EUSER is a special error that is never generated by libgit2
|
||||
* code. You can return it from a callback (e.g to stop an iteration)
|
||||
* to know that it was generated by the callback and not by libgit2.
|
||||
*/
|
||||
GIT_EUSER = -7,
|
||||
|
||||
GIT_EBAREREPO = -8, /**< Operation not allowed on bare repository */
|
||||
GIT_EUNBORNBRANCH = -9, /**< HEAD refers to branch with no commits */
|
||||
GIT_EUNMERGED = -10, /**< Merge in progress prevented operation */
|
||||
GIT_ENONFASTFORWARD = -11, /**< Reference was not fast-forwardable */
|
||||
GIT_EINVALIDSPEC = -12, /**< Name/ref spec was not in a valid format */
|
||||
GIT_ECONFLICT = -13, /**< Checkout conflicts prevented operation */
|
||||
GIT_ELOCKED = -14, /**< Lock file prevented operation */
|
||||
GIT_EMODIFIED = -15, /**< Reference value does not match expected */
|
||||
GIT_EAUTH = -16, /**< Authentication error */
|
||||
GIT_ECERTIFICATE = -17, /**< Server certificate is invalid */
|
||||
GIT_EAPPLIED = -18, /**< Patch/merge has already been applied */
|
||||
GIT_EPEEL = -19, /**< The requested peel operation is not possible */
|
||||
GIT_EEOF = -20, /**< Unexpected EOF */
|
||||
GIT_EINVALID = -21, /**< Invalid operation or input */
|
||||
GIT_EUNCOMMITTED = -22, /**< Uncommitted changes in index prevented operation */
|
||||
GIT_EDIRECTORY = -23, /**< The operation is not valid for a directory */
|
||||
GIT_EMERGECONFLICT = -24, /**< A merge conflict exists and cannot continue */
|
||||
|
||||
GIT_PASSTHROUGH = -30, /**< A user-configured callback refused to act */
|
||||
GIT_ITEROVER = -31, /**< Signals end of iteration with iterator */
|
||||
GIT_RETRY = -32, /**< Internal only */
|
||||
GIT_EMISMATCH = -33, /**< Hashsum mismatch in object */
|
||||
GIT_EINDEXDIRTY = -34, /**< Unsaved changes in the index would be overwritten */
|
||||
GIT_EAPPLYFAIL = -35, /**< Patch application failed */
|
||||
GIT_EOWNER = -36, /**< The object is not owned by the current user */
|
||||
GIT_TIMEOUT = -37, /**< The operation timed out */
|
||||
GIT_EUNCHANGED = -38, /**< There were no changes */
|
||||
GIT_ENOTSUPPORTED = -39, /**< An option is not supported */
|
||||
GIT_EREADONLY = -40 /**< The subject is read-only */
|
||||
} git_error_code;
|
||||
|
||||
/**
|
||||
* Structure to store extra details of the last error that occurred.
|
||||
*
|
||||
* This is kept on a per-thread basis if GIT_THREADS was defined when the
|
||||
* library was build, otherwise one is kept globally for the library
|
||||
*/
|
||||
typedef struct {
|
||||
char *message;
|
||||
int klass;
|
||||
} git_error;
|
||||
|
||||
/** Error classes */
|
||||
typedef enum {
|
||||
GIT_ERROR_NONE = 0,
|
||||
GIT_ERROR_NOMEMORY,
|
||||
GIT_ERROR_OS,
|
||||
GIT_ERROR_INVALID,
|
||||
GIT_ERROR_REFERENCE,
|
||||
GIT_ERROR_ZLIB,
|
||||
GIT_ERROR_REPOSITORY,
|
||||
GIT_ERROR_CONFIG,
|
||||
GIT_ERROR_REGEX,
|
||||
GIT_ERROR_ODB,
|
||||
GIT_ERROR_INDEX,
|
||||
GIT_ERROR_OBJECT,
|
||||
GIT_ERROR_NET,
|
||||
GIT_ERROR_TAG,
|
||||
GIT_ERROR_TREE,
|
||||
GIT_ERROR_INDEXER,
|
||||
GIT_ERROR_SSL,
|
||||
GIT_ERROR_SUBMODULE,
|
||||
GIT_ERROR_THREAD,
|
||||
GIT_ERROR_STASH,
|
||||
GIT_ERROR_CHECKOUT,
|
||||
GIT_ERROR_FETCHHEAD,
|
||||
GIT_ERROR_MERGE,
|
||||
GIT_ERROR_SSH,
|
||||
GIT_ERROR_FILTER,
|
||||
GIT_ERROR_REVERT,
|
||||
GIT_ERROR_CALLBACK,
|
||||
GIT_ERROR_CHERRYPICK,
|
||||
GIT_ERROR_DESCRIBE,
|
||||
GIT_ERROR_REBASE,
|
||||
GIT_ERROR_FILESYSTEM,
|
||||
GIT_ERROR_PATCH,
|
||||
GIT_ERROR_WORKTREE,
|
||||
GIT_ERROR_SHA,
|
||||
GIT_ERROR_HTTP,
|
||||
GIT_ERROR_INTERNAL,
|
||||
GIT_ERROR_GRAFTS
|
||||
} git_error_t;
|
||||
|
||||
/**
|
||||
* Return the last `git_error` object that was generated for the
|
||||
* current thread.
|
||||
*
|
||||
* This function will never return NULL.
|
||||
*
|
||||
* Callers should not rely on this to determine whether an error has
|
||||
* occurred. For error checking, callers should examine the return
|
||||
* codes of libgit2 functions.
|
||||
*
|
||||
* This call can only reliably report error messages when an error
|
||||
* has occurred. (It may contain stale information if it is called
|
||||
* after a different function that succeeds.)
|
||||
*
|
||||
* The memory for this object is managed by libgit2. It should not
|
||||
* be freed.
|
||||
*
|
||||
* @return A git_error object.
|
||||
*/
|
||||
GIT_EXTERN(const git_error *) git_error_last(void);
|
||||
|
||||
/** @} */
|
||||
GIT_END_DECL
|
||||
#endif
|
13
3rdparty/libgit2/include/git2/experimental.h
vendored
Normal file
13
3rdparty/libgit2/include/git2/experimental.h
vendored
Normal file
@ -0,0 +1,13 @@
|
||||
/*
|
||||
* Copyright (C) the libgit2 contributors. All rights reserved.
|
||||
*
|
||||
* This file is part of libgit2, distributed under the GNU GPL v2 with
|
||||
* a Linking Exception. For full terms see the included COPYING file.
|
||||
*/
|
||||
|
||||
#ifndef INCLUDE_experimental_h__
|
||||
#define INCLUDE_experimental_h__
|
||||
|
||||
/* #undef GIT_EXPERIMENTAL_SHA256 */
|
||||
|
||||
#endif
|
276
3rdparty/libgit2/include/git2/filter.h
vendored
Normal file
276
3rdparty/libgit2/include/git2/filter.h
vendored
Normal file
@ -0,0 +1,276 @@
|
||||
/*
|
||||
* Copyright (C) the libgit2 contributors. All rights reserved.
|
||||
*
|
||||
* This file is part of libgit2, distributed under the GNU GPL v2 with
|
||||
* a Linking Exception. For full terms see the included COPYING file.
|
||||
*/
|
||||
#ifndef INCLUDE_git_filter_h__
|
||||
#define INCLUDE_git_filter_h__
|
||||
|
||||
#include "common.h"
|
||||
#include "types.h"
|
||||
#include "oid.h"
|
||||
#include "buffer.h"
|
||||
|
||||
/**
|
||||
* @file git2/filter.h
|
||||
* @brief Git filter APIs
|
||||
*
|
||||
* @ingroup Git
|
||||
* @{
|
||||
*/
|
||||
GIT_BEGIN_DECL
|
||||
|
||||
/**
|
||||
* Filters are applied in one of two directions: smudging - which is
|
||||
* exporting a file from the Git object database to the working directory,
|
||||
* and cleaning - which is importing a file from the working directory to
|
||||
* the Git object database. These values control which direction of
|
||||
* change is being applied.
|
||||
*/
|
||||
typedef enum {
|
||||
GIT_FILTER_TO_WORKTREE = 0,
|
||||
GIT_FILTER_SMUDGE = GIT_FILTER_TO_WORKTREE,
|
||||
GIT_FILTER_TO_ODB = 1,
|
||||
GIT_FILTER_CLEAN = GIT_FILTER_TO_ODB
|
||||
} git_filter_mode_t;
|
||||
|
||||
/**
|
||||
* Filter option flags.
|
||||
*/
|
||||
typedef enum {
|
||||
GIT_FILTER_DEFAULT = 0u,
|
||||
|
||||
/** Don't error for `safecrlf` violations, allow them to continue. */
|
||||
GIT_FILTER_ALLOW_UNSAFE = (1u << 0),
|
||||
|
||||
/** Don't load `/etc/gitattributes` (or the system equivalent) */
|
||||
GIT_FILTER_NO_SYSTEM_ATTRIBUTES = (1u << 1),
|
||||
|
||||
/** Load attributes from `.gitattributes` in the root of HEAD */
|
||||
GIT_FILTER_ATTRIBUTES_FROM_HEAD = (1u << 2),
|
||||
|
||||
/**
|
||||
* Load attributes from `.gitattributes` in a given commit.
|
||||
* This can only be specified in a `git_filter_options`.
|
||||
*/
|
||||
GIT_FILTER_ATTRIBUTES_FROM_COMMIT = (1u << 3)
|
||||
} git_filter_flag_t;
|
||||
|
||||
/**
|
||||
* Filtering options
|
||||
*/
|
||||
typedef struct {
|
||||
unsigned int version;
|
||||
|
||||
/** See `git_filter_flag_t` above */
|
||||
uint32_t flags;
|
||||
|
||||
#ifdef GIT_DEPRECATE_HARD
|
||||
void *reserved;
|
||||
#else
|
||||
git_oid *commit_id;
|
||||
#endif
|
||||
|
||||
/**
|
||||
* The commit to load attributes from, when
|
||||
* `GIT_FILTER_ATTRIBUTES_FROM_COMMIT` is specified.
|
||||
*/
|
||||
git_oid attr_commit_id;
|
||||
} git_filter_options;
|
||||
|
||||
#define GIT_FILTER_OPTIONS_VERSION 1
|
||||
#define GIT_FILTER_OPTIONS_INIT {GIT_FILTER_OPTIONS_VERSION}
|
||||
|
||||
/**
|
||||
* A filter that can transform file data
|
||||
*
|
||||
* This represents a filter that can be used to transform or even replace
|
||||
* file data. Libgit2 includes one built in filter and it is possible to
|
||||
* write your own (see git2/sys/filter.h for information on that).
|
||||
*
|
||||
* The two builtin filters are:
|
||||
*
|
||||
* * "crlf" which uses the complex rules with the "text", "eol", and
|
||||
* "crlf" file attributes to decide how to convert between LF and CRLF
|
||||
* line endings
|
||||
* * "ident" which replaces "$Id$" in a blob with "$Id: <blob OID>$" upon
|
||||
* checkout and replaced "$Id: <anything>$" with "$Id$" on checkin.
|
||||
*/
|
||||
typedef struct git_filter git_filter;
|
||||
|
||||
/**
|
||||
* List of filters to be applied
|
||||
*
|
||||
* This represents a list of filters to be applied to a file / blob. You
|
||||
* can build the list with one call, apply it with another, and dispose it
|
||||
* with a third. In typical usage, there are not many occasions where a
|
||||
* git_filter_list is needed directly since the library will generally
|
||||
* handle conversions for you, but it can be convenient to be able to
|
||||
* build and apply the list sometimes.
|
||||
*/
|
||||
typedef struct git_filter_list git_filter_list;
|
||||
|
||||
/**
|
||||
* Load the filter list for a given path.
|
||||
*
|
||||
* This will return 0 (success) but set the output git_filter_list to NULL
|
||||
* if no filters are requested for the given file.
|
||||
*
|
||||
* @param filters Output newly created git_filter_list (or NULL)
|
||||
* @param repo Repository object that contains `path`
|
||||
* @param blob The blob to which the filter will be applied (if known)
|
||||
* @param path Relative path of the file to be filtered
|
||||
* @param mode Filtering direction (WT->ODB or ODB->WT)
|
||||
* @param flags Combination of `git_filter_flag_t` flags
|
||||
* @return 0 on success (which could still return NULL if no filters are
|
||||
* needed for the requested file), <0 on error
|
||||
*/
|
||||
GIT_EXTERN(int) git_filter_list_load(
|
||||
git_filter_list **filters,
|
||||
git_repository *repo,
|
||||
git_blob *blob, /* can be NULL */
|
||||
const char *path,
|
||||
git_filter_mode_t mode,
|
||||
uint32_t flags);
|
||||
|
||||
/**
|
||||
* Load the filter list for a given path.
|
||||
*
|
||||
* This will return 0 (success) but set the output git_filter_list to NULL
|
||||
* if no filters are requested for the given file.
|
||||
*
|
||||
* @param filters Output newly created git_filter_list (or NULL)
|
||||
* @param repo Repository object that contains `path`
|
||||
* @param blob The blob to which the filter will be applied (if known)
|
||||
* @param path Relative path of the file to be filtered
|
||||
* @param mode Filtering direction (WT->ODB or ODB->WT)
|
||||
* @param opts The `git_filter_options` to use when loading filters
|
||||
* @return 0 on success (which could still return NULL if no filters are
|
||||
* needed for the requested file), <0 on error
|
||||
*/
|
||||
GIT_EXTERN(int) git_filter_list_load_ext(
|
||||
git_filter_list **filters,
|
||||
git_repository *repo,
|
||||
git_blob *blob,
|
||||
const char *path,
|
||||
git_filter_mode_t mode,
|
||||
git_filter_options *opts);
|
||||
|
||||
/**
|
||||
* Query the filter list to see if a given filter (by name) will run.
|
||||
* The built-in filters "crlf" and "ident" can be queried, otherwise this
|
||||
* is the name of the filter specified by the filter attribute.
|
||||
*
|
||||
* This will return 0 if the given filter is not in the list, or 1 if
|
||||
* the filter will be applied.
|
||||
*
|
||||
* @param filters A loaded git_filter_list (or NULL)
|
||||
* @param name The name of the filter to query
|
||||
* @return 1 if the filter is in the list, 0 otherwise
|
||||
*/
|
||||
GIT_EXTERN(int) git_filter_list_contains(
|
||||
git_filter_list *filters,
|
||||
const char *name);
|
||||
|
||||
/**
|
||||
* Apply filter list to a data buffer.
|
||||
*
|
||||
* @param out Buffer to store the result of the filtering
|
||||
* @param filters A loaded git_filter_list (or NULL)
|
||||
* @param in Buffer containing the data to filter
|
||||
* @param in_len The length of the input buffer
|
||||
* @return 0 on success, an error code otherwise
|
||||
*/
|
||||
GIT_EXTERN(int) git_filter_list_apply_to_buffer(
|
||||
git_buf *out,
|
||||
git_filter_list *filters,
|
||||
const char *in,
|
||||
size_t in_len);
|
||||
|
||||
/**
|
||||
* Apply a filter list to the contents of a file on disk
|
||||
*
|
||||
* @param out buffer into which to store the filtered file
|
||||
* @param filters the list of filters to apply
|
||||
* @param repo the repository in which to perform the filtering
|
||||
* @param path the path of the file to filter, a relative path will be
|
||||
* taken as relative to the workdir
|
||||
* @return 0 or an error code.
|
||||
*/
|
||||
GIT_EXTERN(int) git_filter_list_apply_to_file(
|
||||
git_buf *out,
|
||||
git_filter_list *filters,
|
||||
git_repository *repo,
|
||||
const char *path);
|
||||
|
||||
/**
|
||||
* Apply a filter list to the contents of a blob
|
||||
*
|
||||
* @param out buffer into which to store the filtered file
|
||||
* @param filters the list of filters to apply
|
||||
* @param blob the blob to filter
|
||||
* @return 0 or an error code.
|
||||
*/
|
||||
GIT_EXTERN(int) git_filter_list_apply_to_blob(
|
||||
git_buf *out,
|
||||
git_filter_list *filters,
|
||||
git_blob *blob);
|
||||
|
||||
/**
|
||||
* Apply a filter list to an arbitrary buffer as a stream
|
||||
*
|
||||
* @param filters the list of filters to apply
|
||||
* @param buffer the buffer to filter
|
||||
* @param len the size of the buffer
|
||||
* @param target the stream into which the data will be written
|
||||
* @return 0 or an error code.
|
||||
*/
|
||||
GIT_EXTERN(int) git_filter_list_stream_buffer(
|
||||
git_filter_list *filters,
|
||||
const char *buffer,
|
||||
size_t len,
|
||||
git_writestream *target);
|
||||
|
||||
/**
|
||||
* Apply a filter list to a file as a stream
|
||||
*
|
||||
* @param filters the list of filters to apply
|
||||
* @param repo the repository in which to perform the filtering
|
||||
* @param path the path of the file to filter, a relative path will be
|
||||
* taken as relative to the workdir
|
||||
* @param target the stream into which the data will be written
|
||||
* @return 0 or an error code.
|
||||
*/
|
||||
GIT_EXTERN(int) git_filter_list_stream_file(
|
||||
git_filter_list *filters,
|
||||
git_repository *repo,
|
||||
const char *path,
|
||||
git_writestream *target);
|
||||
|
||||
/**
|
||||
* Apply a filter list to a blob as a stream
|
||||
*
|
||||
* @param filters the list of filters to apply
|
||||
* @param blob the blob to filter
|
||||
* @param target the stream into which the data will be written
|
||||
* @return 0 or an error code.
|
||||
*/
|
||||
GIT_EXTERN(int) git_filter_list_stream_blob(
|
||||
git_filter_list *filters,
|
||||
git_blob *blob,
|
||||
git_writestream *target);
|
||||
|
||||
/**
|
||||
* Free a git_filter_list
|
||||
*
|
||||
* @param filters A git_filter_list created by `git_filter_list_load`
|
||||
*/
|
||||
GIT_EXTERN(void) git_filter_list_free(git_filter_list *filters);
|
||||
|
||||
|
||||
GIT_END_DECL
|
||||
|
||||
/** @} */
|
||||
|
||||
#endif
|
44
3rdparty/libgit2/include/git2/global.h
vendored
Normal file
44
3rdparty/libgit2/include/git2/global.h
vendored
Normal file
@ -0,0 +1,44 @@
|
||||
/*
|
||||
* Copyright (C) the libgit2 contributors. All rights reserved.
|
||||
*
|
||||
* This file is part of libgit2, distributed under the GNU GPL v2 with
|
||||
* a Linking Exception. For full terms see the included COPYING file.
|
||||
*/
|
||||
#ifndef INCLUDE_git_global_h__
|
||||
#define INCLUDE_git_global_h__
|
||||
|
||||
#include "common.h"
|
||||
|
||||
GIT_BEGIN_DECL
|
||||
|
||||
/**
|
||||
* Init the global state
|
||||
*
|
||||
* This function must be called before any other libgit2 function in
|
||||
* order to set up global state and threading.
|
||||
*
|
||||
* This function may be called multiple times - it will return the number
|
||||
* of times the initialization has been called (including this one) that have
|
||||
* not subsequently been shutdown.
|
||||
*
|
||||
* @return the number of initializations of the library, or an error code.
|
||||
*/
|
||||
GIT_EXTERN(int) git_libgit2_init(void);
|
||||
|
||||
/**
|
||||
* Shutdown the global state
|
||||
*
|
||||
* Clean up the global state and threading context after calling it as
|
||||
* many times as `git_libgit2_init()` was called - it will return the
|
||||
* number of remainining initializations that have not been shutdown
|
||||
* (after this one).
|
||||
*
|
||||
* @return the number of remaining initializations of the library, or an
|
||||
* error code.
|
||||
*/
|
||||
GIT_EXTERN(int) git_libgit2_shutdown(void);
|
||||
|
||||
/** @} */
|
||||
GIT_END_DECL
|
||||
#endif
|
||||
|
77
3rdparty/libgit2/include/git2/graph.h
vendored
Normal file
77
3rdparty/libgit2/include/git2/graph.h
vendored
Normal file
@ -0,0 +1,77 @@
|
||||
/*
|
||||
* Copyright (C) the libgit2 contributors. All rights reserved.
|
||||
*
|
||||
* This file is part of libgit2, distributed under the GNU GPL v2 with
|
||||
* a Linking Exception. For full terms see the included COPYING file.
|
||||
*/
|
||||
#ifndef INCLUDE_git_graph_h__
|
||||
#define INCLUDE_git_graph_h__
|
||||
|
||||
#include "common.h"
|
||||
#include "types.h"
|
||||
#include "oid.h"
|
||||
|
||||
/**
|
||||
* @file git2/graph.h
|
||||
* @brief Git graph traversal routines
|
||||
* @defgroup git_revwalk Git graph traversal routines
|
||||
* @ingroup Git
|
||||
* @{
|
||||
*/
|
||||
GIT_BEGIN_DECL
|
||||
|
||||
/**
|
||||
* Count the number of unique commits between two commit objects
|
||||
*
|
||||
* There is no need for branches containing the commits to have any
|
||||
* upstream relationship, but it helps to think of one as a branch and
|
||||
* the other as its upstream, the `ahead` and `behind` values will be
|
||||
* what git would report for the branches.
|
||||
*
|
||||
* @param ahead number of unique from commits in `upstream`
|
||||
* @param behind number of unique from commits in `local`
|
||||
* @param repo the repository where the commits exist
|
||||
* @param local the commit for local
|
||||
* @param upstream the commit for upstream
|
||||
* @return 0 or an error code.
|
||||
*/
|
||||
GIT_EXTERN(int) git_graph_ahead_behind(size_t *ahead, size_t *behind, git_repository *repo, const git_oid *local, const git_oid *upstream);
|
||||
|
||||
|
||||
/**
|
||||
* Determine if a commit is the descendant of another commit.
|
||||
*
|
||||
* Note that a commit is not considered a descendant of itself, in contrast
|
||||
* to `git merge-base --is-ancestor`.
|
||||
*
|
||||
* @param repo the repository where the commits exist
|
||||
* @param commit a previously loaded commit
|
||||
* @param ancestor a potential ancestor commit
|
||||
* @return 1 if the given commit is a descendant of the potential ancestor,
|
||||
* 0 if not, error code otherwise.
|
||||
*/
|
||||
GIT_EXTERN(int) git_graph_descendant_of(
|
||||
git_repository *repo,
|
||||
const git_oid *commit,
|
||||
const git_oid *ancestor);
|
||||
|
||||
/**
|
||||
* Determine if a commit is reachable from any of a list of commits by
|
||||
* following parent edges.
|
||||
*
|
||||
* @param repo the repository where the commits exist
|
||||
* @param commit a previously loaded commit
|
||||
* @param length the number of commits in the provided `descendant_array`
|
||||
* @param descendant_array oids of the commits
|
||||
* @return 1 if the given commit is an ancestor of any of the given potential
|
||||
* descendants, 0 if not, error code otherwise.
|
||||
*/
|
||||
GIT_EXTERN(int) git_graph_reachable_from_any(
|
||||
git_repository *repo,
|
||||
const git_oid *commit,
|
||||
const git_oid descendant_array[],
|
||||
size_t length);
|
||||
|
||||
/** @} */
|
||||
GIT_END_DECL
|
||||
#endif
|
78
3rdparty/libgit2/include/git2/ignore.h
vendored
Normal file
78
3rdparty/libgit2/include/git2/ignore.h
vendored
Normal file
@ -0,0 +1,78 @@
|
||||
/*
|
||||
* Copyright (C) the libgit2 contributors. All rights reserved.
|
||||
*
|
||||
* This file is part of libgit2, distributed under the GNU GPL v2 with
|
||||
* a Linking Exception. For full terms see the included COPYING file.
|
||||
*/
|
||||
#ifndef INCLUDE_git_ignore_h__
|
||||
#define INCLUDE_git_ignore_h__
|
||||
|
||||
#include "common.h"
|
||||
#include "types.h"
|
||||
|
||||
GIT_BEGIN_DECL
|
||||
|
||||
/**
|
||||
* Add ignore rules for a repository.
|
||||
*
|
||||
* Excludesfile rules (i.e. .gitignore rules) are generally read from
|
||||
* .gitignore files in the repository tree or from a shared system file
|
||||
* only if a "core.excludesfile" config value is set. The library also
|
||||
* keeps a set of per-repository internal ignores that can be configured
|
||||
* in-memory and will not persist. This function allows you to add to
|
||||
* that internal rules list.
|
||||
*
|
||||
* Example usage:
|
||||
*
|
||||
* error = git_ignore_add_rule(myrepo, "*.c\ndir/\nFile with space\n");
|
||||
*
|
||||
* This would add three rules to the ignores.
|
||||
*
|
||||
* @param repo The repository to add ignore rules to.
|
||||
* @param rules Text of rules, the contents to add on a .gitignore file.
|
||||
* It is okay to have multiple rules in the text; if so,
|
||||
* each rule should be terminated with a newline.
|
||||
* @return 0 on success
|
||||
*/
|
||||
GIT_EXTERN(int) git_ignore_add_rule(
|
||||
git_repository *repo,
|
||||
const char *rules);
|
||||
|
||||
/**
|
||||
* Clear ignore rules that were explicitly added.
|
||||
*
|
||||
* Resets to the default internal ignore rules. This will not turn off
|
||||
* rules in .gitignore files that actually exist in the filesystem.
|
||||
*
|
||||
* The default internal ignores ignore ".", ".." and ".git" entries.
|
||||
*
|
||||
* @param repo The repository to remove ignore rules from.
|
||||
* @return 0 on success
|
||||
*/
|
||||
GIT_EXTERN(int) git_ignore_clear_internal_rules(
|
||||
git_repository *repo);
|
||||
|
||||
/**
|
||||
* Test if the ignore rules apply to a given path.
|
||||
*
|
||||
* This function checks the ignore rules to see if they would apply to the
|
||||
* given file. This indicates if the file would be ignored regardless of
|
||||
* whether the file is already in the index or committed to the repository.
|
||||
*
|
||||
* One way to think of this is if you were to do "git check-ignore --no-index"
|
||||
* on the given file, would it be shown or not?
|
||||
*
|
||||
* @param ignored boolean returning 0 if the file is not ignored, 1 if it is
|
||||
* @param repo a repository object
|
||||
* @param path the file to check ignores for, relative to the repo's workdir.
|
||||
* @return 0 if ignore rules could be processed for the file (regardless
|
||||
* of whether it exists or not), or an error < 0 if they could not.
|
||||
*/
|
||||
GIT_EXTERN(int) git_ignore_path_is_ignored(
|
||||
int *ignored,
|
||||
git_repository *repo,
|
||||
const char *path);
|
||||
|
||||
GIT_END_DECL
|
||||
|
||||
#endif
|
848
3rdparty/libgit2/include/git2/index.h
vendored
Normal file
848
3rdparty/libgit2/include/git2/index.h
vendored
Normal file
@ -0,0 +1,848 @@
|
||||
/*
|
||||
* Copyright (C) the libgit2 contributors. All rights reserved.
|
||||
*
|
||||
* This file is part of libgit2, distributed under the GNU GPL v2 with
|
||||
* a Linking Exception. For full terms see the included COPYING file.
|
||||
*/
|
||||
#ifndef INCLUDE_git_index_h__
|
||||
#define INCLUDE_git_index_h__
|
||||
|
||||
#include "common.h"
|
||||
#include "indexer.h"
|
||||
#include "types.h"
|
||||
#include "oid.h"
|
||||
#include "strarray.h"
|
||||
|
||||
/**
|
||||
* @file git2/index.h
|
||||
* @brief Git index parsing and manipulation routines
|
||||
* @defgroup git_index Git index parsing and manipulation routines
|
||||
* @ingroup Git
|
||||
* @{
|
||||
*/
|
||||
GIT_BEGIN_DECL
|
||||
|
||||
/** Time structure used in a git index entry */
|
||||
typedef struct {
|
||||
int32_t seconds;
|
||||
/* nsec should not be stored as time_t compatible */
|
||||
uint32_t nanoseconds;
|
||||
} git_index_time;
|
||||
|
||||
/**
|
||||
* In-memory representation of a file entry in the index.
|
||||
*
|
||||
* This is a public structure that represents a file entry in the index.
|
||||
* The meaning of the fields corresponds to core Git's documentation (in
|
||||
* "Documentation/technical/index-format.txt").
|
||||
*
|
||||
* The `flags` field consists of a number of bit fields which can be
|
||||
* accessed via the first set of `GIT_INDEX_ENTRY_...` bitmasks below.
|
||||
* These flags are all read from and persisted to disk.
|
||||
*
|
||||
* The `flags_extended` field also has a number of bit fields which can be
|
||||
* accessed via the later `GIT_INDEX_ENTRY_...` bitmasks below. Some of
|
||||
* these flags are read from and written to disk, but some are set aside
|
||||
* for in-memory only reference.
|
||||
*
|
||||
* Note that the time and size fields are truncated to 32 bits. This
|
||||
* is enough to detect changes, which is enough for the index to
|
||||
* function as a cache, but it should not be taken as an authoritative
|
||||
* source for that data.
|
||||
*/
|
||||
typedef struct git_index_entry {
|
||||
git_index_time ctime;
|
||||
git_index_time mtime;
|
||||
|
||||
uint32_t dev;
|
||||
uint32_t ino;
|
||||
uint32_t mode;
|
||||
uint32_t uid;
|
||||
uint32_t gid;
|
||||
uint32_t file_size;
|
||||
|
||||
git_oid id;
|
||||
|
||||
uint16_t flags;
|
||||
uint16_t flags_extended;
|
||||
|
||||
const char *path;
|
||||
} git_index_entry;
|
||||
|
||||
/**
|
||||
* Bitmasks for on-disk fields of `git_index_entry`'s `flags`
|
||||
*
|
||||
* These bitmasks match the four fields in the `git_index_entry` `flags`
|
||||
* value both in memory and on disk. You can use them to interpret the
|
||||
* data in the `flags`.
|
||||
*/
|
||||
|
||||
#define GIT_INDEX_ENTRY_NAMEMASK (0x0fff)
|
||||
#define GIT_INDEX_ENTRY_STAGEMASK (0x3000)
|
||||
#define GIT_INDEX_ENTRY_STAGESHIFT 12
|
||||
|
||||
/**
|
||||
* Flags for index entries
|
||||
*/
|
||||
typedef enum {
|
||||
GIT_INDEX_ENTRY_EXTENDED = (0x4000),
|
||||
GIT_INDEX_ENTRY_VALID = (0x8000)
|
||||
} git_index_entry_flag_t;
|
||||
|
||||
#define GIT_INDEX_ENTRY_STAGE(E) \
|
||||
(((E)->flags & GIT_INDEX_ENTRY_STAGEMASK) >> GIT_INDEX_ENTRY_STAGESHIFT)
|
||||
|
||||
#define GIT_INDEX_ENTRY_STAGE_SET(E,S) do { \
|
||||
(E)->flags = ((E)->flags & ~GIT_INDEX_ENTRY_STAGEMASK) | \
|
||||
(((S) & 0x03) << GIT_INDEX_ENTRY_STAGESHIFT); } while (0)
|
||||
|
||||
/**
|
||||
* Bitmasks for on-disk fields of `git_index_entry`'s `flags_extended`
|
||||
*
|
||||
* In memory, the `flags_extended` fields are divided into two parts: the
|
||||
* fields that are read from and written to disk, and other fields that
|
||||
* in-memory only and used by libgit2. Only the flags in
|
||||
* `GIT_INDEX_ENTRY_EXTENDED_FLAGS` will get saved on-disk.
|
||||
*
|
||||
* Thee first three bitmasks match the three fields in the
|
||||
* `git_index_entry` `flags_extended` value that belong on disk. You
|
||||
* can use them to interpret the data in the `flags_extended`.
|
||||
*
|
||||
* The rest of the bitmasks match the other fields in the `git_index_entry`
|
||||
* `flags_extended` value that are only used in-memory by libgit2.
|
||||
* You can use them to interpret the data in the `flags_extended`.
|
||||
*
|
||||
*/
|
||||
typedef enum {
|
||||
GIT_INDEX_ENTRY_INTENT_TO_ADD = (1 << 13),
|
||||
GIT_INDEX_ENTRY_SKIP_WORKTREE = (1 << 14),
|
||||
|
||||
GIT_INDEX_ENTRY_EXTENDED_FLAGS = (GIT_INDEX_ENTRY_INTENT_TO_ADD | GIT_INDEX_ENTRY_SKIP_WORKTREE),
|
||||
|
||||
GIT_INDEX_ENTRY_UPTODATE = (1 << 2)
|
||||
} git_index_entry_extended_flag_t;
|
||||
|
||||
/** Capabilities of system that affect index actions. */
|
||||
typedef enum {
|
||||
GIT_INDEX_CAPABILITY_IGNORE_CASE = 1,
|
||||
GIT_INDEX_CAPABILITY_NO_FILEMODE = 2,
|
||||
GIT_INDEX_CAPABILITY_NO_SYMLINKS = 4,
|
||||
GIT_INDEX_CAPABILITY_FROM_OWNER = -1
|
||||
} git_index_capability_t;
|
||||
|
||||
|
||||
/** Callback for APIs that add/remove/update files matching pathspec */
|
||||
typedef int GIT_CALLBACK(git_index_matched_path_cb)(
|
||||
const char *path, const char *matched_pathspec, void *payload);
|
||||
|
||||
/** Flags for APIs that add files matching pathspec */
|
||||
typedef enum {
|
||||
GIT_INDEX_ADD_DEFAULT = 0,
|
||||
GIT_INDEX_ADD_FORCE = (1u << 0),
|
||||
GIT_INDEX_ADD_DISABLE_PATHSPEC_MATCH = (1u << 1),
|
||||
GIT_INDEX_ADD_CHECK_PATHSPEC = (1u << 2)
|
||||
} git_index_add_option_t;
|
||||
|
||||
/** Git index stage states */
|
||||
typedef enum {
|
||||
/**
|
||||
* Match any index stage.
|
||||
*
|
||||
* Some index APIs take a stage to match; pass this value to match
|
||||
* any entry matching the path regardless of stage.
|
||||
*/
|
||||
GIT_INDEX_STAGE_ANY = -1,
|
||||
|
||||
/** A normal staged file in the index. */
|
||||
GIT_INDEX_STAGE_NORMAL = 0,
|
||||
|
||||
/** The ancestor side of a conflict. */
|
||||
GIT_INDEX_STAGE_ANCESTOR = 1,
|
||||
|
||||
/** The "ours" side of a conflict. */
|
||||
GIT_INDEX_STAGE_OURS = 2,
|
||||
|
||||
/** The "theirs" side of a conflict. */
|
||||
GIT_INDEX_STAGE_THEIRS = 3
|
||||
} git_index_stage_t;
|
||||
|
||||
/**
|
||||
* Create a new bare Git index object as a memory representation
|
||||
* of the Git index file in 'index_path', without a repository
|
||||
* to back it.
|
||||
*
|
||||
* Since there is no ODB or working directory behind this index,
|
||||
* any Index methods which rely on these (e.g. index_add_bypath)
|
||||
* will fail with the GIT_ERROR error code.
|
||||
*
|
||||
* If you need to access the index of an actual repository,
|
||||
* use the `git_repository_index` wrapper.
|
||||
*
|
||||
* The index must be freed once it's no longer in use.
|
||||
*
|
||||
* @param out the pointer for the new index
|
||||
* @param index_path the path to the index file in disk
|
||||
* @return 0 or an error code
|
||||
*/
|
||||
|
||||
#ifdef GIT_EXPERIMENTAL_SHA256
|
||||
GIT_EXTERN(int) git_index_open(git_index **out, const char *index_path, git_oid_t oid_type);
|
||||
#else
|
||||
GIT_EXTERN(int) git_index_open(git_index **out, const char *index_path);
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Create an in-memory index object.
|
||||
*
|
||||
* This index object cannot be read/written to the filesystem,
|
||||
* but may be used to perform in-memory index operations.
|
||||
*
|
||||
* The index must be freed once it's no longer in use.
|
||||
*
|
||||
* @param out the pointer for the new index
|
||||
* @return 0 or an error code
|
||||
*/
|
||||
#ifdef GIT_EXPERIMENTAL_SHA256
|
||||
GIT_EXTERN(int) git_index_new(git_index **out, git_oid_t oid_type);
|
||||
#else
|
||||
GIT_EXTERN(int) git_index_new(git_index **out);
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Free an existing index object.
|
||||
*
|
||||
* @param index an existing index object
|
||||
*/
|
||||
GIT_EXTERN(void) git_index_free(git_index *index);
|
||||
|
||||
/**
|
||||
* Get the repository this index relates to
|
||||
*
|
||||
* @param index The index
|
||||
* @return A pointer to the repository
|
||||
*/
|
||||
GIT_EXTERN(git_repository *) git_index_owner(const git_index *index);
|
||||
|
||||
/**
|
||||
* Read index capabilities flags.
|
||||
*
|
||||
* @param index An existing index object
|
||||
* @return A combination of GIT_INDEX_CAPABILITY values
|
||||
*/
|
||||
GIT_EXTERN(int) git_index_caps(const git_index *index);
|
||||
|
||||
/**
|
||||
* Set index capabilities flags.
|
||||
*
|
||||
* If you pass `GIT_INDEX_CAPABILITY_FROM_OWNER` for the caps, then
|
||||
* capabilities will be read from the config of the owner object,
|
||||
* looking at `core.ignorecase`, `core.filemode`, `core.symlinks`.
|
||||
*
|
||||
* @param index An existing index object
|
||||
* @param caps A combination of GIT_INDEX_CAPABILITY values
|
||||
* @return 0 on success, -1 on failure
|
||||
*/
|
||||
GIT_EXTERN(int) git_index_set_caps(git_index *index, int caps);
|
||||
|
||||
/**
|
||||
* Get index on-disk version.
|
||||
*
|
||||
* Valid return values are 2, 3, or 4. If 3 is returned, an index
|
||||
* with version 2 may be written instead, if the extension data in
|
||||
* version 3 is not necessary.
|
||||
*
|
||||
* @param index An existing index object
|
||||
* @return the index version
|
||||
*/
|
||||
GIT_EXTERN(unsigned int) git_index_version(git_index *index);
|
||||
|
||||
/**
|
||||
* Set index on-disk version.
|
||||
*
|
||||
* Valid values are 2, 3, or 4. If 2 is given, git_index_write may
|
||||
* write an index with version 3 instead, if necessary to accurately
|
||||
* represent the index.
|
||||
*
|
||||
* @param index An existing index object
|
||||
* @param version The new version number
|
||||
* @return 0 on success, -1 on failure
|
||||
*/
|
||||
GIT_EXTERN(int) git_index_set_version(git_index *index, unsigned int version);
|
||||
|
||||
/**
|
||||
* Update the contents of an existing index object in memory by reading
|
||||
* from the hard disk.
|
||||
*
|
||||
* If `force` is true, this performs a "hard" read that discards in-memory
|
||||
* changes and always reloads the on-disk index data. If there is no
|
||||
* on-disk version, the index will be cleared.
|
||||
*
|
||||
* If `force` is false, this does a "soft" read that reloads the index
|
||||
* data from disk only if it has changed since the last time it was
|
||||
* loaded. Purely in-memory index data will be untouched. Be aware: if
|
||||
* there are changes on disk, unwritten in-memory changes are discarded.
|
||||
*
|
||||
* @param index an existing index object
|
||||
* @param force if true, always reload, vs. only read if file has changed
|
||||
* @return 0 or an error code
|
||||
*/
|
||||
GIT_EXTERN(int) git_index_read(git_index *index, int force);
|
||||
|
||||
/**
|
||||
* Write an existing index object from memory back to disk
|
||||
* using an atomic file lock.
|
||||
*
|
||||
* @param index an existing index object
|
||||
* @return 0 or an error code
|
||||
*/
|
||||
GIT_EXTERN(int) git_index_write(git_index *index);
|
||||
|
||||
/**
|
||||
* Get the full path to the index file on disk.
|
||||
*
|
||||
* @param index an existing index object
|
||||
* @return path to index file or NULL for in-memory index
|
||||
*/
|
||||
GIT_EXTERN(const char *) git_index_path(const git_index *index);
|
||||
|
||||
#ifndef GIT_DEPRECATE_HARD
|
||||
/**
|
||||
* Get the checksum of the index
|
||||
*
|
||||
* This checksum is the SHA-1 hash over the index file (except the
|
||||
* last 20 bytes which are the checksum itself). In cases where the
|
||||
* index does not exist on-disk, it will be zeroed out.
|
||||
*
|
||||
* @deprecated this function is deprecated with no replacement
|
||||
* @param index an existing index object
|
||||
* @return a pointer to the checksum of the index
|
||||
*/
|
||||
GIT_EXTERN(const git_oid *) git_index_checksum(git_index *index);
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Read a tree into the index file with stats
|
||||
*
|
||||
* The current index contents will be replaced by the specified tree.
|
||||
*
|
||||
* @param index an existing index object
|
||||
* @param tree tree to read
|
||||
* @return 0 or an error code
|
||||
*/
|
||||
GIT_EXTERN(int) git_index_read_tree(git_index *index, const git_tree *tree);
|
||||
|
||||
/**
|
||||
* Write the index as a tree
|
||||
*
|
||||
* This method will scan the index and write a representation
|
||||
* of its current state back to disk; it recursively creates
|
||||
* tree objects for each of the subtrees stored in the index,
|
||||
* but only returns the OID of the root tree. This is the OID
|
||||
* that can be used e.g. to create a commit.
|
||||
*
|
||||
* The index instance cannot be bare, and needs to be associated
|
||||
* to an existing repository.
|
||||
*
|
||||
* The index must not contain any file in conflict.
|
||||
*
|
||||
* @param out Pointer where to store the OID of the written tree
|
||||
* @param index Index to write
|
||||
* @return 0 on success, GIT_EUNMERGED when the index is not clean
|
||||
* or an error code
|
||||
*/
|
||||
GIT_EXTERN(int) git_index_write_tree(git_oid *out, git_index *index);
|
||||
|
||||
/**
|
||||
* Write the index as a tree to the given repository
|
||||
*
|
||||
* This method will do the same as `git_index_write_tree`, but
|
||||
* letting the user choose the repository where the tree will
|
||||
* be written.
|
||||
*
|
||||
* The index must not contain any file in conflict.
|
||||
*
|
||||
* @param out Pointer where to store OID of the written tree
|
||||
* @param index Index to write
|
||||
* @param repo Repository where to write the tree
|
||||
* @return 0 on success, GIT_EUNMERGED when the index is not clean
|
||||
* or an error code
|
||||
*/
|
||||
GIT_EXTERN(int) git_index_write_tree_to(git_oid *out, git_index *index, git_repository *repo);
|
||||
|
||||
/**@}*/
|
||||
|
||||
/** @name Raw Index Entry Functions
|
||||
*
|
||||
* These functions work on index entries, and allow for raw manipulation
|
||||
* of the entries.
|
||||
*/
|
||||
/**@{*/
|
||||
|
||||
/* Index entry manipulation */
|
||||
|
||||
/**
|
||||
* Get the count of entries currently in the index
|
||||
*
|
||||
* @param index an existing index object
|
||||
* @return integer of count of current entries
|
||||
*/
|
||||
GIT_EXTERN(size_t) git_index_entrycount(const git_index *index);
|
||||
|
||||
/**
|
||||
* Clear the contents (all the entries) of an index object.
|
||||
*
|
||||
* This clears the index object in memory; changes must be explicitly
|
||||
* written to disk for them to take effect persistently.
|
||||
*
|
||||
* @param index an existing index object
|
||||
* @return 0 on success, error code < 0 on failure
|
||||
*/
|
||||
GIT_EXTERN(int) git_index_clear(git_index *index);
|
||||
|
||||
/**
|
||||
* Get a pointer to one of the entries in the index
|
||||
*
|
||||
* The entry is not modifiable and should not be freed. Because the
|
||||
* `git_index_entry` struct is a publicly defined struct, you should
|
||||
* be able to make your own permanent copy of the data if necessary.
|
||||
*
|
||||
* @param index an existing index object
|
||||
* @param n the position of the entry
|
||||
* @return a pointer to the entry; NULL if out of bounds
|
||||
*/
|
||||
GIT_EXTERN(const git_index_entry *) git_index_get_byindex(
|
||||
git_index *index, size_t n);
|
||||
|
||||
/**
|
||||
* Get a pointer to one of the entries in the index
|
||||
*
|
||||
* The entry is not modifiable and should not be freed. Because the
|
||||
* `git_index_entry` struct is a publicly defined struct, you should
|
||||
* be able to make your own permanent copy of the data if necessary.
|
||||
*
|
||||
* @param index an existing index object
|
||||
* @param path path to search
|
||||
* @param stage stage to search
|
||||
* @return a pointer to the entry; NULL if it was not found
|
||||
*/
|
||||
GIT_EXTERN(const git_index_entry *) git_index_get_bypath(
|
||||
git_index *index, const char *path, int stage);
|
||||
|
||||
/**
|
||||
* Remove an entry from the index
|
||||
*
|
||||
* @param index an existing index object
|
||||
* @param path path to search
|
||||
* @param stage stage to search
|
||||
* @return 0 or an error code
|
||||
*/
|
||||
GIT_EXTERN(int) git_index_remove(git_index *index, const char *path, int stage);
|
||||
|
||||
/**
|
||||
* Remove all entries from the index under a given directory
|
||||
*
|
||||
* @param index an existing index object
|
||||
* @param dir container directory path
|
||||
* @param stage stage to search
|
||||
* @return 0 or an error code
|
||||
*/
|
||||
GIT_EXTERN(int) git_index_remove_directory(
|
||||
git_index *index, const char *dir, int stage);
|
||||
|
||||
/**
|
||||
* Add or update an index entry from an in-memory struct
|
||||
*
|
||||
* If a previous index entry exists that has the same path and stage
|
||||
* as the given 'source_entry', it will be replaced. Otherwise, the
|
||||
* 'source_entry' will be added.
|
||||
*
|
||||
* A full copy (including the 'path' string) of the given
|
||||
* 'source_entry' will be inserted on the index.
|
||||
*
|
||||
* @param index an existing index object
|
||||
* @param source_entry new entry object
|
||||
* @return 0 or an error code
|
||||
*/
|
||||
GIT_EXTERN(int) git_index_add(git_index *index, const git_index_entry *source_entry);
|
||||
|
||||
/**
|
||||
* Return the stage number from a git index entry
|
||||
*
|
||||
* This entry is calculated from the entry's flag attribute like this:
|
||||
*
|
||||
* (entry->flags & GIT_INDEX_ENTRY_STAGEMASK) >> GIT_INDEX_ENTRY_STAGESHIFT
|
||||
*
|
||||
* @param entry The entry
|
||||
* @return the stage number
|
||||
*/
|
||||
GIT_EXTERN(int) git_index_entry_stage(const git_index_entry *entry);
|
||||
|
||||
/**
|
||||
* Return whether the given index entry is a conflict (has a high stage
|
||||
* entry). This is simply shorthand for `git_index_entry_stage > 0`.
|
||||
*
|
||||
* @param entry The entry
|
||||
* @return 1 if the entry is a conflict entry, 0 otherwise
|
||||
*/
|
||||
GIT_EXTERN(int) git_index_entry_is_conflict(const git_index_entry *entry);
|
||||
|
||||
/**@}*/
|
||||
|
||||
/** @name Index Entry Iteration Functions
|
||||
*
|
||||
* These functions provide an iterator for index entries.
|
||||
*/
|
||||
/**@{*/
|
||||
|
||||
/**
|
||||
* Create an iterator that will return every entry contained in the
|
||||
* index at the time of creation. Entries are returned in order,
|
||||
* sorted by path. This iterator is backed by a snapshot that allows
|
||||
* callers to modify the index while iterating without affecting the
|
||||
* iterator.
|
||||
*
|
||||
* @param iterator_out The newly created iterator
|
||||
* @param index The index to iterate
|
||||
* @return 0 or an error code.
|
||||
*/
|
||||
GIT_EXTERN(int) git_index_iterator_new(
|
||||
git_index_iterator **iterator_out,
|
||||
git_index *index);
|
||||
|
||||
/**
|
||||
* Return the next index entry in-order from the iterator.
|
||||
*
|
||||
* @param out Pointer to store the index entry in
|
||||
* @param iterator The iterator
|
||||
* @return 0, GIT_ITEROVER on iteration completion or an error code
|
||||
*/
|
||||
GIT_EXTERN(int) git_index_iterator_next(
|
||||
const git_index_entry **out,
|
||||
git_index_iterator *iterator);
|
||||
|
||||
/**
|
||||
* Free the index iterator
|
||||
*
|
||||
* @param iterator The iterator to free
|
||||
*/
|
||||
GIT_EXTERN(void) git_index_iterator_free(git_index_iterator *iterator);
|
||||
|
||||
/**@}*/
|
||||
|
||||
/** @name Workdir Index Entry Functions
|
||||
*
|
||||
* These functions work on index entries specifically in the working
|
||||
* directory (ie, stage 0).
|
||||
*/
|
||||
/**@{*/
|
||||
|
||||
/**
|
||||
* Add or update an index entry from a file on disk
|
||||
*
|
||||
* The file `path` must be relative to the repository's
|
||||
* working folder and must be readable.
|
||||
*
|
||||
* This method will fail in bare index instances.
|
||||
*
|
||||
* This forces the file to be added to the index, not looking
|
||||
* at gitignore rules. Those rules can be evaluated through
|
||||
* the git_status APIs (in status.h) before calling this.
|
||||
*
|
||||
* If this file currently is the result of a merge conflict, this
|
||||
* file will no longer be marked as conflicting. The data about
|
||||
* the conflict will be moved to the "resolve undo" (REUC) section.
|
||||
*
|
||||
* @param index an existing index object
|
||||
* @param path filename to add
|
||||
* @return 0 or an error code
|
||||
*/
|
||||
GIT_EXTERN(int) git_index_add_bypath(git_index *index, const char *path);
|
||||
|
||||
/**
|
||||
* Add or update an index entry from a buffer in memory
|
||||
*
|
||||
* This method will create a blob in the repository that owns the
|
||||
* index and then add the index entry to the index. The `path` of the
|
||||
* entry represents the position of the blob relative to the
|
||||
* repository's root folder.
|
||||
*
|
||||
* If a previous index entry exists that has the same path as the
|
||||
* given 'entry', it will be replaced. Otherwise, the 'entry' will be
|
||||
* added.
|
||||
*
|
||||
* This forces the file to be added to the index, not looking
|
||||
* at gitignore rules. Those rules can be evaluated through
|
||||
* the git_status APIs (in status.h) before calling this.
|
||||
*
|
||||
* If this file currently is the result of a merge conflict, this
|
||||
* file will no longer be marked as conflicting. The data about
|
||||
* the conflict will be moved to the "resolve undo" (REUC) section.
|
||||
*
|
||||
* @param index an existing index object
|
||||
* @param entry filename to add
|
||||
* @param buffer data to be written into the blob
|
||||
* @param len length of the data
|
||||
* @return 0 or an error code
|
||||
*/
|
||||
GIT_EXTERN(int) git_index_add_from_buffer(
|
||||
git_index *index,
|
||||
const git_index_entry *entry,
|
||||
const void *buffer, size_t len);
|
||||
|
||||
/**
|
||||
* Remove an index entry corresponding to a file on disk
|
||||
*
|
||||
* The file `path` must be relative to the repository's
|
||||
* working folder. It may exist.
|
||||
*
|
||||
* If this file currently is the result of a merge conflict, this
|
||||
* file will no longer be marked as conflicting. The data about
|
||||
* the conflict will be moved to the "resolve undo" (REUC) section.
|
||||
*
|
||||
* @param index an existing index object
|
||||
* @param path filename to remove
|
||||
* @return 0 or an error code
|
||||
*/
|
||||
GIT_EXTERN(int) git_index_remove_bypath(git_index *index, const char *path);
|
||||
|
||||
/**
|
||||
* Add or update index entries matching files in the working directory.
|
||||
*
|
||||
* This method will fail in bare index instances.
|
||||
*
|
||||
* The `pathspec` is a list of file names or shell glob patterns that will
|
||||
* be matched against files in the repository's working directory. Each
|
||||
* file that matches will be added to the index (either updating an
|
||||
* existing entry or adding a new entry). You can disable glob expansion
|
||||
* and force exact matching with the `GIT_INDEX_ADD_DISABLE_PATHSPEC_MATCH`
|
||||
* flag.
|
||||
*
|
||||
* Files that are ignored will be skipped (unlike `git_index_add_bypath`).
|
||||
* If a file is already tracked in the index, then it *will* be updated
|
||||
* even if it is ignored. Pass the `GIT_INDEX_ADD_FORCE` flag to skip
|
||||
* the checking of ignore rules.
|
||||
*
|
||||
* To emulate `git add -A` and generate an error if the pathspec contains
|
||||
* the exact path of an ignored file (when not using FORCE), add the
|
||||
* `GIT_INDEX_ADD_CHECK_PATHSPEC` flag. This checks that each entry
|
||||
* in the `pathspec` that is an exact match to a filename on disk is
|
||||
* either not ignored or already in the index. If this check fails, the
|
||||
* function will return GIT_EINVALIDSPEC.
|
||||
*
|
||||
* To emulate `git add -A` with the "dry-run" option, just use a callback
|
||||
* function that always returns a positive value. See below for details.
|
||||
*
|
||||
* If any files are currently the result of a merge conflict, those files
|
||||
* will no longer be marked as conflicting. The data about the conflicts
|
||||
* will be moved to the "resolve undo" (REUC) section.
|
||||
*
|
||||
* If you provide a callback function, it will be invoked on each matching
|
||||
* item in the working directory immediately *before* it is added to /
|
||||
* updated in the index. Returning zero will add the item to the index,
|
||||
* greater than zero will skip the item, and less than zero will abort the
|
||||
* scan and return that value to the caller.
|
||||
*
|
||||
* @param index an existing index object
|
||||
* @param pathspec array of path patterns
|
||||
* @param flags combination of git_index_add_option_t flags
|
||||
* @param callback notification callback for each added/updated path (also
|
||||
* gets index of matching pathspec entry); can be NULL;
|
||||
* return 0 to add, >0 to skip, <0 to abort scan.
|
||||
* @param payload payload passed through to callback function
|
||||
* @return 0 on success, negative callback return value, or error code
|
||||
*/
|
||||
GIT_EXTERN(int) git_index_add_all(
|
||||
git_index *index,
|
||||
const git_strarray *pathspec,
|
||||
unsigned int flags,
|
||||
git_index_matched_path_cb callback,
|
||||
void *payload);
|
||||
|
||||
/**
|
||||
* Remove all matching index entries.
|
||||
*
|
||||
* If you provide a callback function, it will be invoked on each matching
|
||||
* item in the index immediately *before* it is removed. Return 0 to
|
||||
* remove the item, > 0 to skip the item, and < 0 to abort the scan.
|
||||
*
|
||||
* @param index An existing index object
|
||||
* @param pathspec array of path patterns
|
||||
* @param callback notification callback for each removed path (also
|
||||
* gets index of matching pathspec entry); can be NULL;
|
||||
* return 0 to add, >0 to skip, <0 to abort scan.
|
||||
* @param payload payload passed through to callback function
|
||||
* @return 0 on success, negative callback return value, or error code
|
||||
*/
|
||||
GIT_EXTERN(int) git_index_remove_all(
|
||||
git_index *index,
|
||||
const git_strarray *pathspec,
|
||||
git_index_matched_path_cb callback,
|
||||
void *payload);
|
||||
|
||||
/**
|
||||
* Update all index entries to match the working directory
|
||||
*
|
||||
* This method will fail in bare index instances.
|
||||
*
|
||||
* This scans the existing index entries and synchronizes them with the
|
||||
* working directory, deleting them if the corresponding working directory
|
||||
* file no longer exists otherwise updating the information (including
|
||||
* adding the latest version of file to the ODB if needed).
|
||||
*
|
||||
* If you provide a callback function, it will be invoked on each matching
|
||||
* item in the index immediately *before* it is updated (either refreshed
|
||||
* or removed depending on working directory state). Return 0 to proceed
|
||||
* with updating the item, > 0 to skip the item, and < 0 to abort the scan.
|
||||
*
|
||||
* @param index An existing index object
|
||||
* @param pathspec array of path patterns
|
||||
* @param callback notification callback for each updated path (also
|
||||
* gets index of matching pathspec entry); can be NULL;
|
||||
* return 0 to add, >0 to skip, <0 to abort scan.
|
||||
* @param payload payload passed through to callback function
|
||||
* @return 0 on success, negative callback return value, or error code
|
||||
*/
|
||||
GIT_EXTERN(int) git_index_update_all(
|
||||
git_index *index,
|
||||
const git_strarray *pathspec,
|
||||
git_index_matched_path_cb callback,
|
||||
void *payload);
|
||||
|
||||
/**
|
||||
* Find the first position of any entries which point to given
|
||||
* path in the Git index.
|
||||
*
|
||||
* @param at_pos the address to which the position of the index entry is written (optional)
|
||||
* @param index an existing index object
|
||||
* @param path path to search
|
||||
* @return 0 or an error code
|
||||
*/
|
||||
GIT_EXTERN(int) git_index_find(size_t *at_pos, git_index *index, const char *path);
|
||||
|
||||
/**
|
||||
* Find the first position of any entries matching a prefix. To find the first position
|
||||
* of a path inside a given folder, suffix the prefix with a '/'.
|
||||
*
|
||||
* @param at_pos the address to which the position of the index entry is written (optional)
|
||||
* @param index an existing index object
|
||||
* @param prefix the prefix to search for
|
||||
* @return 0 or an error code
|
||||
*/
|
||||
GIT_EXTERN(int) git_index_find_prefix(size_t *at_pos, git_index *index, const char *prefix);
|
||||
|
||||
/**@}*/
|
||||
|
||||
/** @name Conflict Index Entry Functions
|
||||
*
|
||||
* These functions work on conflict index entries specifically (ie, stages 1-3)
|
||||
*/
|
||||
/**@{*/
|
||||
|
||||
/**
|
||||
* Add or update index entries to represent a conflict. Any staged
|
||||
* entries that exist at the given paths will be removed.
|
||||
*
|
||||
* The entries are the entries from the tree included in the merge. Any
|
||||
* entry may be null to indicate that that file was not present in the
|
||||
* trees during the merge. For example, ancestor_entry may be NULL to
|
||||
* indicate that a file was added in both branches and must be resolved.
|
||||
*
|
||||
* @param index an existing index object
|
||||
* @param ancestor_entry the entry data for the ancestor of the conflict
|
||||
* @param our_entry the entry data for our side of the merge conflict
|
||||
* @param their_entry the entry data for their side of the merge conflict
|
||||
* @return 0 or an error code
|
||||
*/
|
||||
GIT_EXTERN(int) git_index_conflict_add(
|
||||
git_index *index,
|
||||
const git_index_entry *ancestor_entry,
|
||||
const git_index_entry *our_entry,
|
||||
const git_index_entry *their_entry);
|
||||
|
||||
/**
|
||||
* Get the index entries that represent a conflict of a single file.
|
||||
*
|
||||
* The entries are not modifiable and should not be freed. Because the
|
||||
* `git_index_entry` struct is a publicly defined struct, you should
|
||||
* be able to make your own permanent copy of the data if necessary.
|
||||
*
|
||||
* @param ancestor_out Pointer to store the ancestor entry
|
||||
* @param our_out Pointer to store the our entry
|
||||
* @param their_out Pointer to store the their entry
|
||||
* @param index an existing index object
|
||||
* @param path path to search
|
||||
* @return 0 or an error code
|
||||
*/
|
||||
GIT_EXTERN(int) git_index_conflict_get(
|
||||
const git_index_entry **ancestor_out,
|
||||
const git_index_entry **our_out,
|
||||
const git_index_entry **their_out,
|
||||
git_index *index,
|
||||
const char *path);
|
||||
|
||||
/**
|
||||
* Removes the index entries that represent a conflict of a single file.
|
||||
*
|
||||
* @param index an existing index object
|
||||
* @param path path to remove conflicts for
|
||||
* @return 0 or an error code
|
||||
*/
|
||||
GIT_EXTERN(int) git_index_conflict_remove(git_index *index, const char *path);
|
||||
|
||||
/**
|
||||
* Remove all conflicts in the index (entries with a stage greater than 0).
|
||||
*
|
||||
* @param index an existing index object
|
||||
* @return 0 or an error code
|
||||
*/
|
||||
GIT_EXTERN(int) git_index_conflict_cleanup(git_index *index);
|
||||
|
||||
/**
|
||||
* Determine if the index contains entries representing file conflicts.
|
||||
*
|
||||
* @param index An existing index object.
|
||||
* @return 1 if at least one conflict is found, 0 otherwise.
|
||||
*/
|
||||
GIT_EXTERN(int) git_index_has_conflicts(const git_index *index);
|
||||
|
||||
/**
|
||||
* Create an iterator for the conflicts in the index.
|
||||
*
|
||||
* The index must not be modified while iterating; the results are undefined.
|
||||
*
|
||||
* @param iterator_out The newly created conflict iterator
|
||||
* @param index The index to scan
|
||||
* @return 0 or an error code
|
||||
*/
|
||||
GIT_EXTERN(int) git_index_conflict_iterator_new(
|
||||
git_index_conflict_iterator **iterator_out,
|
||||
git_index *index);
|
||||
|
||||
/**
|
||||
* Returns the current conflict (ancestor, ours and theirs entry) and
|
||||
* advance the iterator internally to the next value.
|
||||
*
|
||||
* @param ancestor_out Pointer to store the ancestor side of the conflict
|
||||
* @param our_out Pointer to store our side of the conflict
|
||||
* @param their_out Pointer to store their side of the conflict
|
||||
* @param iterator The conflict iterator.
|
||||
* @return 0 (no error), GIT_ITEROVER (iteration is done) or an error code
|
||||
* (negative value)
|
||||
*/
|
||||
GIT_EXTERN(int) git_index_conflict_next(
|
||||
const git_index_entry **ancestor_out,
|
||||
const git_index_entry **our_out,
|
||||
const git_index_entry **their_out,
|
||||
git_index_conflict_iterator *iterator);
|
||||
|
||||
/**
|
||||
* Frees a `git_index_conflict_iterator`.
|
||||
*
|
||||
* @param iterator pointer to the iterator
|
||||
*/
|
||||
GIT_EXTERN(void) git_index_conflict_iterator_free(
|
||||
git_index_conflict_iterator *iterator);
|
||||
|
||||
/** @} */
|
||||
GIT_END_DECL
|
||||
#endif
|
195
3rdparty/libgit2/include/git2/indexer.h
vendored
Normal file
195
3rdparty/libgit2/include/git2/indexer.h
vendored
Normal file
@ -0,0 +1,195 @@
|
||||
/*
|
||||
* Copyright (C) the libgit2 contributors. All rights reserved.
|
||||
*
|
||||
* This file is part of libgit2, distributed under the GNU GPL v2 with
|
||||
* a Linking Exception. For full terms see the included COPYING file.
|
||||
*/
|
||||
#ifndef _INCLUDE_git_indexer_h__
|
||||
#define _INCLUDE_git_indexer_h__
|
||||
|
||||
#include "common.h"
|
||||
#include "types.h"
|
||||
#include "oid.h"
|
||||
|
||||
GIT_BEGIN_DECL
|
||||
|
||||
/** A git indexer object */
|
||||
typedef struct git_indexer git_indexer;
|
||||
|
||||
/**
|
||||
* This structure is used to provide callers information about the
|
||||
* progress of indexing a packfile, either directly or part of a
|
||||
* fetch or clone that downloads a packfile.
|
||||
*/
|
||||
typedef struct git_indexer_progress {
|
||||
/** number of objects in the packfile being indexed */
|
||||
unsigned int total_objects;
|
||||
|
||||
/** received objects that have been hashed */
|
||||
unsigned int indexed_objects;
|
||||
|
||||
/** received_objects: objects which have been downloaded */
|
||||
unsigned int received_objects;
|
||||
|
||||
/**
|
||||
* locally-available objects that have been injected in order
|
||||
* to fix a thin pack
|
||||
*/
|
||||
unsigned int local_objects;
|
||||
|
||||
/** number of deltas in the packfile being indexed */
|
||||
unsigned int total_deltas;
|
||||
|
||||
/** received deltas that have been indexed */
|
||||
unsigned int indexed_deltas;
|
||||
|
||||
/** size of the packfile received up to now */
|
||||
size_t received_bytes;
|
||||
} git_indexer_progress;
|
||||
|
||||
/**
|
||||
* Type for progress callbacks during indexing. Return a value less
|
||||
* than zero to cancel the indexing or download.
|
||||
*
|
||||
* @param stats Structure containing information about the state of the transfer
|
||||
* @param payload Payload provided by caller
|
||||
*/
|
||||
typedef int GIT_CALLBACK(git_indexer_progress_cb)(const git_indexer_progress *stats, void *payload);
|
||||
|
||||
/**
|
||||
* Options for indexer configuration
|
||||
*/
|
||||
typedef struct git_indexer_options {
|
||||
unsigned int version;
|
||||
|
||||
#ifdef GIT_EXPERIMENTAL_SHA256
|
||||
/** permissions to use creating packfile or 0 for defaults */
|
||||
unsigned int mode;
|
||||
|
||||
/**
|
||||
* object database from which to read base objects when
|
||||
* fixing thin packs. This can be NULL if there are no thin
|
||||
* packs; if a thin pack is encountered, an error will be
|
||||
* returned if there are bases missing.
|
||||
*/
|
||||
git_odb *odb;
|
||||
#endif
|
||||
|
||||
/** progress_cb function to call with progress information */
|
||||
git_indexer_progress_cb progress_cb;
|
||||
|
||||
/** progress_cb_payload payload for the progress callback */
|
||||
void *progress_cb_payload;
|
||||
|
||||
/** Do connectivity checks for the received pack */
|
||||
unsigned char verify;
|
||||
} git_indexer_options;
|
||||
|
||||
#define GIT_INDEXER_OPTIONS_VERSION 1
|
||||
#define GIT_INDEXER_OPTIONS_INIT { GIT_INDEXER_OPTIONS_VERSION }
|
||||
|
||||
/**
|
||||
* Initializes a `git_indexer_options` with default values. Equivalent to
|
||||
* creating an instance with GIT_INDEXER_OPTIONS_INIT.
|
||||
*
|
||||
* @param opts the `git_indexer_options` struct to initialize.
|
||||
* @param version Version of struct; pass `GIT_INDEXER_OPTIONS_VERSION`
|
||||
* @return Zero on success; -1 on failure.
|
||||
*/
|
||||
GIT_EXTERN(int) git_indexer_options_init(
|
||||
git_indexer_options *opts,
|
||||
unsigned int version);
|
||||
|
||||
#ifdef GIT_EXPERIMENTAL_SHA256
|
||||
/**
|
||||
* Create a new indexer instance
|
||||
*
|
||||
* @param out where to store the indexer instance
|
||||
* @param path to the directory where the packfile should be stored
|
||||
* @param oid_type the oid type to use for objects
|
||||
* @return 0 or an error code.
|
||||
*/
|
||||
GIT_EXTERN(int) git_indexer_new(
|
||||
git_indexer **out,
|
||||
const char *path,
|
||||
git_oid_t oid_type,
|
||||
git_indexer_options *opts);
|
||||
#else
|
||||
/**
|
||||
* Create a new indexer instance
|
||||
*
|
||||
* @param out where to store the indexer instance
|
||||
* @param path to the directory where the packfile should be stored
|
||||
* @param mode permissions to use creating packfile or 0 for defaults
|
||||
* @param odb object database from which to read base objects when
|
||||
* fixing thin packs. Pass NULL if no thin pack is expected (an error
|
||||
* will be returned if there are bases missing)
|
||||
* @param opts Optional structure containing additional options. See
|
||||
* `git_indexer_options` above.
|
||||
* @return 0 or an error code.
|
||||
*/
|
||||
GIT_EXTERN(int) git_indexer_new(
|
||||
git_indexer **out,
|
||||
const char *path,
|
||||
unsigned int mode,
|
||||
git_odb *odb,
|
||||
git_indexer_options *opts);
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Add data to the indexer
|
||||
*
|
||||
* @param idx the indexer
|
||||
* @param data the data to add
|
||||
* @param size the size of the data in bytes
|
||||
* @param stats stat storage
|
||||
* @return 0 or an error code.
|
||||
*/
|
||||
GIT_EXTERN(int) git_indexer_append(git_indexer *idx, const void *data, size_t size, git_indexer_progress *stats);
|
||||
|
||||
/**
|
||||
* Finalize the pack and index
|
||||
*
|
||||
* Resolve any pending deltas and write out the index file
|
||||
*
|
||||
* @param idx the indexer
|
||||
* @param stats Stat storage.
|
||||
* @return 0 or an error code.
|
||||
*/
|
||||
GIT_EXTERN(int) git_indexer_commit(git_indexer *idx, git_indexer_progress *stats);
|
||||
|
||||
#ifndef GIT_DEPRECATE_HARD
|
||||
/**
|
||||
* Get the packfile's hash
|
||||
*
|
||||
* A packfile's name is derived from the sorted hashing of all object
|
||||
* names. This is only correct after the index has been finalized.
|
||||
*
|
||||
* @deprecated use git_indexer_name
|
||||
* @param idx the indexer instance
|
||||
* @return the packfile's hash
|
||||
*/
|
||||
GIT_EXTERN(const git_oid *) git_indexer_hash(const git_indexer *idx);
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Get the unique name for the resulting packfile.
|
||||
*
|
||||
* The packfile's name is derived from the packfile's content.
|
||||
* This is only correct after the index has been finalized.
|
||||
*
|
||||
* @param idx the indexer instance
|
||||
* @return a NUL terminated string for the packfile name
|
||||
*/
|
||||
GIT_EXTERN(const char *) git_indexer_name(const git_indexer *idx);
|
||||
|
||||
/**
|
||||
* Free the indexer and its resources
|
||||
*
|
||||
* @param idx the indexer to free
|
||||
*/
|
||||
GIT_EXTERN(void) git_indexer_free(git_indexer *idx);
|
||||
|
||||
GIT_END_DECL
|
||||
|
||||
#endif
|
115
3rdparty/libgit2/include/git2/mailmap.h
vendored
Normal file
115
3rdparty/libgit2/include/git2/mailmap.h
vendored
Normal file
@ -0,0 +1,115 @@
|
||||
/*
|
||||
* Copyright (C) the libgit2 contributors. All rights reserved.
|
||||
*
|
||||
* This file is part of libgit2, distributed under the GNU GPL v2 with
|
||||
* a Linking Exception. For full terms see the included COPYING file.
|
||||
*/
|
||||
#ifndef INCLUDE_git_mailmap_h__
|
||||
#define INCLUDE_git_mailmap_h__
|
||||
|
||||
#include "common.h"
|
||||
#include "types.h"
|
||||
#include "buffer.h"
|
||||
|
||||
/**
|
||||
* @file git2/mailmap.h
|
||||
* @brief Mailmap parsing routines
|
||||
* @defgroup git_mailmap Git mailmap routines
|
||||
* @ingroup Git
|
||||
* @{
|
||||
*/
|
||||
GIT_BEGIN_DECL
|
||||
|
||||
/**
|
||||
* Allocate a new mailmap object.
|
||||
*
|
||||
* This object is empty, so you'll have to add a mailmap file before you can do
|
||||
* anything with it. The mailmap must be freed with 'git_mailmap_free'.
|
||||
*
|
||||
* @param out pointer to store the new mailmap
|
||||
* @return 0 on success, or an error code
|
||||
*/
|
||||
GIT_EXTERN(int) git_mailmap_new(git_mailmap **out);
|
||||
|
||||
/**
|
||||
* Free the mailmap and its associated memory.
|
||||
*
|
||||
* @param mm the mailmap to free
|
||||
*/
|
||||
GIT_EXTERN(void) git_mailmap_free(git_mailmap *mm);
|
||||
|
||||
/**
|
||||
* Add a single entry to the given mailmap object. If the entry already exists,
|
||||
* it will be replaced with the new entry.
|
||||
*
|
||||
* @param mm mailmap to add the entry to
|
||||
* @param real_name the real name to use, or NULL
|
||||
* @param real_email the real email to use, or NULL
|
||||
* @param replace_name the name to replace, or NULL
|
||||
* @param replace_email the email to replace
|
||||
* @return 0 on success, or an error code
|
||||
*/
|
||||
GIT_EXTERN(int) git_mailmap_add_entry(
|
||||
git_mailmap *mm, const char *real_name, const char *real_email,
|
||||
const char *replace_name, const char *replace_email);
|
||||
|
||||
/**
|
||||
* Create a new mailmap instance containing a single mailmap file
|
||||
*
|
||||
* @param out pointer to store the new mailmap
|
||||
* @param buf buffer to parse the mailmap from
|
||||
* @param len the length of the input buffer
|
||||
* @return 0 on success, or an error code
|
||||
*/
|
||||
GIT_EXTERN(int) git_mailmap_from_buffer(
|
||||
git_mailmap **out, const char *buf, size_t len);
|
||||
|
||||
/**
|
||||
* Create a new mailmap instance from a repository, loading mailmap files based
|
||||
* on the repository's configuration.
|
||||
*
|
||||
* Mailmaps are loaded in the following order:
|
||||
* 1. '.mailmap' in the root of the repository's working directory, if present.
|
||||
* 2. The blob object identified by the 'mailmap.blob' config entry, if set.
|
||||
* [NOTE: 'mailmap.blob' defaults to 'HEAD:.mailmap' in bare repositories]
|
||||
* 3. The path in the 'mailmap.file' config entry, if set.
|
||||
*
|
||||
* @param out pointer to store the new mailmap
|
||||
* @param repo repository to load mailmap information from
|
||||
* @return 0 on success, or an error code
|
||||
*/
|
||||
GIT_EXTERN(int) git_mailmap_from_repository(
|
||||
git_mailmap **out, git_repository *repo);
|
||||
|
||||
/**
|
||||
* Resolve a name and email to the corresponding real name and email.
|
||||
*
|
||||
* The lifetime of the strings are tied to `mm`, `name`, and `email` parameters.
|
||||
*
|
||||
* @param real_name pointer to store the real name
|
||||
* @param real_email pointer to store the real email
|
||||
* @param mm the mailmap to perform a lookup with (may be NULL)
|
||||
* @param name the name to look up
|
||||
* @param email the email to look up
|
||||
* @return 0 on success, or an error code
|
||||
*/
|
||||
GIT_EXTERN(int) git_mailmap_resolve(
|
||||
const char **real_name, const char **real_email,
|
||||
const git_mailmap *mm, const char *name, const char *email);
|
||||
|
||||
/**
|
||||
* Resolve a signature to use real names and emails with a mailmap.
|
||||
*
|
||||
* Call `git_signature_free()` to free the data.
|
||||
*
|
||||
* @param out new signature
|
||||
* @param mm mailmap to resolve with
|
||||
* @param sig signature to resolve
|
||||
* @return 0 or an error code
|
||||
*/
|
||||
GIT_EXTERN(int) git_mailmap_resolve_signature(
|
||||
git_signature **out, const git_mailmap *mm, const git_signature *sig);
|
||||
|
||||
/** @} */
|
||||
GIT_END_DECL
|
||||
#endif
|
626
3rdparty/libgit2/include/git2/merge.h
vendored
Normal file
626
3rdparty/libgit2/include/git2/merge.h
vendored
Normal file
@ -0,0 +1,626 @@
|
||||
/*
|
||||
* Copyright (C) the libgit2 contributors. All rights reserved.
|
||||
*
|
||||
* This file is part of libgit2, distributed under the GNU GPL v2 with
|
||||
* a Linking Exception. For full terms see the included COPYING file.
|
||||
*/
|
||||
#ifndef INCLUDE_git_merge_h__
|
||||
#define INCLUDE_git_merge_h__
|
||||
|
||||
#include "common.h"
|
||||
#include "types.h"
|
||||
#include "oid.h"
|
||||
#include "oidarray.h"
|
||||
#include "checkout.h"
|
||||
#include "index.h"
|
||||
#include "annotated_commit.h"
|
||||
|
||||
/**
|
||||
* @file git2/merge.h
|
||||
* @brief Git merge routines
|
||||
* @defgroup git_merge Git merge routines
|
||||
* @ingroup Git
|
||||
* @{
|
||||
*/
|
||||
GIT_BEGIN_DECL
|
||||
|
||||
/**
|
||||
* The file inputs to `git_merge_file`. Callers should populate the
|
||||
* `git_merge_file_input` structure with descriptions of the files in
|
||||
* each side of the conflict for use in producing the merge file.
|
||||
*/
|
||||
typedef struct {
|
||||
unsigned int version;
|
||||
|
||||
/** Pointer to the contents of the file. */
|
||||
const char *ptr;
|
||||
|
||||
/** Size of the contents pointed to in `ptr`. */
|
||||
size_t size;
|
||||
|
||||
/** File name of the conflicted file, or `NULL` to not merge the path. */
|
||||
const char *path;
|
||||
|
||||
/** File mode of the conflicted file, or `0` to not merge the mode. */
|
||||
unsigned int mode;
|
||||
} git_merge_file_input;
|
||||
|
||||
#define GIT_MERGE_FILE_INPUT_VERSION 1
|
||||
#define GIT_MERGE_FILE_INPUT_INIT {GIT_MERGE_FILE_INPUT_VERSION}
|
||||
|
||||
/**
|
||||
* Initializes a `git_merge_file_input` with default values. Equivalent to
|
||||
* creating an instance with GIT_MERGE_FILE_INPUT_INIT.
|
||||
*
|
||||
* @param opts the `git_merge_file_input` instance to initialize.
|
||||
* @param version the version of the struct; you should pass
|
||||
* `GIT_MERGE_FILE_INPUT_VERSION` here.
|
||||
* @return Zero on success; -1 on failure.
|
||||
*/
|
||||
GIT_EXTERN(int) git_merge_file_input_init(
|
||||
git_merge_file_input *opts,
|
||||
unsigned int version);
|
||||
|
||||
/**
|
||||
* Flags for `git_merge` options. A combination of these flags can be
|
||||
* passed in via the `flags` value in the `git_merge_options`.
|
||||
*/
|
||||
typedef enum {
|
||||
/**
|
||||
* Detect renames that occur between the common ancestor and the "ours"
|
||||
* side or the common ancestor and the "theirs" side. This will enable
|
||||
* the ability to merge between a modified and renamed file.
|
||||
*/
|
||||
GIT_MERGE_FIND_RENAMES = (1 << 0),
|
||||
|
||||
/**
|
||||
* If a conflict occurs, exit immediately instead of attempting to
|
||||
* continue resolving conflicts. The merge operation will fail with
|
||||
* GIT_EMERGECONFLICT and no index will be returned.
|
||||
*/
|
||||
GIT_MERGE_FAIL_ON_CONFLICT = (1 << 1),
|
||||
|
||||
/**
|
||||
* Do not write the REUC extension on the generated index
|
||||
*/
|
||||
GIT_MERGE_SKIP_REUC = (1 << 2),
|
||||
|
||||
/**
|
||||
* If the commits being merged have multiple merge bases, do not build
|
||||
* a recursive merge base (by merging the multiple merge bases),
|
||||
* instead simply use the first base. This flag provides a similar
|
||||
* merge base to `git-merge-resolve`.
|
||||
*/
|
||||
GIT_MERGE_NO_RECURSIVE = (1 << 3),
|
||||
|
||||
/**
|
||||
* Treat this merge as if it is to produce the virtual base
|
||||
* of a recursive merge. This will ensure that there are
|
||||
* no conflicts, any conflicting regions will keep conflict
|
||||
* markers in the merge result.
|
||||
*/
|
||||
GIT_MERGE_VIRTUAL_BASE = (1 << 4)
|
||||
} git_merge_flag_t;
|
||||
|
||||
/**
|
||||
* Merge file favor options for `git_merge_options` instruct the file-level
|
||||
* merging functionality how to deal with conflicting regions of the files.
|
||||
*/
|
||||
typedef enum {
|
||||
/**
|
||||
* When a region of a file is changed in both branches, a conflict
|
||||
* will be recorded in the index so that `git_checkout` can produce
|
||||
* a merge file with conflict markers in the working directory.
|
||||
* This is the default.
|
||||
*/
|
||||
GIT_MERGE_FILE_FAVOR_NORMAL = 0,
|
||||
|
||||
/**
|
||||
* When a region of a file is changed in both branches, the file
|
||||
* created in the index will contain the "ours" side of any conflicting
|
||||
* region. The index will not record a conflict.
|
||||
*/
|
||||
GIT_MERGE_FILE_FAVOR_OURS = 1,
|
||||
|
||||
/**
|
||||
* When a region of a file is changed in both branches, the file
|
||||
* created in the index will contain the "theirs" side of any conflicting
|
||||
* region. The index will not record a conflict.
|
||||
*/
|
||||
GIT_MERGE_FILE_FAVOR_THEIRS = 2,
|
||||
|
||||
/**
|
||||
* When a region of a file is changed in both branches, the file
|
||||
* created in the index will contain each unique line from each side,
|
||||
* which has the result of combining both files. The index will not
|
||||
* record a conflict.
|
||||
*/
|
||||
GIT_MERGE_FILE_FAVOR_UNION = 3
|
||||
} git_merge_file_favor_t;
|
||||
|
||||
/**
|
||||
* File merging flags
|
||||
*/
|
||||
typedef enum {
|
||||
/** Defaults */
|
||||
GIT_MERGE_FILE_DEFAULT = 0,
|
||||
|
||||
/** Create standard conflicted merge files */
|
||||
GIT_MERGE_FILE_STYLE_MERGE = (1 << 0),
|
||||
|
||||
/** Create diff3-style files */
|
||||
GIT_MERGE_FILE_STYLE_DIFF3 = (1 << 1),
|
||||
|
||||
/** Condense non-alphanumeric regions for simplified diff file */
|
||||
GIT_MERGE_FILE_SIMPLIFY_ALNUM = (1 << 2),
|
||||
|
||||
/** Ignore all whitespace */
|
||||
GIT_MERGE_FILE_IGNORE_WHITESPACE = (1 << 3),
|
||||
|
||||
/** Ignore changes in amount of whitespace */
|
||||
GIT_MERGE_FILE_IGNORE_WHITESPACE_CHANGE = (1 << 4),
|
||||
|
||||
/** Ignore whitespace at end of line */
|
||||
GIT_MERGE_FILE_IGNORE_WHITESPACE_EOL = (1 << 5),
|
||||
|
||||
/** Use the "patience diff" algorithm */
|
||||
GIT_MERGE_FILE_DIFF_PATIENCE = (1 << 6),
|
||||
|
||||
/** Take extra time to find minimal diff */
|
||||
GIT_MERGE_FILE_DIFF_MINIMAL = (1 << 7),
|
||||
|
||||
/** Create zdiff3 ("zealous diff3")-style files */
|
||||
GIT_MERGE_FILE_STYLE_ZDIFF3 = (1 << 8),
|
||||
|
||||
/**
|
||||
* Do not produce file conflicts when common regions have
|
||||
* changed; keep the conflict markers in the file and accept
|
||||
* that as the merge result.
|
||||
*/
|
||||
GIT_MERGE_FILE_ACCEPT_CONFLICTS = (1 << 9)
|
||||
} git_merge_file_flag_t;
|
||||
|
||||
#define GIT_MERGE_CONFLICT_MARKER_SIZE 7
|
||||
|
||||
/**
|
||||
* Options for merging a file
|
||||
*/
|
||||
typedef struct {
|
||||
unsigned int version;
|
||||
|
||||
/**
|
||||
* Label for the ancestor file side of the conflict which will be prepended
|
||||
* to labels in diff3-format merge files.
|
||||
*/
|
||||
const char *ancestor_label;
|
||||
|
||||
/**
|
||||
* Label for our file side of the conflict which will be prepended
|
||||
* to labels in merge files.
|
||||
*/
|
||||
const char *our_label;
|
||||
|
||||
/**
|
||||
* Label for their file side of the conflict which will be prepended
|
||||
* to labels in merge files.
|
||||
*/
|
||||
const char *their_label;
|
||||
|
||||
/** The file to favor in region conflicts. */
|
||||
git_merge_file_favor_t favor;
|
||||
|
||||
/** see `git_merge_file_flag_t` above */
|
||||
uint32_t flags;
|
||||
|
||||
/** The size of conflict markers (eg, "<<<<<<<"). Default is
|
||||
* GIT_MERGE_CONFLICT_MARKER_SIZE. */
|
||||
unsigned short marker_size;
|
||||
} git_merge_file_options;
|
||||
|
||||
#define GIT_MERGE_FILE_OPTIONS_VERSION 1
|
||||
#define GIT_MERGE_FILE_OPTIONS_INIT {GIT_MERGE_FILE_OPTIONS_VERSION}
|
||||
|
||||
/**
|
||||
* Initialize git_merge_file_options structure
|
||||
*
|
||||
* Initializes a `git_merge_file_options` with default values. Equivalent to
|
||||
* creating an instance with `GIT_MERGE_FILE_OPTIONS_INIT`.
|
||||
*
|
||||
* @param opts The `git_merge_file_options` struct to initialize.
|
||||
* @param version The struct version; pass `GIT_MERGE_FILE_OPTIONS_VERSION`.
|
||||
* @return Zero on success; -1 on failure.
|
||||
*/
|
||||
GIT_EXTERN(int) git_merge_file_options_init(git_merge_file_options *opts, unsigned int version);
|
||||
|
||||
/**
|
||||
* Information about file-level merging
|
||||
*/
|
||||
typedef struct {
|
||||
/**
|
||||
* True if the output was automerged, false if the output contains
|
||||
* conflict markers.
|
||||
*/
|
||||
unsigned int automergeable;
|
||||
|
||||
/**
|
||||
* The path that the resultant merge file should use, or NULL if a
|
||||
* filename conflict would occur.
|
||||
*/
|
||||
const char *path;
|
||||
|
||||
/** The mode that the resultant merge file should use. */
|
||||
unsigned int mode;
|
||||
|
||||
/** The contents of the merge. */
|
||||
const char *ptr;
|
||||
|
||||
/** The length of the merge contents. */
|
||||
size_t len;
|
||||
} git_merge_file_result;
|
||||
|
||||
/**
|
||||
* Merging options
|
||||
*/
|
||||
typedef struct {
|
||||
unsigned int version;
|
||||
|
||||
/** See `git_merge_flag_t` above */
|
||||
uint32_t flags;
|
||||
|
||||
/**
|
||||
* Similarity to consider a file renamed (default 50). If
|
||||
* `GIT_MERGE_FIND_RENAMES` is enabled, added files will be compared
|
||||
* with deleted files to determine their similarity. Files that are
|
||||
* more similar than the rename threshold (percentage-wise) will be
|
||||
* treated as a rename.
|
||||
*/
|
||||
unsigned int rename_threshold;
|
||||
|
||||
/**
|
||||
* Maximum similarity sources to examine for renames (default 200).
|
||||
* If the number of rename candidates (add / delete pairs) is greater
|
||||
* than this value, inexact rename detection is aborted.
|
||||
*
|
||||
* This setting overrides the `merge.renameLimit` configuration value.
|
||||
*/
|
||||
unsigned int target_limit;
|
||||
|
||||
/** Pluggable similarity metric; pass NULL to use internal metric */
|
||||
git_diff_similarity_metric *metric;
|
||||
|
||||
/**
|
||||
* Maximum number of times to merge common ancestors to build a
|
||||
* virtual merge base when faced with criss-cross merges. When this
|
||||
* limit is reached, the next ancestor will simply be used instead of
|
||||
* attempting to merge it. The default is unlimited.
|
||||
*/
|
||||
unsigned int recursion_limit;
|
||||
|
||||
/**
|
||||
* Default merge driver to be used when both sides of a merge have
|
||||
* changed. The default is the `text` driver.
|
||||
*/
|
||||
const char *default_driver;
|
||||
|
||||
/**
|
||||
* Flags for handling conflicting content, to be used with the standard
|
||||
* (`text`) merge driver.
|
||||
*/
|
||||
git_merge_file_favor_t file_favor;
|
||||
|
||||
/** see `git_merge_file_flag_t` above */
|
||||
uint32_t file_flags;
|
||||
} git_merge_options;
|
||||
|
||||
#define GIT_MERGE_OPTIONS_VERSION 1
|
||||
#define GIT_MERGE_OPTIONS_INIT { \
|
||||
GIT_MERGE_OPTIONS_VERSION, GIT_MERGE_FIND_RENAMES }
|
||||
|
||||
/**
|
||||
* Initialize git_merge_options structure
|
||||
*
|
||||
* Initializes a `git_merge_options` with default values. Equivalent to
|
||||
* creating an instance with `GIT_MERGE_OPTIONS_INIT`.
|
||||
*
|
||||
* @param opts The `git_merge_options` struct to initialize.
|
||||
* @param version The struct version; pass `GIT_MERGE_OPTIONS_VERSION`.
|
||||
* @return Zero on success; -1 on failure.
|
||||
*/
|
||||
GIT_EXTERN(int) git_merge_options_init(git_merge_options *opts, unsigned int version);
|
||||
|
||||
/**
|
||||
* The results of `git_merge_analysis` indicate the merge opportunities.
|
||||
*/
|
||||
typedef enum {
|
||||
/** No merge is possible. (Unused.) */
|
||||
GIT_MERGE_ANALYSIS_NONE = 0,
|
||||
|
||||
/**
|
||||
* A "normal" merge; both HEAD and the given merge input have diverged
|
||||
* from their common ancestor. The divergent commits must be merged.
|
||||
*/
|
||||
GIT_MERGE_ANALYSIS_NORMAL = (1 << 0),
|
||||
|
||||
/**
|
||||
* All given merge inputs are reachable from HEAD, meaning the
|
||||
* repository is up-to-date and no merge needs to be performed.
|
||||
*/
|
||||
GIT_MERGE_ANALYSIS_UP_TO_DATE = (1 << 1),
|
||||
|
||||
/**
|
||||
* The given merge input is a fast-forward from HEAD and no merge
|
||||
* needs to be performed. Instead, the client can check out the
|
||||
* given merge input.
|
||||
*/
|
||||
GIT_MERGE_ANALYSIS_FASTFORWARD = (1 << 2),
|
||||
|
||||
/**
|
||||
* The HEAD of the current repository is "unborn" and does not point to
|
||||
* a valid commit. No merge can be performed, but the caller may wish
|
||||
* to simply set HEAD to the target commit(s).
|
||||
*/
|
||||
GIT_MERGE_ANALYSIS_UNBORN = (1 << 3)
|
||||
} git_merge_analysis_t;
|
||||
|
||||
/**
|
||||
* The user's stated preference for merges.
|
||||
*/
|
||||
typedef enum {
|
||||
/**
|
||||
* No configuration was found that suggests a preferred behavior for
|
||||
* merge.
|
||||
*/
|
||||
GIT_MERGE_PREFERENCE_NONE = 0,
|
||||
|
||||
/**
|
||||
* There is a `merge.ff=false` configuration setting, suggesting that
|
||||
* the user does not want to allow a fast-forward merge.
|
||||
*/
|
||||
GIT_MERGE_PREFERENCE_NO_FASTFORWARD = (1 << 0),
|
||||
|
||||
/**
|
||||
* There is a `merge.ff=only` configuration setting, suggesting that
|
||||
* the user only wants fast-forward merges.
|
||||
*/
|
||||
GIT_MERGE_PREFERENCE_FASTFORWARD_ONLY = (1 << 1)
|
||||
} git_merge_preference_t;
|
||||
|
||||
/**
|
||||
* Analyzes the given branch(es) and determines the opportunities for
|
||||
* merging them into the HEAD of the repository.
|
||||
*
|
||||
* @param analysis_out analysis enumeration that the result is written into
|
||||
* @param preference_out One of the `git_merge_preference_t` flag.
|
||||
* @param repo the repository to merge
|
||||
* @param their_heads the heads to merge into
|
||||
* @param their_heads_len the number of heads to merge
|
||||
* @return 0 on success or error code
|
||||
*/
|
||||
GIT_EXTERN(int) git_merge_analysis(
|
||||
git_merge_analysis_t *analysis_out,
|
||||
git_merge_preference_t *preference_out,
|
||||
git_repository *repo,
|
||||
const git_annotated_commit **their_heads,
|
||||
size_t their_heads_len);
|
||||
|
||||
/**
|
||||
* Analyzes the given branch(es) and determines the opportunities for
|
||||
* merging them into a reference.
|
||||
*
|
||||
* @param analysis_out analysis enumeration that the result is written into
|
||||
* @param preference_out One of the `git_merge_preference_t` flag.
|
||||
* @param repo the repository to merge
|
||||
* @param our_ref the reference to perform the analysis from
|
||||
* @param their_heads the heads to merge into
|
||||
* @param their_heads_len the number of heads to merge
|
||||
* @return 0 on success or error code
|
||||
*/
|
||||
GIT_EXTERN(int) git_merge_analysis_for_ref(
|
||||
git_merge_analysis_t *analysis_out,
|
||||
git_merge_preference_t *preference_out,
|
||||
git_repository *repo,
|
||||
git_reference *our_ref,
|
||||
const git_annotated_commit **their_heads,
|
||||
size_t their_heads_len);
|
||||
|
||||
/**
|
||||
* Find a merge base between two commits
|
||||
*
|
||||
* @param out the OID of a merge base between 'one' and 'two'
|
||||
* @param repo the repository where the commits exist
|
||||
* @param one one of the commits
|
||||
* @param two the other commit
|
||||
* @return 0 on success, GIT_ENOTFOUND if not found or error code
|
||||
*/
|
||||
GIT_EXTERN(int) git_merge_base(
|
||||
git_oid *out,
|
||||
git_repository *repo,
|
||||
const git_oid *one,
|
||||
const git_oid *two);
|
||||
|
||||
/**
|
||||
* Find merge bases between two commits
|
||||
*
|
||||
* @param out array in which to store the resulting ids
|
||||
* @param repo the repository where the commits exist
|
||||
* @param one one of the commits
|
||||
* @param two the other commit
|
||||
* @return 0 on success, GIT_ENOTFOUND if not found or error code
|
||||
*/
|
||||
GIT_EXTERN(int) git_merge_bases(
|
||||
git_oidarray *out,
|
||||
git_repository *repo,
|
||||
const git_oid *one,
|
||||
const git_oid *two);
|
||||
|
||||
/**
|
||||
* Find a merge base given a list of commits
|
||||
*
|
||||
* @param out the OID of a merge base considering all the commits
|
||||
* @param repo the repository where the commits exist
|
||||
* @param length The number of commits in the provided `input_array`
|
||||
* @param input_array oids of the commits
|
||||
* @return Zero on success; GIT_ENOTFOUND or -1 on failure.
|
||||
*/
|
||||
GIT_EXTERN(int) git_merge_base_many(
|
||||
git_oid *out,
|
||||
git_repository *repo,
|
||||
size_t length,
|
||||
const git_oid input_array[]);
|
||||
|
||||
/**
|
||||
* Find all merge bases given a list of commits
|
||||
*
|
||||
* @param out array in which to store the resulting ids
|
||||
* @param repo the repository where the commits exist
|
||||
* @param length The number of commits in the provided `input_array`
|
||||
* @param input_array oids of the commits
|
||||
* @return Zero on success; GIT_ENOTFOUND or -1 on failure.
|
||||
*/
|
||||
GIT_EXTERN(int) git_merge_bases_many(
|
||||
git_oidarray *out,
|
||||
git_repository *repo,
|
||||
size_t length,
|
||||
const git_oid input_array[]);
|
||||
|
||||
/**
|
||||
* Find a merge base in preparation for an octopus merge
|
||||
*
|
||||
* @param out the OID of a merge base considering all the commits
|
||||
* @param repo the repository where the commits exist
|
||||
* @param length The number of commits in the provided `input_array`
|
||||
* @param input_array oids of the commits
|
||||
* @return Zero on success; GIT_ENOTFOUND or -1 on failure.
|
||||
*/
|
||||
GIT_EXTERN(int) git_merge_base_octopus(
|
||||
git_oid *out,
|
||||
git_repository *repo,
|
||||
size_t length,
|
||||
const git_oid input_array[]);
|
||||
|
||||
/**
|
||||
* Merge two files as they exist in the in-memory data structures, using
|
||||
* the given common ancestor as the baseline, producing a
|
||||
* `git_merge_file_result` that reflects the merge result. The
|
||||
* `git_merge_file_result` must be freed with `git_merge_file_result_free`.
|
||||
*
|
||||
* Note that this function does not reference a repository and any
|
||||
* configuration must be passed as `git_merge_file_options`.
|
||||
*
|
||||
* @param out The git_merge_file_result to be filled in
|
||||
* @param ancestor The contents of the ancestor file
|
||||
* @param ours The contents of the file in "our" side
|
||||
* @param theirs The contents of the file in "their" side
|
||||
* @param opts The merge file options or `NULL` for defaults
|
||||
* @return 0 on success or error code
|
||||
*/
|
||||
GIT_EXTERN(int) git_merge_file(
|
||||
git_merge_file_result *out,
|
||||
const git_merge_file_input *ancestor,
|
||||
const git_merge_file_input *ours,
|
||||
const git_merge_file_input *theirs,
|
||||
const git_merge_file_options *opts);
|
||||
|
||||
/**
|
||||
* Merge two files as they exist in the index, using the given common
|
||||
* ancestor as the baseline, producing a `git_merge_file_result` that
|
||||
* reflects the merge result. The `git_merge_file_result` must be freed with
|
||||
* `git_merge_file_result_free`.
|
||||
*
|
||||
* @param out The git_merge_file_result to be filled in
|
||||
* @param repo The repository
|
||||
* @param ancestor The index entry for the ancestor file (stage level 1)
|
||||
* @param ours The index entry for our file (stage level 2)
|
||||
* @param theirs The index entry for their file (stage level 3)
|
||||
* @param opts The merge file options or NULL
|
||||
* @return 0 on success or error code
|
||||
*/
|
||||
GIT_EXTERN(int) git_merge_file_from_index(
|
||||
git_merge_file_result *out,
|
||||
git_repository *repo,
|
||||
const git_index_entry *ancestor,
|
||||
const git_index_entry *ours,
|
||||
const git_index_entry *theirs,
|
||||
const git_merge_file_options *opts);
|
||||
|
||||
/**
|
||||
* Frees a `git_merge_file_result`.
|
||||
*
|
||||
* @param result The result to free or `NULL`
|
||||
*/
|
||||
GIT_EXTERN(void) git_merge_file_result_free(git_merge_file_result *result);
|
||||
|
||||
/**
|
||||
* Merge two trees, producing a `git_index` that reflects the result of
|
||||
* the merge. The index may be written as-is to the working directory
|
||||
* or checked out. If the index is to be converted to a tree, the caller
|
||||
* should resolve any conflicts that arose as part of the merge.
|
||||
*
|
||||
* The returned index must be freed explicitly with `git_index_free`.
|
||||
*
|
||||
* @param out pointer to store the index result in
|
||||
* @param repo repository that contains the given trees
|
||||
* @param ancestor_tree the common ancestor between the trees (or null if none)
|
||||
* @param our_tree the tree that reflects the destination tree
|
||||
* @param their_tree the tree to merge in to `our_tree`
|
||||
* @param opts the merge tree options (or null for defaults)
|
||||
* @return 0 on success or error code
|
||||
*/
|
||||
GIT_EXTERN(int) git_merge_trees(
|
||||
git_index **out,
|
||||
git_repository *repo,
|
||||
const git_tree *ancestor_tree,
|
||||
const git_tree *our_tree,
|
||||
const git_tree *their_tree,
|
||||
const git_merge_options *opts);
|
||||
|
||||
/**
|
||||
* Merge two commits, producing a `git_index` that reflects the result of
|
||||
* the merge. The index may be written as-is to the working directory
|
||||
* or checked out. If the index is to be converted to a tree, the caller
|
||||
* should resolve any conflicts that arose as part of the merge.
|
||||
*
|
||||
* The returned index must be freed explicitly with `git_index_free`.
|
||||
*
|
||||
* @param out pointer to store the index result in
|
||||
* @param repo repository that contains the given trees
|
||||
* @param our_commit the commit that reflects the destination tree
|
||||
* @param their_commit the commit to merge in to `our_commit`
|
||||
* @param opts the merge tree options (or null for defaults)
|
||||
* @return 0 on success or error code
|
||||
*/
|
||||
GIT_EXTERN(int) git_merge_commits(
|
||||
git_index **out,
|
||||
git_repository *repo,
|
||||
const git_commit *our_commit,
|
||||
const git_commit *their_commit,
|
||||
const git_merge_options *opts);
|
||||
|
||||
/**
|
||||
* Merges the given commit(s) into HEAD, writing the results into the working
|
||||
* directory. Any changes are staged for commit and any conflicts are written
|
||||
* to the index. Callers should inspect the repository's index after this
|
||||
* completes, resolve any conflicts and prepare a commit.
|
||||
*
|
||||
* For compatibility with git, the repository is put into a merging
|
||||
* state. Once the commit is done (or if the user wishes to abort),
|
||||
* you should clear this state by calling
|
||||
* `git_repository_state_cleanup()`.
|
||||
*
|
||||
* @param repo the repository to merge
|
||||
* @param their_heads the heads to merge into
|
||||
* @param their_heads_len the number of heads to merge
|
||||
* @param merge_opts merge options
|
||||
* @param checkout_opts checkout options
|
||||
* @return 0 on success or error code
|
||||
*/
|
||||
GIT_EXTERN(int) git_merge(
|
||||
git_repository *repo,
|
||||
const git_annotated_commit **their_heads,
|
||||
size_t their_heads_len,
|
||||
const git_merge_options *merge_opts,
|
||||
const git_checkout_options *checkout_opts);
|
||||
|
||||
/** @} */
|
||||
GIT_END_DECL
|
||||
#endif
|
86
3rdparty/libgit2/include/git2/message.h
vendored
Normal file
86
3rdparty/libgit2/include/git2/message.h
vendored
Normal file
@ -0,0 +1,86 @@
|
||||
/*
|
||||
* Copyright (C) the libgit2 contributors. All rights reserved.
|
||||
*
|
||||
* This file is part of libgit2, distributed under the GNU GPL v2 with
|
||||
* a Linking Exception. For full terms see the included COPYING file.
|
||||
*/
|
||||
#ifndef INCLUDE_git_message_h__
|
||||
#define INCLUDE_git_message_h__
|
||||
|
||||
#include "common.h"
|
||||
#include "buffer.h"
|
||||
|
||||
/**
|
||||
* @file git2/message.h
|
||||
* @brief Git message management routines
|
||||
* @ingroup Git
|
||||
* @{
|
||||
*/
|
||||
GIT_BEGIN_DECL
|
||||
|
||||
/**
|
||||
* Clean up excess whitespace and make sure there is a trailing newline in the message.
|
||||
*
|
||||
* Optionally, it can remove lines which start with the comment character.
|
||||
*
|
||||
* @param out The user-allocated git_buf which will be filled with the
|
||||
* cleaned up message.
|
||||
*
|
||||
* @param message The message to be prettified.
|
||||
*
|
||||
* @param strip_comments Non-zero to remove comment lines, 0 to leave them in.
|
||||
*
|
||||
* @param comment_char Comment character. Lines starting with this character
|
||||
* are considered to be comments and removed if `strip_comments` is non-zero.
|
||||
*
|
||||
* @return 0 or an error code.
|
||||
*/
|
||||
GIT_EXTERN(int) git_message_prettify(git_buf *out, const char *message, int strip_comments, char comment_char);
|
||||
|
||||
/**
|
||||
* Represents a single git message trailer.
|
||||
*/
|
||||
typedef struct {
|
||||
const char *key;
|
||||
const char *value;
|
||||
} git_message_trailer;
|
||||
|
||||
/**
|
||||
* Represents an array of git message trailers.
|
||||
*
|
||||
* Struct members under the private comment are private, subject to change
|
||||
* and should not be used by callers.
|
||||
*/
|
||||
typedef struct {
|
||||
git_message_trailer *trailers;
|
||||
size_t count;
|
||||
|
||||
/* private */
|
||||
char *_trailer_block;
|
||||
} git_message_trailer_array;
|
||||
|
||||
/**
|
||||
* Parse trailers out of a message, filling the array pointed to by +arr+.
|
||||
*
|
||||
* Trailers are key/value pairs in the last paragraph of a message, not
|
||||
* including any patches or conflicts that may be present.
|
||||
*
|
||||
* @param arr A pre-allocated git_message_trailer_array struct to be filled in
|
||||
* with any trailers found during parsing.
|
||||
* @param message The message to be parsed
|
||||
* @return 0 on success, or non-zero on error.
|
||||
*/
|
||||
GIT_EXTERN(int) git_message_trailers(git_message_trailer_array *arr, const char *message);
|
||||
|
||||
/**
|
||||
* Clean's up any allocated memory in the git_message_trailer_array filled by
|
||||
* a call to git_message_trailers.
|
||||
*
|
||||
* @param arr The trailer to free.
|
||||
*/
|
||||
GIT_EXTERN(void) git_message_trailer_array_free(git_message_trailer_array *arr);
|
||||
|
||||
/** @} */
|
||||
GIT_END_DECL
|
||||
|
||||
#endif /* INCLUDE_git_message_h__ */
|
54
3rdparty/libgit2/include/git2/net.h
vendored
Normal file
54
3rdparty/libgit2/include/git2/net.h
vendored
Normal file
@ -0,0 +1,54 @@
|
||||
/*
|
||||
* Copyright (C) the libgit2 contributors. All rights reserved.
|
||||
*
|
||||
* This file is part of libgit2, distributed under the GNU GPL v2 with
|
||||
* a Linking Exception. For full terms see the included COPYING file.
|
||||
*/
|
||||
#ifndef INCLUDE_git_net_h__
|
||||
#define INCLUDE_git_net_h__
|
||||
|
||||
#include "common.h"
|
||||
#include "oid.h"
|
||||
#include "types.h"
|
||||
|
||||
/**
|
||||
* @file git2/net.h
|
||||
* @brief Git networking declarations
|
||||
* @ingroup Git
|
||||
* @{
|
||||
*/
|
||||
GIT_BEGIN_DECL
|
||||
|
||||
#define GIT_DEFAULT_PORT "9418"
|
||||
|
||||
/**
|
||||
* Direction of the connection.
|
||||
*
|
||||
* We need this because we need to know whether we should call
|
||||
* git-upload-pack or git-receive-pack on the remote end when get_refs
|
||||
* gets called.
|
||||
*/
|
||||
typedef enum {
|
||||
GIT_DIRECTION_FETCH = 0,
|
||||
GIT_DIRECTION_PUSH = 1
|
||||
} git_direction;
|
||||
|
||||
/**
|
||||
* Description of a reference advertised by a remote server, given out
|
||||
* on `ls` calls.
|
||||
*/
|
||||
struct git_remote_head {
|
||||
int local; /* available locally */
|
||||
git_oid oid;
|
||||
git_oid loid;
|
||||
char *name;
|
||||
/**
|
||||
* If the server send a symref mapping for this ref, this will
|
||||
* point to the target.
|
||||
*/
|
||||
char *symref_target;
|
||||
};
|
||||
|
||||
/** @} */
|
||||
GIT_END_DECL
|
||||
#endif
|
306
3rdparty/libgit2/include/git2/notes.h
vendored
Normal file
306
3rdparty/libgit2/include/git2/notes.h
vendored
Normal file
@ -0,0 +1,306 @@
|
||||
/*
|
||||
* Copyright (C) the libgit2 contributors. All rights reserved.
|
||||
*
|
||||
* This file is part of libgit2, distributed under the GNU GPL v2 with
|
||||
* a Linking Exception. For full terms see the included COPYING file.
|
||||
*/
|
||||
#ifndef INCLUDE_git_note_h__
|
||||
#define INCLUDE_git_note_h__
|
||||
|
||||
#include "oid.h"
|
||||
|
||||
/**
|
||||
* @file git2/notes.h
|
||||
* @brief Git notes management routines
|
||||
* @defgroup git_note Git notes management routines
|
||||
* @ingroup Git
|
||||
* @{
|
||||
*/
|
||||
GIT_BEGIN_DECL
|
||||
|
||||
/**
|
||||
* Callback for git_note_foreach.
|
||||
*
|
||||
* Receives:
|
||||
* - blob_id: Oid of the blob containing the message
|
||||
* - annotated_object_id: Oid of the git object being annotated
|
||||
* - payload: Payload data passed to `git_note_foreach`
|
||||
*/
|
||||
typedef int GIT_CALLBACK(git_note_foreach_cb)(
|
||||
const git_oid *blob_id, const git_oid *annotated_object_id, void *payload);
|
||||
|
||||
/**
|
||||
* note iterator
|
||||
*/
|
||||
typedef struct git_iterator git_note_iterator;
|
||||
|
||||
/**
|
||||
* Creates a new iterator for notes
|
||||
*
|
||||
* The iterator must be freed manually by the user.
|
||||
*
|
||||
* @param out pointer to the iterator
|
||||
* @param repo repository where to look up the note
|
||||
* @param notes_ref canonical name of the reference to use (optional); defaults to
|
||||
* "refs/notes/commits"
|
||||
*
|
||||
* @return 0 or an error code
|
||||
*/
|
||||
GIT_EXTERN(int) git_note_iterator_new(
|
||||
git_note_iterator **out,
|
||||
git_repository *repo,
|
||||
const char *notes_ref);
|
||||
|
||||
/**
|
||||
* Creates a new iterator for notes from a commit
|
||||
*
|
||||
* The iterator must be freed manually by the user.
|
||||
*
|
||||
* @param out pointer to the iterator
|
||||
* @param notes_commit a pointer to the notes commit object
|
||||
*
|
||||
* @return 0 or an error code
|
||||
*/
|
||||
GIT_EXTERN(int) git_note_commit_iterator_new(
|
||||
git_note_iterator **out,
|
||||
git_commit *notes_commit);
|
||||
|
||||
/**
|
||||
* Frees an git_note_iterator
|
||||
*
|
||||
* @param it pointer to the iterator
|
||||
*/
|
||||
GIT_EXTERN(void) git_note_iterator_free(git_note_iterator *it);
|
||||
|
||||
/**
|
||||
* Return the current item (note_id and annotated_id) and advance the iterator
|
||||
* internally to the next value
|
||||
*
|
||||
* @param note_id id of blob containing the message
|
||||
* @param annotated_id id of the git object being annotated
|
||||
* @param it pointer to the iterator
|
||||
*
|
||||
* @return 0 (no error), GIT_ITEROVER (iteration is done) or an error code
|
||||
* (negative value)
|
||||
*/
|
||||
GIT_EXTERN(int) git_note_next(
|
||||
git_oid *note_id,
|
||||
git_oid *annotated_id,
|
||||
git_note_iterator *it);
|
||||
|
||||
|
||||
/**
|
||||
* Read the note for an object
|
||||
*
|
||||
* The note must be freed manually by the user.
|
||||
*
|
||||
* @param out pointer to the read note; NULL in case of error
|
||||
* @param repo repository where to look up the note
|
||||
* @param notes_ref canonical name of the reference to use (optional); defaults to
|
||||
* "refs/notes/commits"
|
||||
* @param oid OID of the git object to read the note from
|
||||
*
|
||||
* @return 0 or an error code
|
||||
*/
|
||||
GIT_EXTERN(int) git_note_read(
|
||||
git_note **out,
|
||||
git_repository *repo,
|
||||
const char *notes_ref,
|
||||
const git_oid *oid);
|
||||
|
||||
|
||||
/**
|
||||
* Read the note for an object from a note commit
|
||||
*
|
||||
* The note must be freed manually by the user.
|
||||
*
|
||||
* @param out pointer to the read note; NULL in case of error
|
||||
* @param repo repository where to look up the note
|
||||
* @param notes_commit a pointer to the notes commit object
|
||||
* @param oid OID of the git object to read the note from
|
||||
*
|
||||
* @return 0 or an error code
|
||||
*/
|
||||
GIT_EXTERN(int) git_note_commit_read(
|
||||
git_note **out,
|
||||
git_repository *repo,
|
||||
git_commit *notes_commit,
|
||||
const git_oid *oid);
|
||||
|
||||
/**
|
||||
* Get the note author
|
||||
*
|
||||
* @param note the note
|
||||
* @return the author
|
||||
*/
|
||||
GIT_EXTERN(const git_signature *) git_note_author(const git_note *note);
|
||||
|
||||
/**
|
||||
* Get the note committer
|
||||
*
|
||||
* @param note the note
|
||||
* @return the committer
|
||||
*/
|
||||
GIT_EXTERN(const git_signature *) git_note_committer(const git_note *note);
|
||||
|
||||
|
||||
/**
|
||||
* Get the note message
|
||||
*
|
||||
* @param note the note
|
||||
* @return the note message
|
||||
*/
|
||||
GIT_EXTERN(const char *) git_note_message(const git_note *note);
|
||||
|
||||
|
||||
/**
|
||||
* Get the note object's id
|
||||
*
|
||||
* @param note the note
|
||||
* @return the note object's id
|
||||
*/
|
||||
GIT_EXTERN(const git_oid *) git_note_id(const git_note *note);
|
||||
|
||||
/**
|
||||
* Add a note for an object
|
||||
*
|
||||
* @param out pointer to store the OID (optional); NULL in case of error
|
||||
* @param repo repository where to store the note
|
||||
* @param notes_ref canonical name of the reference to use (optional);
|
||||
* defaults to "refs/notes/commits"
|
||||
* @param author signature of the notes commit author
|
||||
* @param committer signature of the notes commit committer
|
||||
* @param oid OID of the git object to decorate
|
||||
* @param note Content of the note to add for object oid
|
||||
* @param force Overwrite existing note
|
||||
*
|
||||
* @return 0 or an error code
|
||||
*/
|
||||
GIT_EXTERN(int) git_note_create(
|
||||
git_oid *out,
|
||||
git_repository *repo,
|
||||
const char *notes_ref,
|
||||
const git_signature *author,
|
||||
const git_signature *committer,
|
||||
const git_oid *oid,
|
||||
const char *note,
|
||||
int force);
|
||||
|
||||
/**
|
||||
* Add a note for an object from a commit
|
||||
*
|
||||
* This function will create a notes commit for a given object,
|
||||
* the commit is a dangling commit, no reference is created.
|
||||
*
|
||||
* @param notes_commit_out pointer to store the commit (optional);
|
||||
* NULL in case of error
|
||||
* @param notes_blob_out a point to the id of a note blob (optional)
|
||||
* @param repo repository where the note will live
|
||||
* @param parent Pointer to parent note
|
||||
* or NULL if this shall start a new notes tree
|
||||
* @param author signature of the notes commit author
|
||||
* @param committer signature of the notes commit committer
|
||||
* @param oid OID of the git object to decorate
|
||||
* @param note Content of the note to add for object oid
|
||||
* @param allow_note_overwrite Overwrite existing note
|
||||
*
|
||||
* @return 0 or an error code
|
||||
*/
|
||||
GIT_EXTERN(int) git_note_commit_create(
|
||||
git_oid *notes_commit_out,
|
||||
git_oid *notes_blob_out,
|
||||
git_repository *repo,
|
||||
git_commit *parent,
|
||||
const git_signature *author,
|
||||
const git_signature *committer,
|
||||
const git_oid *oid,
|
||||
const char *note,
|
||||
int allow_note_overwrite);
|
||||
|
||||
/**
|
||||
* Remove the note for an object
|
||||
*
|
||||
* @param repo repository where the note lives
|
||||
* @param notes_ref canonical name of the reference to use (optional);
|
||||
* defaults to "refs/notes/commits"
|
||||
* @param author signature of the notes commit author
|
||||
* @param committer signature of the notes commit committer
|
||||
* @param oid OID of the git object to remove the note from
|
||||
*
|
||||
* @return 0 or an error code
|
||||
*/
|
||||
GIT_EXTERN(int) git_note_remove(
|
||||
git_repository *repo,
|
||||
const char *notes_ref,
|
||||
const git_signature *author,
|
||||
const git_signature *committer,
|
||||
const git_oid *oid);
|
||||
|
||||
/**
|
||||
* Remove the note for an object
|
||||
*
|
||||
* @param notes_commit_out pointer to store the new notes commit (optional);
|
||||
* NULL in case of error.
|
||||
* When removing a note a new tree containing all notes
|
||||
* sans the note to be removed is created and a new commit
|
||||
* pointing to that tree is also created.
|
||||
* In the case where the resulting tree is an empty tree
|
||||
* a new commit pointing to this empty tree will be returned.
|
||||
* @param repo repository where the note lives
|
||||
* @param notes_commit a pointer to the notes commit object
|
||||
* @param author signature of the notes commit author
|
||||
* @param committer signature of the notes commit committer
|
||||
* @param oid OID of the git object to remove the note from
|
||||
*
|
||||
* @return 0 or an error code
|
||||
*/
|
||||
GIT_EXTERN(int) git_note_commit_remove(
|
||||
git_oid *notes_commit_out,
|
||||
git_repository *repo,
|
||||
git_commit *notes_commit,
|
||||
const git_signature *author,
|
||||
const git_signature *committer,
|
||||
const git_oid *oid);
|
||||
|
||||
/**
|
||||
* Free a git_note object
|
||||
*
|
||||
* @param note git_note object
|
||||
*/
|
||||
GIT_EXTERN(void) git_note_free(git_note *note);
|
||||
|
||||
/**
|
||||
* Get the default notes reference for a repository
|
||||
*
|
||||
* @param out buffer in which to store the name of the default notes reference
|
||||
* @param repo The Git repository
|
||||
*
|
||||
* @return 0 or an error code
|
||||
*/
|
||||
GIT_EXTERN(int) git_note_default_ref(git_buf *out, git_repository *repo);
|
||||
|
||||
/**
|
||||
* Loop over all the notes within a specified namespace
|
||||
* and issue a callback for each one.
|
||||
*
|
||||
* @param repo Repository where to find the notes.
|
||||
*
|
||||
* @param notes_ref Reference to read from (optional); defaults to
|
||||
* "refs/notes/commits".
|
||||
*
|
||||
* @param note_cb Callback to invoke per found annotation. Return non-zero
|
||||
* to stop looping.
|
||||
*
|
||||
* @param payload Extra parameter to callback function.
|
||||
*
|
||||
* @return 0 on success, non-zero callback return value, or error code
|
||||
*/
|
||||
GIT_EXTERN(int) git_note_foreach(
|
||||
git_repository *repo,
|
||||
const char *notes_ref,
|
||||
git_note_foreach_cb note_cb,
|
||||
void *payload);
|
||||
|
||||
/** @} */
|
||||
GIT_END_DECL
|
||||
#endif
|
279
3rdparty/libgit2/include/git2/object.h
vendored
Normal file
279
3rdparty/libgit2/include/git2/object.h
vendored
Normal file
@ -0,0 +1,279 @@
|
||||
/*
|
||||
* Copyright (C) the libgit2 contributors. All rights reserved.
|
||||
*
|
||||
* This file is part of libgit2, distributed under the GNU GPL v2 with
|
||||
* a Linking Exception. For full terms see the included COPYING file.
|
||||
*/
|
||||
#ifndef INCLUDE_git_object_h__
|
||||
#define INCLUDE_git_object_h__
|
||||
|
||||
#include "common.h"
|
||||
#include "types.h"
|
||||
#include "oid.h"
|
||||
#include "buffer.h"
|
||||
|
||||
/**
|
||||
* @file git2/object.h
|
||||
* @brief Git revision object management routines
|
||||
* @defgroup git_object Git revision object management routines
|
||||
* @ingroup Git
|
||||
* @{
|
||||
*/
|
||||
GIT_BEGIN_DECL
|
||||
|
||||
#define GIT_OBJECT_SIZE_MAX UINT64_MAX
|
||||
|
||||
/**
|
||||
* Lookup a reference to one of the objects in a repository.
|
||||
*
|
||||
* The generated reference is owned by the repository and
|
||||
* should be closed with the `git_object_free` method
|
||||
* instead of free'd manually.
|
||||
*
|
||||
* The 'type' parameter must match the type of the object
|
||||
* in the odb; the method will fail otherwise.
|
||||
* The special value 'GIT_OBJECT_ANY' may be passed to let
|
||||
* the method guess the object's type.
|
||||
*
|
||||
* @param object pointer to the looked-up object
|
||||
* @param repo the repository to look up the object
|
||||
* @param id the unique identifier for the object
|
||||
* @param type the type of the object
|
||||
* @return 0 or an error code
|
||||
*/
|
||||
GIT_EXTERN(int) git_object_lookup(
|
||||
git_object **object,
|
||||
git_repository *repo,
|
||||
const git_oid *id,
|
||||
git_object_t type);
|
||||
|
||||
/**
|
||||
* Lookup a reference to one of the objects in a repository,
|
||||
* given a prefix of its identifier (short id).
|
||||
*
|
||||
* The object obtained will be so that its identifier
|
||||
* matches the first 'len' hexadecimal characters
|
||||
* (packets of 4 bits) of the given 'id'.
|
||||
* 'len' must be at least GIT_OID_MINPREFIXLEN, and
|
||||
* long enough to identify a unique object matching
|
||||
* the prefix; otherwise the method will fail.
|
||||
*
|
||||
* The generated reference is owned by the repository and
|
||||
* should be closed with the `git_object_free` method
|
||||
* instead of free'd manually.
|
||||
*
|
||||
* The 'type' parameter must match the type of the object
|
||||
* in the odb; the method will fail otherwise.
|
||||
* The special value 'GIT_OBJECT_ANY' may be passed to let
|
||||
* the method guess the object's type.
|
||||
*
|
||||
* @param object_out pointer where to store the looked-up object
|
||||
* @param repo the repository to look up the object
|
||||
* @param id a short identifier for the object
|
||||
* @param len the length of the short identifier
|
||||
* @param type the type of the object
|
||||
* @return 0 or an error code
|
||||
*/
|
||||
GIT_EXTERN(int) git_object_lookup_prefix(
|
||||
git_object **object_out,
|
||||
git_repository *repo,
|
||||
const git_oid *id,
|
||||
size_t len,
|
||||
git_object_t type);
|
||||
|
||||
|
||||
/**
|
||||
* Lookup an object that represents a tree entry.
|
||||
*
|
||||
* @param out buffer that receives a pointer to the object (which must be freed
|
||||
* by the caller)
|
||||
* @param treeish root object that can be peeled to a tree
|
||||
* @param path relative path from the root object to the desired object
|
||||
* @param type type of object desired
|
||||
* @return 0 on success, or an error code
|
||||
*/
|
||||
GIT_EXTERN(int) git_object_lookup_bypath(
|
||||
git_object **out,
|
||||
const git_object *treeish,
|
||||
const char *path,
|
||||
git_object_t type);
|
||||
|
||||
/**
|
||||
* Get the id (SHA1) of a repository object
|
||||
*
|
||||
* @param obj the repository object
|
||||
* @return the SHA1 id
|
||||
*/
|
||||
GIT_EXTERN(const git_oid *) git_object_id(const git_object *obj);
|
||||
|
||||
/**
|
||||
* Get a short abbreviated OID string for the object
|
||||
*
|
||||
* This starts at the "core.abbrev" length (default 7 characters) and
|
||||
* iteratively extends to a longer string if that length is ambiguous.
|
||||
* The result will be unambiguous (at least until new objects are added to
|
||||
* the repository).
|
||||
*
|
||||
* @param out Buffer to write string into
|
||||
* @param obj The object to get an ID for
|
||||
* @return 0 on success, <0 for error
|
||||
*/
|
||||
GIT_EXTERN(int) git_object_short_id(git_buf *out, const git_object *obj);
|
||||
|
||||
/**
|
||||
* Get the object type of an object
|
||||
*
|
||||
* @param obj the repository object
|
||||
* @return the object's type
|
||||
*/
|
||||
GIT_EXTERN(git_object_t) git_object_type(const git_object *obj);
|
||||
|
||||
/**
|
||||
* Get the repository that owns this object
|
||||
*
|
||||
* Freeing or calling `git_repository_close` on the
|
||||
* returned pointer will invalidate the actual object.
|
||||
*
|
||||
* Any other operation may be run on the repository without
|
||||
* affecting the object.
|
||||
*
|
||||
* @param obj the object
|
||||
* @return the repository who owns this object
|
||||
*/
|
||||
GIT_EXTERN(git_repository *) git_object_owner(const git_object *obj);
|
||||
|
||||
/**
|
||||
* Close an open object
|
||||
*
|
||||
* This method instructs the library to close an existing
|
||||
* object; note that git_objects are owned and cached by the repository
|
||||
* so the object may or may not be freed after this library call,
|
||||
* depending on how aggressive is the caching mechanism used
|
||||
* by the repository.
|
||||
*
|
||||
* IMPORTANT:
|
||||
* It *is* necessary to call this method when you stop using
|
||||
* an object. Failure to do so will cause a memory leak.
|
||||
*
|
||||
* @param object the object to close
|
||||
*/
|
||||
GIT_EXTERN(void) git_object_free(git_object *object);
|
||||
|
||||
/**
|
||||
* Convert an object type to its string representation.
|
||||
*
|
||||
* The result is a pointer to a string in static memory and
|
||||
* should not be free()'ed.
|
||||
*
|
||||
* @param type object type to convert.
|
||||
* @return the corresponding string representation.
|
||||
*/
|
||||
GIT_EXTERN(const char *) git_object_type2string(git_object_t type);
|
||||
|
||||
/**
|
||||
* Convert a string object type representation to it's git_object_t.
|
||||
*
|
||||
* @param str the string to convert.
|
||||
* @return the corresponding git_object_t.
|
||||
*/
|
||||
GIT_EXTERN(git_object_t) git_object_string2type(const char *str);
|
||||
|
||||
/**
|
||||
* Determine if the given git_object_t is a valid loose object type.
|
||||
*
|
||||
* @param type object type to test.
|
||||
* @return true if the type represents a valid loose object type,
|
||||
* false otherwise.
|
||||
*/
|
||||
GIT_EXTERN(int) git_object_typeisloose(git_object_t type);
|
||||
|
||||
/**
|
||||
* Recursively peel an object until an object of the specified type is met.
|
||||
*
|
||||
* If the query cannot be satisfied due to the object model,
|
||||
* GIT_EINVALIDSPEC will be returned (e.g. trying to peel a blob to a
|
||||
* tree).
|
||||
*
|
||||
* If you pass `GIT_OBJECT_ANY` as the target type, then the object will
|
||||
* be peeled until the type changes. A tag will be peeled until the
|
||||
* referenced object is no longer a tag, and a commit will be peeled
|
||||
* to a tree. Any other object type will return GIT_EINVALIDSPEC.
|
||||
*
|
||||
* If peeling a tag we discover an object which cannot be peeled to
|
||||
* the target type due to the object model, GIT_EPEEL will be
|
||||
* returned.
|
||||
*
|
||||
* You must free the returned object.
|
||||
*
|
||||
* @param peeled Pointer to the peeled git_object
|
||||
* @param object The object to be processed
|
||||
* @param target_type The type of the requested object (a GIT_OBJECT_ value)
|
||||
* @return 0 on success, GIT_EINVALIDSPEC, GIT_EPEEL, or an error code
|
||||
*/
|
||||
GIT_EXTERN(int) git_object_peel(
|
||||
git_object **peeled,
|
||||
const git_object *object,
|
||||
git_object_t target_type);
|
||||
|
||||
/**
|
||||
* Create an in-memory copy of a Git object. The copy must be
|
||||
* explicitly free'd or it will leak.
|
||||
*
|
||||
* @param dest Pointer to store the copy of the object
|
||||
* @param source Original object to copy
|
||||
* @return 0 or an error code
|
||||
*/
|
||||
GIT_EXTERN(int) git_object_dup(git_object **dest, git_object *source);
|
||||
|
||||
#ifdef GIT_EXPERIMENTAL_SHA256
|
||||
/**
|
||||
* Analyzes a buffer of raw object content and determines its validity.
|
||||
* Tree, commit, and tag objects will be parsed and ensured that they
|
||||
* are valid, parseable content. (Blobs are always valid by definition.)
|
||||
* An error message will be set with an informative message if the object
|
||||
* is not valid.
|
||||
*
|
||||
* @warning This function is experimental and its signature may change in
|
||||
* the future.
|
||||
*
|
||||
* @param valid Output pointer to set with validity of the object content
|
||||
* @param buf The contents to validate
|
||||
* @param len The length of the buffer
|
||||
* @param object_type The type of the object in the buffer
|
||||
* @param oid_type The object ID type for the OIDs in the given buffer
|
||||
* @return 0 on success or an error code
|
||||
*/
|
||||
GIT_EXTERN(int) git_object_rawcontent_is_valid(
|
||||
int *valid,
|
||||
const char *buf,
|
||||
size_t len,
|
||||
git_object_t object_type,
|
||||
git_oid_t oid_type);
|
||||
#else
|
||||
/**
|
||||
* Analyzes a buffer of raw object content and determines its validity.
|
||||
* Tree, commit, and tag objects will be parsed and ensured that they
|
||||
* are valid, parseable content. (Blobs are always valid by definition.)
|
||||
* An error message will be set with an informative message if the object
|
||||
* is not valid.
|
||||
*
|
||||
* @warning This function is experimental and its signature may change in
|
||||
* the future.
|
||||
*
|
||||
* @param valid Output pointer to set with validity of the object content
|
||||
* @param buf The contents to validate
|
||||
* @param len The length of the buffer
|
||||
* @param object_type The type of the object in the buffer
|
||||
* @return 0 on success or an error code
|
||||
*/
|
||||
GIT_EXTERN(int) git_object_rawcontent_is_valid(
|
||||
int *valid,
|
||||
const char *buf,
|
||||
size_t len,
|
||||
git_object_t object_type);
|
||||
#endif
|
||||
|
||||
/** @} */
|
||||
GIT_END_DECL
|
||||
|
||||
#endif
|
654
3rdparty/libgit2/include/git2/odb.h
vendored
Normal file
654
3rdparty/libgit2/include/git2/odb.h
vendored
Normal file
@ -0,0 +1,654 @@
|
||||
/*
|
||||
* Copyright (C) the libgit2 contributors. All rights reserved.
|
||||
*
|
||||
* This file is part of libgit2, distributed under the GNU GPL v2 with
|
||||
* a Linking Exception. For full terms see the included COPYING file.
|
||||
*/
|
||||
#ifndef INCLUDE_git_odb_h__
|
||||
#define INCLUDE_git_odb_h__
|
||||
|
||||
#include "common.h"
|
||||
#include "types.h"
|
||||
#include "oid.h"
|
||||
#include "oidarray.h"
|
||||
#include "indexer.h"
|
||||
|
||||
/**
|
||||
* @file git2/odb.h
|
||||
* @brief Git object database routines
|
||||
* @defgroup git_odb Git object database routines
|
||||
* @ingroup Git
|
||||
* @{
|
||||
*/
|
||||
GIT_BEGIN_DECL
|
||||
|
||||
/** Flags controlling the behavior of ODB lookup operations */
|
||||
typedef enum {
|
||||
/**
|
||||
* Don't call `git_odb_refresh` if the lookup fails. Useful when doing
|
||||
* a batch of lookup operations for objects that may legitimately not
|
||||
* exist. When using this flag, you may wish to manually call
|
||||
* `git_odb_refresh` before processing a batch of objects.
|
||||
*/
|
||||
GIT_ODB_LOOKUP_NO_REFRESH = (1 << 0)
|
||||
} git_odb_lookup_flags_t;
|
||||
|
||||
/**
|
||||
* Function type for callbacks from git_odb_foreach.
|
||||
*/
|
||||
typedef int GIT_CALLBACK(git_odb_foreach_cb)(const git_oid *id, void *payload);
|
||||
|
||||
/** Options for configuring a loose object backend. */
|
||||
typedef struct {
|
||||
unsigned int version; /**< version for the struct */
|
||||
|
||||
/**
|
||||
* Type of object IDs to use for this object database, or
|
||||
* 0 for default (currently SHA1).
|
||||
*/
|
||||
git_oid_t oid_type;
|
||||
} git_odb_options;
|
||||
|
||||
/* The current version of the diff options structure */
|
||||
#define GIT_ODB_OPTIONS_VERSION 1
|
||||
|
||||
/* Stack initializer for odb options. Alternatively use
|
||||
* `git_odb_options_init` programmatic initialization.
|
||||
*/
|
||||
#define GIT_ODB_OPTIONS_INIT { GIT_ODB_OPTIONS_VERSION }
|
||||
|
||||
/**
|
||||
* Create a new object database with no backends.
|
||||
*
|
||||
* Before the ODB can be used for read/writing, a custom database
|
||||
* backend must be manually added using `git_odb_add_backend()`
|
||||
*
|
||||
* @param out location to store the database pointer, if opened.
|
||||
* Set to NULL if the open failed.
|
||||
* @param opts the options for this object database or NULL for defaults
|
||||
* @return 0 or an error code
|
||||
*/
|
||||
#ifdef GIT_EXPERIMENTAL_SHA256
|
||||
GIT_EXTERN(int) git_odb_new(git_odb **out, const git_odb_options *opts);
|
||||
#else
|
||||
GIT_EXTERN(int) git_odb_new(git_odb **out);
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Create a new object database and automatically add
|
||||
* the two default backends:
|
||||
*
|
||||
* - git_odb_backend_loose: read and write loose object files
|
||||
* from disk, assuming `objects_dir` as the Objects folder
|
||||
*
|
||||
* - git_odb_backend_pack: read objects from packfiles,
|
||||
* assuming `objects_dir` as the Objects folder which
|
||||
* contains a 'pack/' folder with the corresponding data
|
||||
*
|
||||
* @param out location to store the database pointer, if opened.
|
||||
* Set to NULL if the open failed.
|
||||
* @param objects_dir path of the backends' "objects" directory.
|
||||
* @param opts the options for this object database or NULL for defaults
|
||||
* @return 0 or an error code
|
||||
*/
|
||||
#ifdef GIT_EXPERIMENTAL_SHA256
|
||||
GIT_EXTERN(int) git_odb_open(
|
||||
git_odb **out,
|
||||
const char *objects_dir,
|
||||
const git_odb_options *opts);
|
||||
#else
|
||||
GIT_EXTERN(int) git_odb_open(git_odb **out, const char *objects_dir);
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Add an on-disk alternate to an existing Object DB.
|
||||
*
|
||||
* Note that the added path must point to an `objects`, not
|
||||
* to a full repository, to use it as an alternate store.
|
||||
*
|
||||
* Alternate backends are always checked for objects *after*
|
||||
* all the main backends have been exhausted.
|
||||
*
|
||||
* Writing is disabled on alternate backends.
|
||||
*
|
||||
* @param odb database to add the backend to
|
||||
* @param path path to the objects folder for the alternate
|
||||
* @return 0 on success, error code otherwise
|
||||
*/
|
||||
GIT_EXTERN(int) git_odb_add_disk_alternate(git_odb *odb, const char *path);
|
||||
|
||||
/**
|
||||
* Close an open object database.
|
||||
*
|
||||
* @param db database pointer to close. If NULL no action is taken.
|
||||
*/
|
||||
GIT_EXTERN(void) git_odb_free(git_odb *db);
|
||||
|
||||
/**
|
||||
* Read an object from the database.
|
||||
*
|
||||
* This method queries all available ODB backends
|
||||
* trying to read the given OID.
|
||||
*
|
||||
* The returned object is reference counted and
|
||||
* internally cached, so it should be closed
|
||||
* by the user once it's no longer in use.
|
||||
*
|
||||
* @param out pointer where to store the read object
|
||||
* @param db database to search for the object in.
|
||||
* @param id identity of the object to read.
|
||||
* @return 0 if the object was read, GIT_ENOTFOUND if the object is
|
||||
* not in the database.
|
||||
*/
|
||||
GIT_EXTERN(int) git_odb_read(git_odb_object **out, git_odb *db, const git_oid *id);
|
||||
|
||||
/**
|
||||
* Read an object from the database, given a prefix
|
||||
* of its identifier.
|
||||
*
|
||||
* This method queries all available ODB backends
|
||||
* trying to match the 'len' first hexadecimal
|
||||
* characters of the 'short_id'.
|
||||
* The remaining (GIT_OID_SHA1_HEXSIZE-len)*4 bits of
|
||||
* 'short_id' must be 0s.
|
||||
* 'len' must be at least GIT_OID_MINPREFIXLEN,
|
||||
* and the prefix must be long enough to identify
|
||||
* a unique object in all the backends; the
|
||||
* method will fail otherwise.
|
||||
*
|
||||
* The returned object is reference counted and
|
||||
* internally cached, so it should be closed
|
||||
* by the user once it's no longer in use.
|
||||
*
|
||||
* @param out pointer where to store the read object
|
||||
* @param db database to search for the object in.
|
||||
* @param short_id a prefix of the id of the object to read.
|
||||
* @param len the length of the prefix
|
||||
* @return 0 if the object was read, GIT_ENOTFOUND if the object is not in the
|
||||
* database. GIT_EAMBIGUOUS if the prefix is ambiguous
|
||||
* (several objects match the prefix)
|
||||
*/
|
||||
GIT_EXTERN(int) git_odb_read_prefix(git_odb_object **out, git_odb *db, const git_oid *short_id, size_t len);
|
||||
|
||||
/**
|
||||
* Read the header of an object from the database, without
|
||||
* reading its full contents.
|
||||
*
|
||||
* The header includes the length and the type of an object.
|
||||
*
|
||||
* Note that most backends do not support reading only the header
|
||||
* of an object, so the whole object will be read and then the
|
||||
* header will be returned.
|
||||
*
|
||||
* @param len_out pointer where to store the length
|
||||
* @param type_out pointer where to store the type
|
||||
* @param db database to search for the object in.
|
||||
* @param id identity of the object to read.
|
||||
* @return 0 if the object was read, GIT_ENOTFOUND if the object is not
|
||||
* in the database.
|
||||
*/
|
||||
GIT_EXTERN(int) git_odb_read_header(size_t *len_out, git_object_t *type_out, git_odb *db, const git_oid *id);
|
||||
|
||||
/**
|
||||
* Determine if the given object can be found in the object database.
|
||||
*
|
||||
* @param db database to be searched for the given object.
|
||||
* @param id the object to search for.
|
||||
* @return 1 if the object was found, 0 otherwise
|
||||
*/
|
||||
GIT_EXTERN(int) git_odb_exists(git_odb *db, const git_oid *id);
|
||||
|
||||
/**
|
||||
* Determine if the given object can be found in the object database, with
|
||||
* extended options.
|
||||
*
|
||||
* @param db database to be searched for the given object.
|
||||
* @param id the object to search for.
|
||||
* @param flags flags affecting the lookup (see `git_odb_lookup_flags_t`)
|
||||
* @return 1 if the object was found, 0 otherwise
|
||||
*/
|
||||
GIT_EXTERN(int) git_odb_exists_ext(git_odb *db, const git_oid *id, unsigned int flags);
|
||||
|
||||
/**
|
||||
* Determine if an object can be found in the object database by an
|
||||
* abbreviated object ID.
|
||||
*
|
||||
* @param out The full OID of the found object if just one is found.
|
||||
* @param db The database to be searched for the given object.
|
||||
* @param short_id A prefix of the id of the object to read.
|
||||
* @param len The length of the prefix.
|
||||
* @return 0 if found, GIT_ENOTFOUND if not found, GIT_EAMBIGUOUS if multiple
|
||||
* matches were found, other value < 0 if there was a read error.
|
||||
*/
|
||||
GIT_EXTERN(int) git_odb_exists_prefix(
|
||||
git_oid *out, git_odb *db, const git_oid *short_id, size_t len);
|
||||
|
||||
/**
|
||||
* The information about object IDs to query in `git_odb_expand_ids`,
|
||||
* which will be populated upon return.
|
||||
*/
|
||||
typedef struct git_odb_expand_id {
|
||||
/** The object ID to expand */
|
||||
git_oid id;
|
||||
|
||||
/**
|
||||
* The length of the object ID (in nibbles, or packets of 4 bits; the
|
||||
* number of hex characters)
|
||||
* */
|
||||
unsigned short length;
|
||||
|
||||
/**
|
||||
* The (optional) type of the object to search for; leave as `0` or set
|
||||
* to `GIT_OBJECT_ANY` to query for any object matching the ID.
|
||||
*/
|
||||
git_object_t type;
|
||||
} git_odb_expand_id;
|
||||
|
||||
/**
|
||||
* Determine if one or more objects can be found in the object database
|
||||
* by their abbreviated object ID and type.
|
||||
*
|
||||
* The given array will be updated in place: for each abbreviated ID that is
|
||||
* unique in the database, and of the given type (if specified),
|
||||
* the full object ID, object ID length (`GIT_OID_SHA1_HEXSIZE`) and type will be
|
||||
* written back to the array. For IDs that are not found (or are ambiguous),
|
||||
* the array entry will be zeroed.
|
||||
*
|
||||
* Note that since this function operates on multiple objects, the
|
||||
* underlying database will not be asked to be reloaded if an object is
|
||||
* not found (which is unlike other object database operations.)
|
||||
*
|
||||
* @param db The database to be searched for the given objects.
|
||||
* @param ids An array of short object IDs to search for
|
||||
* @param count The length of the `ids` array
|
||||
* @return 0 on success or an error code on failure
|
||||
*/
|
||||
GIT_EXTERN(int) git_odb_expand_ids(
|
||||
git_odb *db,
|
||||
git_odb_expand_id *ids,
|
||||
size_t count);
|
||||
|
||||
/**
|
||||
* Refresh the object database to load newly added files.
|
||||
*
|
||||
* If the object databases have changed on disk while the library
|
||||
* is running, this function will force a reload of the underlying
|
||||
* indexes.
|
||||
*
|
||||
* Use this function when you're confident that an external
|
||||
* application has tampered with the ODB.
|
||||
*
|
||||
* NOTE that it is not necessary to call this function at all. The
|
||||
* library will automatically attempt to refresh the ODB
|
||||
* when a lookup fails, to see if the looked up object exists
|
||||
* on disk but hasn't been loaded yet.
|
||||
*
|
||||
* @param db database to refresh
|
||||
* @return 0 on success, error code otherwise
|
||||
*/
|
||||
GIT_EXTERN(int) git_odb_refresh(struct git_odb *db);
|
||||
|
||||
/**
|
||||
* List all objects available in the database
|
||||
*
|
||||
* The callback will be called for each object available in the
|
||||
* database. Note that the objects are likely to be returned in the index
|
||||
* order, which would make accessing the objects in that order inefficient.
|
||||
* Return a non-zero value from the callback to stop looping.
|
||||
*
|
||||
* @param db database to use
|
||||
* @param cb the callback to call for each object
|
||||
* @param payload data to pass to the callback
|
||||
* @return 0 on success, non-zero callback return value, or error code
|
||||
*/
|
||||
GIT_EXTERN(int) git_odb_foreach(git_odb *db, git_odb_foreach_cb cb, void *payload);
|
||||
|
||||
/**
|
||||
* Write an object directly into the ODB
|
||||
*
|
||||
* This method writes a full object straight into the ODB.
|
||||
* For most cases, it is preferred to write objects through a write
|
||||
* stream, which is both faster and less memory intensive, specially
|
||||
* for big objects.
|
||||
*
|
||||
* This method is provided for compatibility with custom backends
|
||||
* which are not able to support streaming writes
|
||||
*
|
||||
* @param out pointer to store the OID result of the write
|
||||
* @param odb object database where to store the object
|
||||
* @param data buffer with the data to store
|
||||
* @param len size of the buffer
|
||||
* @param type type of the data to store
|
||||
* @return 0 or an error code
|
||||
*/
|
||||
GIT_EXTERN(int) git_odb_write(git_oid *out, git_odb *odb, const void *data, size_t len, git_object_t type);
|
||||
|
||||
/**
|
||||
* Open a stream to write an object into the ODB
|
||||
*
|
||||
* The type and final length of the object must be specified
|
||||
* when opening the stream.
|
||||
*
|
||||
* The returned stream will be of type `GIT_STREAM_WRONLY`, and it
|
||||
* won't be effective until `git_odb_stream_finalize_write` is called
|
||||
* and returns without an error
|
||||
*
|
||||
* The stream must always be freed when done with `git_odb_stream_free` or
|
||||
* will leak memory.
|
||||
*
|
||||
* @see git_odb_stream
|
||||
*
|
||||
* @param out pointer where to store the stream
|
||||
* @param db object database where the stream will write
|
||||
* @param size final size of the object that will be written
|
||||
* @param type type of the object that will be written
|
||||
* @return 0 if the stream was created; error code otherwise
|
||||
*/
|
||||
GIT_EXTERN(int) git_odb_open_wstream(git_odb_stream **out, git_odb *db, git_object_size_t size, git_object_t type);
|
||||
|
||||
/**
|
||||
* Write to an odb stream
|
||||
*
|
||||
* This method will fail if the total number of received bytes exceeds the
|
||||
* size declared with `git_odb_open_wstream()`
|
||||
*
|
||||
* @param stream the stream
|
||||
* @param buffer the data to write
|
||||
* @param len the buffer's length
|
||||
* @return 0 if the write succeeded, error code otherwise
|
||||
*/
|
||||
GIT_EXTERN(int) git_odb_stream_write(git_odb_stream *stream, const char *buffer, size_t len);
|
||||
|
||||
/**
|
||||
* Finish writing to an odb stream
|
||||
*
|
||||
* The object will take its final name and will be available to the
|
||||
* odb.
|
||||
*
|
||||
* This method will fail if the total number of received bytes
|
||||
* differs from the size declared with `git_odb_open_wstream()`
|
||||
*
|
||||
* @param out pointer to store the resulting object's id
|
||||
* @param stream the stream
|
||||
* @return 0 on success, an error code otherwise
|
||||
*/
|
||||
GIT_EXTERN(int) git_odb_stream_finalize_write(git_oid *out, git_odb_stream *stream);
|
||||
|
||||
/**
|
||||
* Read from an odb stream
|
||||
*
|
||||
* Most backends don't implement streaming reads
|
||||
*
|
||||
* @param stream the stream
|
||||
* @param buffer a user-allocated buffer to store the data in.
|
||||
* @param len the buffer's length
|
||||
* @return 0 if the read succeeded, error code otherwise
|
||||
*/
|
||||
GIT_EXTERN(int) git_odb_stream_read(git_odb_stream *stream, char *buffer, size_t len);
|
||||
|
||||
/**
|
||||
* Free an odb stream
|
||||
*
|
||||
* @param stream the stream to free
|
||||
*/
|
||||
GIT_EXTERN(void) git_odb_stream_free(git_odb_stream *stream);
|
||||
|
||||
/**
|
||||
* Open a stream to read an object from the ODB
|
||||
*
|
||||
* Note that most backends do *not* support streaming reads
|
||||
* because they store their objects as compressed/delta'ed blobs.
|
||||
*
|
||||
* It's recommended to use `git_odb_read` instead, which is
|
||||
* assured to work on all backends.
|
||||
*
|
||||
* The returned stream will be of type `GIT_STREAM_RDONLY` and
|
||||
* will have the following methods:
|
||||
*
|
||||
* - stream->read: read `n` bytes from the stream
|
||||
* - stream->free: free the stream
|
||||
*
|
||||
* The stream must always be free'd or will leak memory.
|
||||
*
|
||||
* @see git_odb_stream
|
||||
*
|
||||
* @param out pointer where to store the stream
|
||||
* @param len pointer where to store the length of the object
|
||||
* @param type pointer where to store the type of the object
|
||||
* @param db object database where the stream will read from
|
||||
* @param oid oid of the object the stream will read from
|
||||
* @return 0 if the stream was created, error code otherwise
|
||||
*/
|
||||
GIT_EXTERN(int) git_odb_open_rstream(
|
||||
git_odb_stream **out,
|
||||
size_t *len,
|
||||
git_object_t *type,
|
||||
git_odb *db,
|
||||
const git_oid *oid);
|
||||
|
||||
/**
|
||||
* Open a stream for writing a pack file to the ODB.
|
||||
*
|
||||
* If the ODB layer understands pack files, then the given
|
||||
* packfile will likely be streamed directly to disk (and a
|
||||
* corresponding index created). If the ODB layer does not
|
||||
* understand pack files, the objects will be stored in whatever
|
||||
* format the ODB layer uses.
|
||||
*
|
||||
* @see git_odb_writepack
|
||||
*
|
||||
* @param out pointer to the writepack functions
|
||||
* @param db object database where the stream will read from
|
||||
* @param progress_cb function to call with progress information.
|
||||
* Be aware that this is called inline with network and indexing operations,
|
||||
* so performance may be affected.
|
||||
* @param progress_payload payload for the progress callback
|
||||
* @return 0 or an error code.
|
||||
*/
|
||||
GIT_EXTERN(int) git_odb_write_pack(
|
||||
git_odb_writepack **out,
|
||||
git_odb *db,
|
||||
git_indexer_progress_cb progress_cb,
|
||||
void *progress_payload);
|
||||
|
||||
/**
|
||||
* Write a `multi-pack-index` file from all the `.pack` files in the ODB.
|
||||
*
|
||||
* If the ODB layer understands pack files, then this will create a file called
|
||||
* `multi-pack-index` next to the `.pack` and `.idx` files, which will contain
|
||||
* an index of all objects stored in `.pack` files. This will allow for
|
||||
* O(log n) lookup for n objects (regardless of how many packfiles there
|
||||
* exist).
|
||||
*
|
||||
* @param db object database where the `multi-pack-index` file will be written.
|
||||
* @return 0 or an error code.
|
||||
*/
|
||||
GIT_EXTERN(int) git_odb_write_multi_pack_index(
|
||||
git_odb *db);
|
||||
|
||||
/**
|
||||
* Determine the object-ID (sha1 or sha256 hash) of a data buffer
|
||||
*
|
||||
* The resulting OID will be the identifier for the data buffer as if
|
||||
* the data buffer it were to written to the ODB.
|
||||
*
|
||||
* @param out the resulting object-ID.
|
||||
* @param data data to hash
|
||||
* @param len size of the data
|
||||
* @param object_type of the data to hash
|
||||
* @param oid_type the oid type to hash to
|
||||
* @return 0 or an error code
|
||||
*/
|
||||
#ifdef GIT_EXPERIMENTAL_SHA256
|
||||
GIT_EXTERN(int) git_odb_hash(
|
||||
git_oid *out,
|
||||
const void *data,
|
||||
size_t len,
|
||||
git_object_t object_type,
|
||||
git_oid_t oid_type);
|
||||
#else
|
||||
GIT_EXTERN(int) git_odb_hash(git_oid *out, const void *data, size_t len, git_object_t type);
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Read a file from disk and fill a git_oid with the object id
|
||||
* that the file would have if it were written to the Object
|
||||
* Database as an object of the given type (w/o applying filters).
|
||||
* Similar functionality to git.git's `git hash-object` without
|
||||
* the `-w` flag, however, with the --no-filters flag.
|
||||
* If you need filters, see git_repository_hashfile.
|
||||
*
|
||||
* @param out oid structure the result is written into.
|
||||
* @param path file to read and determine object id for
|
||||
* @param object_type of the data to hash
|
||||
* @param oid_type the oid type to hash to
|
||||
* @return 0 or an error code
|
||||
*/
|
||||
#ifdef GIT_EXPERIMENTAL_SHA256
|
||||
GIT_EXTERN(int) git_odb_hashfile(
|
||||
git_oid *out,
|
||||
const char *path,
|
||||
git_object_t object_type,
|
||||
git_oid_t oid_type);
|
||||
#else
|
||||
GIT_EXTERN(int) git_odb_hashfile(git_oid *out, const char *path, git_object_t type);
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Create a copy of an odb_object
|
||||
*
|
||||
* The returned copy must be manually freed with `git_odb_object_free`.
|
||||
* Note that because of an implementation detail, the returned copy will be
|
||||
* the same pointer as `source`: the object is internally refcounted, so the
|
||||
* copy still needs to be freed twice.
|
||||
*
|
||||
* @param dest pointer where to store the copy
|
||||
* @param source object to copy
|
||||
* @return 0 or an error code
|
||||
*/
|
||||
GIT_EXTERN(int) git_odb_object_dup(git_odb_object **dest, git_odb_object *source);
|
||||
|
||||
/**
|
||||
* Close an ODB object
|
||||
*
|
||||
* This method must always be called once a `git_odb_object` is no
|
||||
* longer needed, otherwise memory will leak.
|
||||
*
|
||||
* @param object object to close
|
||||
*/
|
||||
GIT_EXTERN(void) git_odb_object_free(git_odb_object *object);
|
||||
|
||||
/**
|
||||
* Return the OID of an ODB object
|
||||
*
|
||||
* This is the OID from which the object was read from
|
||||
*
|
||||
* @param object the object
|
||||
* @return a pointer to the OID
|
||||
*/
|
||||
GIT_EXTERN(const git_oid *) git_odb_object_id(git_odb_object *object);
|
||||
|
||||
/**
|
||||
* Return the data of an ODB object
|
||||
*
|
||||
* This is the uncompressed, raw data as read from the ODB,
|
||||
* without the leading header.
|
||||
*
|
||||
* This pointer is owned by the object and shall not be free'd.
|
||||
*
|
||||
* @param object the object
|
||||
* @return a pointer to the data
|
||||
*/
|
||||
GIT_EXTERN(const void *) git_odb_object_data(git_odb_object *object);
|
||||
|
||||
/**
|
||||
* Return the size of an ODB object
|
||||
*
|
||||
* This is the real size of the `data` buffer, not the
|
||||
* actual size of the object.
|
||||
*
|
||||
* @param object the object
|
||||
* @return the size
|
||||
*/
|
||||
GIT_EXTERN(size_t) git_odb_object_size(git_odb_object *object);
|
||||
|
||||
/**
|
||||
* Return the type of an ODB object
|
||||
*
|
||||
* @param object the object
|
||||
* @return the type
|
||||
*/
|
||||
GIT_EXTERN(git_object_t) git_odb_object_type(git_odb_object *object);
|
||||
|
||||
/**
|
||||
* Add a custom backend to an existing Object DB
|
||||
*
|
||||
* The backends are checked in relative ordering, based on the
|
||||
* value of the `priority` parameter.
|
||||
*
|
||||
* Read <sys/odb_backend.h> for more information.
|
||||
*
|
||||
* @param odb database to add the backend to
|
||||
* @param backend pointer to a git_odb_backend instance
|
||||
* @param priority Value for ordering the backends queue
|
||||
* @return 0 on success, error code otherwise
|
||||
*/
|
||||
GIT_EXTERN(int) git_odb_add_backend(git_odb *odb, git_odb_backend *backend, int priority);
|
||||
|
||||
/**
|
||||
* Add a custom backend to an existing Object DB; this
|
||||
* backend will work as an alternate.
|
||||
*
|
||||
* Alternate backends are always checked for objects *after*
|
||||
* all the main backends have been exhausted.
|
||||
*
|
||||
* The backends are checked in relative ordering, based on the
|
||||
* value of the `priority` parameter.
|
||||
*
|
||||
* Writing is disabled on alternate backends.
|
||||
*
|
||||
* Read <sys/odb_backend.h> for more information.
|
||||
*
|
||||
* @param odb database to add the backend to
|
||||
* @param backend pointer to a git_odb_backend instance
|
||||
* @param priority Value for ordering the backends queue
|
||||
* @return 0 on success, error code otherwise
|
||||
*/
|
||||
GIT_EXTERN(int) git_odb_add_alternate(git_odb *odb, git_odb_backend *backend, int priority);
|
||||
|
||||
/**
|
||||
* Get the number of ODB backend objects
|
||||
*
|
||||
* @param odb object database
|
||||
* @return number of backends in the ODB
|
||||
*/
|
||||
GIT_EXTERN(size_t) git_odb_num_backends(git_odb *odb);
|
||||
|
||||
/**
|
||||
* Lookup an ODB backend object by index
|
||||
*
|
||||
* @param out output pointer to ODB backend at pos
|
||||
* @param odb object database
|
||||
* @param pos index into object database backend list
|
||||
* @return 0 on success, GIT_ENOTFOUND if pos is invalid, other errors < 0
|
||||
*/
|
||||
GIT_EXTERN(int) git_odb_get_backend(git_odb_backend **out, git_odb *odb, size_t pos);
|
||||
|
||||
/**
|
||||
* Set the git commit-graph for the ODB.
|
||||
*
|
||||
* After a successful call, the ownership of the cgraph parameter will be
|
||||
* transferred to libgit2, and the caller should not free it.
|
||||
*
|
||||
* The commit-graph can also be unset by explicitly passing NULL as the cgraph
|
||||
* parameter.
|
||||
*
|
||||
* @param odb object database
|
||||
* @param cgraph the git commit-graph
|
||||
* @return 0 on success; error code otherwise
|
||||
*/
|
||||
GIT_EXTERN(int) git_odb_set_commit_graph(git_odb *odb, git_commit_graph *cgraph);
|
||||
|
||||
/** @} */
|
||||
GIT_END_DECL
|
||||
#endif
|
223
3rdparty/libgit2/include/git2/odb_backend.h
vendored
Normal file
223
3rdparty/libgit2/include/git2/odb_backend.h
vendored
Normal file
@ -0,0 +1,223 @@
|
||||
/*
|
||||
* Copyright (C) the libgit2 contributors. All rights reserved.
|
||||
*
|
||||
* This file is part of libgit2, distributed under the GNU GPL v2 with
|
||||
* a Linking Exception. For full terms see the included COPYING file.
|
||||
*/
|
||||
#ifndef INCLUDE_git_odb_backend_h__
|
||||
#define INCLUDE_git_odb_backend_h__
|
||||
|
||||
#include "common.h"
|
||||
#include "types.h"
|
||||
#include "indexer.h"
|
||||
|
||||
/**
|
||||
* @file git2/backend.h
|
||||
* @brief Git custom backend functions
|
||||
* @defgroup git_odb Git object database routines
|
||||
* @ingroup Git
|
||||
* @{
|
||||
*/
|
||||
GIT_BEGIN_DECL
|
||||
|
||||
/*
|
||||
* Constructors for in-box ODB backends.
|
||||
*/
|
||||
|
||||
/** Options for configuring a packfile object backend. */
|
||||
typedef struct {
|
||||
unsigned int version; /**< version for the struct */
|
||||
|
||||
/**
|
||||
* Type of object IDs to use for this object database, or
|
||||
* 0 for default (currently SHA1).
|
||||
*/
|
||||
git_oid_t oid_type;
|
||||
} git_odb_backend_pack_options;
|
||||
|
||||
/* The current version of the diff options structure */
|
||||
#define GIT_ODB_BACKEND_PACK_OPTIONS_VERSION 1
|
||||
|
||||
/* Stack initializer for odb pack backend options. Alternatively use
|
||||
* `git_odb_backend_pack_options_init` programmatic initialization.
|
||||
*/
|
||||
#define GIT_ODB_BACKEND_PACK_OPTIONS_INIT \
|
||||
{ GIT_ODB_BACKEND_PACK_OPTIONS_VERSION }
|
||||
|
||||
/**
|
||||
* Create a backend for the packfiles.
|
||||
*
|
||||
* @param out location to store the odb backend pointer
|
||||
* @param objects_dir the Git repository's objects directory
|
||||
*
|
||||
* @return 0 or an error code
|
||||
*/
|
||||
#ifdef GIT_EXPERIMENTAL_SHA256
|
||||
GIT_EXTERN(int) git_odb_backend_pack(
|
||||
git_odb_backend **out,
|
||||
const char *objects_dir,
|
||||
const git_odb_backend_pack_options *opts);
|
||||
#else
|
||||
GIT_EXTERN(int) git_odb_backend_pack(
|
||||
git_odb_backend **out,
|
||||
const char *objects_dir);
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Create a backend out of a single packfile
|
||||
*
|
||||
* This can be useful for inspecting the contents of a single
|
||||
* packfile.
|
||||
*
|
||||
* @param out location to store the odb backend pointer
|
||||
* @param index_file path to the packfile's .idx file
|
||||
*
|
||||
* @return 0 or an error code
|
||||
*/
|
||||
#ifdef GIT_EXPERIMENTAL_SHA256
|
||||
GIT_EXTERN(int) git_odb_backend_one_pack(
|
||||
git_odb_backend **out,
|
||||
const char *index_file,
|
||||
const git_odb_backend_pack_options *opts);
|
||||
#else
|
||||
GIT_EXTERN(int) git_odb_backend_one_pack(
|
||||
git_odb_backend **out,
|
||||
const char *index_file);
|
||||
#endif
|
||||
|
||||
typedef enum {
|
||||
GIT_ODB_BACKEND_LOOSE_FSYNC = (1 << 0)
|
||||
} git_odb_backend_loose_flag_t;
|
||||
|
||||
/** Options for configuring a loose object backend. */
|
||||
typedef struct {
|
||||
unsigned int version; /**< version for the struct */
|
||||
|
||||
/** A combination of the `git_odb_backend_loose_flag_t` types. */
|
||||
uint32_t flags;
|
||||
|
||||
/**
|
||||
* zlib compression level to use (0-9), where 1 is the fastest
|
||||
* at the expense of larger files, and 9 produces the best
|
||||
* compression at the expense of speed. 0 indicates that no
|
||||
* compression should be performed. -1 is the default (currently
|
||||
* optimizing for speed).
|
||||
*/
|
||||
int compression_level;
|
||||
|
||||
/** Permissions to use creating a directory or 0 for defaults */
|
||||
unsigned int dir_mode;
|
||||
|
||||
/** Permissions to use creating a file or 0 for defaults */
|
||||
unsigned int file_mode;
|
||||
|
||||
/**
|
||||
* Type of object IDs to use for this object database, or
|
||||
* 0 for default (currently SHA1).
|
||||
*/
|
||||
git_oid_t oid_type;
|
||||
} git_odb_backend_loose_options;
|
||||
|
||||
/* The current version of the diff options structure */
|
||||
#define GIT_ODB_BACKEND_LOOSE_OPTIONS_VERSION 1
|
||||
|
||||
/* Stack initializer for odb loose backend options. Alternatively use
|
||||
* `git_odb_backend_loose_options_init` programmatic initialization.
|
||||
*/
|
||||
#define GIT_ODB_BACKEND_LOOSE_OPTIONS_INIT \
|
||||
{ GIT_ODB_BACKEND_LOOSE_OPTIONS_VERSION, 0, -1 }
|
||||
|
||||
/**
|
||||
* Create a backend for loose objects
|
||||
*
|
||||
* @param out location to store the odb backend pointer
|
||||
* @param objects_dir the Git repository's objects directory
|
||||
* @param opts options for the loose object backend or NULL
|
||||
*
|
||||
* @return 0 or an error code
|
||||
*/
|
||||
#ifdef GIT_EXPERIMENTAL_SHA256
|
||||
GIT_EXTERN(int) git_odb_backend_loose(
|
||||
git_odb_backend **out,
|
||||
const char *objects_dir,
|
||||
git_odb_backend_loose_options *opts);
|
||||
#else
|
||||
GIT_EXTERN(int) git_odb_backend_loose(
|
||||
git_odb_backend **out,
|
||||
const char *objects_dir,
|
||||
int compression_level,
|
||||
int do_fsync,
|
||||
unsigned int dir_mode,
|
||||
unsigned int file_mode);
|
||||
#endif
|
||||
|
||||
/** Streaming mode */
|
||||
typedef enum {
|
||||
GIT_STREAM_RDONLY = (1 << 1),
|
||||
GIT_STREAM_WRONLY = (1 << 2),
|
||||
GIT_STREAM_RW = (GIT_STREAM_RDONLY | GIT_STREAM_WRONLY)
|
||||
} git_odb_stream_t;
|
||||
|
||||
/**
|
||||
* A stream to read/write from a backend.
|
||||
*
|
||||
* This represents a stream of data being written to or read from a
|
||||
* backend. When writing, the frontend functions take care of
|
||||
* calculating the object's id and all `finalize_write` needs to do is
|
||||
* store the object with the id it is passed.
|
||||
*/
|
||||
struct git_odb_stream {
|
||||
git_odb_backend *backend;
|
||||
unsigned int mode;
|
||||
void *hash_ctx;
|
||||
|
||||
#ifdef GIT_EXPERIMENTAL_SHA256
|
||||
git_oid_t oid_type;
|
||||
#endif
|
||||
|
||||
git_object_size_t declared_size;
|
||||
git_object_size_t received_bytes;
|
||||
|
||||
/**
|
||||
* Write at most `len` bytes into `buffer` and advance the stream.
|
||||
*/
|
||||
int GIT_CALLBACK(read)(git_odb_stream *stream, char *buffer, size_t len);
|
||||
|
||||
/**
|
||||
* Write `len` bytes from `buffer` into the stream.
|
||||
*/
|
||||
int GIT_CALLBACK(write)(git_odb_stream *stream, const char *buffer, size_t len);
|
||||
|
||||
/**
|
||||
* Store the contents of the stream as an object with the id
|
||||
* specified in `oid`.
|
||||
*
|
||||
* This method might not be invoked if:
|
||||
* - an error occurs earlier with the `write` callback,
|
||||
* - the object referred to by `oid` already exists in any backend, or
|
||||
* - the final number of received bytes differs from the size declared
|
||||
* with `git_odb_open_wstream()`
|
||||
*/
|
||||
int GIT_CALLBACK(finalize_write)(git_odb_stream *stream, const git_oid *oid);
|
||||
|
||||
/**
|
||||
* Free the stream's memory.
|
||||
*
|
||||
* This method might be called without a call to `finalize_write` if
|
||||
* an error occurs or if the object is already present in the ODB.
|
||||
*/
|
||||
void GIT_CALLBACK(free)(git_odb_stream *stream);
|
||||
};
|
||||
|
||||
/** A stream to write a pack file to the ODB */
|
||||
struct git_odb_writepack {
|
||||
git_odb_backend *backend;
|
||||
|
||||
int GIT_CALLBACK(append)(git_odb_writepack *writepack, const void *data, size_t size, git_indexer_progress *stats);
|
||||
int GIT_CALLBACK(commit)(git_odb_writepack *writepack, git_indexer_progress *stats);
|
||||
void GIT_CALLBACK(free)(git_odb_writepack *writepack);
|
||||
};
|
||||
|
||||
GIT_END_DECL
|
||||
|
||||
#endif
|
373
3rdparty/libgit2/include/git2/oid.h
vendored
Normal file
373
3rdparty/libgit2/include/git2/oid.h
vendored
Normal file
@ -0,0 +1,373 @@
|
||||
/*
|
||||
* Copyright (C) the libgit2 contributors. All rights reserved.
|
||||
*
|
||||
* This file is part of libgit2, distributed under the GNU GPL v2 with
|
||||
* a Linking Exception. For full terms see the included COPYING file.
|
||||
*/
|
||||
#ifndef INCLUDE_git_oid_h__
|
||||
#define INCLUDE_git_oid_h__
|
||||
|
||||
#include "common.h"
|
||||
#include "types.h"
|
||||
#include "experimental.h"
|
||||
|
||||
/**
|
||||
* @file git2/oid.h
|
||||
* @brief Git object id routines
|
||||
* @defgroup git_oid Git object id routines
|
||||
* @ingroup Git
|
||||
* @{
|
||||
*/
|
||||
GIT_BEGIN_DECL
|
||||
|
||||
/** The type of object id. */
|
||||
typedef enum {
|
||||
|
||||
#ifdef GIT_EXPERIMENTAL_SHA256
|
||||
GIT_OID_SHA1 = 1, /**< SHA1 */
|
||||
GIT_OID_SHA256 = 2 /**< SHA256 */
|
||||
#else
|
||||
GIT_OID_SHA1 = 1 /**< SHA1 */
|
||||
#endif
|
||||
|
||||
} git_oid_t;
|
||||
|
||||
/*
|
||||
* SHA1 is currently the only supported object ID type.
|
||||
*/
|
||||
|
||||
/** SHA1 is currently libgit2's default oid type. */
|
||||
#define GIT_OID_DEFAULT GIT_OID_SHA1
|
||||
|
||||
/** Size (in bytes) of a raw/binary sha1 oid */
|
||||
#define GIT_OID_SHA1_SIZE 20
|
||||
/** Size (in bytes) of a hex formatted sha1 oid */
|
||||
#define GIT_OID_SHA1_HEXSIZE (GIT_OID_SHA1_SIZE * 2)
|
||||
|
||||
/**
|
||||
* The binary representation of the null sha1 object ID.
|
||||
*/
|
||||
#ifndef GIT_EXPERIMENTAL_SHA256
|
||||
# define GIT_OID_SHA1_ZERO { { 0 } }
|
||||
#else
|
||||
# define GIT_OID_SHA1_ZERO { GIT_OID_SHA1, { 0 } }
|
||||
#endif
|
||||
|
||||
/**
|
||||
* The string representation of the null sha1 object ID.
|
||||
*/
|
||||
#define GIT_OID_SHA1_HEXZERO "0000000000000000000000000000000000000000"
|
||||
|
||||
/*
|
||||
* Experimental SHA256 support is a breaking change to the API.
|
||||
* This exists for application compatibility testing.
|
||||
*/
|
||||
|
||||
#ifdef GIT_EXPERIMENTAL_SHA256
|
||||
|
||||
/** Size (in bytes) of a raw/binary sha256 oid */
|
||||
# define GIT_OID_SHA256_SIZE 32
|
||||
/** Size (in bytes) of a hex formatted sha256 oid */
|
||||
# define GIT_OID_SHA256_HEXSIZE (GIT_OID_SHA256_SIZE * 2)
|
||||
|
||||
/**
|
||||
* The binary representation of the null sha256 object ID.
|
||||
*/
|
||||
# define GIT_OID_SHA256_ZERO { GIT_OID_SHA256, { 0 } }
|
||||
|
||||
/**
|
||||
* The string representation of the null sha256 object ID.
|
||||
*/
|
||||
# define GIT_OID_SHA256_HEXZERO "0000000000000000000000000000000000000000000000000000000000000000"
|
||||
|
||||
#endif
|
||||
|
||||
/* Maximum possible object ID size in raw / hex string format. */
|
||||
#ifndef GIT_EXPERIMENTAL_SHA256
|
||||
# define GIT_OID_MAX_SIZE GIT_OID_SHA1_SIZE
|
||||
# define GIT_OID_MAX_HEXSIZE GIT_OID_SHA1_HEXSIZE
|
||||
#else
|
||||
# define GIT_OID_MAX_SIZE GIT_OID_SHA256_SIZE
|
||||
# define GIT_OID_MAX_HEXSIZE GIT_OID_SHA256_HEXSIZE
|
||||
#endif
|
||||
|
||||
/** Minimum length (in number of hex characters,
|
||||
* i.e. packets of 4 bits) of an oid prefix */
|
||||
#define GIT_OID_MINPREFIXLEN 4
|
||||
|
||||
/** Unique identity of any object (commit, tree, blob, tag). */
|
||||
typedef struct git_oid {
|
||||
|
||||
#ifdef GIT_EXPERIMENTAL_SHA256
|
||||
/** type of object id */
|
||||
unsigned char type;
|
||||
#endif
|
||||
|
||||
/** raw binary formatted id */
|
||||
unsigned char id[GIT_OID_MAX_SIZE];
|
||||
} git_oid;
|
||||
|
||||
/**
|
||||
* Parse a hex formatted object id into a git_oid.
|
||||
*
|
||||
* The appropriate number of bytes for the given object ID type will
|
||||
* be read from the string - 40 bytes for SHA1, 64 bytes for SHA256.
|
||||
* The given string need not be NUL terminated.
|
||||
*
|
||||
* @param out oid structure the result is written into.
|
||||
* @param str input hex string; must be pointing at the start of
|
||||
* the hex sequence and have at least the number of bytes
|
||||
* needed for an oid encoded in hex (40 bytes for sha1,
|
||||
* 256 bytes for sha256).
|
||||
* @param type the type of object id
|
||||
* @return 0 or an error code
|
||||
*/
|
||||
#ifdef GIT_EXPERIMENTAL_SHA256
|
||||
GIT_EXTERN(int) git_oid_fromstr(git_oid *out, const char *str, git_oid_t type);
|
||||
#else
|
||||
GIT_EXTERN(int) git_oid_fromstr(git_oid *out, const char *str);
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Parse a hex formatted NUL-terminated string into a git_oid.
|
||||
*
|
||||
* @param out oid structure the result is written into.
|
||||
* @param str input hex string; must be null-terminated.
|
||||
* @param type the type of object id
|
||||
* @return 0 or an error code
|
||||
*/
|
||||
#ifdef GIT_EXPERIMENTAL_SHA256
|
||||
GIT_EXTERN(int) git_oid_fromstrp(git_oid *out, const char *str, git_oid_t type);
|
||||
#else
|
||||
GIT_EXTERN(int) git_oid_fromstrp(git_oid *out, const char *str);
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Parse N characters of a hex formatted object id into a git_oid.
|
||||
*
|
||||
* If N is odd, the last byte's high nibble will be read in and the
|
||||
* low nibble set to zero.
|
||||
*
|
||||
* @param out oid structure the result is written into.
|
||||
* @param str input hex string of at least size `length`
|
||||
* @param length length of the input string
|
||||
* @param type the type of object id
|
||||
* @return 0 or an error code
|
||||
*/
|
||||
#ifdef GIT_EXPERIMENTAL_SHA256
|
||||
GIT_EXTERN(int) git_oid_fromstrn(git_oid *out, const char *str, size_t length, git_oid_t type);
|
||||
#else
|
||||
GIT_EXTERN(int) git_oid_fromstrn(git_oid *out, const char *str, size_t length);
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Copy an already raw oid into a git_oid structure.
|
||||
*
|
||||
* @param out oid structure the result is written into.
|
||||
* @param raw the raw input bytes to be copied.
|
||||
* @return 0 on success or error code
|
||||
*/
|
||||
#ifdef GIT_EXPERIMENTAL_SHA256
|
||||
GIT_EXTERN(int) git_oid_fromraw(git_oid *out, const unsigned char *raw, git_oid_t type);
|
||||
#else
|
||||
GIT_EXTERN(int) git_oid_fromraw(git_oid *out, const unsigned char *raw);
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Format a git_oid into a hex string.
|
||||
*
|
||||
* @param out output hex string; must be pointing at the start of
|
||||
* the hex sequence and have at least the number of bytes
|
||||
* needed for an oid encoded in hex (40 bytes for SHA1,
|
||||
* 64 bytes for SHA256). Only the oid digits are written;
|
||||
* a '\\0' terminator must be added by the caller if it is
|
||||
* required.
|
||||
* @param id oid structure to format.
|
||||
* @return 0 on success or error code
|
||||
*/
|
||||
GIT_EXTERN(int) git_oid_fmt(char *out, const git_oid *id);
|
||||
|
||||
/**
|
||||
* Format a git_oid into a partial hex string.
|
||||
*
|
||||
* @param out output hex string; you say how many bytes to write.
|
||||
* If the number of bytes is > GIT_OID_SHA1_HEXSIZE, extra bytes
|
||||
* will be zeroed; if not, a '\0' terminator is NOT added.
|
||||
* @param n number of characters to write into out string
|
||||
* @param id oid structure to format.
|
||||
* @return 0 on success or error code
|
||||
*/
|
||||
GIT_EXTERN(int) git_oid_nfmt(char *out, size_t n, const git_oid *id);
|
||||
|
||||
/**
|
||||
* Format a git_oid into a loose-object path string.
|
||||
*
|
||||
* The resulting string is "aa/...", where "aa" is the first two
|
||||
* hex digits of the oid and "..." is the remaining 38 digits.
|
||||
*
|
||||
* @param out output hex string; must be pointing at the start of
|
||||
* the hex sequence and have at least the number of bytes
|
||||
* needed for an oid encoded in hex (41 bytes for SHA1,
|
||||
* 65 bytes for SHA256). Only the oid digits are written;
|
||||
* a '\\0' terminator must be added by the caller if it
|
||||
* is required.
|
||||
* @param id oid structure to format.
|
||||
* @return 0 on success, non-zero callback return value, or error code
|
||||
*/
|
||||
GIT_EXTERN(int) git_oid_pathfmt(char *out, const git_oid *id);
|
||||
|
||||
/**
|
||||
* Format a git_oid into a statically allocated c-string.
|
||||
*
|
||||
* The c-string is owned by the library and should not be freed
|
||||
* by the user. If libgit2 is built with thread support, the string
|
||||
* will be stored in TLS (i.e. one buffer per thread) to allow for
|
||||
* concurrent calls of the function.
|
||||
*
|
||||
* @param oid The oid structure to format
|
||||
* @return the c-string or NULL on failure
|
||||
*/
|
||||
GIT_EXTERN(char *) git_oid_tostr_s(const git_oid *oid);
|
||||
|
||||
/**
|
||||
* Format a git_oid into a buffer as a hex format c-string.
|
||||
*
|
||||
* If the buffer is smaller than the size of a hex-formatted oid string
|
||||
* plus an additional byte (GIT_OID_SHA_HEXSIZE + 1 for SHA1 or
|
||||
* GIT_OID_SHA256_HEXSIZE + 1 for SHA256), then the resulting
|
||||
* oid c-string will be truncated to n-1 characters (but will still be
|
||||
* NUL-byte terminated).
|
||||
*
|
||||
* If there are any input parameter errors (out == NULL, n == 0, oid ==
|
||||
* NULL), then a pointer to an empty string is returned, so that the
|
||||
* return value can always be printed.
|
||||
*
|
||||
* @param out the buffer into which the oid string is output.
|
||||
* @param n the size of the out buffer.
|
||||
* @param id the oid structure to format.
|
||||
* @return the out buffer pointer, assuming no input parameter
|
||||
* errors, otherwise a pointer to an empty string.
|
||||
*/
|
||||
GIT_EXTERN(char *) git_oid_tostr(char *out, size_t n, const git_oid *id);
|
||||
|
||||
/**
|
||||
* Copy an oid from one structure to another.
|
||||
*
|
||||
* @param out oid structure the result is written into.
|
||||
* @param src oid structure to copy from.
|
||||
* @return 0 on success or error code
|
||||
*/
|
||||
GIT_EXTERN(int) git_oid_cpy(git_oid *out, const git_oid *src);
|
||||
|
||||
/**
|
||||
* Compare two oid structures.
|
||||
*
|
||||
* @param a first oid structure.
|
||||
* @param b second oid structure.
|
||||
* @return <0, 0, >0 if a < b, a == b, a > b.
|
||||
*/
|
||||
GIT_EXTERN(int) git_oid_cmp(const git_oid *a, const git_oid *b);
|
||||
|
||||
/**
|
||||
* Compare two oid structures for equality
|
||||
*
|
||||
* @param a first oid structure.
|
||||
* @param b second oid structure.
|
||||
* @return true if equal, false otherwise
|
||||
*/
|
||||
GIT_EXTERN(int) git_oid_equal(const git_oid *a, const git_oid *b);
|
||||
|
||||
/**
|
||||
* Compare the first 'len' hexadecimal characters (packets of 4 bits)
|
||||
* of two oid structures.
|
||||
*
|
||||
* @param a first oid structure.
|
||||
* @param b second oid structure.
|
||||
* @param len the number of hex chars to compare
|
||||
* @return 0 in case of a match
|
||||
*/
|
||||
GIT_EXTERN(int) git_oid_ncmp(const git_oid *a, const git_oid *b, size_t len);
|
||||
|
||||
/**
|
||||
* Check if an oid equals an hex formatted object id.
|
||||
*
|
||||
* @param id oid structure.
|
||||
* @param str input hex string of an object id.
|
||||
* @return 0 in case of a match, -1 otherwise.
|
||||
*/
|
||||
GIT_EXTERN(int) git_oid_streq(const git_oid *id, const char *str);
|
||||
|
||||
/**
|
||||
* Compare an oid to an hex formatted object id.
|
||||
*
|
||||
* @param id oid structure.
|
||||
* @param str input hex string of an object id.
|
||||
* @return -1 if str is not valid, <0 if id sorts before str,
|
||||
* 0 if id matches str, >0 if id sorts after str.
|
||||
*/
|
||||
GIT_EXTERN(int) git_oid_strcmp(const git_oid *id, const char *str);
|
||||
|
||||
/**
|
||||
* Check is an oid is all zeros.
|
||||
*
|
||||
* @return 1 if all zeros, 0 otherwise.
|
||||
*/
|
||||
GIT_EXTERN(int) git_oid_is_zero(const git_oid *id);
|
||||
|
||||
/**
|
||||
* OID Shortener object
|
||||
*/
|
||||
typedef struct git_oid_shorten git_oid_shorten;
|
||||
|
||||
/**
|
||||
* Create a new OID shortener.
|
||||
*
|
||||
* The OID shortener is used to process a list of OIDs
|
||||
* in text form and return the shortest length that would
|
||||
* uniquely identify all of them.
|
||||
*
|
||||
* E.g. look at the result of `git log --abbrev`.
|
||||
*
|
||||
* @param min_length The minimal length for all identifiers,
|
||||
* which will be used even if shorter OIDs would still
|
||||
* be unique.
|
||||
* @return a `git_oid_shorten` instance, NULL if OOM
|
||||
*/
|
||||
GIT_EXTERN(git_oid_shorten *) git_oid_shorten_new(size_t min_length);
|
||||
|
||||
/**
|
||||
* Add a new OID to set of shortened OIDs and calculate
|
||||
* the minimal length to uniquely identify all the OIDs in
|
||||
* the set.
|
||||
*
|
||||
* The OID is expected to be a 40-char hexadecimal string.
|
||||
* The OID is owned by the user and will not be modified
|
||||
* or freed.
|
||||
*
|
||||
* For performance reasons, there is a hard-limit of how many
|
||||
* OIDs can be added to a single set (around ~32000, assuming
|
||||
* a mostly randomized distribution), which should be enough
|
||||
* for any kind of program, and keeps the algorithm fast and
|
||||
* memory-efficient.
|
||||
*
|
||||
* Attempting to add more than those OIDs will result in a
|
||||
* GIT_ERROR_INVALID error
|
||||
*
|
||||
* @param os a `git_oid_shorten` instance
|
||||
* @param text_id an OID in text form
|
||||
* @return the minimal length to uniquely identify all OIDs
|
||||
* added so far to the set; or an error code (<0) if an
|
||||
* error occurs.
|
||||
*/
|
||||
GIT_EXTERN(int) git_oid_shorten_add(git_oid_shorten *os, const char *text_id);
|
||||
|
||||
/**
|
||||
* Free an OID shortener instance
|
||||
*
|
||||
* @param os a `git_oid_shorten` instance
|
||||
*/
|
||||
GIT_EXTERN(void) git_oid_shorten_free(git_oid_shorten *os);
|
||||
|
||||
/** @} */
|
||||
GIT_END_DECL
|
||||
#endif
|
37
3rdparty/libgit2/include/git2/oidarray.h
vendored
Normal file
37
3rdparty/libgit2/include/git2/oidarray.h
vendored
Normal file
@ -0,0 +1,37 @@
|
||||
/*
|
||||
* Copyright (C) the libgit2 contributors. All rights reserved.
|
||||
*
|
||||
* This file is part of libgit2, distributed under the GNU GPL v2 with
|
||||
* a Linking Exception. For full terms see the included COPYING file.
|
||||
*/
|
||||
#ifndef INCLUDE_git_oidarray_h__
|
||||
#define INCLUDE_git_oidarray_h__
|
||||
|
||||
#include "common.h"
|
||||
#include "oid.h"
|
||||
|
||||
GIT_BEGIN_DECL
|
||||
|
||||
/** Array of object ids */
|
||||
typedef struct git_oidarray {
|
||||
git_oid *ids;
|
||||
size_t count;
|
||||
} git_oidarray;
|
||||
|
||||
/**
|
||||
* Free the object IDs contained in an oid_array. This method should
|
||||
* be called on `git_oidarray` objects that were provided by the
|
||||
* library. Not doing so will result in a memory leak.
|
||||
*
|
||||
* This does not free the `git_oidarray` itself, since the library will
|
||||
* never allocate that object directly itself.
|
||||
*
|
||||
* @param array git_oidarray from which to free oid data
|
||||
*/
|
||||
GIT_EXTERN(void) git_oidarray_dispose(git_oidarray *array);
|
||||
|
||||
/** @} */
|
||||
GIT_END_DECL
|
||||
|
||||
#endif
|
||||
|
267
3rdparty/libgit2/include/git2/pack.h
vendored
Normal file
267
3rdparty/libgit2/include/git2/pack.h
vendored
Normal file
@ -0,0 +1,267 @@
|
||||
/*
|
||||
* Copyright (C) the libgit2 contributors. All rights reserved.
|
||||
*
|
||||
* This file is part of libgit2, distributed under the GNU GPL v2 with
|
||||
* a Linking Exception. For full terms see the included COPYING file.
|
||||
*/
|
||||
#ifndef INCLUDE_git_pack_h__
|
||||
#define INCLUDE_git_pack_h__
|
||||
|
||||
#include "common.h"
|
||||
#include "oid.h"
|
||||
#include "indexer.h"
|
||||
|
||||
/**
|
||||
* @file git2/pack.h
|
||||
* @brief Git pack management routines
|
||||
*
|
||||
* Packing objects
|
||||
* ---------------
|
||||
*
|
||||
* Creation of packfiles requires two steps:
|
||||
*
|
||||
* - First, insert all the objects you want to put into the packfile
|
||||
* using `git_packbuilder_insert` and `git_packbuilder_insert_tree`.
|
||||
* It's important to add the objects in recency order ("in the order
|
||||
* that they are 'reachable' from head").
|
||||
*
|
||||
* "ANY order will give you a working pack, ... [but it is] the thing
|
||||
* that gives packs good locality. It keeps the objects close to the
|
||||
* head (whether they are old or new, but they are _reachable_ from the
|
||||
* head) at the head of the pack. So packs actually have absolutely
|
||||
* _wonderful_ IO patterns." - Linus Torvalds
|
||||
* git.git/Documentation/technical/pack-heuristics.txt
|
||||
*
|
||||
* - Second, use `git_packbuilder_write` or `git_packbuilder_foreach` to
|
||||
* write the resulting packfile.
|
||||
*
|
||||
* libgit2 will take care of the delta ordering and generation.
|
||||
* `git_packbuilder_set_threads` can be used to adjust the number of
|
||||
* threads used for the process.
|
||||
*
|
||||
* See tests/pack/packbuilder.c for an example.
|
||||
*
|
||||
* @ingroup Git
|
||||
* @{
|
||||
*/
|
||||
GIT_BEGIN_DECL
|
||||
|
||||
/**
|
||||
* Stages that are reported by the packbuilder progress callback.
|
||||
*/
|
||||
typedef enum {
|
||||
GIT_PACKBUILDER_ADDING_OBJECTS = 0,
|
||||
GIT_PACKBUILDER_DELTAFICATION = 1
|
||||
} git_packbuilder_stage_t;
|
||||
|
||||
/**
|
||||
* Initialize a new packbuilder
|
||||
*
|
||||
* @param out The new packbuilder object
|
||||
* @param repo The repository
|
||||
*
|
||||
* @return 0 or an error code
|
||||
*/
|
||||
GIT_EXTERN(int) git_packbuilder_new(git_packbuilder **out, git_repository *repo);
|
||||
|
||||
/**
|
||||
* Set number of threads to spawn
|
||||
*
|
||||
* By default, libgit2 won't spawn any threads at all;
|
||||
* when set to 0, libgit2 will autodetect the number of
|
||||
* CPUs.
|
||||
*
|
||||
* @param pb The packbuilder
|
||||
* @param n Number of threads to spawn
|
||||
* @return number of actual threads to be used
|
||||
*/
|
||||
GIT_EXTERN(unsigned int) git_packbuilder_set_threads(git_packbuilder *pb, unsigned int n);
|
||||
|
||||
/**
|
||||
* Insert a single object
|
||||
*
|
||||
* For an optimal pack it's mandatory to insert objects in recency order,
|
||||
* commits followed by trees and blobs.
|
||||
*
|
||||
* @param pb The packbuilder
|
||||
* @param id The oid of the commit
|
||||
* @param name The name; might be NULL
|
||||
*
|
||||
* @return 0 or an error code
|
||||
*/
|
||||
GIT_EXTERN(int) git_packbuilder_insert(git_packbuilder *pb, const git_oid *id, const char *name);
|
||||
|
||||
/**
|
||||
* Insert a root tree object
|
||||
*
|
||||
* This will add the tree as well as all referenced trees and blobs.
|
||||
*
|
||||
* @param pb The packbuilder
|
||||
* @param id The oid of the root tree
|
||||
*
|
||||
* @return 0 or an error code
|
||||
*/
|
||||
GIT_EXTERN(int) git_packbuilder_insert_tree(git_packbuilder *pb, const git_oid *id);
|
||||
|
||||
/**
|
||||
* Insert a commit object
|
||||
*
|
||||
* This will add a commit as well as the completed referenced tree.
|
||||
*
|
||||
* @param pb The packbuilder
|
||||
* @param id The oid of the commit
|
||||
*
|
||||
* @return 0 or an error code
|
||||
*/
|
||||
GIT_EXTERN(int) git_packbuilder_insert_commit(git_packbuilder *pb, const git_oid *id);
|
||||
|
||||
/**
|
||||
* Insert objects as given by the walk
|
||||
*
|
||||
* Those commits and all objects they reference will be inserted into
|
||||
* the packbuilder.
|
||||
*
|
||||
* @param pb the packbuilder
|
||||
* @param walk the revwalk to use to fill the packbuilder
|
||||
*
|
||||
* @return 0 or an error code
|
||||
*/
|
||||
GIT_EXTERN(int) git_packbuilder_insert_walk(git_packbuilder *pb, git_revwalk *walk);
|
||||
|
||||
/**
|
||||
* Recursively insert an object and its referenced objects
|
||||
*
|
||||
* Insert the object as well as any object it references.
|
||||
*
|
||||
* @param pb the packbuilder
|
||||
* @param id the id of the root object to insert
|
||||
* @param name optional name for the object
|
||||
* @return 0 or an error code
|
||||
*/
|
||||
GIT_EXTERN(int) git_packbuilder_insert_recur(git_packbuilder *pb, const git_oid *id, const char *name);
|
||||
|
||||
/**
|
||||
* Write the contents of the packfile to an in-memory buffer
|
||||
*
|
||||
* The contents of the buffer will become a valid packfile, even though there
|
||||
* will be no attached index
|
||||
*
|
||||
* @param buf Buffer where to write the packfile
|
||||
* @param pb The packbuilder
|
||||
* @return 0 or an error code
|
||||
*/
|
||||
GIT_EXTERN(int) git_packbuilder_write_buf(git_buf *buf, git_packbuilder *pb);
|
||||
|
||||
/**
|
||||
* Write the new pack and corresponding index file to path.
|
||||
*
|
||||
* @param pb The packbuilder
|
||||
* @param path Path to the directory where the packfile and index should be stored, or NULL for default location
|
||||
* @param mode permissions to use creating a packfile or 0 for defaults
|
||||
* @param progress_cb function to call with progress information from the indexer (optional)
|
||||
* @param progress_cb_payload payload for the progress callback (optional)
|
||||
*
|
||||
* @return 0 or an error code
|
||||
*/
|
||||
GIT_EXTERN(int) git_packbuilder_write(
|
||||
git_packbuilder *pb,
|
||||
const char *path,
|
||||
unsigned int mode,
|
||||
git_indexer_progress_cb progress_cb,
|
||||
void *progress_cb_payload);
|
||||
|
||||
#ifndef GIT_DEPRECATE_HARD
|
||||
/**
|
||||
* Get the packfile's hash
|
||||
*
|
||||
* A packfile's name is derived from the sorted hashing of all object
|
||||
* names. This is only correct after the packfile has been written.
|
||||
*
|
||||
* @deprecated use git_packbuilder_name
|
||||
* @param pb The packbuilder object
|
||||
* @return 0 or an error code
|
||||
*/
|
||||
GIT_EXTERN(const git_oid *) git_packbuilder_hash(git_packbuilder *pb);
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Get the unique name for the resulting packfile.
|
||||
*
|
||||
* The packfile's name is derived from the packfile's content.
|
||||
* This is only correct after the packfile has been written.
|
||||
*
|
||||
* @param pb the packbuilder instance
|
||||
* @return a NUL terminated string for the packfile name
|
||||
*/
|
||||
GIT_EXTERN(const char *) git_packbuilder_name(git_packbuilder *pb);
|
||||
|
||||
/**
|
||||
* Callback used to iterate over packed objects
|
||||
*
|
||||
* @see git_packbuilder_foreach
|
||||
*
|
||||
* @param buf A pointer to the object's data
|
||||
* @param size The size of the underlying object
|
||||
* @param payload Payload passed to git_packbuilder_foreach
|
||||
* @return non-zero to terminate the iteration
|
||||
*/
|
||||
typedef int GIT_CALLBACK(git_packbuilder_foreach_cb)(void *buf, size_t size, void *payload);
|
||||
|
||||
/**
|
||||
* Create the new pack and pass each object to the callback
|
||||
*
|
||||
* @param pb the packbuilder
|
||||
* @param cb the callback to call with each packed object's buffer
|
||||
* @param payload the callback's data
|
||||
* @return 0 or an error code
|
||||
*/
|
||||
GIT_EXTERN(int) git_packbuilder_foreach(git_packbuilder *pb, git_packbuilder_foreach_cb cb, void *payload);
|
||||
|
||||
/**
|
||||
* Get the total number of objects the packbuilder will write out
|
||||
*
|
||||
* @param pb the packbuilder
|
||||
* @return the number of objects in the packfile
|
||||
*/
|
||||
GIT_EXTERN(size_t) git_packbuilder_object_count(git_packbuilder *pb);
|
||||
|
||||
/**
|
||||
* Get the number of objects the packbuilder has already written out
|
||||
*
|
||||
* @param pb the packbuilder
|
||||
* @return the number of objects which have already been written
|
||||
*/
|
||||
GIT_EXTERN(size_t) git_packbuilder_written(git_packbuilder *pb);
|
||||
|
||||
/** Packbuilder progress notification function */
|
||||
typedef int GIT_CALLBACK(git_packbuilder_progress)(
|
||||
int stage,
|
||||
uint32_t current,
|
||||
uint32_t total,
|
||||
void *payload);
|
||||
|
||||
/**
|
||||
* Set the callbacks for a packbuilder
|
||||
*
|
||||
* @param pb The packbuilder object
|
||||
* @param progress_cb Function to call with progress information during
|
||||
* pack building. Be aware that this is called inline with pack building
|
||||
* operations, so performance may be affected.
|
||||
* @param progress_cb_payload Payload for progress callback.
|
||||
* @return 0 or an error code
|
||||
*/
|
||||
GIT_EXTERN(int) git_packbuilder_set_callbacks(
|
||||
git_packbuilder *pb,
|
||||
git_packbuilder_progress progress_cb,
|
||||
void *progress_cb_payload);
|
||||
|
||||
/**
|
||||
* Free the packbuilder and all associated data
|
||||
*
|
||||
* @param pb The packbuilder
|
||||
*/
|
||||
GIT_EXTERN(void) git_packbuilder_free(git_packbuilder *pb);
|
||||
|
||||
/** @} */
|
||||
GIT_END_DECL
|
||||
#endif
|
290
3rdparty/libgit2/include/git2/patch.h
vendored
Normal file
290
3rdparty/libgit2/include/git2/patch.h
vendored
Normal file
@ -0,0 +1,290 @@
|
||||
/*
|
||||
* Copyright (C) the libgit2 contributors. All rights reserved.
|
||||
*
|
||||
* This file is part of libgit2, distributed under the GNU GPL v2 with
|
||||
* a Linking Exception. For full terms see the included COPYING file.
|
||||
*/
|
||||
#ifndef INCLUDE_git_patch_h__
|
||||
#define INCLUDE_git_patch_h__
|
||||
|
||||
#include "common.h"
|
||||
#include "types.h"
|
||||
#include "oid.h"
|
||||
#include "diff.h"
|
||||
|
||||
/**
|
||||
* @file git2/patch.h
|
||||
* @brief Patch handling routines.
|
||||
* @ingroup Git
|
||||
* @{
|
||||
*/
|
||||
GIT_BEGIN_DECL
|
||||
|
||||
/**
|
||||
* The diff patch is used to store all the text diffs for a delta.
|
||||
*
|
||||
* You can easily loop over the content of patches and get information about
|
||||
* them.
|
||||
*/
|
||||
typedef struct git_patch git_patch;
|
||||
|
||||
/**
|
||||
* Get the repository associated with this patch. May be NULL.
|
||||
*
|
||||
* @param patch the patch
|
||||
* @return a pointer to the repository
|
||||
*/
|
||||
GIT_EXTERN(git_repository *) git_patch_owner(const git_patch *patch);
|
||||
|
||||
/**
|
||||
* Return a patch for an entry in the diff list.
|
||||
*
|
||||
* The `git_patch` is a newly created object contains the text diffs
|
||||
* for the delta. You have to call `git_patch_free()` when you are
|
||||
* done with it. You can use the patch object to loop over all the hunks
|
||||
* and lines in the diff of the one delta.
|
||||
*
|
||||
* For an unchanged file or a binary file, no `git_patch` will be
|
||||
* created, the output will be set to NULL, and the `binary` flag will be
|
||||
* set true in the `git_diff_delta` structure.
|
||||
*
|
||||
* It is okay to pass NULL for either of the output parameters; if you pass
|
||||
* NULL for the `git_patch`, then the text diff will not be calculated.
|
||||
*
|
||||
* @param out Output parameter for the delta patch object
|
||||
* @param diff Diff list object
|
||||
* @param idx Index into diff list
|
||||
* @return 0 on success, other value < 0 on error
|
||||
*/
|
||||
GIT_EXTERN(int) git_patch_from_diff(
|
||||
git_patch **out, git_diff *diff, size_t idx);
|
||||
|
||||
/**
|
||||
* Directly generate a patch from the difference between two blobs.
|
||||
*
|
||||
* This is just like `git_diff_blobs()` except it generates a patch object
|
||||
* for the difference instead of directly making callbacks. You can use the
|
||||
* standard `git_patch` accessor functions to read the patch data, and
|
||||
* you must call `git_patch_free()` on the patch when done.
|
||||
*
|
||||
* @param out The generated patch; NULL on error
|
||||
* @param old_blob Blob for old side of diff, or NULL for empty blob
|
||||
* @param old_as_path Treat old blob as if it had this filename; can be NULL
|
||||
* @param new_blob Blob for new side of diff, or NULL for empty blob
|
||||
* @param new_as_path Treat new blob as if it had this filename; can be NULL
|
||||
* @param opts Options for diff, or NULL for default options
|
||||
* @return 0 on success or error code < 0
|
||||
*/
|
||||
GIT_EXTERN(int) git_patch_from_blobs(
|
||||
git_patch **out,
|
||||
const git_blob *old_blob,
|
||||
const char *old_as_path,
|
||||
const git_blob *new_blob,
|
||||
const char *new_as_path,
|
||||
const git_diff_options *opts);
|
||||
|
||||
/**
|
||||
* Directly generate a patch from the difference between a blob and a buffer.
|
||||
*
|
||||
* This is just like `git_diff_blob_to_buffer()` except it generates a patch
|
||||
* object for the difference instead of directly making callbacks. You can
|
||||
* use the standard `git_patch` accessor functions to read the patch
|
||||
* data, and you must call `git_patch_free()` on the patch when done.
|
||||
*
|
||||
* @param out The generated patch; NULL on error
|
||||
* @param old_blob Blob for old side of diff, or NULL for empty blob
|
||||
* @param old_as_path Treat old blob as if it had this filename; can be NULL
|
||||
* @param buffer Raw data for new side of diff, or NULL for empty
|
||||
* @param buffer_len Length of raw data for new side of diff
|
||||
* @param buffer_as_path Treat buffer as if it had this filename; can be NULL
|
||||
* @param opts Options for diff, or NULL for default options
|
||||
* @return 0 on success or error code < 0
|
||||
*/
|
||||
GIT_EXTERN(int) git_patch_from_blob_and_buffer(
|
||||
git_patch **out,
|
||||
const git_blob *old_blob,
|
||||
const char *old_as_path,
|
||||
const void *buffer,
|
||||
size_t buffer_len,
|
||||
const char *buffer_as_path,
|
||||
const git_diff_options *opts);
|
||||
|
||||
/**
|
||||
* Directly generate a patch from the difference between two buffers.
|
||||
*
|
||||
* This is just like `git_diff_buffers()` except it generates a patch
|
||||
* object for the difference instead of directly making callbacks. You can
|
||||
* use the standard `git_patch` accessor functions to read the patch
|
||||
* data, and you must call `git_patch_free()` on the patch when done.
|
||||
*
|
||||
* @param out The generated patch; NULL on error
|
||||
* @param old_buffer Raw data for old side of diff, or NULL for empty
|
||||
* @param old_len Length of the raw data for old side of the diff
|
||||
* @param old_as_path Treat old buffer as if it had this filename; can be NULL
|
||||
* @param new_buffer Raw data for new side of diff, or NULL for empty
|
||||
* @param new_len Length of raw data for new side of diff
|
||||
* @param new_as_path Treat buffer as if it had this filename; can be NULL
|
||||
* @param opts Options for diff, or NULL for default options
|
||||
* @return 0 on success or error code < 0
|
||||
*/
|
||||
GIT_EXTERN(int) git_patch_from_buffers(
|
||||
git_patch **out,
|
||||
const void *old_buffer,
|
||||
size_t old_len,
|
||||
const char *old_as_path,
|
||||
const void *new_buffer,
|
||||
size_t new_len,
|
||||
const char *new_as_path,
|
||||
const git_diff_options *opts);
|
||||
|
||||
/**
|
||||
* Free a git_patch object.
|
||||
*
|
||||
* @param patch The patch to free.
|
||||
*/
|
||||
GIT_EXTERN(void) git_patch_free(git_patch *patch);
|
||||
|
||||
/**
|
||||
* Get the delta associated with a patch. This delta points to internal
|
||||
* data and you do not have to release it when you are done with it.
|
||||
*
|
||||
* @param patch The patch in which to get the delta.
|
||||
* @return The delta associated with the patch.
|
||||
*/
|
||||
GIT_EXTERN(const git_diff_delta *) git_patch_get_delta(const git_patch *patch);
|
||||
|
||||
/**
|
||||
* Get the number of hunks in a patch
|
||||
*
|
||||
* @param patch The patch in which to get the number of hunks.
|
||||
* @return The number of hunks of the patch.
|
||||
*/
|
||||
GIT_EXTERN(size_t) git_patch_num_hunks(const git_patch *patch);
|
||||
|
||||
/**
|
||||
* Get line counts of each type in a patch.
|
||||
*
|
||||
* This helps imitate a diff --numstat type of output. For that purpose,
|
||||
* you only need the `total_additions` and `total_deletions` values, but we
|
||||
* include the `total_context` line count in case you want the total number
|
||||
* of lines of diff output that will be generated.
|
||||
*
|
||||
* All outputs are optional. Pass NULL if you don't need a particular count.
|
||||
*
|
||||
* @param total_context Count of context lines in output, can be NULL.
|
||||
* @param total_additions Count of addition lines in output, can be NULL.
|
||||
* @param total_deletions Count of deletion lines in output, can be NULL.
|
||||
* @param patch The git_patch object
|
||||
* @return 0 on success, <0 on error
|
||||
*/
|
||||
GIT_EXTERN(int) git_patch_line_stats(
|
||||
size_t *total_context,
|
||||
size_t *total_additions,
|
||||
size_t *total_deletions,
|
||||
const git_patch *patch);
|
||||
|
||||
/**
|
||||
* Get the information about a hunk in a patch
|
||||
*
|
||||
* Given a patch and a hunk index into the patch, this returns detailed
|
||||
* information about that hunk. Any of the output pointers can be passed
|
||||
* as NULL if you don't care about that particular piece of information.
|
||||
*
|
||||
* @param out Output pointer to git_diff_hunk of hunk
|
||||
* @param lines_in_hunk Output count of total lines in this hunk
|
||||
* @param patch Input pointer to patch object
|
||||
* @param hunk_idx Input index of hunk to get information about
|
||||
* @return 0 on success, GIT_ENOTFOUND if hunk_idx out of range, <0 on error
|
||||
*/
|
||||
GIT_EXTERN(int) git_patch_get_hunk(
|
||||
const git_diff_hunk **out,
|
||||
size_t *lines_in_hunk,
|
||||
git_patch *patch,
|
||||
size_t hunk_idx);
|
||||
|
||||
/**
|
||||
* Get the number of lines in a hunk.
|
||||
*
|
||||
* @param patch The git_patch object
|
||||
* @param hunk_idx Index of the hunk
|
||||
* @return Number of lines in hunk or GIT_ENOTFOUND if invalid hunk index
|
||||
*/
|
||||
GIT_EXTERN(int) git_patch_num_lines_in_hunk(
|
||||
const git_patch *patch,
|
||||
size_t hunk_idx);
|
||||
|
||||
/**
|
||||
* Get data about a line in a hunk of a patch.
|
||||
*
|
||||
* Given a patch, a hunk index, and a line index in the hunk, this
|
||||
* will return a lot of details about that line. If you pass a hunk
|
||||
* index larger than the number of hunks or a line index larger than
|
||||
* the number of lines in the hunk, this will return -1.
|
||||
*
|
||||
* @param out The git_diff_line data for this line
|
||||
* @param patch The patch to look in
|
||||
* @param hunk_idx The index of the hunk
|
||||
* @param line_of_hunk The index of the line in the hunk
|
||||
* @return 0 on success, <0 on failure
|
||||
*/
|
||||
GIT_EXTERN(int) git_patch_get_line_in_hunk(
|
||||
const git_diff_line **out,
|
||||
git_patch *patch,
|
||||
size_t hunk_idx,
|
||||
size_t line_of_hunk);
|
||||
|
||||
/**
|
||||
* Look up size of patch diff data in bytes
|
||||
*
|
||||
* This returns the raw size of the patch data. This only includes the
|
||||
* actual data from the lines of the diff, not the file or hunk headers.
|
||||
*
|
||||
* If you pass `include_context` as true (non-zero), this will be the size
|
||||
* of all of the diff output; if you pass it as false (zero), this will
|
||||
* only include the actual changed lines (as if `context_lines` was 0).
|
||||
*
|
||||
* @param patch A git_patch representing changes to one file
|
||||
* @param include_context Include context lines in size if non-zero
|
||||
* @param include_hunk_headers Include hunk header lines if non-zero
|
||||
* @param include_file_headers Include file header lines if non-zero
|
||||
* @return The number of bytes of data
|
||||
*/
|
||||
GIT_EXTERN(size_t) git_patch_size(
|
||||
git_patch *patch,
|
||||
int include_context,
|
||||
int include_hunk_headers,
|
||||
int include_file_headers);
|
||||
|
||||
/**
|
||||
* Serialize the patch to text via callback.
|
||||
*
|
||||
* Returning a non-zero value from the callback will terminate the iteration
|
||||
* and return that value to the caller.
|
||||
*
|
||||
* @param patch A git_patch representing changes to one file
|
||||
* @param print_cb Callback function to output lines of the patch. Will be
|
||||
* called for file headers, hunk headers, and diff lines.
|
||||
* @param payload Reference pointer that will be passed to your callbacks.
|
||||
* @return 0 on success, non-zero callback return value, or error code
|
||||
*/
|
||||
GIT_EXTERN(int) git_patch_print(
|
||||
git_patch *patch,
|
||||
git_diff_line_cb print_cb,
|
||||
void *payload);
|
||||
|
||||
/**
|
||||
* Get the content of a patch as a single diff text.
|
||||
*
|
||||
* @param out The git_buf to be filled in
|
||||
* @param patch A git_patch representing changes to one file
|
||||
* @return 0 on success, <0 on failure.
|
||||
*/
|
||||
GIT_EXTERN(int) git_patch_to_buf(
|
||||
git_buf *out,
|
||||
git_patch *patch);
|
||||
|
||||
GIT_END_DECL
|
||||
|
||||
/**@}*/
|
||||
|
||||
#endif
|
280
3rdparty/libgit2/include/git2/pathspec.h
vendored
Normal file
280
3rdparty/libgit2/include/git2/pathspec.h
vendored
Normal file
@ -0,0 +1,280 @@
|
||||
/*
|
||||
* Copyright (C) the libgit2 contributors. All rights reserved.
|
||||
*
|
||||
* This file is part of libgit2, distributed under the GNU GPL v2 with
|
||||
* a Linking Exception. For full terms see the included COPYING file.
|
||||
*/
|
||||
#ifndef INCLUDE_git_pathspec_h__
|
||||
#define INCLUDE_git_pathspec_h__
|
||||
|
||||
#include "common.h"
|
||||
#include "types.h"
|
||||
#include "strarray.h"
|
||||
#include "diff.h"
|
||||
|
||||
GIT_BEGIN_DECL
|
||||
|
||||
/**
|
||||
* Compiled pathspec
|
||||
*/
|
||||
typedef struct git_pathspec git_pathspec;
|
||||
|
||||
/**
|
||||
* List of filenames matching a pathspec
|
||||
*/
|
||||
typedef struct git_pathspec_match_list git_pathspec_match_list;
|
||||
|
||||
/**
|
||||
* Options controlling how pathspec match should be executed
|
||||
*/
|
||||
typedef enum {
|
||||
GIT_PATHSPEC_DEFAULT = 0,
|
||||
|
||||
/**
|
||||
* GIT_PATHSPEC_IGNORE_CASE forces match to ignore case; otherwise
|
||||
* match will use native case sensitivity of platform filesystem
|
||||
*/
|
||||
GIT_PATHSPEC_IGNORE_CASE = (1u << 0),
|
||||
|
||||
/**
|
||||
* GIT_PATHSPEC_USE_CASE forces case sensitive match; otherwise
|
||||
* match will use native case sensitivity of platform filesystem
|
||||
*/
|
||||
GIT_PATHSPEC_USE_CASE = (1u << 1),
|
||||
|
||||
/**
|
||||
* GIT_PATHSPEC_NO_GLOB disables glob patterns and just uses simple
|
||||
* string comparison for matching
|
||||
*/
|
||||
GIT_PATHSPEC_NO_GLOB = (1u << 2),
|
||||
|
||||
/**
|
||||
* GIT_PATHSPEC_NO_MATCH_ERROR means the match functions return error
|
||||
* code GIT_ENOTFOUND if no matches are found; otherwise no matches is
|
||||
* still success (return 0) but `git_pathspec_match_list_entrycount`
|
||||
* will indicate 0 matches.
|
||||
*/
|
||||
GIT_PATHSPEC_NO_MATCH_ERROR = (1u << 3),
|
||||
|
||||
/**
|
||||
* GIT_PATHSPEC_FIND_FAILURES means that the `git_pathspec_match_list`
|
||||
* should track which patterns matched which files so that at the end of
|
||||
* the match we can identify patterns that did not match any files.
|
||||
*/
|
||||
GIT_PATHSPEC_FIND_FAILURES = (1u << 4),
|
||||
|
||||
/**
|
||||
* GIT_PATHSPEC_FAILURES_ONLY means that the `git_pathspec_match_list`
|
||||
* does not need to keep the actual matching filenames. Use this to
|
||||
* just test if there were any matches at all or in combination with
|
||||
* GIT_PATHSPEC_FIND_FAILURES to validate a pathspec.
|
||||
*/
|
||||
GIT_PATHSPEC_FAILURES_ONLY = (1u << 5)
|
||||
} git_pathspec_flag_t;
|
||||
|
||||
/**
|
||||
* Compile a pathspec
|
||||
*
|
||||
* @param out Output of the compiled pathspec
|
||||
* @param pathspec A git_strarray of the paths to match
|
||||
* @return 0 on success, <0 on failure
|
||||
*/
|
||||
GIT_EXTERN(int) git_pathspec_new(
|
||||
git_pathspec **out, const git_strarray *pathspec);
|
||||
|
||||
/**
|
||||
* Free a pathspec
|
||||
*
|
||||
* @param ps The compiled pathspec
|
||||
*/
|
||||
GIT_EXTERN(void) git_pathspec_free(git_pathspec *ps);
|
||||
|
||||
/**
|
||||
* Try to match a path against a pathspec
|
||||
*
|
||||
* Unlike most of the other pathspec matching functions, this will not
|
||||
* fall back on the native case-sensitivity for your platform. You must
|
||||
* explicitly pass flags to control case sensitivity or else this will
|
||||
* fall back on being case sensitive.
|
||||
*
|
||||
* @param ps The compiled pathspec
|
||||
* @param flags Combination of git_pathspec_flag_t options to control match
|
||||
* @param path The pathname to attempt to match
|
||||
* @return 1 is path matches spec, 0 if it does not
|
||||
*/
|
||||
GIT_EXTERN(int) git_pathspec_matches_path(
|
||||
const git_pathspec *ps, uint32_t flags, const char *path);
|
||||
|
||||
/**
|
||||
* Match a pathspec against the working directory of a repository.
|
||||
*
|
||||
* This matches the pathspec against the current files in the working
|
||||
* directory of the repository. It is an error to invoke this on a bare
|
||||
* repo. This handles git ignores (i.e. ignored files will not be
|
||||
* considered to match the `pathspec` unless the file is tracked in the
|
||||
* index).
|
||||
*
|
||||
* If `out` is not NULL, this returns a `git_patchspec_match_list`. That
|
||||
* contains the list of all matched filenames (unless you pass the
|
||||
* `GIT_PATHSPEC_FAILURES_ONLY` flag) and may also contain the list of
|
||||
* pathspecs with no match (if you used the `GIT_PATHSPEC_FIND_FAILURES`
|
||||
* flag). You must call `git_pathspec_match_list_free()` on this object.
|
||||
*
|
||||
* @param out Output list of matches; pass NULL to just get return value
|
||||
* @param repo The repository in which to match; bare repo is an error
|
||||
* @param flags Combination of git_pathspec_flag_t options to control match
|
||||
* @param ps Pathspec to be matched
|
||||
* @return 0 on success, -1 on error, GIT_ENOTFOUND if no matches and
|
||||
* the GIT_PATHSPEC_NO_MATCH_ERROR flag was given
|
||||
*/
|
||||
GIT_EXTERN(int) git_pathspec_match_workdir(
|
||||
git_pathspec_match_list **out,
|
||||
git_repository *repo,
|
||||
uint32_t flags,
|
||||
git_pathspec *ps);
|
||||
|
||||
/**
|
||||
* Match a pathspec against entries in an index.
|
||||
*
|
||||
* This matches the pathspec against the files in the repository index.
|
||||
*
|
||||
* NOTE: At the moment, the case sensitivity of this match is controlled
|
||||
* by the current case-sensitivity of the index object itself and the
|
||||
* USE_CASE and IGNORE_CASE flags will have no effect. This behavior will
|
||||
* be corrected in a future release.
|
||||
*
|
||||
* If `out` is not NULL, this returns a `git_patchspec_match_list`. That
|
||||
* contains the list of all matched filenames (unless you pass the
|
||||
* `GIT_PATHSPEC_FAILURES_ONLY` flag) and may also contain the list of
|
||||
* pathspecs with no match (if you used the `GIT_PATHSPEC_FIND_FAILURES`
|
||||
* flag). You must call `git_pathspec_match_list_free()` on this object.
|
||||
*
|
||||
* @param out Output list of matches; pass NULL to just get return value
|
||||
* @param index The index to match against
|
||||
* @param flags Combination of git_pathspec_flag_t options to control match
|
||||
* @param ps Pathspec to be matched
|
||||
* @return 0 on success, -1 on error, GIT_ENOTFOUND if no matches and
|
||||
* the GIT_PATHSPEC_NO_MATCH_ERROR flag is used
|
||||
*/
|
||||
GIT_EXTERN(int) git_pathspec_match_index(
|
||||
git_pathspec_match_list **out,
|
||||
git_index *index,
|
||||
uint32_t flags,
|
||||
git_pathspec *ps);
|
||||
|
||||
/**
|
||||
* Match a pathspec against files in a tree.
|
||||
*
|
||||
* This matches the pathspec against the files in the given tree.
|
||||
*
|
||||
* If `out` is not NULL, this returns a `git_patchspec_match_list`. That
|
||||
* contains the list of all matched filenames (unless you pass the
|
||||
* `GIT_PATHSPEC_FAILURES_ONLY` flag) and may also contain the list of
|
||||
* pathspecs with no match (if you used the `GIT_PATHSPEC_FIND_FAILURES`
|
||||
* flag). You must call `git_pathspec_match_list_free()` on this object.
|
||||
*
|
||||
* @param out Output list of matches; pass NULL to just get return value
|
||||
* @param tree The root-level tree to match against
|
||||
* @param flags Combination of git_pathspec_flag_t options to control match
|
||||
* @param ps Pathspec to be matched
|
||||
* @return 0 on success, -1 on error, GIT_ENOTFOUND if no matches and
|
||||
* the GIT_PATHSPEC_NO_MATCH_ERROR flag is used
|
||||
*/
|
||||
GIT_EXTERN(int) git_pathspec_match_tree(
|
||||
git_pathspec_match_list **out,
|
||||
git_tree *tree,
|
||||
uint32_t flags,
|
||||
git_pathspec *ps);
|
||||
|
||||
/**
|
||||
* Match a pathspec against files in a diff list.
|
||||
*
|
||||
* This matches the pathspec against the files in the given diff list.
|
||||
*
|
||||
* If `out` is not NULL, this returns a `git_patchspec_match_list`. That
|
||||
* contains the list of all matched filenames (unless you pass the
|
||||
* `GIT_PATHSPEC_FAILURES_ONLY` flag) and may also contain the list of
|
||||
* pathspecs with no match (if you used the `GIT_PATHSPEC_FIND_FAILURES`
|
||||
* flag). You must call `git_pathspec_match_list_free()` on this object.
|
||||
*
|
||||
* @param out Output list of matches; pass NULL to just get return value
|
||||
* @param diff A generated diff list
|
||||
* @param flags Combination of git_pathspec_flag_t options to control match
|
||||
* @param ps Pathspec to be matched
|
||||
* @return 0 on success, -1 on error, GIT_ENOTFOUND if no matches and
|
||||
* the GIT_PATHSPEC_NO_MATCH_ERROR flag is used
|
||||
*/
|
||||
GIT_EXTERN(int) git_pathspec_match_diff(
|
||||
git_pathspec_match_list **out,
|
||||
git_diff *diff,
|
||||
uint32_t flags,
|
||||
git_pathspec *ps);
|
||||
|
||||
/**
|
||||
* Free memory associates with a git_pathspec_match_list
|
||||
*
|
||||
* @param m The git_pathspec_match_list to be freed
|
||||
*/
|
||||
GIT_EXTERN(void) git_pathspec_match_list_free(git_pathspec_match_list *m);
|
||||
|
||||
/**
|
||||
* Get the number of items in a match list.
|
||||
*
|
||||
* @param m The git_pathspec_match_list object
|
||||
* @return Number of items in match list
|
||||
*/
|
||||
GIT_EXTERN(size_t) git_pathspec_match_list_entrycount(
|
||||
const git_pathspec_match_list *m);
|
||||
|
||||
/**
|
||||
* Get a matching filename by position.
|
||||
*
|
||||
* This routine cannot be used if the match list was generated by
|
||||
* `git_pathspec_match_diff`. If so, it will always return NULL.
|
||||
*
|
||||
* @param m The git_pathspec_match_list object
|
||||
* @param pos The index into the list
|
||||
* @return The filename of the match
|
||||
*/
|
||||
GIT_EXTERN(const char *) git_pathspec_match_list_entry(
|
||||
const git_pathspec_match_list *m, size_t pos);
|
||||
|
||||
/**
|
||||
* Get a matching diff delta by position.
|
||||
*
|
||||
* This routine can only be used if the match list was generated by
|
||||
* `git_pathspec_match_diff`. Otherwise it will always return NULL.
|
||||
*
|
||||
* @param m The git_pathspec_match_list object
|
||||
* @param pos The index into the list
|
||||
* @return The filename of the match
|
||||
*/
|
||||
GIT_EXTERN(const git_diff_delta *) git_pathspec_match_list_diff_entry(
|
||||
const git_pathspec_match_list *m, size_t pos);
|
||||
|
||||
/**
|
||||
* Get the number of pathspec items that did not match.
|
||||
*
|
||||
* This will be zero unless you passed GIT_PATHSPEC_FIND_FAILURES when
|
||||
* generating the git_pathspec_match_list.
|
||||
*
|
||||
* @param m The git_pathspec_match_list object
|
||||
* @return Number of items in original pathspec that had no matches
|
||||
*/
|
||||
GIT_EXTERN(size_t) git_pathspec_match_list_failed_entrycount(
|
||||
const git_pathspec_match_list *m);
|
||||
|
||||
/**
|
||||
* Get an original pathspec string that had no matches.
|
||||
*
|
||||
* This will be return NULL for positions out of range.
|
||||
*
|
||||
* @param m The git_pathspec_match_list object
|
||||
* @param pos The index into the failed items
|
||||
* @return The pathspec pattern that didn't match anything
|
||||
*/
|
||||
GIT_EXTERN(const char *) git_pathspec_match_list_failed_entry(
|
||||
const git_pathspec_match_list *m, size_t pos);
|
||||
|
||||
GIT_END_DECL
|
||||
#endif
|
98
3rdparty/libgit2/include/git2/proxy.h
vendored
Normal file
98
3rdparty/libgit2/include/git2/proxy.h
vendored
Normal file
@ -0,0 +1,98 @@
|
||||
/*
|
||||
* Copyright (C) the libgit2 contributors. All rights reserved.
|
||||
*
|
||||
* This file is part of libgit2, distributed under the GNU GPL v2 with
|
||||
* a Linking Exception. For full terms see the included COPYING file.
|
||||
*/
|
||||
#ifndef INCLUDE_git_proxy_h__
|
||||
#define INCLUDE_git_proxy_h__
|
||||
|
||||
#include "common.h"
|
||||
|
||||
#include "cert.h"
|
||||
#include "credential.h"
|
||||
|
||||
GIT_BEGIN_DECL
|
||||
|
||||
/**
|
||||
* The type of proxy to use.
|
||||
*/
|
||||
typedef enum {
|
||||
/**
|
||||
* Do not attempt to connect through a proxy
|
||||
*
|
||||
* If built against libcurl, it itself may attempt to connect
|
||||
* to a proxy if the environment variables specify it.
|
||||
*/
|
||||
GIT_PROXY_NONE,
|
||||
/**
|
||||
* Try to auto-detect the proxy from the git configuration.
|
||||
*/
|
||||
GIT_PROXY_AUTO,
|
||||
/**
|
||||
* Connect via the URL given in the options
|
||||
*/
|
||||
GIT_PROXY_SPECIFIED
|
||||
} git_proxy_t;
|
||||
|
||||
/**
|
||||
* Options for connecting through a proxy
|
||||
*
|
||||
* Note that not all types may be supported, depending on the platform
|
||||
* and compilation options.
|
||||
*/
|
||||
typedef struct {
|
||||
unsigned int version;
|
||||
|
||||
/**
|
||||
* The type of proxy to use, by URL, auto-detect.
|
||||
*/
|
||||
git_proxy_t type;
|
||||
|
||||
/**
|
||||
* The URL of the proxy.
|
||||
*/
|
||||
const char *url;
|
||||
|
||||
/**
|
||||
* This will be called if the remote host requires
|
||||
* authentication in order to connect to it.
|
||||
*
|
||||
* Returning GIT_PASSTHROUGH will make libgit2 behave as
|
||||
* though this field isn't set.
|
||||
*/
|
||||
git_credential_acquire_cb credentials;
|
||||
|
||||
/**
|
||||
* If cert verification fails, this will be called to let the
|
||||
* user make the final decision of whether to allow the
|
||||
* connection to proceed. Returns 0 to allow the connection
|
||||
* or a negative value to indicate an error.
|
||||
*/
|
||||
git_transport_certificate_check_cb certificate_check;
|
||||
|
||||
/**
|
||||
* Payload to be provided to the credentials and certificate
|
||||
* check callbacks.
|
||||
*/
|
||||
void *payload;
|
||||
} git_proxy_options;
|
||||
|
||||
#define GIT_PROXY_OPTIONS_VERSION 1
|
||||
#define GIT_PROXY_OPTIONS_INIT {GIT_PROXY_OPTIONS_VERSION}
|
||||
|
||||
/**
|
||||
* Initialize git_proxy_options structure
|
||||
*
|
||||
* Initializes a `git_proxy_options` with default values. Equivalent to
|
||||
* creating an instance with `GIT_PROXY_OPTIONS_INIT`.
|
||||
*
|
||||
* @param opts The `git_proxy_options` struct to initialize.
|
||||
* @param version The struct version; pass `GIT_PROXY_OPTIONS_VERSION`.
|
||||
* @return Zero on success; -1 on failure.
|
||||
*/
|
||||
GIT_EXTERN(int) git_proxy_options_init(git_proxy_options *opts, unsigned int version);
|
||||
|
||||
GIT_END_DECL
|
||||
|
||||
#endif
|
399
3rdparty/libgit2/include/git2/rebase.h
vendored
Normal file
399
3rdparty/libgit2/include/git2/rebase.h
vendored
Normal file
@ -0,0 +1,399 @@
|
||||
/*
|
||||
* Copyright (C) the libgit2 contributors. All rights reserved.
|
||||
*
|
||||
* This file is part of libgit2, distributed under the GNU GPL v2 with
|
||||
* a Linking Exception. For full terms see the included COPYING file.
|
||||
*/
|
||||
#ifndef INCLUDE_git_rebase_h__
|
||||
#define INCLUDE_git_rebase_h__
|
||||
|
||||
#include "common.h"
|
||||
#include "types.h"
|
||||
#include "oid.h"
|
||||
#include "annotated_commit.h"
|
||||
#include "merge.h"
|
||||
#include "checkout.h"
|
||||
#include "commit.h"
|
||||
|
||||
/**
|
||||
* @file git2/rebase.h
|
||||
* @brief Git rebase routines
|
||||
* @defgroup git_rebase Git merge routines
|
||||
* @ingroup Git
|
||||
* @{
|
||||
*/
|
||||
GIT_BEGIN_DECL
|
||||
|
||||
/**
|
||||
* Rebase options
|
||||
*
|
||||
* Use to tell the rebase machinery how to operate.
|
||||
*/
|
||||
typedef struct {
|
||||
unsigned int version;
|
||||
|
||||
/**
|
||||
* Used by `git_rebase_init`, this will instruct other clients working
|
||||
* on this rebase that you want a quiet rebase experience, which they
|
||||
* may choose to provide in an application-specific manner. This has no
|
||||
* effect upon libgit2 directly, but is provided for interoperability
|
||||
* between Git tools.
|
||||
*/
|
||||
int quiet;
|
||||
|
||||
/**
|
||||
* Used by `git_rebase_init`, this will begin an in-memory rebase,
|
||||
* which will allow callers to step through the rebase operations and
|
||||
* commit the rebased changes, but will not rewind HEAD or update the
|
||||
* repository to be in a rebasing state. This will not interfere with
|
||||
* the working directory (if there is one).
|
||||
*/
|
||||
int inmemory;
|
||||
|
||||
/**
|
||||
* Used by `git_rebase_finish`, this is the name of the notes reference
|
||||
* used to rewrite notes for rebased commits when finishing the rebase;
|
||||
* if NULL, the contents of the configuration option `notes.rewriteRef`
|
||||
* is examined, unless the configuration option `notes.rewrite.rebase`
|
||||
* is set to false. If `notes.rewriteRef` is also NULL, notes will
|
||||
* not be rewritten.
|
||||
*/
|
||||
const char *rewrite_notes_ref;
|
||||
|
||||
/**
|
||||
* Options to control how trees are merged during `git_rebase_next`.
|
||||
*/
|
||||
git_merge_options merge_options;
|
||||
|
||||
/**
|
||||
* Options to control how files are written during `git_rebase_init`,
|
||||
* `git_rebase_next` and `git_rebase_abort`. Note that a minimum
|
||||
* strategy of `GIT_CHECKOUT_SAFE` is defaulted in `init` and `next`,
|
||||
* and a minimum strategy of `GIT_CHECKOUT_FORCE` is defaulted in
|
||||
* `abort` to match git semantics.
|
||||
*/
|
||||
git_checkout_options checkout_options;
|
||||
|
||||
/**
|
||||
* Optional callback that allows users to override commit
|
||||
* creation in `git_rebase_commit`. If specified, users can
|
||||
* create their own commit and provide the commit ID, which
|
||||
* may be useful for signing commits or otherwise customizing
|
||||
* the commit creation.
|
||||
*
|
||||
* If this callback returns `GIT_PASSTHROUGH`, then
|
||||
* `git_rebase_commit` will continue to create the commit.
|
||||
*/
|
||||
git_commit_create_cb commit_create_cb;
|
||||
|
||||
#ifdef GIT_DEPRECATE_HARD
|
||||
void *reserved;
|
||||
#else
|
||||
/**
|
||||
* If provided, this will be called with the commit content, allowing
|
||||
* a signature to be added to the rebase commit. Can be skipped with
|
||||
* GIT_PASSTHROUGH. If GIT_PASSTHROUGH is returned, a commit will be made
|
||||
* without a signature.
|
||||
*
|
||||
* This field is only used when performing git_rebase_commit.
|
||||
*
|
||||
* This callback is not invoked if a `git_commit_create_cb` is
|
||||
* specified.
|
||||
*
|
||||
* This callback is deprecated; users should provide a
|
||||
* creation callback as `commit_create_cb` that produces a
|
||||
* commit buffer, signs it, and commits it.
|
||||
*/
|
||||
int (*signing_cb)(git_buf *, git_buf *, const char *, void *);
|
||||
#endif
|
||||
|
||||
/**
|
||||
* This will be passed to each of the callbacks in this struct
|
||||
* as the last parameter.
|
||||
*/
|
||||
void *payload;
|
||||
} git_rebase_options;
|
||||
|
||||
/**
|
||||
* Type of rebase operation in-progress after calling `git_rebase_next`.
|
||||
*/
|
||||
typedef enum {
|
||||
/**
|
||||
* The given commit is to be cherry-picked. The client should commit
|
||||
* the changes and continue if there are no conflicts.
|
||||
*/
|
||||
GIT_REBASE_OPERATION_PICK = 0,
|
||||
|
||||
/**
|
||||
* The given commit is to be cherry-picked, but the client should prompt
|
||||
* the user to provide an updated commit message.
|
||||
*/
|
||||
GIT_REBASE_OPERATION_REWORD,
|
||||
|
||||
/**
|
||||
* The given commit is to be cherry-picked, but the client should stop
|
||||
* to allow the user to edit the changes before committing them.
|
||||
*/
|
||||
GIT_REBASE_OPERATION_EDIT,
|
||||
|
||||
/**
|
||||
* The given commit is to be squashed into the previous commit. The
|
||||
* commit message will be merged with the previous message.
|
||||
*/
|
||||
GIT_REBASE_OPERATION_SQUASH,
|
||||
|
||||
/**
|
||||
* The given commit is to be squashed into the previous commit. The
|
||||
* commit message from this commit will be discarded.
|
||||
*/
|
||||
GIT_REBASE_OPERATION_FIXUP,
|
||||
|
||||
/**
|
||||
* No commit will be cherry-picked. The client should run the given
|
||||
* command and (if successful) continue.
|
||||
*/
|
||||
GIT_REBASE_OPERATION_EXEC
|
||||
} git_rebase_operation_t;
|
||||
|
||||
#define GIT_REBASE_OPTIONS_VERSION 1
|
||||
#define GIT_REBASE_OPTIONS_INIT \
|
||||
{ GIT_REBASE_OPTIONS_VERSION, 0, 0, NULL, GIT_MERGE_OPTIONS_INIT, \
|
||||
GIT_CHECKOUT_OPTIONS_INIT, NULL, NULL }
|
||||
|
||||
/** Indicates that a rebase operation is not (yet) in progress. */
|
||||
#define GIT_REBASE_NO_OPERATION SIZE_MAX
|
||||
|
||||
/**
|
||||
* A rebase operation
|
||||
*
|
||||
* Describes a single instruction/operation to be performed during the
|
||||
* rebase.
|
||||
*/
|
||||
typedef struct {
|
||||
/** The type of rebase operation. */
|
||||
git_rebase_operation_t type;
|
||||
|
||||
/**
|
||||
* The commit ID being cherry-picked. This will be populated for
|
||||
* all operations except those of type `GIT_REBASE_OPERATION_EXEC`.
|
||||
*/
|
||||
const git_oid id;
|
||||
|
||||
/**
|
||||
* The executable the user has requested be run. This will only
|
||||
* be populated for operations of type `GIT_REBASE_OPERATION_EXEC`.
|
||||
*/
|
||||
const char *exec;
|
||||
} git_rebase_operation;
|
||||
|
||||
/**
|
||||
* Initialize git_rebase_options structure
|
||||
*
|
||||
* Initializes a `git_rebase_options` with default values. Equivalent to
|
||||
* creating an instance with `GIT_REBASE_OPTIONS_INIT`.
|
||||
*
|
||||
* @param opts The `git_rebase_options` struct to initialize.
|
||||
* @param version The struct version; pass `GIT_REBASE_OPTIONS_VERSION`.
|
||||
* @return Zero on success; -1 on failure.
|
||||
*/
|
||||
GIT_EXTERN(int) git_rebase_options_init(
|
||||
git_rebase_options *opts,
|
||||
unsigned int version);
|
||||
|
||||
/**
|
||||
* Initializes a rebase operation to rebase the changes in `branch`
|
||||
* relative to `upstream` onto another branch. To begin the rebase
|
||||
* process, call `git_rebase_next`. When you have finished with this
|
||||
* object, call `git_rebase_free`.
|
||||
*
|
||||
* @param out Pointer to store the rebase object
|
||||
* @param repo The repository to perform the rebase
|
||||
* @param branch The terminal commit to rebase, or NULL to rebase the
|
||||
* current branch
|
||||
* @param upstream The commit to begin rebasing from, or NULL to rebase all
|
||||
* reachable commits
|
||||
* @param onto The branch to rebase onto, or NULL to rebase onto the given
|
||||
* upstream
|
||||
* @param opts Options to specify how rebase is performed, or NULL
|
||||
* @return Zero on success; -1 on failure.
|
||||
*/
|
||||
GIT_EXTERN(int) git_rebase_init(
|
||||
git_rebase **out,
|
||||
git_repository *repo,
|
||||
const git_annotated_commit *branch,
|
||||
const git_annotated_commit *upstream,
|
||||
const git_annotated_commit *onto,
|
||||
const git_rebase_options *opts);
|
||||
|
||||
/**
|
||||
* Opens an existing rebase that was previously started by either an
|
||||
* invocation of `git_rebase_init` or by another client.
|
||||
*
|
||||
* @param out Pointer to store the rebase object
|
||||
* @param repo The repository that has a rebase in-progress
|
||||
* @param opts Options to specify how rebase is performed
|
||||
* @return Zero on success; -1 on failure.
|
||||
*/
|
||||
GIT_EXTERN(int) git_rebase_open(
|
||||
git_rebase **out,
|
||||
git_repository *repo,
|
||||
const git_rebase_options *opts);
|
||||
|
||||
/**
|
||||
* Gets the original `HEAD` ref name for merge rebases.
|
||||
*
|
||||
* @param rebase The in-progress rebase.
|
||||
* @return The original `HEAD` ref name
|
||||
*/
|
||||
GIT_EXTERN(const char *) git_rebase_orig_head_name(git_rebase *rebase);
|
||||
|
||||
/**
|
||||
* Gets the original `HEAD` id for merge rebases.
|
||||
*
|
||||
* @param rebase The in-progress rebase.
|
||||
* @return The original `HEAD` id
|
||||
*/
|
||||
GIT_EXTERN(const git_oid *) git_rebase_orig_head_id(git_rebase *rebase);
|
||||
|
||||
/**
|
||||
* Gets the `onto` ref name for merge rebases.
|
||||
*
|
||||
* @param rebase The in-progress rebase.
|
||||
* @return The `onto` ref name
|
||||
*/
|
||||
GIT_EXTERN(const char *) git_rebase_onto_name(git_rebase *rebase);
|
||||
|
||||
/**
|
||||
* Gets the `onto` id for merge rebases.
|
||||
*
|
||||
* @param rebase The in-progress rebase.
|
||||
* @return The `onto` id
|
||||
*/
|
||||
GIT_EXTERN(const git_oid *) git_rebase_onto_id(git_rebase *rebase);
|
||||
|
||||
/**
|
||||
* Gets the count of rebase operations that are to be applied.
|
||||
*
|
||||
* @param rebase The in-progress rebase
|
||||
* @return The number of rebase operations in total
|
||||
*/
|
||||
GIT_EXTERN(size_t) git_rebase_operation_entrycount(git_rebase *rebase);
|
||||
|
||||
/**
|
||||
* Gets the index of the rebase operation that is currently being applied.
|
||||
* If the first operation has not yet been applied (because you have
|
||||
* called `init` but not yet `next`) then this returns
|
||||
* `GIT_REBASE_NO_OPERATION`.
|
||||
*
|
||||
* @param rebase The in-progress rebase
|
||||
* @return The index of the rebase operation currently being applied.
|
||||
*/
|
||||
GIT_EXTERN(size_t) git_rebase_operation_current(git_rebase *rebase);
|
||||
|
||||
/**
|
||||
* Gets the rebase operation specified by the given index.
|
||||
*
|
||||
* @param rebase The in-progress rebase
|
||||
* @param idx The index of the rebase operation to retrieve
|
||||
* @return The rebase operation or NULL if `idx` was out of bounds
|
||||
*/
|
||||
GIT_EXTERN(git_rebase_operation *) git_rebase_operation_byindex(
|
||||
git_rebase *rebase,
|
||||
size_t idx);
|
||||
|
||||
/**
|
||||
* Performs the next rebase operation and returns the information about it.
|
||||
* If the operation is one that applies a patch (which is any operation except
|
||||
* GIT_REBASE_OPERATION_EXEC) then the patch will be applied and the index and
|
||||
* working directory will be updated with the changes. If there are conflicts,
|
||||
* you will need to address those before committing the changes.
|
||||
*
|
||||
* @param operation Pointer to store the rebase operation that is to be performed next
|
||||
* @param rebase The rebase in progress
|
||||
* @return Zero on success; -1 on failure.
|
||||
*/
|
||||
GIT_EXTERN(int) git_rebase_next(
|
||||
git_rebase_operation **operation,
|
||||
git_rebase *rebase);
|
||||
|
||||
/**
|
||||
* Gets the index produced by the last operation, which is the result
|
||||
* of `git_rebase_next` and which will be committed by the next
|
||||
* invocation of `git_rebase_commit`. This is useful for resolving
|
||||
* conflicts in an in-memory rebase before committing them. You must
|
||||
* call `git_index_free` when you are finished with this.
|
||||
*
|
||||
* This is only applicable for in-memory rebases; for rebases within
|
||||
* a working directory, the changes were applied to the repository's
|
||||
* index.
|
||||
*
|
||||
* @param index The result index of the last operation.
|
||||
* @param rebase The in-progress rebase.
|
||||
* @return 0 or an error code
|
||||
*/
|
||||
GIT_EXTERN(int) git_rebase_inmemory_index(
|
||||
git_index **index,
|
||||
git_rebase *rebase);
|
||||
|
||||
/**
|
||||
* Commits the current patch. You must have resolved any conflicts that
|
||||
* were introduced during the patch application from the `git_rebase_next`
|
||||
* invocation.
|
||||
*
|
||||
* @param id Pointer in which to store the OID of the newly created commit
|
||||
* @param rebase The rebase that is in-progress
|
||||
* @param author The author of the updated commit, or NULL to keep the
|
||||
* author from the original commit
|
||||
* @param committer The committer of the rebase
|
||||
* @param message_encoding The encoding for the message in the commit,
|
||||
* represented with a standard encoding name. If message is NULL,
|
||||
* this should also be NULL, and the encoding from the original
|
||||
* commit will be maintained. If message is specified, this may be
|
||||
* NULL to indicate that "UTF-8" is to be used.
|
||||
* @param message The message for this commit, or NULL to use the message
|
||||
* from the original commit.
|
||||
* @return Zero on success, GIT_EUNMERGED if there are unmerged changes in
|
||||
* the index, GIT_EAPPLIED if the current commit has already
|
||||
* been applied to the upstream and there is nothing to commit,
|
||||
* -1 on failure.
|
||||
*/
|
||||
GIT_EXTERN(int) git_rebase_commit(
|
||||
git_oid *id,
|
||||
git_rebase *rebase,
|
||||
const git_signature *author,
|
||||
const git_signature *committer,
|
||||
const char *message_encoding,
|
||||
const char *message);
|
||||
|
||||
/**
|
||||
* Aborts a rebase that is currently in progress, resetting the repository
|
||||
* and working directory to their state before rebase began.
|
||||
*
|
||||
* @param rebase The rebase that is in-progress
|
||||
* @return Zero on success; GIT_ENOTFOUND if a rebase is not in progress,
|
||||
* -1 on other errors.
|
||||
*/
|
||||
GIT_EXTERN(int) git_rebase_abort(git_rebase *rebase);
|
||||
|
||||
/**
|
||||
* Finishes a rebase that is currently in progress once all patches have
|
||||
* been applied.
|
||||
*
|
||||
* @param rebase The rebase that is in-progress
|
||||
* @param signature The identity that is finishing the rebase (optional)
|
||||
* @return Zero on success; -1 on error
|
||||
*/
|
||||
GIT_EXTERN(int) git_rebase_finish(
|
||||
git_rebase *rebase,
|
||||
const git_signature *signature);
|
||||
|
||||
/**
|
||||
* Frees the `git_rebase` object.
|
||||
*
|
||||
* @param rebase The rebase object
|
||||
*/
|
||||
GIT_EXTERN(void) git_rebase_free(git_rebase *rebase);
|
||||
|
||||
/** @} */
|
||||
GIT_END_DECL
|
||||
#endif
|
71
3rdparty/libgit2/include/git2/refdb.h
vendored
Normal file
71
3rdparty/libgit2/include/git2/refdb.h
vendored
Normal file
@ -0,0 +1,71 @@
|
||||
/*
|
||||
* Copyright (C) the libgit2 contributors. All rights reserved.
|
||||
*
|
||||
* This file is part of libgit2, distributed under the GNU GPL v2 with
|
||||
* a Linking Exception. For full terms see the included COPYING file.
|
||||
*/
|
||||
#ifndef INCLUDE_git_refdb_h__
|
||||
#define INCLUDE_git_refdb_h__
|
||||
|
||||
#include "common.h"
|
||||
#include "types.h"
|
||||
#include "oid.h"
|
||||
#include "refs.h"
|
||||
|
||||
/**
|
||||
* @file git2/refdb.h
|
||||
* @brief Git custom refs backend functions
|
||||
* @defgroup git_refdb Git custom refs backend API
|
||||
* @ingroup Git
|
||||
* @{
|
||||
*/
|
||||
GIT_BEGIN_DECL
|
||||
|
||||
/**
|
||||
* Create a new reference database with no backends.
|
||||
*
|
||||
* Before the Ref DB can be used for read/writing, a custom database
|
||||
* backend must be manually set using `git_refdb_set_backend()`
|
||||
*
|
||||
* @param out location to store the database pointer, if opened.
|
||||
* Set to NULL if the open failed.
|
||||
* @param repo the repository
|
||||
* @return 0 or an error code
|
||||
*/
|
||||
GIT_EXTERN(int) git_refdb_new(git_refdb **out, git_repository *repo);
|
||||
|
||||
/**
|
||||
* Create a new reference database and automatically add
|
||||
* the default backends:
|
||||
*
|
||||
* - git_refdb_dir: read and write loose and packed refs
|
||||
* from disk, assuming the repository dir as the folder
|
||||
*
|
||||
* @param out location to store the database pointer, if opened.
|
||||
* Set to NULL if the open failed.
|
||||
* @param repo the repository
|
||||
* @return 0 or an error code
|
||||
*/
|
||||
GIT_EXTERN(int) git_refdb_open(git_refdb **out, git_repository *repo);
|
||||
|
||||
/**
|
||||
* Suggests that the given refdb compress or optimize its references.
|
||||
* This mechanism is implementation specific. For on-disk reference
|
||||
* databases, for example, this may pack all loose references.
|
||||
*
|
||||
* @param refdb The reference database to optimize.
|
||||
* @return 0 or an error code.
|
||||
*/
|
||||
GIT_EXTERN(int) git_refdb_compress(git_refdb *refdb);
|
||||
|
||||
/**
|
||||
* Close an open reference database.
|
||||
*
|
||||
* @param refdb reference database pointer or NULL
|
||||
*/
|
||||
GIT_EXTERN(void) git_refdb_free(git_refdb *refdb);
|
||||
|
||||
/** @} */
|
||||
GIT_END_DECL
|
||||
|
||||
#endif
|
170
3rdparty/libgit2/include/git2/reflog.h
vendored
Normal file
170
3rdparty/libgit2/include/git2/reflog.h
vendored
Normal file
@ -0,0 +1,170 @@
|
||||
/*
|
||||
* Copyright (C) the libgit2 contributors. All rights reserved.
|
||||
*
|
||||
* This file is part of libgit2, distributed under the GNU GPL v2 with
|
||||
* a Linking Exception. For full terms see the included COPYING file.
|
||||
*/
|
||||
#ifndef INCLUDE_git_reflog_h__
|
||||
#define INCLUDE_git_reflog_h__
|
||||
|
||||
#include "common.h"
|
||||
#include "types.h"
|
||||
#include "oid.h"
|
||||
|
||||
/**
|
||||
* @file git2/reflog.h
|
||||
* @brief Git reflog management routines
|
||||
* @defgroup git_reflog Git reflog management routines
|
||||
* @ingroup Git
|
||||
* @{
|
||||
*/
|
||||
GIT_BEGIN_DECL
|
||||
|
||||
/**
|
||||
* Read the reflog for the given reference
|
||||
*
|
||||
* If there is no reflog file for the given
|
||||
* reference yet, an empty reflog object will
|
||||
* be returned.
|
||||
*
|
||||
* The reflog must be freed manually by using
|
||||
* git_reflog_free().
|
||||
*
|
||||
* @param out pointer to reflog
|
||||
* @param repo the repository
|
||||
* @param name reference to look up
|
||||
* @return 0 or an error code
|
||||
*/
|
||||
GIT_EXTERN(int) git_reflog_read(git_reflog **out, git_repository *repo, const char *name);
|
||||
|
||||
/**
|
||||
* Write an existing in-memory reflog object back to disk
|
||||
* using an atomic file lock.
|
||||
*
|
||||
* @param reflog an existing reflog object
|
||||
* @return 0 or an error code
|
||||
*/
|
||||
GIT_EXTERN(int) git_reflog_write(git_reflog *reflog);
|
||||
|
||||
/**
|
||||
* Add a new entry to the in-memory reflog.
|
||||
*
|
||||
* `msg` is optional and can be NULL.
|
||||
*
|
||||
* @param reflog an existing reflog object
|
||||
* @param id the OID the reference is now pointing to
|
||||
* @param committer the signature of the committer
|
||||
* @param msg the reflog message
|
||||
* @return 0 or an error code
|
||||
*/
|
||||
GIT_EXTERN(int) git_reflog_append(git_reflog *reflog, const git_oid *id, const git_signature *committer, const char *msg);
|
||||
|
||||
/**
|
||||
* Rename a reflog
|
||||
*
|
||||
* The reflog to be renamed is expected to already exist
|
||||
*
|
||||
* The new name will be checked for validity.
|
||||
* See `git_reference_create_symbolic()` for rules about valid names.
|
||||
*
|
||||
* @param repo the repository
|
||||
* @param old_name the old name of the reference
|
||||
* @param name the new name of the reference
|
||||
* @return 0 on success, GIT_EINVALIDSPEC or an error code
|
||||
*/
|
||||
GIT_EXTERN(int) git_reflog_rename(git_repository *repo, const char *old_name, const char *name);
|
||||
|
||||
/**
|
||||
* Delete the reflog for the given reference
|
||||
*
|
||||
* @param repo the repository
|
||||
* @param name the reflog to delete
|
||||
* @return 0 or an error code
|
||||
*/
|
||||
GIT_EXTERN(int) git_reflog_delete(git_repository *repo, const char *name);
|
||||
|
||||
/**
|
||||
* Get the number of log entries in a reflog
|
||||
*
|
||||
* @param reflog the previously loaded reflog
|
||||
* @return the number of log entries
|
||||
*/
|
||||
GIT_EXTERN(size_t) git_reflog_entrycount(git_reflog *reflog);
|
||||
|
||||
/**
|
||||
* Lookup an entry by its index
|
||||
*
|
||||
* Requesting the reflog entry with an index of 0 (zero) will
|
||||
* return the most recently created entry.
|
||||
*
|
||||
* @param reflog a previously loaded reflog
|
||||
* @param idx the position of the entry to lookup. Should be greater than or
|
||||
* equal to 0 (zero) and less than `git_reflog_entrycount()`.
|
||||
* @return the entry; NULL if not found
|
||||
*/
|
||||
GIT_EXTERN(const git_reflog_entry *) git_reflog_entry_byindex(const git_reflog *reflog, size_t idx);
|
||||
|
||||
/**
|
||||
* Remove an entry from the reflog by its index
|
||||
*
|
||||
* To ensure there's no gap in the log history, set `rewrite_previous_entry`
|
||||
* param value to 1. When deleting entry `n`, member old_oid of entry `n-1`
|
||||
* (if any) will be updated with the value of member new_oid of entry `n+1`.
|
||||
*
|
||||
* @param reflog a previously loaded reflog.
|
||||
*
|
||||
* @param idx the position of the entry to remove. Should be greater than or
|
||||
* equal to 0 (zero) and less than `git_reflog_entrycount()`.
|
||||
*
|
||||
* @param rewrite_previous_entry 1 to rewrite the history; 0 otherwise.
|
||||
*
|
||||
* @return 0 on success, GIT_ENOTFOUND if the entry doesn't exist
|
||||
* or an error code.
|
||||
*/
|
||||
GIT_EXTERN(int) git_reflog_drop(
|
||||
git_reflog *reflog,
|
||||
size_t idx,
|
||||
int rewrite_previous_entry);
|
||||
|
||||
/**
|
||||
* Get the old oid
|
||||
*
|
||||
* @param entry a reflog entry
|
||||
* @return the old oid
|
||||
*/
|
||||
GIT_EXTERN(const git_oid *) git_reflog_entry_id_old(const git_reflog_entry *entry);
|
||||
|
||||
/**
|
||||
* Get the new oid
|
||||
*
|
||||
* @param entry a reflog entry
|
||||
* @return the new oid at this time
|
||||
*/
|
||||
GIT_EXTERN(const git_oid *) git_reflog_entry_id_new(const git_reflog_entry *entry);
|
||||
|
||||
/**
|
||||
* Get the committer of this entry
|
||||
*
|
||||
* @param entry a reflog entry
|
||||
* @return the committer
|
||||
*/
|
||||
GIT_EXTERN(const git_signature *) git_reflog_entry_committer(const git_reflog_entry *entry);
|
||||
|
||||
/**
|
||||
* Get the log message
|
||||
*
|
||||
* @param entry a reflog entry
|
||||
* @return the log msg
|
||||
*/
|
||||
GIT_EXTERN(const char *) git_reflog_entry_message(const git_reflog_entry *entry);
|
||||
|
||||
/**
|
||||
* Free the reflog
|
||||
*
|
||||
* @param reflog reflog to free
|
||||
*/
|
||||
GIT_EXTERN(void) git_reflog_free(git_reflog *reflog);
|
||||
|
||||
/** @} */
|
||||
GIT_END_DECL
|
||||
#endif
|
771
3rdparty/libgit2/include/git2/refs.h
vendored
Normal file
771
3rdparty/libgit2/include/git2/refs.h
vendored
Normal file
@ -0,0 +1,771 @@
|
||||
/*
|
||||
* Copyright (C) the libgit2 contributors. All rights reserved.
|
||||
*
|
||||
* This file is part of libgit2, distributed under the GNU GPL v2 with
|
||||
* a Linking Exception. For full terms see the included COPYING file.
|
||||
*/
|
||||
#ifndef INCLUDE_git_refs_h__
|
||||
#define INCLUDE_git_refs_h__
|
||||
|
||||
#include "common.h"
|
||||
#include "types.h"
|
||||
#include "oid.h"
|
||||
#include "strarray.h"
|
||||
|
||||
/**
|
||||
* @file git2/refs.h
|
||||
* @brief Git reference management routines
|
||||
* @defgroup git_reference Git reference management routines
|
||||
* @ingroup Git
|
||||
* @{
|
||||
*/
|
||||
GIT_BEGIN_DECL
|
||||
|
||||
/**
|
||||
* Lookup a reference by name in a repository.
|
||||
*
|
||||
* The returned reference must be freed by the user.
|
||||
*
|
||||
* The name will be checked for validity.
|
||||
* See `git_reference_symbolic_create()` for rules about valid names.
|
||||
*
|
||||
* @param out pointer to the looked-up reference
|
||||
* @param repo the repository to look up the reference
|
||||
* @param name the long name for the reference (e.g. HEAD, refs/heads/master, refs/tags/v0.1.0, ...)
|
||||
* @return 0 on success, GIT_ENOTFOUND, GIT_EINVALIDSPEC or an error code.
|
||||
*/
|
||||
GIT_EXTERN(int) git_reference_lookup(git_reference **out, git_repository *repo, const char *name);
|
||||
|
||||
/**
|
||||
* Lookup a reference by name and resolve immediately to OID.
|
||||
*
|
||||
* This function provides a quick way to resolve a reference name straight
|
||||
* through to the object id that it refers to. This avoids having to
|
||||
* allocate or free any `git_reference` objects for simple situations.
|
||||
*
|
||||
* The name will be checked for validity.
|
||||
* See `git_reference_symbolic_create()` for rules about valid names.
|
||||
*
|
||||
* @param out Pointer to oid to be filled in
|
||||
* @param repo The repository in which to look up the reference
|
||||
* @param name The long name for the reference (e.g. HEAD, refs/heads/master, refs/tags/v0.1.0, ...)
|
||||
* @return 0 on success, GIT_ENOTFOUND, GIT_EINVALIDSPEC or an error code.
|
||||
*/
|
||||
GIT_EXTERN(int) git_reference_name_to_id(
|
||||
git_oid *out, git_repository *repo, const char *name);
|
||||
|
||||
/**
|
||||
* Lookup a reference by DWIMing its short name
|
||||
*
|
||||
* Apply the git precedence rules to the given shorthand to determine
|
||||
* which reference the user is referring to.
|
||||
*
|
||||
* @param out pointer in which to store the reference
|
||||
* @param repo the repository in which to look
|
||||
* @param shorthand the short name for the reference
|
||||
* @return 0 or an error code
|
||||
*/
|
||||
GIT_EXTERN(int) git_reference_dwim(git_reference **out, git_repository *repo, const char *shorthand);
|
||||
|
||||
/**
|
||||
* Conditionally create a new symbolic reference.
|
||||
*
|
||||
* A symbolic reference is a reference name that refers to another
|
||||
* reference name. If the other name moves, the symbolic name will move,
|
||||
* too. As a simple example, the "HEAD" reference might refer to
|
||||
* "refs/heads/master" while on the "master" branch of a repository.
|
||||
*
|
||||
* The symbolic reference will be created in the repository and written to
|
||||
* the disk. The generated reference object must be freed by the user.
|
||||
*
|
||||
* Valid reference names must follow one of two patterns:
|
||||
*
|
||||
* 1. Top-level names must contain only capital letters and underscores,
|
||||
* and must begin and end with a letter. (e.g. "HEAD", "ORIG_HEAD").
|
||||
* 2. Names prefixed with "refs/" can be almost anything. You must avoid
|
||||
* the characters '~', '^', ':', '\\', '?', '[', and '*', and the
|
||||
* sequences ".." and "@{" which have special meaning to revparse.
|
||||
*
|
||||
* This function will return an error if a reference already exists with the
|
||||
* given name unless `force` is true, in which case it will be overwritten.
|
||||
*
|
||||
* The message for the reflog will be ignored if the reference does
|
||||
* not belong in the standard set (HEAD, branches and remote-tracking
|
||||
* branches) and it does not have a reflog.
|
||||
*
|
||||
* It will return GIT_EMODIFIED if the reference's value at the time
|
||||
* of updating does not match the one passed through `current_value`
|
||||
* (i.e. if the ref has changed since the user read it).
|
||||
*
|
||||
* If `current_value` is all zeros, this function will return GIT_EMODIFIED
|
||||
* if the ref already exists.
|
||||
*
|
||||
* @param out Pointer to the newly created reference
|
||||
* @param repo Repository where that reference will live
|
||||
* @param name The name of the reference
|
||||
* @param target The target of the reference
|
||||
* @param force Overwrite existing references
|
||||
* @param current_value The expected value of the reference when updating
|
||||
* @param log_message The one line long message to be appended to the reflog
|
||||
* @return 0 on success, GIT_EEXISTS, GIT_EINVALIDSPEC, GIT_EMODIFIED or an error code
|
||||
*/
|
||||
GIT_EXTERN(int) git_reference_symbolic_create_matching(git_reference **out, git_repository *repo, const char *name, const char *target, int force, const char *current_value, const char *log_message);
|
||||
|
||||
/**
|
||||
* Create a new symbolic reference.
|
||||
*
|
||||
* A symbolic reference is a reference name that refers to another
|
||||
* reference name. If the other name moves, the symbolic name will move,
|
||||
* too. As a simple example, the "HEAD" reference might refer to
|
||||
* "refs/heads/master" while on the "master" branch of a repository.
|
||||
*
|
||||
* The symbolic reference will be created in the repository and written to
|
||||
* the disk. The generated reference object must be freed by the user.
|
||||
*
|
||||
* Valid reference names must follow one of two patterns:
|
||||
*
|
||||
* 1. Top-level names must contain only capital letters and underscores,
|
||||
* and must begin and end with a letter. (e.g. "HEAD", "ORIG_HEAD").
|
||||
* 2. Names prefixed with "refs/" can be almost anything. You must avoid
|
||||
* the characters '~', '^', ':', '\\', '?', '[', and '*', and the
|
||||
* sequences ".." and "@{" which have special meaning to revparse.
|
||||
*
|
||||
* This function will return an error if a reference already exists with the
|
||||
* given name unless `force` is true, in which case it will be overwritten.
|
||||
*
|
||||
* The message for the reflog will be ignored if the reference does
|
||||
* not belong in the standard set (HEAD, branches and remote-tracking
|
||||
* branches) and it does not have a reflog.
|
||||
*
|
||||
* @param out Pointer to the newly created reference
|
||||
* @param repo Repository where that reference will live
|
||||
* @param name The name of the reference
|
||||
* @param target The target of the reference
|
||||
* @param force Overwrite existing references
|
||||
* @param log_message The one line long message to be appended to the reflog
|
||||
* @return 0 on success, GIT_EEXISTS, GIT_EINVALIDSPEC or an error code
|
||||
*/
|
||||
GIT_EXTERN(int) git_reference_symbolic_create(git_reference **out, git_repository *repo, const char *name, const char *target, int force, const char *log_message);
|
||||
|
||||
/**
|
||||
* Create a new direct reference.
|
||||
*
|
||||
* A direct reference (also called an object id reference) refers directly
|
||||
* to a specific object id (a.k.a. OID or SHA) in the repository. The id
|
||||
* permanently refers to the object (although the reference itself can be
|
||||
* moved). For example, in libgit2 the direct ref "refs/tags/v0.17.0"
|
||||
* refers to OID 5b9fac39d8a76b9139667c26a63e6b3f204b3977.
|
||||
*
|
||||
* The direct reference will be created in the repository and written to
|
||||
* the disk. The generated reference object must be freed by the user.
|
||||
*
|
||||
* Valid reference names must follow one of two patterns:
|
||||
*
|
||||
* 1. Top-level names must contain only capital letters and underscores,
|
||||
* and must begin and end with a letter. (e.g. "HEAD", "ORIG_HEAD").
|
||||
* 2. Names prefixed with "refs/" can be almost anything. You must avoid
|
||||
* the characters '~', '^', ':', '\\', '?', '[', and '*', and the
|
||||
* sequences ".." and "@{" which have special meaning to revparse.
|
||||
*
|
||||
* This function will return an error if a reference already exists with the
|
||||
* given name unless `force` is true, in which case it will be overwritten.
|
||||
*
|
||||
* The message for the reflog will be ignored if the reference does
|
||||
* not belong in the standard set (HEAD, branches and remote-tracking
|
||||
* branches) and it does not have a reflog.
|
||||
*
|
||||
* @param out Pointer to the newly created reference
|
||||
* @param repo Repository where that reference will live
|
||||
* @param name The name of the reference
|
||||
* @param id The object id pointed to by the reference.
|
||||
* @param force Overwrite existing references
|
||||
* @param log_message The one line long message to be appended to the reflog
|
||||
* @return 0 on success, GIT_EEXISTS, GIT_EINVALIDSPEC or an error code
|
||||
*/
|
||||
GIT_EXTERN(int) git_reference_create(git_reference **out, git_repository *repo, const char *name, const git_oid *id, int force, const char *log_message);
|
||||
|
||||
/**
|
||||
* Conditionally create new direct reference
|
||||
*
|
||||
* A direct reference (also called an object id reference) refers directly
|
||||
* to a specific object id (a.k.a. OID or SHA) in the repository. The id
|
||||
* permanently refers to the object (although the reference itself can be
|
||||
* moved). For example, in libgit2 the direct ref "refs/tags/v0.17.0"
|
||||
* refers to OID 5b9fac39d8a76b9139667c26a63e6b3f204b3977.
|
||||
*
|
||||
* The direct reference will be created in the repository and written to
|
||||
* the disk. The generated reference object must be freed by the user.
|
||||
*
|
||||
* Valid reference names must follow one of two patterns:
|
||||
*
|
||||
* 1. Top-level names must contain only capital letters and underscores,
|
||||
* and must begin and end with a letter. (e.g. "HEAD", "ORIG_HEAD").
|
||||
* 2. Names prefixed with "refs/" can be almost anything. You must avoid
|
||||
* the characters '~', '^', ':', '\\', '?', '[', and '*', and the
|
||||
* sequences ".." and "@{" which have special meaning to revparse.
|
||||
*
|
||||
* This function will return an error if a reference already exists with the
|
||||
* given name unless `force` is true, in which case it will be overwritten.
|
||||
*
|
||||
* The message for the reflog will be ignored if the reference does
|
||||
* not belong in the standard set (HEAD, branches and remote-tracking
|
||||
* branches) and it does not have a reflog.
|
||||
*
|
||||
* It will return GIT_EMODIFIED if the reference's value at the time
|
||||
* of updating does not match the one passed through `current_id`
|
||||
* (i.e. if the ref has changed since the user read it).
|
||||
*
|
||||
* @param out Pointer to the newly created reference
|
||||
* @param repo Repository where that reference will live
|
||||
* @param name The name of the reference
|
||||
* @param id The object id pointed to by the reference.
|
||||
* @param force Overwrite existing references
|
||||
* @param current_id The expected value of the reference at the time of update
|
||||
* @param log_message The one line long message to be appended to the reflog
|
||||
* @return 0 on success, GIT_EMODIFIED if the value of the reference
|
||||
* has changed, GIT_EEXISTS, GIT_EINVALIDSPEC or an error code
|
||||
*/
|
||||
GIT_EXTERN(int) git_reference_create_matching(git_reference **out, git_repository *repo, const char *name, const git_oid *id, int force, const git_oid *current_id, const char *log_message);
|
||||
|
||||
/**
|
||||
* Get the OID pointed to by a direct reference.
|
||||
*
|
||||
* Only available if the reference is direct (i.e. an object id reference,
|
||||
* not a symbolic one).
|
||||
*
|
||||
* To find the OID of a symbolic ref, call `git_reference_resolve()` and
|
||||
* then this function (or maybe use `git_reference_name_to_id()` to
|
||||
* directly resolve a reference name all the way through to an OID).
|
||||
*
|
||||
* @param ref The reference
|
||||
* @return a pointer to the oid if available, NULL otherwise
|
||||
*/
|
||||
GIT_EXTERN(const git_oid *) git_reference_target(const git_reference *ref);
|
||||
|
||||
/**
|
||||
* Return the peeled OID target of this reference.
|
||||
*
|
||||
* This peeled OID only applies to direct references that point to
|
||||
* a hard Tag object: it is the result of peeling such Tag.
|
||||
*
|
||||
* @param ref The reference
|
||||
* @return a pointer to the oid if available, NULL otherwise
|
||||
*/
|
||||
GIT_EXTERN(const git_oid *) git_reference_target_peel(const git_reference *ref);
|
||||
|
||||
/**
|
||||
* Get full name to the reference pointed to by a symbolic reference.
|
||||
*
|
||||
* Only available if the reference is symbolic.
|
||||
*
|
||||
* @param ref The reference
|
||||
* @return a pointer to the name if available, NULL otherwise
|
||||
*/
|
||||
GIT_EXTERN(const char *) git_reference_symbolic_target(const git_reference *ref);
|
||||
|
||||
/**
|
||||
* Get the type of a reference.
|
||||
*
|
||||
* Either direct (GIT_REFERENCE_DIRECT) or symbolic (GIT_REFERENCE_SYMBOLIC)
|
||||
*
|
||||
* @param ref The reference
|
||||
* @return the type
|
||||
*/
|
||||
GIT_EXTERN(git_reference_t) git_reference_type(const git_reference *ref);
|
||||
|
||||
/**
|
||||
* Get the full name of a reference.
|
||||
*
|
||||
* See `git_reference_symbolic_create()` for rules about valid names.
|
||||
*
|
||||
* @param ref The reference
|
||||
* @return the full name for the ref
|
||||
*/
|
||||
GIT_EXTERN(const char *) git_reference_name(const git_reference *ref);
|
||||
|
||||
/**
|
||||
* Resolve a symbolic reference to a direct reference.
|
||||
*
|
||||
* This method iteratively peels a symbolic reference until it resolves to
|
||||
* a direct reference to an OID.
|
||||
*
|
||||
* The peeled reference is returned in the `resolved_ref` argument, and
|
||||
* must be freed manually once it's no longer needed.
|
||||
*
|
||||
* If a direct reference is passed as an argument, a copy of that
|
||||
* reference is returned. This copy must be manually freed too.
|
||||
*
|
||||
* @param out Pointer to the peeled reference
|
||||
* @param ref The reference
|
||||
* @return 0 or an error code
|
||||
*/
|
||||
GIT_EXTERN(int) git_reference_resolve(git_reference **out, const git_reference *ref);
|
||||
|
||||
/**
|
||||
* Get the repository where a reference resides.
|
||||
*
|
||||
* @param ref The reference
|
||||
* @return a pointer to the repo
|
||||
*/
|
||||
GIT_EXTERN(git_repository *) git_reference_owner(const git_reference *ref);
|
||||
|
||||
/**
|
||||
* Create a new reference with the same name as the given reference but a
|
||||
* different symbolic target. The reference must be a symbolic reference,
|
||||
* otherwise this will fail.
|
||||
*
|
||||
* The new reference will be written to disk, overwriting the given reference.
|
||||
*
|
||||
* The target name will be checked for validity.
|
||||
* See `git_reference_symbolic_create()` for rules about valid names.
|
||||
*
|
||||
* The message for the reflog will be ignored if the reference does
|
||||
* not belong in the standard set (HEAD, branches and remote-tracking
|
||||
* branches) and it does not have a reflog.
|
||||
*
|
||||
* @param out Pointer to the newly created reference
|
||||
* @param ref The reference
|
||||
* @param target The new target for the reference
|
||||
* @param log_message The one line long message to be appended to the reflog
|
||||
* @return 0 on success, GIT_EINVALIDSPEC or an error code
|
||||
*/
|
||||
GIT_EXTERN(int) git_reference_symbolic_set_target(
|
||||
git_reference **out,
|
||||
git_reference *ref,
|
||||
const char *target,
|
||||
const char *log_message);
|
||||
|
||||
/**
|
||||
* Conditionally create a new reference with the same name as the given reference but a
|
||||
* different OID target. The reference must be a direct reference, otherwise
|
||||
* this will fail.
|
||||
*
|
||||
* The new reference will be written to disk, overwriting the given reference.
|
||||
*
|
||||
* @param out Pointer to the newly created reference
|
||||
* @param ref The reference
|
||||
* @param id The new target OID for the reference
|
||||
* @param log_message The one line long message to be appended to the reflog
|
||||
* @return 0 on success, GIT_EMODIFIED if the value of the reference
|
||||
* has changed since it was read, or an error code
|
||||
*/
|
||||
GIT_EXTERN(int) git_reference_set_target(
|
||||
git_reference **out,
|
||||
git_reference *ref,
|
||||
const git_oid *id,
|
||||
const char *log_message);
|
||||
|
||||
/**
|
||||
* Rename an existing reference.
|
||||
*
|
||||
* This method works for both direct and symbolic references.
|
||||
*
|
||||
* The new name will be checked for validity.
|
||||
* See `git_reference_symbolic_create()` for rules about valid names.
|
||||
*
|
||||
* If the `force` flag is not enabled, and there's already
|
||||
* a reference with the given name, the renaming will fail.
|
||||
*
|
||||
* IMPORTANT:
|
||||
* The user needs to write a proper reflog entry if the
|
||||
* reflog is enabled for the repository. We only rename
|
||||
* the reflog if it exists.
|
||||
*
|
||||
* @param ref The reference to rename
|
||||
* @param new_name The new name for the reference
|
||||
* @param force Overwrite an existing reference
|
||||
* @param log_message The one line long message to be appended to the reflog
|
||||
* @return 0 on success, GIT_EINVALIDSPEC, GIT_EEXISTS or an error code
|
||||
*
|
||||
*/
|
||||
GIT_EXTERN(int) git_reference_rename(
|
||||
git_reference **new_ref,
|
||||
git_reference *ref,
|
||||
const char *new_name,
|
||||
int force,
|
||||
const char *log_message);
|
||||
|
||||
/**
|
||||
* Delete an existing reference.
|
||||
*
|
||||
* This method works for both direct and symbolic references. The reference
|
||||
* will be immediately removed on disk but the memory will not be freed.
|
||||
* Callers must call `git_reference_free`.
|
||||
*
|
||||
* This function will return an error if the reference has changed
|
||||
* from the time it was looked up.
|
||||
*
|
||||
* @param ref The reference to remove
|
||||
* @return 0, GIT_EMODIFIED or an error code
|
||||
*/
|
||||
GIT_EXTERN(int) git_reference_delete(git_reference *ref);
|
||||
|
||||
/**
|
||||
* Delete an existing reference by name
|
||||
*
|
||||
* This method removes the named reference from the repository without
|
||||
* looking at its old value.
|
||||
*
|
||||
* @param name The reference to remove
|
||||
* @return 0 or an error code
|
||||
*/
|
||||
GIT_EXTERN(int) git_reference_remove(git_repository *repo, const char *name);
|
||||
|
||||
/**
|
||||
* Fill a list with all the references that can be found in a repository.
|
||||
*
|
||||
* The string array will be filled with the names of all references; these
|
||||
* values are owned by the user and should be free'd manually when no
|
||||
* longer needed, using `git_strarray_free()`.
|
||||
*
|
||||
* @param array Pointer to a git_strarray structure where
|
||||
* the reference names will be stored
|
||||
* @param repo Repository where to find the refs
|
||||
* @return 0 or an error code
|
||||
*/
|
||||
GIT_EXTERN(int) git_reference_list(git_strarray *array, git_repository *repo);
|
||||
|
||||
/**
|
||||
* Callback used to iterate over references
|
||||
*
|
||||
* @see git_reference_foreach
|
||||
*
|
||||
* @param reference The reference object
|
||||
* @param payload Payload passed to git_reference_foreach
|
||||
* @return non-zero to terminate the iteration
|
||||
*/
|
||||
typedef int GIT_CALLBACK(git_reference_foreach_cb)(git_reference *reference, void *payload);
|
||||
|
||||
/**
|
||||
* Callback used to iterate over reference names
|
||||
*
|
||||
* @see git_reference_foreach_name
|
||||
*
|
||||
* @param name The reference name
|
||||
* @param payload Payload passed to git_reference_foreach_name
|
||||
* @return non-zero to terminate the iteration
|
||||
*/
|
||||
typedef int GIT_CALLBACK(git_reference_foreach_name_cb)(const char *name, void *payload);
|
||||
|
||||
/**
|
||||
* Perform a callback on each reference in the repository.
|
||||
*
|
||||
* The `callback` function will be called for each reference in the
|
||||
* repository, receiving the reference object and the `payload` value
|
||||
* passed to this method. Returning a non-zero value from the callback
|
||||
* will terminate the iteration.
|
||||
*
|
||||
* Note that the callback function is responsible to call `git_reference_free`
|
||||
* on each reference passed to it.
|
||||
*
|
||||
* @param repo Repository where to find the refs
|
||||
* @param callback Function which will be called for every listed ref
|
||||
* @param payload Additional data to pass to the callback
|
||||
* @return 0 on success, non-zero callback return value, or error code
|
||||
*/
|
||||
GIT_EXTERN(int) git_reference_foreach(
|
||||
git_repository *repo,
|
||||
git_reference_foreach_cb callback,
|
||||
void *payload);
|
||||
|
||||
/**
|
||||
* Perform a callback on the fully-qualified name of each reference.
|
||||
*
|
||||
* The `callback` function will be called for each reference in the
|
||||
* repository, receiving the name of the reference and the `payload` value
|
||||
* passed to this method. Returning a non-zero value from the callback
|
||||
* will terminate the iteration.
|
||||
*
|
||||
* @param repo Repository where to find the refs
|
||||
* @param callback Function which will be called for every listed ref name
|
||||
* @param payload Additional data to pass to the callback
|
||||
* @return 0 on success, non-zero callback return value, or error code
|
||||
*/
|
||||
GIT_EXTERN(int) git_reference_foreach_name(
|
||||
git_repository *repo,
|
||||
git_reference_foreach_name_cb callback,
|
||||
void *payload);
|
||||
|
||||
/**
|
||||
* Create a copy of an existing reference.
|
||||
*
|
||||
* Call `git_reference_free` to free the data.
|
||||
*
|
||||
* @param dest pointer where to store the copy
|
||||
* @param source object to copy
|
||||
* @return 0 or an error code
|
||||
*/
|
||||
GIT_EXTERN(int) git_reference_dup(git_reference **dest, git_reference *source);
|
||||
|
||||
/**
|
||||
* Free the given reference.
|
||||
*
|
||||
* @param ref git_reference
|
||||
*/
|
||||
GIT_EXTERN(void) git_reference_free(git_reference *ref);
|
||||
|
||||
/**
|
||||
* Compare two references.
|
||||
*
|
||||
* @param ref1 The first git_reference
|
||||
* @param ref2 The second git_reference
|
||||
* @return 0 if the same, else a stable but meaningless ordering.
|
||||
*/
|
||||
GIT_EXTERN(int) git_reference_cmp(
|
||||
const git_reference *ref1,
|
||||
const git_reference *ref2);
|
||||
|
||||
/**
|
||||
* Create an iterator for the repo's references
|
||||
*
|
||||
* @param out pointer in which to store the iterator
|
||||
* @param repo the repository
|
||||
* @return 0 or an error code
|
||||
*/
|
||||
GIT_EXTERN(int) git_reference_iterator_new(
|
||||
git_reference_iterator **out,
|
||||
git_repository *repo);
|
||||
|
||||
/**
|
||||
* Create an iterator for the repo's references that match the
|
||||
* specified glob
|
||||
*
|
||||
* @param out pointer in which to store the iterator
|
||||
* @param repo the repository
|
||||
* @param glob the glob to match against the reference names
|
||||
* @return 0 or an error code
|
||||
*/
|
||||
GIT_EXTERN(int) git_reference_iterator_glob_new(
|
||||
git_reference_iterator **out,
|
||||
git_repository *repo,
|
||||
const char *glob);
|
||||
|
||||
/**
|
||||
* Get the next reference
|
||||
*
|
||||
* @param out pointer in which to store the reference
|
||||
* @param iter the iterator
|
||||
* @return 0, GIT_ITEROVER if there are no more; or an error code
|
||||
*/
|
||||
GIT_EXTERN(int) git_reference_next(git_reference **out, git_reference_iterator *iter);
|
||||
|
||||
/**
|
||||
* Get the next reference's name
|
||||
*
|
||||
* This function is provided for convenience in case only the names
|
||||
* are interesting as it avoids the allocation of the `git_reference`
|
||||
* object which `git_reference_next()` needs.
|
||||
*
|
||||
* @param out pointer in which to store the string
|
||||
* @param iter the iterator
|
||||
* @return 0, GIT_ITEROVER if there are no more; or an error code
|
||||
*/
|
||||
GIT_EXTERN(int) git_reference_next_name(const char **out, git_reference_iterator *iter);
|
||||
|
||||
/**
|
||||
* Free the iterator and its associated resources
|
||||
*
|
||||
* @param iter the iterator to free
|
||||
*/
|
||||
GIT_EXTERN(void) git_reference_iterator_free(git_reference_iterator *iter);
|
||||
|
||||
/**
|
||||
* Perform a callback on each reference in the repository whose name
|
||||
* matches the given pattern.
|
||||
*
|
||||
* This function acts like `git_reference_foreach()` with an additional
|
||||
* pattern match being applied to the reference name before issuing the
|
||||
* callback function. See that function for more information.
|
||||
*
|
||||
* The pattern is matched using fnmatch or "glob" style where a '*' matches
|
||||
* any sequence of letters, a '?' matches any letter, and square brackets
|
||||
* can be used to define character ranges (such as "[0-9]" for digits).
|
||||
*
|
||||
* @param repo Repository where to find the refs
|
||||
* @param glob Pattern to match (fnmatch-style) against reference name.
|
||||
* @param callback Function which will be called for every listed ref
|
||||
* @param payload Additional data to pass to the callback
|
||||
* @return 0 on success, GIT_EUSER on non-zero callback, or error code
|
||||
*/
|
||||
GIT_EXTERN(int) git_reference_foreach_glob(
|
||||
git_repository *repo,
|
||||
const char *glob,
|
||||
git_reference_foreach_name_cb callback,
|
||||
void *payload);
|
||||
|
||||
/**
|
||||
* Check if a reflog exists for the specified reference.
|
||||
*
|
||||
* @param repo the repository
|
||||
* @param refname the reference's name
|
||||
* @return 0 when no reflog can be found, 1 when it exists;
|
||||
* otherwise an error code.
|
||||
*/
|
||||
GIT_EXTERN(int) git_reference_has_log(git_repository *repo, const char *refname);
|
||||
|
||||
/**
|
||||
* Ensure there is a reflog for a particular reference.
|
||||
*
|
||||
* Make sure that successive updates to the reference will append to
|
||||
* its log.
|
||||
*
|
||||
* @param repo the repository
|
||||
* @param refname the reference's name
|
||||
* @return 0 or an error code.
|
||||
*/
|
||||
GIT_EXTERN(int) git_reference_ensure_log(git_repository *repo, const char *refname);
|
||||
|
||||
/**
|
||||
* Check if a reference is a local branch.
|
||||
*
|
||||
* @param ref A git reference
|
||||
*
|
||||
* @return 1 when the reference lives in the refs/heads
|
||||
* namespace; 0 otherwise.
|
||||
*/
|
||||
GIT_EXTERN(int) git_reference_is_branch(const git_reference *ref);
|
||||
|
||||
/**
|
||||
* Check if a reference is a remote tracking branch
|
||||
*
|
||||
* @param ref A git reference
|
||||
*
|
||||
* @return 1 when the reference lives in the refs/remotes
|
||||
* namespace; 0 otherwise.
|
||||
*/
|
||||
GIT_EXTERN(int) git_reference_is_remote(const git_reference *ref);
|
||||
|
||||
/**
|
||||
* Check if a reference is a tag
|
||||
*
|
||||
* @param ref A git reference
|
||||
*
|
||||
* @return 1 when the reference lives in the refs/tags
|
||||
* namespace; 0 otherwise.
|
||||
*/
|
||||
GIT_EXTERN(int) git_reference_is_tag(const git_reference *ref);
|
||||
|
||||
/**
|
||||
* Check if a reference is a note
|
||||
*
|
||||
* @param ref A git reference
|
||||
*
|
||||
* @return 1 when the reference lives in the refs/notes
|
||||
* namespace; 0 otherwise.
|
||||
*/
|
||||
GIT_EXTERN(int) git_reference_is_note(const git_reference *ref);
|
||||
|
||||
/**
|
||||
* Normalization options for reference lookup
|
||||
*/
|
||||
typedef enum {
|
||||
/**
|
||||
* No particular normalization.
|
||||
*/
|
||||
GIT_REFERENCE_FORMAT_NORMAL = 0u,
|
||||
|
||||
/**
|
||||
* Control whether one-level refnames are accepted
|
||||
* (i.e., refnames that do not contain multiple /-separated
|
||||
* components). Those are expected to be written only using
|
||||
* uppercase letters and underscore (FETCH_HEAD, ...)
|
||||
*/
|
||||
GIT_REFERENCE_FORMAT_ALLOW_ONELEVEL = (1u << 0),
|
||||
|
||||
/**
|
||||
* Interpret the provided name as a reference pattern for a
|
||||
* refspec (as used with remote repositories). If this option
|
||||
* is enabled, the name is allowed to contain a single * (<star>)
|
||||
* in place of a one full pathname component
|
||||
* (e.g., foo/<star>/bar but not foo/bar<star>).
|
||||
*/
|
||||
GIT_REFERENCE_FORMAT_REFSPEC_PATTERN = (1u << 1),
|
||||
|
||||
/**
|
||||
* Interpret the name as part of a refspec in shorthand form
|
||||
* so the `ONELEVEL` naming rules aren't enforced and 'master'
|
||||
* becomes a valid name.
|
||||
*/
|
||||
GIT_REFERENCE_FORMAT_REFSPEC_SHORTHAND = (1u << 2)
|
||||
} git_reference_format_t;
|
||||
|
||||
/**
|
||||
* Normalize reference name and check validity.
|
||||
*
|
||||
* This will normalize the reference name by removing any leading slash
|
||||
* '/' characters and collapsing runs of adjacent slashes between name
|
||||
* components into a single slash.
|
||||
*
|
||||
* Once normalized, if the reference name is valid, it will be returned in
|
||||
* the user allocated buffer.
|
||||
*
|
||||
* See `git_reference_symbolic_create()` for rules about valid names.
|
||||
*
|
||||
* @param buffer_out User allocated buffer to store normalized name
|
||||
* @param buffer_size Size of buffer_out
|
||||
* @param name Reference name to be checked.
|
||||
* @param flags Flags to constrain name validation rules - see the
|
||||
* GIT_REFERENCE_FORMAT constants above.
|
||||
* @return 0 on success, GIT_EBUFS if buffer is too small, GIT_EINVALIDSPEC
|
||||
* or an error code.
|
||||
*/
|
||||
GIT_EXTERN(int) git_reference_normalize_name(
|
||||
char *buffer_out,
|
||||
size_t buffer_size,
|
||||
const char *name,
|
||||
unsigned int flags);
|
||||
|
||||
/**
|
||||
* Recursively peel reference until object of the specified type is found.
|
||||
*
|
||||
* The retrieved `peeled` object is owned by the repository
|
||||
* and should be closed with the `git_object_free` method.
|
||||
*
|
||||
* If you pass `GIT_OBJECT_ANY` as the target type, then the object
|
||||
* will be peeled until a non-tag object is met.
|
||||
*
|
||||
* @param out Pointer to the peeled git_object
|
||||
* @param ref The reference to be processed
|
||||
* @param type The type of the requested object (GIT_OBJECT_COMMIT,
|
||||
* GIT_OBJECT_TAG, GIT_OBJECT_TREE, GIT_OBJECT_BLOB or GIT_OBJECT_ANY).
|
||||
* @return 0 on success, GIT_EAMBIGUOUS, GIT_ENOTFOUND or an error code
|
||||
*/
|
||||
GIT_EXTERN(int) git_reference_peel(
|
||||
git_object **out,
|
||||
const git_reference *ref,
|
||||
git_object_t type);
|
||||
|
||||
/**
|
||||
* Ensure the reference name is well-formed.
|
||||
*
|
||||
* Valid reference names must follow one of two patterns:
|
||||
*
|
||||
* 1. Top-level names must contain only capital letters and underscores,
|
||||
* and must begin and end with a letter. (e.g. "HEAD", "ORIG_HEAD").
|
||||
* 2. Names prefixed with "refs/" can be almost anything. You must avoid
|
||||
* the characters '~', '^', ':', '\\', '?', '[', and '*', and the
|
||||
* sequences ".." and "@{" which have special meaning to revparse.
|
||||
*
|
||||
* @param valid output pointer to set with validity of given reference name
|
||||
* @param refname name to be checked.
|
||||
* @return 0 on success or an error code
|
||||
*/
|
||||
GIT_EXTERN(int) git_reference_name_is_valid(int *valid, const char *refname);
|
||||
|
||||
/**
|
||||
* Get the reference's short name
|
||||
*
|
||||
* This will transform the reference name into a name "human-readable"
|
||||
* version. If no shortname is appropriate, it will return the full
|
||||
* name.
|
||||
*
|
||||
* The memory is owned by the reference and must not be freed.
|
||||
*
|
||||
* @param ref a reference
|
||||
* @return the human-readable version of the name
|
||||
*/
|
||||
GIT_EXTERN(const char *) git_reference_shorthand(const git_reference *ref);
|
||||
|
||||
/** @} */
|
||||
GIT_END_DECL
|
||||
#endif
|
121
3rdparty/libgit2/include/git2/refspec.h
vendored
Normal file
121
3rdparty/libgit2/include/git2/refspec.h
vendored
Normal file
@ -0,0 +1,121 @@
|
||||
/*
|
||||
* Copyright (C) the libgit2 contributors. All rights reserved.
|
||||
*
|
||||
* This file is part of libgit2, distributed under the GNU GPL v2 with
|
||||
* a Linking Exception. For full terms see the included COPYING file.
|
||||
*/
|
||||
#ifndef INCLUDE_git_refspec_h__
|
||||
#define INCLUDE_git_refspec_h__
|
||||
|
||||
#include "common.h"
|
||||
#include "types.h"
|
||||
#include "net.h"
|
||||
#include "buffer.h"
|
||||
|
||||
/**
|
||||
* @file git2/refspec.h
|
||||
* @brief Git refspec attributes
|
||||
* @defgroup git_refspec Git refspec attributes
|
||||
* @ingroup Git
|
||||
* @{
|
||||
*/
|
||||
GIT_BEGIN_DECL
|
||||
|
||||
/**
|
||||
* Parse a given refspec string
|
||||
*
|
||||
* @param refspec a pointer to hold the refspec handle
|
||||
* @param input the refspec string
|
||||
* @param is_fetch is this a refspec for a fetch
|
||||
* @return 0 if the refspec string could be parsed, -1 otherwise
|
||||
*/
|
||||
GIT_EXTERN(int) git_refspec_parse(git_refspec **refspec, const char *input, int is_fetch);
|
||||
|
||||
/**
|
||||
* Free a refspec object which has been created by git_refspec_parse
|
||||
*
|
||||
* @param refspec the refspec object
|
||||
*/
|
||||
GIT_EXTERN(void) git_refspec_free(git_refspec *refspec);
|
||||
|
||||
/**
|
||||
* Get the source specifier
|
||||
*
|
||||
* @param refspec the refspec
|
||||
* @return the refspec's source specifier
|
||||
*/
|
||||
GIT_EXTERN(const char *) git_refspec_src(const git_refspec *refspec);
|
||||
|
||||
/**
|
||||
* Get the destination specifier
|
||||
*
|
||||
* @param refspec the refspec
|
||||
* @return the refspec's destination specifier
|
||||
*/
|
||||
GIT_EXTERN(const char *) git_refspec_dst(const git_refspec *refspec);
|
||||
|
||||
/**
|
||||
* Get the refspec's string
|
||||
*
|
||||
* @param refspec the refspec
|
||||
* @returns the refspec's original string
|
||||
*/
|
||||
GIT_EXTERN(const char *) git_refspec_string(const git_refspec *refspec);
|
||||
|
||||
/**
|
||||
* Get the force update setting
|
||||
*
|
||||
* @param refspec the refspec
|
||||
* @return 1 if force update has been set, 0 otherwise
|
||||
*/
|
||||
GIT_EXTERN(int) git_refspec_force(const git_refspec *refspec);
|
||||
|
||||
/**
|
||||
* Get the refspec's direction.
|
||||
*
|
||||
* @param spec refspec
|
||||
* @return GIT_DIRECTION_FETCH or GIT_DIRECTION_PUSH
|
||||
*/
|
||||
GIT_EXTERN(git_direction) git_refspec_direction(const git_refspec *spec);
|
||||
|
||||
/**
|
||||
* Check if a refspec's source descriptor matches a reference
|
||||
*
|
||||
* @param refspec the refspec
|
||||
* @param refname the name of the reference to check
|
||||
* @return 1 if the refspec matches, 0 otherwise
|
||||
*/
|
||||
GIT_EXTERN(int) git_refspec_src_matches(const git_refspec *refspec, const char *refname);
|
||||
|
||||
/**
|
||||
* Check if a refspec's destination descriptor matches a reference
|
||||
*
|
||||
* @param refspec the refspec
|
||||
* @param refname the name of the reference to check
|
||||
* @return 1 if the refspec matches, 0 otherwise
|
||||
*/
|
||||
GIT_EXTERN(int) git_refspec_dst_matches(const git_refspec *refspec, const char *refname);
|
||||
|
||||
/**
|
||||
* Transform a reference to its target following the refspec's rules
|
||||
*
|
||||
* @param out where to store the target name
|
||||
* @param spec the refspec
|
||||
* @param name the name of the reference to transform
|
||||
* @return 0, GIT_EBUFS or another error
|
||||
*/
|
||||
GIT_EXTERN(int) git_refspec_transform(git_buf *out, const git_refspec *spec, const char *name);
|
||||
|
||||
/**
|
||||
* Transform a target reference to its source reference following the refspec's rules
|
||||
*
|
||||
* @param out where to store the source reference name
|
||||
* @param spec the refspec
|
||||
* @param name the name of the reference to transform
|
||||
* @return 0, GIT_EBUFS or another error
|
||||
*/
|
||||
GIT_EXTERN(int) git_refspec_rtransform(git_buf *out, const git_refspec *spec, const char *name);
|
||||
|
||||
GIT_END_DECL
|
||||
|
||||
#endif
|
1195
3rdparty/libgit2/include/git2/remote.h
vendored
Normal file
1195
3rdparty/libgit2/include/git2/remote.h
vendored
Normal file
File diff suppressed because it is too large
Load Diff
996
3rdparty/libgit2/include/git2/repository.h
vendored
Normal file
996
3rdparty/libgit2/include/git2/repository.h
vendored
Normal file
@ -0,0 +1,996 @@
|
||||
/*
|
||||
* Copyright (C) the libgit2 contributors. All rights reserved.
|
||||
*
|
||||
* This file is part of libgit2, distributed under the GNU GPL v2 with
|
||||
* a Linking Exception. For full terms see the included COPYING file.
|
||||
*/
|
||||
#ifndef INCLUDE_git_repository_h__
|
||||
#define INCLUDE_git_repository_h__
|
||||
|
||||
#include "common.h"
|
||||
#include "types.h"
|
||||
#include "oid.h"
|
||||
#include "buffer.h"
|
||||
#include "commit.h"
|
||||
|
||||
/**
|
||||
* @file git2/repository.h
|
||||
* @brief Git repository management routines
|
||||
* @defgroup git_repository Git repository management routines
|
||||
* @ingroup Git
|
||||
* @{
|
||||
*/
|
||||
GIT_BEGIN_DECL
|
||||
|
||||
/**
|
||||
* Open a git repository.
|
||||
*
|
||||
* The 'path' argument must point to either a git repository
|
||||
* folder, or an existing work dir.
|
||||
*
|
||||
* The method will automatically detect if 'path' is a normal
|
||||
* or bare repository or fail is 'path' is neither.
|
||||
*
|
||||
* @param out pointer to the repo which will be opened
|
||||
* @param path the path to the repository
|
||||
* @return 0 or an error code
|
||||
*/
|
||||
GIT_EXTERN(int) git_repository_open(git_repository **out, const char *path);
|
||||
/**
|
||||
* Open working tree as a repository
|
||||
*
|
||||
* Open the working directory of the working tree as a normal
|
||||
* repository that can then be worked on.
|
||||
*
|
||||
* @param out Output pointer containing opened repository
|
||||
* @param wt Working tree to open
|
||||
* @return 0 or an error code
|
||||
*/
|
||||
GIT_EXTERN(int) git_repository_open_from_worktree(git_repository **out, git_worktree *wt);
|
||||
|
||||
/**
|
||||
* Create a "fake" repository to wrap an object database
|
||||
*
|
||||
* Create a repository object to wrap an object database to be used
|
||||
* with the API when all you have is an object database. This doesn't
|
||||
* have any paths associated with it, so use with care.
|
||||
*
|
||||
* @param out pointer to the repo
|
||||
* @param odb the object database to wrap
|
||||
* @param oid_type the oid type of the object database
|
||||
* @return 0 or an error code
|
||||
*/
|
||||
#ifdef GIT_EXPERIMENTAL_SHA256
|
||||
GIT_EXTERN(int) git_repository_wrap_odb(
|
||||
git_repository **out,
|
||||
git_odb *odb,
|
||||
git_oid_t oid_type);
|
||||
#else
|
||||
GIT_EXTERN(int) git_repository_wrap_odb(
|
||||
git_repository **out,
|
||||
git_odb *odb);
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Look for a git repository and copy its path in the given buffer.
|
||||
* The lookup start from base_path and walk across parent directories
|
||||
* if nothing has been found. The lookup ends when the first repository
|
||||
* is found, or when reaching a directory referenced in ceiling_dirs
|
||||
* or when the filesystem changes (in case across_fs is true).
|
||||
*
|
||||
* The method will automatically detect if the repository is bare
|
||||
* (if there is a repository).
|
||||
*
|
||||
* @param out A pointer to a user-allocated git_buf which will contain
|
||||
* the found path.
|
||||
*
|
||||
* @param start_path The base path where the lookup starts.
|
||||
*
|
||||
* @param across_fs If true, then the lookup will not stop when a
|
||||
* filesystem device change is detected while exploring parent directories.
|
||||
*
|
||||
* @param ceiling_dirs A GIT_PATH_LIST_SEPARATOR separated list of
|
||||
* absolute symbolic link free paths. The lookup will stop when any
|
||||
* of this paths is reached. Note that the lookup always performs on
|
||||
* start_path no matter start_path appears in ceiling_dirs ceiling_dirs
|
||||
* might be NULL (which is equivalent to an empty string)
|
||||
*
|
||||
* @return 0 or an error code
|
||||
*/
|
||||
GIT_EXTERN(int) git_repository_discover(
|
||||
git_buf *out,
|
||||
const char *start_path,
|
||||
int across_fs,
|
||||
const char *ceiling_dirs);
|
||||
|
||||
/**
|
||||
* Option flags for `git_repository_open_ext`.
|
||||
*/
|
||||
typedef enum {
|
||||
/**
|
||||
* Only open the repository if it can be immediately found in the
|
||||
* start_path. Do not walk up from the start_path looking at parent
|
||||
* directories.
|
||||
*/
|
||||
GIT_REPOSITORY_OPEN_NO_SEARCH = (1 << 0),
|
||||
|
||||
/**
|
||||
* Unless this flag is set, open will not continue searching across
|
||||
* filesystem boundaries (i.e. when `st_dev` changes from the `stat`
|
||||
* system call). For example, searching in a user's home directory at
|
||||
* "/home/user/source/" will not return "/.git/" as the found repo if
|
||||
* "/" is a different filesystem than "/home".
|
||||
*/
|
||||
GIT_REPOSITORY_OPEN_CROSS_FS = (1 << 1),
|
||||
|
||||
/**
|
||||
* Open repository as a bare repo regardless of core.bare config, and
|
||||
* defer loading config file for faster setup.
|
||||
* Unlike `git_repository_open_bare`, this can follow gitlinks.
|
||||
*/
|
||||
GIT_REPOSITORY_OPEN_BARE = (1 << 2),
|
||||
|
||||
/**
|
||||
* Do not check for a repository by appending /.git to the start_path;
|
||||
* only open the repository if start_path itself points to the git
|
||||
* directory.
|
||||
*/
|
||||
GIT_REPOSITORY_OPEN_NO_DOTGIT = (1 << 3),
|
||||
|
||||
/**
|
||||
* Find and open a git repository, respecting the environment variables
|
||||
* used by the git command-line tools.
|
||||
* If set, `git_repository_open_ext` will ignore the other flags and
|
||||
* the `ceiling_dirs` argument, and will allow a NULL `path` to use
|
||||
* `GIT_DIR` or search from the current directory.
|
||||
* The search for a repository will respect $GIT_CEILING_DIRECTORIES and
|
||||
* $GIT_DISCOVERY_ACROSS_FILESYSTEM. The opened repository will
|
||||
* respect $GIT_INDEX_FILE, $GIT_NAMESPACE, $GIT_OBJECT_DIRECTORY, and
|
||||
* $GIT_ALTERNATE_OBJECT_DIRECTORIES.
|
||||
* In the future, this flag will also cause `git_repository_open_ext`
|
||||
* to respect $GIT_WORK_TREE and $GIT_COMMON_DIR; currently,
|
||||
* `git_repository_open_ext` with this flag will error out if either
|
||||
* $GIT_WORK_TREE or $GIT_COMMON_DIR is set.
|
||||
*/
|
||||
GIT_REPOSITORY_OPEN_FROM_ENV = (1 << 4)
|
||||
} git_repository_open_flag_t;
|
||||
|
||||
/**
|
||||
* Find and open a repository with extended controls.
|
||||
*
|
||||
* @param out Pointer to the repo which will be opened. This can
|
||||
* actually be NULL if you only want to use the error code to
|
||||
* see if a repo at this path could be opened.
|
||||
* @param path Path to open as git repository. If the flags
|
||||
* permit "searching", then this can be a path to a subdirectory
|
||||
* inside the working directory of the repository. May be NULL if
|
||||
* flags is GIT_REPOSITORY_OPEN_FROM_ENV.
|
||||
* @param flags A combination of the GIT_REPOSITORY_OPEN flags above.
|
||||
* @param ceiling_dirs A GIT_PATH_LIST_SEPARATOR delimited list of path
|
||||
* prefixes at which the search for a containing repository should
|
||||
* terminate.
|
||||
* @return 0 on success, GIT_ENOTFOUND if no repository could be found,
|
||||
* or -1 if there was a repository but open failed for some reason
|
||||
* (such as repo corruption or system errors).
|
||||
*/
|
||||
GIT_EXTERN(int) git_repository_open_ext(
|
||||
git_repository **out,
|
||||
const char *path,
|
||||
unsigned int flags,
|
||||
const char *ceiling_dirs);
|
||||
|
||||
/**
|
||||
* Open a bare repository on the serverside.
|
||||
*
|
||||
* This is a fast open for bare repositories that will come in handy
|
||||
* if you're e.g. hosting git repositories and need to access them
|
||||
* efficiently
|
||||
*
|
||||
* @param out Pointer to the repo which will be opened.
|
||||
* @param bare_path Direct path to the bare repository
|
||||
* @return 0 on success, or an error code
|
||||
*/
|
||||
GIT_EXTERN(int) git_repository_open_bare(git_repository **out, const char *bare_path);
|
||||
|
||||
/**
|
||||
* Free a previously allocated repository
|
||||
*
|
||||
* Note that after a repository is free'd, all the objects it has spawned
|
||||
* will still exist until they are manually closed by the user
|
||||
* with `git_object_free`, but accessing any of the attributes of
|
||||
* an object without a backing repository will result in undefined
|
||||
* behavior
|
||||
*
|
||||
* @param repo repository handle to close. If NULL nothing occurs.
|
||||
*/
|
||||
GIT_EXTERN(void) git_repository_free(git_repository *repo);
|
||||
|
||||
/**
|
||||
* Creates a new Git repository in the given folder.
|
||||
*
|
||||
* TODO:
|
||||
* - Reinit the repository
|
||||
*
|
||||
* @param out pointer to the repo which will be created or reinitialized
|
||||
* @param path the path to the repository
|
||||
* @param is_bare if true, a Git repository without a working directory is
|
||||
* created at the pointed path. If false, provided path will be
|
||||
* considered as the working directory into which the .git directory
|
||||
* will be created.
|
||||
*
|
||||
* @return 0 or an error code
|
||||
*/
|
||||
GIT_EXTERN(int) git_repository_init(
|
||||
git_repository **out,
|
||||
const char *path,
|
||||
unsigned is_bare);
|
||||
|
||||
/**
|
||||
* Option flags for `git_repository_init_ext`.
|
||||
*
|
||||
* These flags configure extra behaviors to `git_repository_init_ext`.
|
||||
* In every case, the default behavior is the zero value (i.e. flag is
|
||||
* not set). Just OR the flag values together for the `flags` parameter
|
||||
* when initializing a new repo.
|
||||
*/
|
||||
typedef enum {
|
||||
/**
|
||||
* Create a bare repository with no working directory.
|
||||
*/
|
||||
GIT_REPOSITORY_INIT_BARE = (1u << 0),
|
||||
|
||||
/**
|
||||
* Return an GIT_EEXISTS error if the repo_path appears to already be
|
||||
* an git repository.
|
||||
*/
|
||||
GIT_REPOSITORY_INIT_NO_REINIT = (1u << 1),
|
||||
|
||||
/**
|
||||
* Normally a "/.git/" will be appended to the repo path for
|
||||
* non-bare repos (if it is not already there), but passing this flag
|
||||
* prevents that behavior.
|
||||
*/
|
||||
GIT_REPOSITORY_INIT_NO_DOTGIT_DIR = (1u << 2),
|
||||
|
||||
/**
|
||||
* Make the repo_path (and workdir_path) as needed. Init is always willing
|
||||
* to create the ".git" directory even without this flag. This flag tells
|
||||
* init to create the trailing component of the repo and workdir paths
|
||||
* as needed.
|
||||
*/
|
||||
GIT_REPOSITORY_INIT_MKDIR = (1u << 3),
|
||||
|
||||
/**
|
||||
* Recursively make all components of the repo and workdir paths as
|
||||
* necessary.
|
||||
*/
|
||||
GIT_REPOSITORY_INIT_MKPATH = (1u << 4),
|
||||
|
||||
/**
|
||||
* libgit2 normally uses internal templates to initialize a new repo.
|
||||
* This flags enables external templates, looking the "template_path" from
|
||||
* the options if set, or the `init.templatedir` global config if not,
|
||||
* or falling back on "/usr/share/git-core/templates" if it exists.
|
||||
*/
|
||||
GIT_REPOSITORY_INIT_EXTERNAL_TEMPLATE = (1u << 5),
|
||||
|
||||
/**
|
||||
* If an alternate workdir is specified, use relative paths for the gitdir
|
||||
* and core.worktree.
|
||||
*/
|
||||
GIT_REPOSITORY_INIT_RELATIVE_GITLINK = (1u << 6)
|
||||
} git_repository_init_flag_t;
|
||||
|
||||
/**
|
||||
* Mode options for `git_repository_init_ext`.
|
||||
*
|
||||
* Set the mode field of the `git_repository_init_options` structure
|
||||
* either to the custom mode that you would like, or to one of the
|
||||
* defined modes.
|
||||
*/
|
||||
typedef enum {
|
||||
/**
|
||||
* Use permissions configured by umask - the default.
|
||||
*/
|
||||
GIT_REPOSITORY_INIT_SHARED_UMASK = 0,
|
||||
|
||||
/**
|
||||
* Use "--shared=group" behavior, chmod'ing the new repo to be group
|
||||
* writable and "g+sx" for sticky group assignment.
|
||||
*/
|
||||
GIT_REPOSITORY_INIT_SHARED_GROUP = 0002775,
|
||||
|
||||
/**
|
||||
* Use "--shared=all" behavior, adding world readability.
|
||||
*/
|
||||
GIT_REPOSITORY_INIT_SHARED_ALL = 0002777
|
||||
} git_repository_init_mode_t;
|
||||
|
||||
/**
|
||||
* Extended options structure for `git_repository_init_ext`.
|
||||
*
|
||||
* This contains extra options for `git_repository_init_ext` that enable
|
||||
* additional initialization features.
|
||||
*/
|
||||
typedef struct {
|
||||
unsigned int version;
|
||||
|
||||
/**
|
||||
* Combination of GIT_REPOSITORY_INIT flags above.
|
||||
*/
|
||||
uint32_t flags;
|
||||
|
||||
/**
|
||||
* Set to one of the standard GIT_REPOSITORY_INIT_SHARED_... constants
|
||||
* above, or to a custom value that you would like.
|
||||
*/
|
||||
uint32_t mode;
|
||||
|
||||
/**
|
||||
* The path to the working dir or NULL for default (i.e. repo_path parent
|
||||
* on non-bare repos). IF THIS IS RELATIVE PATH, IT WILL BE EVALUATED
|
||||
* RELATIVE TO THE REPO_PATH. If this is not the "natural" working
|
||||
* directory, a .git gitlink file will be created here linking to the
|
||||
* repo_path.
|
||||
*/
|
||||
const char *workdir_path;
|
||||
|
||||
/**
|
||||
* If set, this will be used to initialize the "description" file in the
|
||||
* repository, instead of using the template content.
|
||||
*/
|
||||
const char *description;
|
||||
|
||||
/**
|
||||
* When GIT_REPOSITORY_INIT_EXTERNAL_TEMPLATE is set, this contains
|
||||
* the path to use for the template directory. If this is NULL, the config
|
||||
* or default directory options will be used instead.
|
||||
*/
|
||||
const char *template_path;
|
||||
|
||||
/**
|
||||
* The name of the head to point HEAD at. If NULL, then this will be
|
||||
* treated as "master" and the HEAD ref will be set to "refs/heads/master".
|
||||
* If this begins with "refs/" it will be used verbatim;
|
||||
* otherwise "refs/heads/" will be prefixed.
|
||||
*/
|
||||
const char *initial_head;
|
||||
|
||||
/**
|
||||
* If this is non-NULL, then after the rest of the repository
|
||||
* initialization is completed, an "origin" remote will be added
|
||||
* pointing to this URL.
|
||||
*/
|
||||
const char *origin_url;
|
||||
|
||||
#ifdef GIT_EXPERIMENTAL_SHA256
|
||||
/**
|
||||
*
|
||||
* Type of object IDs to use for this repository, or 0 for
|
||||
* default (currently SHA1).
|
||||
*/
|
||||
git_oid_t oid_type;
|
||||
#endif
|
||||
} git_repository_init_options;
|
||||
|
||||
#define GIT_REPOSITORY_INIT_OPTIONS_VERSION 1
|
||||
#define GIT_REPOSITORY_INIT_OPTIONS_INIT {GIT_REPOSITORY_INIT_OPTIONS_VERSION}
|
||||
|
||||
/**
|
||||
* Initialize git_repository_init_options structure
|
||||
*
|
||||
* Initializes a `git_repository_init_options` with default values. Equivalent to
|
||||
* creating an instance with `GIT_REPOSITORY_INIT_OPTIONS_INIT`.
|
||||
*
|
||||
* @param opts The `git_repository_init_options` struct to initialize.
|
||||
* @param version The struct version; pass `GIT_REPOSITORY_INIT_OPTIONS_VERSION`.
|
||||
* @return Zero on success; -1 on failure.
|
||||
*/
|
||||
GIT_EXTERN(int) git_repository_init_options_init(
|
||||
git_repository_init_options *opts,
|
||||
unsigned int version);
|
||||
|
||||
/**
|
||||
* Create a new Git repository in the given folder with extended controls.
|
||||
*
|
||||
* This will initialize a new git repository (creating the repo_path
|
||||
* if requested by flags) and working directory as needed. It will
|
||||
* auto-detect the case sensitivity of the file system and if the
|
||||
* file system supports file mode bits correctly.
|
||||
*
|
||||
* @param out Pointer to the repo which will be created or reinitialized.
|
||||
* @param repo_path The path to the repository.
|
||||
* @param opts Pointer to git_repository_init_options struct.
|
||||
* @return 0 or an error code on failure.
|
||||
*/
|
||||
GIT_EXTERN(int) git_repository_init_ext(
|
||||
git_repository **out,
|
||||
const char *repo_path,
|
||||
git_repository_init_options *opts);
|
||||
|
||||
/**
|
||||
* Retrieve and resolve the reference pointed at by HEAD.
|
||||
*
|
||||
* The returned `git_reference` will be owned by caller and
|
||||
* `git_reference_free()` must be called when done with it to release the
|
||||
* allocated memory and prevent a leak.
|
||||
*
|
||||
* @param out pointer to the reference which will be retrieved
|
||||
* @param repo a repository object
|
||||
*
|
||||
* @return 0 on success, GIT_EUNBORNBRANCH when HEAD points to a non existing
|
||||
* branch, GIT_ENOTFOUND when HEAD is missing; an error code otherwise
|
||||
*/
|
||||
GIT_EXTERN(int) git_repository_head(git_reference **out, git_repository *repo);
|
||||
|
||||
/**
|
||||
* Retrieve the referenced HEAD for the worktree
|
||||
*
|
||||
* @param out pointer to the reference which will be retrieved
|
||||
* @param repo a repository object
|
||||
* @param name name of the worktree to retrieve HEAD for
|
||||
* @return 0 when successful, error-code otherwise
|
||||
*/
|
||||
GIT_EXTERN(int) git_repository_head_for_worktree(git_reference **out, git_repository *repo,
|
||||
const char *name);
|
||||
|
||||
/**
|
||||
* Check if a repository's HEAD is detached
|
||||
*
|
||||
* A repository's HEAD is detached when it points directly to a commit
|
||||
* instead of a branch.
|
||||
*
|
||||
* @param repo Repo to test
|
||||
* @return 1 if HEAD is detached, 0 if it's not; error code if there
|
||||
* was an error.
|
||||
*/
|
||||
GIT_EXTERN(int) git_repository_head_detached(git_repository *repo);
|
||||
|
||||
/**
|
||||
* Check if a worktree's HEAD is detached
|
||||
*
|
||||
* A worktree's HEAD is detached when it points directly to a
|
||||
* commit instead of a branch.
|
||||
*
|
||||
* @param repo a repository object
|
||||
* @param name name of the worktree to retrieve HEAD for
|
||||
* @return 1 if HEAD is detached, 0 if its not; error code if
|
||||
* there was an error
|
||||
*/
|
||||
GIT_EXTERN(int) git_repository_head_detached_for_worktree(git_repository *repo,
|
||||
const char *name);
|
||||
|
||||
/**
|
||||
* Check if the current branch is unborn
|
||||
*
|
||||
* An unborn branch is one named from HEAD but which doesn't exist in
|
||||
* the refs namespace, because it doesn't have any commit to point to.
|
||||
*
|
||||
* @param repo Repo to test
|
||||
* @return 1 if the current branch is unborn, 0 if it's not; error
|
||||
* code if there was an error
|
||||
*/
|
||||
GIT_EXTERN(int) git_repository_head_unborn(git_repository *repo);
|
||||
|
||||
/**
|
||||
* Check if a repository is empty
|
||||
*
|
||||
* An empty repository has just been initialized and contains no references
|
||||
* apart from HEAD, which must be pointing to the unborn master branch,
|
||||
* or the branch specified for the repository in the `init.defaultBranch`
|
||||
* configuration variable.
|
||||
*
|
||||
* @param repo Repo to test
|
||||
* @return 1 if the repository is empty, 0 if it isn't, error code
|
||||
* if the repository is corrupted
|
||||
*/
|
||||
GIT_EXTERN(int) git_repository_is_empty(git_repository *repo);
|
||||
|
||||
/**
|
||||
* List of items which belong to the git repository layout
|
||||
*/
|
||||
typedef enum {
|
||||
GIT_REPOSITORY_ITEM_GITDIR,
|
||||
GIT_REPOSITORY_ITEM_WORKDIR,
|
||||
GIT_REPOSITORY_ITEM_COMMONDIR,
|
||||
GIT_REPOSITORY_ITEM_INDEX,
|
||||
GIT_REPOSITORY_ITEM_OBJECTS,
|
||||
GIT_REPOSITORY_ITEM_REFS,
|
||||
GIT_REPOSITORY_ITEM_PACKED_REFS,
|
||||
GIT_REPOSITORY_ITEM_REMOTES,
|
||||
GIT_REPOSITORY_ITEM_CONFIG,
|
||||
GIT_REPOSITORY_ITEM_INFO,
|
||||
GIT_REPOSITORY_ITEM_HOOKS,
|
||||
GIT_REPOSITORY_ITEM_LOGS,
|
||||
GIT_REPOSITORY_ITEM_MODULES,
|
||||
GIT_REPOSITORY_ITEM_WORKTREES,
|
||||
GIT_REPOSITORY_ITEM_WORKTREE_CONFIG,
|
||||
GIT_REPOSITORY_ITEM__LAST
|
||||
} git_repository_item_t;
|
||||
|
||||
/**
|
||||
* Get the location of a specific repository file or directory
|
||||
*
|
||||
* This function will retrieve the path of a specific repository
|
||||
* item. It will thereby honor things like the repository's
|
||||
* common directory, gitdir, etc. In case a file path cannot
|
||||
* exist for a given item (e.g. the working directory of a bare
|
||||
* repository), GIT_ENOTFOUND is returned.
|
||||
*
|
||||
* @param out Buffer to store the path at
|
||||
* @param repo Repository to get path for
|
||||
* @param item The repository item for which to retrieve the path
|
||||
* @return 0, GIT_ENOTFOUND if the path cannot exist or an error code
|
||||
*/
|
||||
GIT_EXTERN(int) git_repository_item_path(git_buf *out, const git_repository *repo, git_repository_item_t item);
|
||||
|
||||
/**
|
||||
* Get the path of this repository
|
||||
*
|
||||
* This is the path of the `.git` folder for normal repositories,
|
||||
* or of the repository itself for bare repositories.
|
||||
*
|
||||
* @param repo A repository object
|
||||
* @return the path to the repository
|
||||
*/
|
||||
GIT_EXTERN(const char *) git_repository_path(const git_repository *repo);
|
||||
|
||||
/**
|
||||
* Get the path of the working directory for this repository
|
||||
*
|
||||
* If the repository is bare, this function will always return
|
||||
* NULL.
|
||||
*
|
||||
* @param repo A repository object
|
||||
* @return the path to the working dir, if it exists
|
||||
*/
|
||||
GIT_EXTERN(const char *) git_repository_workdir(const git_repository *repo);
|
||||
|
||||
/**
|
||||
* Get the path of the shared common directory for this repository.
|
||||
*
|
||||
* If the repository is bare, it is the root directory for the repository.
|
||||
* If the repository is a worktree, it is the parent repo's gitdir.
|
||||
* Otherwise, it is the gitdir.
|
||||
*
|
||||
* @param repo A repository object
|
||||
* @return the path to the common dir
|
||||
*/
|
||||
GIT_EXTERN(const char *) git_repository_commondir(const git_repository *repo);
|
||||
|
||||
/**
|
||||
* Set the path to the working directory for this repository
|
||||
*
|
||||
* The working directory doesn't need to be the same one
|
||||
* that contains the `.git` folder for this repository.
|
||||
*
|
||||
* If this repository is bare, setting its working directory
|
||||
* will turn it into a normal repository, capable of performing
|
||||
* all the common workdir operations (checkout, status, index
|
||||
* manipulation, etc).
|
||||
*
|
||||
* @param repo A repository object
|
||||
* @param workdir The path to a working directory
|
||||
* @param update_gitlink Create/update gitlink in workdir and set config
|
||||
* "core.worktree" (if workdir is not the parent of the .git directory)
|
||||
* @return 0, or an error code
|
||||
*/
|
||||
GIT_EXTERN(int) git_repository_set_workdir(
|
||||
git_repository *repo, const char *workdir, int update_gitlink);
|
||||
|
||||
/**
|
||||
* Check if a repository is bare
|
||||
*
|
||||
* @param repo Repo to test
|
||||
* @return 1 if the repository is bare, 0 otherwise.
|
||||
*/
|
||||
GIT_EXTERN(int) git_repository_is_bare(const git_repository *repo);
|
||||
|
||||
/**
|
||||
* Check if a repository is a linked work tree
|
||||
*
|
||||
* @param repo Repo to test
|
||||
* @return 1 if the repository is a linked work tree, 0 otherwise.
|
||||
*/
|
||||
GIT_EXTERN(int) git_repository_is_worktree(const git_repository *repo);
|
||||
|
||||
/**
|
||||
* Get the configuration file for this repository.
|
||||
*
|
||||
* If a configuration file has not been set, the default
|
||||
* config set for the repository will be returned, including
|
||||
* global and system configurations (if they are available).
|
||||
*
|
||||
* The configuration file must be freed once it's no longer
|
||||
* being used by the user.
|
||||
*
|
||||
* @param out Pointer to store the loaded configuration
|
||||
* @param repo A repository object
|
||||
* @return 0, or an error code
|
||||
*/
|
||||
GIT_EXTERN(int) git_repository_config(git_config **out, git_repository *repo);
|
||||
|
||||
/**
|
||||
* Get a snapshot of the repository's configuration
|
||||
*
|
||||
* Convenience function to take a snapshot from the repository's
|
||||
* configuration. The contents of this snapshot will not change,
|
||||
* even if the underlying config files are modified.
|
||||
*
|
||||
* The configuration file must be freed once it's no longer
|
||||
* being used by the user.
|
||||
*
|
||||
* @param out Pointer to store the loaded configuration
|
||||
* @param repo the repository
|
||||
* @return 0, or an error code
|
||||
*/
|
||||
GIT_EXTERN(int) git_repository_config_snapshot(git_config **out, git_repository *repo);
|
||||
|
||||
/**
|
||||
* Get the Object Database for this repository.
|
||||
*
|
||||
* If a custom ODB has not been set, the default
|
||||
* database for the repository will be returned (the one
|
||||
* located in `.git/objects`).
|
||||
*
|
||||
* The ODB must be freed once it's no longer being used by
|
||||
* the user.
|
||||
*
|
||||
* @param out Pointer to store the loaded ODB
|
||||
* @param repo A repository object
|
||||
* @return 0, or an error code
|
||||
*/
|
||||
GIT_EXTERN(int) git_repository_odb(git_odb **out, git_repository *repo);
|
||||
|
||||
/**
|
||||
* Get the Reference Database Backend for this repository.
|
||||
*
|
||||
* If a custom refsdb has not been set, the default database for
|
||||
* the repository will be returned (the one that manipulates loose
|
||||
* and packed references in the `.git` directory).
|
||||
*
|
||||
* The refdb must be freed once it's no longer being used by
|
||||
* the user.
|
||||
*
|
||||
* @param out Pointer to store the loaded refdb
|
||||
* @param repo A repository object
|
||||
* @return 0, or an error code
|
||||
*/
|
||||
GIT_EXTERN(int) git_repository_refdb(git_refdb **out, git_repository *repo);
|
||||
|
||||
/**
|
||||
* Get the Index file for this repository.
|
||||
*
|
||||
* If a custom index has not been set, the default
|
||||
* index for the repository will be returned (the one
|
||||
* located in `.git/index`).
|
||||
*
|
||||
* The index must be freed once it's no longer being used by
|
||||
* the user.
|
||||
*
|
||||
* @param out Pointer to store the loaded index
|
||||
* @param repo A repository object
|
||||
* @return 0, or an error code
|
||||
*/
|
||||
GIT_EXTERN(int) git_repository_index(git_index **out, git_repository *repo);
|
||||
|
||||
/**
|
||||
* Retrieve git's prepared message
|
||||
*
|
||||
* Operations such as git revert/cherry-pick/merge with the -n option
|
||||
* stop just short of creating a commit with the changes and save
|
||||
* their prepared message in .git/MERGE_MSG so the next git-commit
|
||||
* execution can present it to the user for them to amend if they
|
||||
* wish.
|
||||
*
|
||||
* Use this function to get the contents of this file. Don't forget to
|
||||
* remove the file after you create the commit.
|
||||
*
|
||||
* @param out git_buf to write data into
|
||||
* @param repo Repository to read prepared message from
|
||||
* @return 0, GIT_ENOTFOUND if no message exists or an error code
|
||||
*/
|
||||
GIT_EXTERN(int) git_repository_message(git_buf *out, git_repository *repo);
|
||||
|
||||
/**
|
||||
* Remove git's prepared message.
|
||||
*
|
||||
* Remove the message that `git_repository_message` retrieves.
|
||||
*
|
||||
* @param repo Repository to remove prepared message from.
|
||||
* @return 0 or an error code.
|
||||
*/
|
||||
GIT_EXTERN(int) git_repository_message_remove(git_repository *repo);
|
||||
|
||||
/**
|
||||
* Remove all the metadata associated with an ongoing command like merge,
|
||||
* revert, cherry-pick, etc. For example: MERGE_HEAD, MERGE_MSG, etc.
|
||||
*
|
||||
* @param repo A repository object
|
||||
* @return 0 on success, or error
|
||||
*/
|
||||
GIT_EXTERN(int) git_repository_state_cleanup(git_repository *repo);
|
||||
|
||||
/**
|
||||
* Callback used to iterate over each FETCH_HEAD entry
|
||||
*
|
||||
* @see git_repository_fetchhead_foreach
|
||||
*
|
||||
* @param ref_name The reference name
|
||||
* @param remote_url The remote URL
|
||||
* @param oid The reference target OID
|
||||
* @param is_merge Was the reference the result of a merge
|
||||
* @param payload Payload passed to git_repository_fetchhead_foreach
|
||||
* @return non-zero to terminate the iteration
|
||||
*/
|
||||
typedef int GIT_CALLBACK(git_repository_fetchhead_foreach_cb)(const char *ref_name,
|
||||
const char *remote_url,
|
||||
const git_oid *oid,
|
||||
unsigned int is_merge,
|
||||
void *payload);
|
||||
|
||||
/**
|
||||
* Invoke 'callback' for each entry in the given FETCH_HEAD file.
|
||||
*
|
||||
* Return a non-zero value from the callback to stop the loop.
|
||||
*
|
||||
* @param repo A repository object
|
||||
* @param callback Callback function
|
||||
* @param payload Pointer to callback data (optional)
|
||||
* @return 0 on success, non-zero callback return value, GIT_ENOTFOUND if
|
||||
* there is no FETCH_HEAD file, or other error code.
|
||||
*/
|
||||
GIT_EXTERN(int) git_repository_fetchhead_foreach(
|
||||
git_repository *repo,
|
||||
git_repository_fetchhead_foreach_cb callback,
|
||||
void *payload);
|
||||
|
||||
/**
|
||||
* Callback used to iterate over each MERGE_HEAD entry
|
||||
*
|
||||
* @see git_repository_mergehead_foreach
|
||||
*
|
||||
* @param oid The merge OID
|
||||
* @param payload Payload passed to git_repository_mergehead_foreach
|
||||
* @return non-zero to terminate the iteration
|
||||
*/
|
||||
typedef int GIT_CALLBACK(git_repository_mergehead_foreach_cb)(const git_oid *oid,
|
||||
void *payload);
|
||||
|
||||
/**
|
||||
* If a merge is in progress, invoke 'callback' for each commit ID in the
|
||||
* MERGE_HEAD file.
|
||||
*
|
||||
* Return a non-zero value from the callback to stop the loop.
|
||||
*
|
||||
* @param repo A repository object
|
||||
* @param callback Callback function
|
||||
* @param payload Pointer to callback data (optional)
|
||||
* @return 0 on success, non-zero callback return value, GIT_ENOTFOUND if
|
||||
* there is no MERGE_HEAD file, or other error code.
|
||||
*/
|
||||
GIT_EXTERN(int) git_repository_mergehead_foreach(
|
||||
git_repository *repo,
|
||||
git_repository_mergehead_foreach_cb callback,
|
||||
void *payload);
|
||||
|
||||
/**
|
||||
* Calculate hash of file using repository filtering rules.
|
||||
*
|
||||
* If you simply want to calculate the hash of a file on disk with no filters,
|
||||
* you can just use the `git_odb_hashfile()` API. However, if you want to
|
||||
* hash a file in the repository and you want to apply filtering rules (e.g.
|
||||
* crlf filters) before generating the SHA, then use this function.
|
||||
*
|
||||
* Note: if the repository has `core.safecrlf` set to fail and the
|
||||
* filtering triggers that failure, then this function will return an
|
||||
* error and not calculate the hash of the file.
|
||||
*
|
||||
* @param out Output value of calculated SHA
|
||||
* @param repo Repository pointer
|
||||
* @param path Path to file on disk whose contents should be hashed. This
|
||||
* may be an absolute path or a relative path, in which case it
|
||||
* will be treated as a path within the working directory.
|
||||
* @param type The object type to hash as (e.g. GIT_OBJECT_BLOB)
|
||||
* @param as_path The path to use to look up filtering rules. If this is
|
||||
* an empty string then no filters will be applied when
|
||||
* calculating the hash. If this is `NULL` and the `path`
|
||||
* parameter is a file within the repository's working
|
||||
* directory, then the `path` will be used.
|
||||
* @return 0 on success, or an error code
|
||||
*/
|
||||
GIT_EXTERN(int) git_repository_hashfile(
|
||||
git_oid *out,
|
||||
git_repository *repo,
|
||||
const char *path,
|
||||
git_object_t type,
|
||||
const char *as_path);
|
||||
|
||||
/**
|
||||
* Make the repository HEAD point to the specified reference.
|
||||
*
|
||||
* If the provided reference points to a Tree or a Blob, the HEAD is
|
||||
* unaltered and -1 is returned.
|
||||
*
|
||||
* If the provided reference points to a branch, the HEAD will point
|
||||
* to that branch, staying attached, or become attached if it isn't yet.
|
||||
* If the branch doesn't exist yet, no error will be return. The HEAD
|
||||
* will then be attached to an unborn branch.
|
||||
*
|
||||
* Otherwise, the HEAD will be detached and will directly point to
|
||||
* the Commit.
|
||||
*
|
||||
* @param repo Repository pointer
|
||||
* @param refname Canonical name of the reference the HEAD should point at
|
||||
* @return 0 on success, or an error code
|
||||
*/
|
||||
GIT_EXTERN(int) git_repository_set_head(
|
||||
git_repository *repo,
|
||||
const char *refname);
|
||||
|
||||
/**
|
||||
* Make the repository HEAD directly point to the Commit.
|
||||
*
|
||||
* If the provided committish cannot be found in the repository, the HEAD
|
||||
* is unaltered and GIT_ENOTFOUND is returned.
|
||||
*
|
||||
* If the provided committish cannot be peeled into a commit, the HEAD
|
||||
* is unaltered and -1 is returned.
|
||||
*
|
||||
* Otherwise, the HEAD will eventually be detached and will directly point to
|
||||
* the peeled Commit.
|
||||
*
|
||||
* @param repo Repository pointer
|
||||
* @param committish Object id of the Commit the HEAD should point to
|
||||
* @return 0 on success, or an error code
|
||||
*/
|
||||
GIT_EXTERN(int) git_repository_set_head_detached(
|
||||
git_repository *repo,
|
||||
const git_oid *committish);
|
||||
|
||||
/**
|
||||
* Make the repository HEAD directly point to the Commit.
|
||||
*
|
||||
* This behaves like `git_repository_set_head_detached()` but takes an
|
||||
* annotated commit, which lets you specify which extended sha syntax
|
||||
* string was specified by a user, allowing for more exact reflog
|
||||
* messages.
|
||||
*
|
||||
* See the documentation for `git_repository_set_head_detached()`.
|
||||
*
|
||||
* @see git_repository_set_head_detached
|
||||
*/
|
||||
GIT_EXTERN(int) git_repository_set_head_detached_from_annotated(
|
||||
git_repository *repo,
|
||||
const git_annotated_commit *committish);
|
||||
|
||||
/**
|
||||
* Detach the HEAD.
|
||||
*
|
||||
* If the HEAD is already detached and points to a Commit, 0 is returned.
|
||||
*
|
||||
* If the HEAD is already detached and points to a Tag, the HEAD is
|
||||
* updated into making it point to the peeled Commit, and 0 is returned.
|
||||
*
|
||||
* If the HEAD is already detached and points to a non committish, the HEAD is
|
||||
* unaltered, and -1 is returned.
|
||||
*
|
||||
* Otherwise, the HEAD will be detached and point to the peeled Commit.
|
||||
*
|
||||
* @param repo Repository pointer
|
||||
* @return 0 on success, GIT_EUNBORNBRANCH when HEAD points to a non existing
|
||||
* branch or an error code
|
||||
*/
|
||||
GIT_EXTERN(int) git_repository_detach_head(
|
||||
git_repository *repo);
|
||||
|
||||
/**
|
||||
* Repository state
|
||||
*
|
||||
* These values represent possible states for the repository to be in,
|
||||
* based on the current operation which is ongoing.
|
||||
*/
|
||||
typedef enum {
|
||||
GIT_REPOSITORY_STATE_NONE,
|
||||
GIT_REPOSITORY_STATE_MERGE,
|
||||
GIT_REPOSITORY_STATE_REVERT,
|
||||
GIT_REPOSITORY_STATE_REVERT_SEQUENCE,
|
||||
GIT_REPOSITORY_STATE_CHERRYPICK,
|
||||
GIT_REPOSITORY_STATE_CHERRYPICK_SEQUENCE,
|
||||
GIT_REPOSITORY_STATE_BISECT,
|
||||
GIT_REPOSITORY_STATE_REBASE,
|
||||
GIT_REPOSITORY_STATE_REBASE_INTERACTIVE,
|
||||
GIT_REPOSITORY_STATE_REBASE_MERGE,
|
||||
GIT_REPOSITORY_STATE_APPLY_MAILBOX,
|
||||
GIT_REPOSITORY_STATE_APPLY_MAILBOX_OR_REBASE
|
||||
} git_repository_state_t;
|
||||
|
||||
/**
|
||||
* Determines the status of a git repository - ie, whether an operation
|
||||
* (merge, cherry-pick, etc) is in progress.
|
||||
*
|
||||
* @param repo Repository pointer
|
||||
* @return The state of the repository
|
||||
*/
|
||||
GIT_EXTERN(int) git_repository_state(git_repository *repo);
|
||||
|
||||
/**
|
||||
* Sets the active namespace for this Git Repository
|
||||
*
|
||||
* This namespace affects all reference operations for the repo.
|
||||
* See `man gitnamespaces`
|
||||
*
|
||||
* @param repo The repo
|
||||
* @param nmspace The namespace. This should not include the refs
|
||||
* folder, e.g. to namespace all references under `refs/namespaces/foo/`,
|
||||
* use `foo` as the namespace.
|
||||
* @return 0 on success, -1 on error
|
||||
*/
|
||||
GIT_EXTERN(int) git_repository_set_namespace(git_repository *repo, const char *nmspace);
|
||||
|
||||
/**
|
||||
* Get the currently active namespace for this repository
|
||||
*
|
||||
* @param repo The repo
|
||||
* @return the active namespace, or NULL if there isn't one
|
||||
*/
|
||||
GIT_EXTERN(const char *) git_repository_get_namespace(git_repository *repo);
|
||||
|
||||
|
||||
/**
|
||||
* Determine if the repository was a shallow clone
|
||||
*
|
||||
* @param repo The repository
|
||||
* @return 1 if shallow, zero if not
|
||||
*/
|
||||
GIT_EXTERN(int) git_repository_is_shallow(git_repository *repo);
|
||||
|
||||
/**
|
||||
* Retrieve the configured identity to use for reflogs
|
||||
*
|
||||
* The memory is owned by the repository and must not be freed by the
|
||||
* user.
|
||||
*
|
||||
* @param name where to store the pointer to the name
|
||||
* @param email where to store the pointer to the email
|
||||
* @param repo the repository
|
||||
* @return 0 or an error code
|
||||
*/
|
||||
GIT_EXTERN(int) git_repository_ident(const char **name, const char **email, const git_repository *repo);
|
||||
|
||||
/**
|
||||
* Set the identity to be used for writing reflogs
|
||||
*
|
||||
* If both are set, this name and email will be used to write to the
|
||||
* reflog. Pass NULL to unset. When unset, the identity will be taken
|
||||
* from the repository's configuration.
|
||||
*
|
||||
* @param repo the repository to configure
|
||||
* @param name the name to use for the reflog entries
|
||||
* @param email the email to use for the reflog entries
|
||||
* @return 0 or an error code.
|
||||
*/
|
||||
GIT_EXTERN(int) git_repository_set_ident(git_repository *repo, const char *name, const char *email);
|
||||
|
||||
/**
|
||||
* Gets the object type used by this repository.
|
||||
*
|
||||
* @param repo the repository
|
||||
* @return the object id type
|
||||
*/
|
||||
GIT_EXTERN(git_oid_t) git_repository_oid_type(git_repository *repo);
|
||||
|
||||
/**
|
||||
* Gets the parents of the next commit, given the current repository state.
|
||||
* Generally, this is the HEAD commit, except when performing a merge, in
|
||||
* which case it is two or more commits.
|
||||
*
|
||||
* @param commits a `git_commitarray` that will contain the commit parents
|
||||
* @param repo the repository
|
||||
* @return 0 or an error code
|
||||
*/
|
||||
GIT_EXTERN(int) git_repository_commit_parents(git_commitarray *commits, git_repository *repo);
|
||||
|
||||
/** @} */
|
||||
GIT_END_DECL
|
||||
#endif
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user