Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
1944e07
Merge branch 'ss/revert-builtin-bswap-stuff' into ss/compat-bswap-revamp
gitster Jun 12, 2025
14d7583
config: remove unneeded struct field
phillipwood Jul 15, 2025
a6b0070
Merge branch 'bc/use-sha256-by-default-in-3.0' into kl/test-installed…
gitster Jul 15, 2025
d79f8c6
test-lib: respect GIT_TEST_INSTALLED when querying default hash
spectral54 Jul 15, 2025
f1b8524
bswap.h: add support for __BYTE_ORDER__
sebastianas Jul 15, 2025
30dea7d
bswap.h: define GIT_LITTLE_ENDIAN on msvc as little endian
sebastianas Jul 15, 2025
4544cd1
bswap.h: always overwrite ntohl/ ntohll macros
sebastianas Jul 15, 2025
0132f11
bswap.h: remove optimized x86 version of bswap32/64
sebastianas Jul 15, 2025
f4ac32c
bswap.h: provide a built-in based version of bswap32/64 if possible
sebastianas Jul 15, 2025
586919c
meson: fix installation when -Dlibexexdir is set
ramsay-jones Jul 15, 2025
056dbe8
po/meson.build: add missing 'ga' language code
ramsay-jones Jul 15, 2025
1f0fed3
SubmittingPatches: allow non-real name contributions
bk2204 Jul 16, 2025
bfa405e
CodingGuidelines: allow the use of bool
phillipwood Jul 16, 2025
f3ba426
git-compat-util: convert string predicates to return bool
phillipwood Jul 16, 2025
f006e03
strbuf: convert predicates to return bool
phillipwood Jul 16, 2025
5ce9702
Merge branch 'pw/adopt-c99-bool-officially'
gitster Jul 24, 2025
79c64eb
Merge branch 'kl/test-installed-fix'
gitster Jul 24, 2025
0686fa4
Merge branch 'pw/config-kvi-remove-path'
gitster Jul 24, 2025
42eb288
Merge branch 'ss/compat-bswap-revamp'
gitster Jul 24, 2025
8c7817c
Merge branch 'rj/meson-libexecdir-fix'
gitster Jul 24, 2025
422a522
Merge branch 'bc/contribution-under-non-real-names'
gitster Jul 24, 2025
e4ef048
The fourteenth batch
gitster Jul 24, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Documentation/CodingGuidelines
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,9 @@ For C programs:
. since late 2021 with 44ba10d6, we have had variables declared in
the for loop "for (int i = 0; i < 10; i++)".

. since late 2023 with 8277dbe987 we have been using the bool type
from <stdbool.h>.

New C99 features that we cannot use yet:

. %z and %zu as a printf() argument for a size_t (the %z being for
Expand Down
18 changes: 18 additions & 0 deletions Documentation/RelNotes/2.51.0.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,12 @@ Performance, Internal Implementation, Development Support etc.
* Flipping the default hash function to SHA-256 at Git 3.0 boundary
is planned.

* Declare weather-balloon we raised for "bool" type 18 months ago a
success and officially allow using the type in our codebase.

* GIT_TEST_INSTALLED was not honored in the recent topic related to
SHA256 hashes, which has been corrected.


Fixes since v2.50
-----------------
Expand Down Expand Up @@ -208,6 +214,17 @@ including security updates, are included in this release.
<sane-ctype.h> ourselves.
(merge 9d3b33125f ps/sane-ctype-workaround later to maint).

* Clean-up compat/bswap.h mess.
(merge f4ac32c03a ss/compat-bswap-revamp later to maint).

* Meson-based build did not handle libexecdir setting correctly,
which has been corrected.
(merge 056dbe8612 rj/meson-libexecdir-fix later to maint).

* Document that we do not require "real" name when signing your
patches off.
(merge 1f0fed312a bc/contribution-under-non-real-names later to maint).

* Other code cleanup, docfix, build fix, etc.
(merge b257adb571 lo/my-first-ow-doc-update later to maint).
(merge 8b34b6a220 ly/sequencer-update-squash-is-fixup-only later to maint).
Expand All @@ -233,3 +250,4 @@ including security updates, are included in this release.
(merge ad7780b38f ps/doc-pack-refs-auto-with-files-backend-fix later to maint).
(merge f4fa8a3687 rh/doc-glob-pathspec-fix later to maint).
(merge b27be108c8 ja/doc-git-log-markup later to maint).
(merge 14d7583beb pw/config-kvi-remove-path later to maint).
11 changes: 9 additions & 2 deletions Documentation/SubmittingPatches
Original file line number Diff line number Diff line change
Expand Up @@ -408,8 +408,15 @@ your patch differs from project to project, so it may be different
from that of the project you are accustomed to.

[[real-name]]
Also notice that a real name is used in the `Signed-off-by` trailer. Please
don't hide your real name.
Please use a known identity in the `Signed-off-by` trailer, since we cannot
accept anonymous contributions. It is common, but not required, to use some form
of your real name. We realize that some contributors are not comfortable doing
so or prefer to contribute under a pseudonym or preferred name and we can accept
your patch either way, as long as the name and email you use are distinctive,
identifying, and not misleading.

The goal of this policy is to allow us to have sufficient information to contact
you if questions arise about your contribution.

[[commit-trailers]]
If you like, you can put extra trailers at the end:
Expand Down
110 changes: 46 additions & 64 deletions compat/bswap.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,78 +32,35 @@ static inline uint64_t default_bswap64(uint64_t val)
((val & (uint64_t)0xff00000000000000ULL) >> 56));
}

/*
* __has_builtin is available since Clang 10 and GCC 10.
* Below is a fallback for older compilers.
*/
#ifndef __has_builtin
# define __has_builtin(x) 0
#endif

#undef bswap32
#undef bswap64

#if defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__))

#define bswap32 git_bswap32
static inline uint32_t git_bswap32(uint32_t x)
{
uint32_t result;
if (__builtin_constant_p(x))
result = default_swab32(x);
else
__asm__("bswap %0" : "=r" (result) : "0" (x));
return result;
}

#define bswap64 git_bswap64
#if defined(__x86_64__)
static inline uint64_t git_bswap64(uint64_t x)
{
uint64_t result;
if (__builtin_constant_p(x))
result = default_bswap64(x);
else
__asm__("bswap %q0" : "=r" (result) : "0" (x));
return result;
}
#else
static inline uint64_t git_bswap64(uint64_t x)
{
union { uint64_t i64; uint32_t i32[2]; } tmp, result;
if (__builtin_constant_p(x))
result.i64 = default_bswap64(x);
else {
tmp.i64 = x;
result.i32[0] = git_bswap32(tmp.i32[1]);
result.i32[1] = git_bswap32(tmp.i32[0]);
}
return result.i64;
}
#endif

#elif defined(_MSC_VER) && (defined(_M_IX86) || defined(_M_X64) || defined(_M_ARM64))
#if defined(_MSC_VER) && (defined(_M_IX86) || defined(_M_X64) || defined(_M_ARM64))

#include <stdlib.h>

#define bswap32(x) _byteswap_ulong(x)
#define bswap64(x) _byteswap_uint64(x)

#endif
#define GIT_LITTLE_ENDIAN 1234
#define GIT_BIG_ENDIAN 4321
#define GIT_BYTE_ORDER GIT_LITTLE_ENDIAN

#if defined(bswap32)
#elif __has_builtin(__builtin_bswap32) && __has_builtin(__builtin_bswap64)

#undef ntohl
#undef htonl
#define ntohl(x) bswap32(x)
#define htonl(x) bswap32(x)
#define bswap32(x) __builtin_bswap32((x))
#define bswap64(x) __builtin_bswap64((x))

#endif

#if defined(bswap64)

#undef ntohll
#undef htonll
#define ntohll(x) bswap64(x)
#define htonll(x) bswap64(x)

#else

#undef ntohll
#undef htonll

#if defined(__BYTE_ORDER) && defined(__LITTLE_ENDIAN) && defined(__BIG_ENDIAN)

# define GIT_BYTE_ORDER __BYTE_ORDER
Expand All @@ -116,7 +73,13 @@ static inline uint64_t git_bswap64(uint64_t x)
# define GIT_LITTLE_ENDIAN LITTLE_ENDIAN
# define GIT_BIG_ENDIAN BIG_ENDIAN

#else
#elif defined(__BYTE_ORDER__) && defined(__ORDER_LITTLE_ENDIAN__) && defined(__ORDER_BIG_ENDIAN__)

# define GIT_BYTE_ORDER __BYTE_ORDER__
# define GIT_LITTLE_ENDIAN __ORDER_LITTLE_ENDIAN__
# define GIT_BIG_ENDIAN __ORDER_BIG_ENDIAN__

#elif !defined(GIT_BYTE_ORDER)

# define GIT_BIG_ENDIAN 4321
# define GIT_LITTLE_ENDIAN 1234
Expand All @@ -135,14 +98,33 @@ static inline uint64_t git_bswap64(uint64_t x)

#endif

#undef ntohl
#undef htonl
#undef ntohll
#undef htonll

#if GIT_BYTE_ORDER == GIT_BIG_ENDIAN
# define ntohll(n) (n)
# define htonll(n) (n)
# define ntohl(x) (x)
# define htonl(x) (x)
# define ntohll(x) (x)
# define htonll(x) (x)
#else
# define ntohll(n) default_bswap64(n)
# define htonll(n) default_bswap64(n)
#endif

# if defined(bswap32)
# define ntohl(x) bswap32(x)
# define htonl(x) bswap32(x)
# else
# define ntohl(x) default_swab32(x)
# define htonl(x) default_swab32(x)
# endif

# if defined(bswap64)
# define ntohll(x) bswap64(x)
# define htonll(x) bswap64(x)
# else
# define ntohll(x) default_bswap64(x)
# define htonll(x) default_bswap64(x)
# endif
#endif

static inline uint16_t get_be16(const void *ptr)
Expand Down
28 changes: 13 additions & 15 deletions config.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ struct config_source {
} u;
enum config_origin_type origin_type;
const char *name;
const char *path;
enum config_error_action default_error_action;
int linenr;
int eof;
Expand Down Expand Up @@ -173,14 +172,14 @@ static int handle_path_include(const struct key_value_info *kvi,
if (!is_absolute_path(path)) {
char *slash;

if (!kvi || !kvi->path) {
if (!kvi || kvi->origin_type != CONFIG_ORIGIN_FILE) {
ret = error(_("relative config includes must come from files"));
goto cleanup;
}

slash = find_last_dir_sep(kvi->path);
slash = find_last_dir_sep(kvi->filename);
if (slash)
strbuf_add(&buf, kvi->path, slash - kvi->path + 1);
strbuf_add(&buf, kvi->filename, slash - kvi->filename + 1);
strbuf_addstr(&buf, path);
path = buf.buf;
}
Expand Down Expand Up @@ -224,11 +223,11 @@ static int prepare_include_condition_pattern(const struct key_value_info *kvi,
if (pat->buf[0] == '.' && is_dir_sep(pat->buf[1])) {
const char *slash;

if (!kvi || !kvi->path)
if (!kvi || kvi->origin_type != CONFIG_ORIGIN_FILE)
return error(_("relative config include "
"conditionals must come from files"));

strbuf_realpath(&path, kvi->path, 1);
strbuf_realpath(&path, kvi->filename, 1);
slash = find_last_dir_sep(path.buf);
if (!slash)
BUG("how is this possible?");
Expand Down Expand Up @@ -633,7 +632,6 @@ void kvi_from_param(struct key_value_info *out)
out->linenr = -1;
out->origin_type = CONFIG_ORIGIN_CMDLINE;
out->scope = CONFIG_SCOPE_COMMAND;
out->path = NULL;
}

int git_config_parse_parameter(const char *text,
Expand Down Expand Up @@ -1036,7 +1034,6 @@ static void kvi_from_source(struct config_source *cs,
out->origin_type = cs->origin_type;
out->linenr = cs->linenr;
out->scope = scope;
out->path = cs->path;
}

static int git_parse_source(struct config_source *cs, config_fn_t fn,
Expand Down Expand Up @@ -1850,17 +1847,19 @@ static int do_config_from(struct config_source *top, config_fn_t fn,

static int do_config_from_file(config_fn_t fn,
const enum config_origin_type origin_type,
const char *name, const char *path, FILE *f,
void *data, enum config_scope scope,
const char *name, FILE *f, void *data,
enum config_scope scope,
const struct config_options *opts)
{
struct config_source top = CONFIG_SOURCE_INIT;
int ret;

if (origin_type == CONFIG_ORIGIN_FILE && (!name || !*name))
BUG("missing filename for CONFIG_ORIGIN_FILE");

top.u.file = f;
top.origin_type = origin_type;
top.name = name;
top.path = path;
top.default_error_action = CONFIG_ERROR_DIE;
top.do_fgetc = config_file_fgetc;
top.do_ungetc = config_file_ungetc;
Expand All @@ -1875,8 +1874,8 @@ static int do_config_from_file(config_fn_t fn,
static int git_config_from_stdin(config_fn_t fn, void *data,
enum config_scope scope)
{
return do_config_from_file(fn, CONFIG_ORIGIN_STDIN, "", NULL, stdin,
data, scope, NULL);
return do_config_from_file(fn, CONFIG_ORIGIN_STDIN, "", stdin, data,
scope, NULL);
}

int git_config_from_file_with_options(config_fn_t fn, const char *filename,
Expand All @@ -1891,7 +1890,7 @@ int git_config_from_file_with_options(config_fn_t fn, const char *filename,
f = fopen_or_warn(filename, "r");
if (f) {
ret = do_config_from_file(fn, CONFIG_ORIGIN_FILE, filename,
filename, f, data, scope, opts);
f, data, scope, opts);
fclose(f);
}
return ret;
Expand All @@ -1916,7 +1915,6 @@ int git_config_from_mem(config_fn_t fn,
top.u.buf.pos = 0;
top.origin_type = origin_type;
top.name = name;
top.path = NULL;
top.default_error_action = CONFIG_ERROR_ERROR;
top.do_fgetc = config_buf_fgetc;
top.do_ungetc = config_buf_ungetc;
Expand Down
2 changes: 0 additions & 2 deletions config.h
Original file line number Diff line number Diff line change
Expand Up @@ -122,14 +122,12 @@ struct key_value_info {
int linenr;
enum config_origin_type origin_type;
enum config_scope scope;
const char *path;
};
#define KVI_INIT { \
.filename = NULL, \
.linenr = -1, \
.origin_type = CONFIG_ORIGIN_UNKNOWN, \
.scope = CONFIG_SCOPE_UNKNOWN, \
.path = NULL, \
}

/* Captures additional information that a config callback can use. */
Expand Down
12 changes: 6 additions & 6 deletions git-compat-util.h
Original file line number Diff line number Diff line change
Expand Up @@ -897,35 +897,35 @@ static inline size_t xsize_t(off_t len)
* is done via tolower(), so it is strictly ASCII (no multi-byte characters or
* locale-specific conversions).
*/
static inline int skip_iprefix(const char *str, const char *prefix,
static inline bool skip_iprefix(const char *str, const char *prefix,
const char **out)
{
do {
if (!*prefix) {
*out = str;
return 1;
return true;
}
} while (tolower(*str++) == tolower(*prefix++));
return 0;
return false;
}

/*
* Like skip_prefix_mem, but compare case-insensitively. Note that the
* comparison is done via tolower(), so it is strictly ASCII (no multi-byte
* characters or locale-specific conversions).
*/
static inline int skip_iprefix_mem(const char *buf, size_t len,
static inline bool skip_iprefix_mem(const char *buf, size_t len,
const char *prefix,
const char **out, size_t *outlen)
{
do {
if (!*prefix) {
*out = buf;
*outlen = len;
return 1;
return true;
}
} while (len-- > 0 && tolower(*buf++) == tolower(*prefix++));
return 0;
return false;
}

static inline int strtoul_ui(char const *s, int base, unsigned int *result)
Expand Down
Loading