Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
85dd425
refs: handle ORIG_HEAD via the refdb
pks-t Jul 14, 2025
ee55d24
refs: handle REVERT_HEAD via the refdb
pks-t Jul 14, 2025
5740985
refs: handle CHERRY_PICK_HEAD via the refdb
pks-t Jul 14, 2025
96a418d
refs: rename GIT_STASH_FILE to indicate this is a ref
pks-t Jul 14, 2025
bfb1959
refs: introduce GIT_HEAD_REF define
pks-t Jul 14, 2025
3e82367
repository: only consider repo-level config to read repo format
pks-t Jul 21, 2025
4dac4f0
repository: wire up refStorage extension
pks-t Feb 6, 2025
be52a46
repository: allow initialization with a specific refdb type
pks-t Jul 11, 2025
fc68ee3
tests: refactor test to not circumvent the refdb when writing HEAD
pks-t Jul 11, 2025
8fcaec5
refdb: initialize on-disk data structures via the backend
pks-t Jul 11, 2025
10413fe
tests/clar: introduce `cl_repo_has_ref_format()`
pks-t Jul 29, 2025
79b3919
tests/libgit2: don't access refs via filesystem
pks-t Jul 29, 2025
6a51b9c
tests/libgit2: don't overwrite config when testing conditionals
pks-t Jul 29, 2025
60e21fb
tests/libgit2: conditional checks for the "files"-backend
pks-t Jul 29, 2025
c0b1b40
refdb_fs: defer reading the configuration
pks-t Jul 14, 2025
6cf6c8e
config_file: use the refdb to evaluate "onbranch" condition
pks-t Jul 14, 2025
c40dd7d
refdb_fs: expose function to read a loose ref
pks-t Jul 14, 2025
4d310f3
refs: always read pseudorefs as loose refs
pks-t Jul 14, 2025
d7fc1cd
Merge branch 'pks-refformat-extension' into HEAD
pks-t Aug 4, 2025
db25710
Merge branch 'pks-refdb-pseudorefs' into HEAD
pks-t Aug 4, 2025
d4ea2f3
Merge branch 'pks-test-fixes-for-reftables' into HEAD
pks-t Aug 4, 2025
1d1d1d5
deps: import reftable library
pks-t Feb 6, 2025
f891151
deps/reftable: implement system compatibility code
pks-t Jul 4, 2025
b7eaf6f
deps/reftable: drop Git-specific QSORT macro in the writer code
pks-t Jul 4, 2025
adb54c2
deps/reftable: fix compiler warning due to missing braces
pks-t Jul 7, 2025
736a75a
deps/reftable: wire up library with CMake
pks-t Jul 4, 2025
52b0ece
deps/reftable: allow passing flags to `reftable_stack_add()`
pks-t Aug 1, 2025
0abd1a6
deps/reftable: fix for concurrent compaction
pks-t Aug 4, 2025
cf19c24
deps/reftable: don't second-guess errors from flock interface
pks-t Aug 4, 2025
a5cc370
deps/reftable: don't assume `inline` to be available
pks-t Aug 4, 2025
c9a7198
deps/reftable: provide mmap and munap via system.h
pks-t Aug 5, 2025
d4f3862
deps/reftable: allow providing fstat(3p) at all
pks-t Aug 4, 2025
9b24d21
deps/reftable: allow providing sleeping-related functions
pks-t Aug 5, 2025
f7b9d26
deps/reftable: don't use fsync(3p) if none was provided
pks-t Aug 5, 2025
76a102c
deps/reftable: fix "unknown size" warning with MSVC
pks-t Aug 5, 2025
57d35b4
deps/reftable: fix type used for number of records
pks-t Aug 5, 2025
318dedf
deps/reftable: consistently include reftable-basics.h
pks-t Aug 5, 2025
1831e12
refdb: implement reftable backend
pks-t Feb 6, 2025
08d8620
refdb: wire up "reftable" storage format
pks-t Jul 11, 2025
b6196ab
tests: generate test resources for reftables
pks-t Jul 22, 2025
dd1ff7d
tests: wire up reftable tests
pks-t Jul 22, 2025
b122fb0
github: wire up reftable tests
pks-t Aug 4, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
The diff you're trying to view is too large. We only load the first 3000 changed files.
37 changes: 37 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,43 @@ jobs:
SKIP_SSH_TESTS: true
SKIP_NEGOTIATE_TESTS: true

# All builds: reftable
- name: "Linux (Noble, GCC, OpenSSL, libssh2, reftable)"
id: noble-gcc-openssl-reftable
os: ubuntu-latest
container:
name: noble
env:
CC: gcc
CLAR_REF_FORMAT: reftable
CMAKE_GENERATOR: Ninja
CMAKE_OPTIONS: -DUSE_HTTPS=OpenSSL -DREGEX_BACKEND=builtin -DDEPRECATE_HARD=ON -DDEBUG_LEAK_CHECKER=valgrind -DUSE_GSSAPI=ON -DUSE_SSH=libssh2 -DDEBUG_STRICT_ALLOC=ON -DDEBUG_STRICT_OPEN=ON
- name: "macOS (reftable)"
id: macos-reftable
os: macos-13
setup-script: osx
env:
CC: clang
CLAR_REF_FORMAT: reftable
CMAKE_OPTIONS: -DREGEX_BACKEND=regcomp_l -DDEPRECATE_HARD=ON -DDEBUG_LEAK_CHECKER=leaks -DUSE_GSSAPI=ON
CMAKE_GENERATOR: Ninja
PKG_CONFIG_PATH: /usr/local/opt/openssl/lib/pkgconfig
SKIP_SSH_TESTS: true
SKIP_NEGOTIATE_TESTS: true
- name: "Windows (amd64, Visual Studio, Schannel, reftable)"
id: windows-amd64-vs-reftable
os: windows-2022
setup-script: win32
env:
ARCH: amd64
CLAR_REF_FORMAT: reftable
CMAKE_GENERATOR: Visual Studio 17 2022
CMAKE_OPTIONS: -A x64 -DDEBUG_LEAK_CHECKER=win32 -DDEPRECATE_HARD=ON -DUSE_HTTPS=Schannel -DUSE_SSH=ON -DCMAKE_PREFIX_PATH=D:\Temp\libssh2
BUILD_PATH: C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Program Files (x86)\CMake\bin;D:\Temp\libssh2\bin
BUILD_TEMP: D:\Temp
SKIP_SSH_TESTS: true
SKIP_NEGOTIATE_TESTS: true

# All builds: sanitizers
- name: "Sanitizer (Memory)"
id: sanitizer-memory
Expand Down
29 changes: 29 additions & 0 deletions deps/reftable/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
add_library(reftable OBJECT ${SRC_REFTABLE})

disable_warnings(implicit-fallthrough)

file(GLOB SRC_REFTABLE "*.c" "*.h")
list(SORT SRC_REFTABLE)

set_property(TARGET reftable PROPERTY C_STANDARD 99)
target_sources(reftable PRIVATE ${SRC_REFTABLE})
target_include_directories(reftable PRIVATE
include
"${PROJECT_BINARY_DIR}/src/util"
"${PROJECT_BINARY_DIR}/include"
"${PROJECT_SOURCE_DIR}/src/util"
"${PROJECT_SOURCE_DIR}/include"
${LIBGIT2_DEPENDENCY_INCLUDES}
${LIBGIT2_SYSTEM_INCLUDES}
)

# The reftable library is not warning-free, so we disable turning warnings into
# errors.
if(MSVC)
set_source_files_properties(block.c PROPERTIES COMPILE_FLAGS -WX-)
set_source_files_properties(blocksource.c PROPERTIES COMPILE_FLAGS -WX-)
set_source_files_properties(record.c PROPERTIES COMPILE_FLAGS -WX-)
set_source_files_properties(stack.c PROPERTIES COMPILE_FLAGS -WX-)
set_source_files_properties(table.c PROPERTIES COMPILE_FLAGS -WX-)
set_source_files_properties(writer.c PROPERTIES COMPILE_FLAGS -WX-)
endif()
31 changes: 31 additions & 0 deletions deps/reftable/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
BSD License

Copyright (c) 2020, Google LLC
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:

* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.

* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.

* Neither the name of Google LLC nor the names of its contributors may
be used to endorse or promote products derived from this software
without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
267 changes: 267 additions & 0 deletions deps/reftable/basics.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,267 @@
/*
* Copyright 2020 Google LLC
*
* Use of this source code is governed by a BSD-style
* license that can be found in the LICENSE file or at
* https://developers.google.com/open-source/licenses/bsd
*/

#define REFTABLE_ALLOW_BANNED_ALLOCATORS
#include "basics.h"
#include "reftable-basics.h"
#include "reftable-error.h"

static void *(*reftable_malloc_ptr)(size_t sz);
static void *(*reftable_realloc_ptr)(void *, size_t);
static void (*reftable_free_ptr)(void *);

void *reftable_malloc(size_t sz)
{
if (!sz)
return NULL;
if (reftable_malloc_ptr)
return (*reftable_malloc_ptr)(sz);
return malloc(sz);
}

void *reftable_realloc(void *p, size_t sz)
{
if (!sz) {
reftable_free(p);
return NULL;
}

if (reftable_realloc_ptr)
return (*reftable_realloc_ptr)(p, sz);
return realloc(p, sz);
}

void reftable_free(void *p)
{
if (reftable_free_ptr)
reftable_free_ptr(p);
else
free(p);
}

void *reftable_calloc(size_t nelem, size_t elsize)
{
void *p;

if (nelem && elsize > SIZE_MAX / nelem)
return NULL;

p = reftable_malloc(nelem * elsize);
if (!p)
return NULL;

memset(p, 0, nelem * elsize);
return p;
}

char *reftable_strdup(const char *str)
{
size_t len = strlen(str);
char *result = reftable_malloc(len + 1);
if (!result)
return NULL;
memcpy(result, str, len + 1);
return result;
}

void reftable_set_alloc(void *(*malloc)(size_t),
void *(*realloc)(void *, size_t), void (*free)(void *))
{
reftable_malloc_ptr = malloc;
reftable_realloc_ptr = realloc;
reftable_free_ptr = free;
}

void reftable_buf_init(struct reftable_buf *buf)
{
struct reftable_buf empty = REFTABLE_BUF_INIT;
*buf = empty;
}

void reftable_buf_release(struct reftable_buf *buf)
{
reftable_free(buf->buf);
reftable_buf_init(buf);
}

void reftable_buf_reset(struct reftable_buf *buf)
{
if (buf->alloc) {
buf->len = 0;
buf->buf[0] = '\0';
}
}

int reftable_buf_setlen(struct reftable_buf *buf, size_t len)
{
if (len > buf->len)
return -1;
if (len == buf->len)
return 0;
buf->buf[len] = '\0';
buf->len = len;
return 0;
}

int reftable_buf_cmp(const struct reftable_buf *a, const struct reftable_buf *b)
{
size_t len = a->len < b->len ? a->len : b->len;
if (len) {
int cmp = memcmp(a->buf, b->buf, len);
if (cmp)
return cmp;
}
return a->len < b->len ? -1 : a->len != b->len;
}

int reftable_buf_add(struct reftable_buf *buf, const void *data, size_t len)
{
size_t newlen = buf->len + len;

if (newlen + 1 > buf->alloc) {
if (REFTABLE_ALLOC_GROW(buf->buf, newlen + 1, buf->alloc))
return REFTABLE_OUT_OF_MEMORY_ERROR;
}

memcpy(buf->buf + buf->len, data, len);
buf->buf[newlen] = '\0';
buf->len = newlen;

return 0;
}

int reftable_buf_addstr(struct reftable_buf *buf, const char *s)
{
return reftable_buf_add(buf, s, strlen(s));
}

char *reftable_buf_detach(struct reftable_buf *buf)
{
char *result = buf->buf;
reftable_buf_init(buf);
return result;
}

size_t binsearch(size_t sz, int (*f)(size_t k, void *args), void *args)
{
size_t lo = 0;
size_t hi = sz;

/* Invariants:
*
* (hi == sz) || f(hi) == true
* (lo == 0 && f(0) == true) || fi(lo) == false
*/
while (hi - lo > 1) {
size_t mid = lo + (hi - lo) / 2;
int ret = f(mid, args);
if (ret < 0)
return sz;

if (ret > 0)
hi = mid;
else
lo = mid;
}

if (lo)
return hi;

return f(0, args) ? 0 : 1;
}

void free_names(char **a)
{
char **p;
if (!a) {
return;
}
for (p = a; *p; p++) {
reftable_free(*p);
}
reftable_free(a);
}

size_t names_length(const char **names)
{
const char **p = names;
while (*p)
p++;
return p - names;
}

char **parse_names(char *buf, int size)
{
char **names = NULL;
size_t names_cap = 0;
size_t names_len = 0;
char *p = buf;
char *end = buf + size;

while (p < end) {
char *next = strchr(p, '\n');
if (next && next < end) {
*next = 0;
} else {
next = end;
}
if (p < next) {
if (REFTABLE_ALLOC_GROW(names, names_len + 1,
names_cap))
goto err;

names[names_len] = reftable_strdup(p);
if (!names[names_len++])
goto err;
}
p = next + 1;
}

if (REFTABLE_ALLOC_GROW(names, names_len + 1, names_cap))
goto err;
names[names_len] = NULL;

return names;

err:
for (size_t i = 0; i < names_len; i++)
reftable_free(names[i]);
reftable_free(names);
return NULL;
}

int names_equal(const char **a, const char **b)
{
size_t i = 0;
for (; a[i] && b[i]; i++)
if (strcmp(a[i], b[i]))
return 0;
return a[i] == b[i];
}

size_t common_prefix_size(struct reftable_buf *a, struct reftable_buf *b)
{
size_t p = 0;
for (; p < a->len && p < b->len; p++)
if (a->buf[p] != b->buf[p])
break;
return p;
}

uint32_t hash_size(enum reftable_hash id)
{
if (!id)
return REFTABLE_HASH_SIZE_SHA1;
switch (id) {
case REFTABLE_HASH_SHA1:
return REFTABLE_HASH_SIZE_SHA1;
case REFTABLE_HASH_SHA256:
return REFTABLE_HASH_SIZE_SHA256;
}
abort();
}
Loading
Loading