Skip to content

Commit ca39da6

Browse files
committed
Merge branch 'ps/meson-contrib-bits'
Update meson-based build procedure to cover contrib/ and other places as well. * ps/meson-contrib-bits: ci: exercise credential helpers ci: fix propagating UTF-8 test locale in musl-based Meson job meson: wire up static analysis via Coccinelle meson: wire up git-contacts(1) meson: wire up credential helpers contrib/credential: fix compilation of "osxkeychain" helper contrib/credential: fix compiling "libsecret" helper contrib/credential: fix compilation of wincred helper with MSVC contrib/credential: fix "netrc" tests with out-of-tree builds GIT-BUILD-OPTIONS: propagate project's source directory
2 parents 85e342a + 63a597d commit ca39da6

24 files changed

+229
-27
lines changed

.github/workflows/main.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ jobs:
265265
run: pip install meson ninja
266266
- name: Setup
267267
shell: pwsh
268-
run: meson setup build -Dperl=disabled
268+
run: meson setup build -Dperl=disabled -Dcredential_helpers=wincred
269269
- name: Compile
270270
shell: pwsh
271271
run: meson compile -C build

.gitlab-ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ build:msvc-meson:
164164
extends: .msvc-meson
165165
stage: build
166166
script:
167-
- meson setup build -Dperl=disabled -Dbackend_max_links=1
167+
- meson setup build -Dperl=disabled -Dbackend_max_links=1 -Dcredential_helpers=wincred
168168
- meson compile -C build
169169
artifacts:
170170
paths:

GIT-BUILD-OPTIONS.in

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,13 @@ GIT_PERF_MAKE_COMMAND=@GIT_PERF_MAKE_COMMAND@
99
GIT_PERF_MAKE_OPTS=@GIT_PERF_MAKE_OPTS@
1010
GIT_PERF_REPEAT_COUNT=@GIT_PERF_REPEAT_COUNT@
1111
GIT_PERF_REPO=@GIT_PERF_REPO@
12+
GIT_SOURCE_DIR=@GIT_SOURCE_DIR@
1213
GIT_TEST_CMP=@GIT_TEST_CMP@
1314
GIT_TEST_CMP_USE_COPIED_CONTEXT=@GIT_TEST_CMP_USE_COPIED_CONTEXT@
1415
GIT_TEST_GITPERLLIB=@GIT_TEST_GITPERLLIB@
1516
GIT_TEST_INDEX_VERSION=@GIT_TEST_INDEX_VERSION@
16-
GIT_TEST_MERGE_TOOLS_DIR=@GIT_TEST_MERGE_TOOLS_DIR@
1717
GIT_TEST_OPTS=@GIT_TEST_OPTS@
1818
GIT_TEST_PERL_FATAL_WARNINGS=@GIT_TEST_PERL_FATAL_WARNINGS@
19-
GIT_TEST_POPATH=@GIT_TEST_POPATH@
2019
GIT_TEST_TEMPLATE_DIR=@GIT_TEST_TEMPLATE_DIR@
2120
GIT_TEST_TEXTDOMAINDIR=@GIT_TEST_TEXTDOMAINDIR@
2221
GIT_TEST_UTF8_LOCALE=@GIT_TEST_UTF8_LOCALE@

Makefile

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3193,14 +3193,13 @@ GIT-BUILD-OPTIONS: FORCE
31933193
-e "s|@GIT_PERF_MAKE_OPTS@|\'$(GIT_PERF_MAKE_OPTS)\'|" \
31943194
-e "s|@GIT_PERF_REPEAT_COUNT@|\'$(GIT_PERF_REPEAT_COUNT)\'|" \
31953195
-e "s|@GIT_PERF_REPO@|\'$(GIT_PERF_REPO)\'|" \
3196+
-e "s|@GIT_SOURCE_DIR@|\'$(shell pwd)\'|" \
31963197
-e "s|@GIT_TEST_CMP@|\'$(GIT_TEST_CMP)\'|" \
31973198
-e "s|@GIT_TEST_CMP_USE_COPIED_CONTEXT@|\'$(GIT_TEST_CMP_USE_COPIED_CONTEXT)\'|" \
31983199
-e "s|@GIT_TEST_GITPERLLIB@|\'$(shell pwd)/perl/build/lib\'|" \
31993200
-e "s|@GIT_TEST_INDEX_VERSION@|\'$(GIT_TEST_INDEX_VERSION)\'|" \
3200-
-e "s|@GIT_TEST_MERGE_TOOLS_DIR@|\'$(shell pwd)/mergetools\'|" \
32013201
-e "s|@GIT_TEST_OPTS@|\'$(GIT_TEST_OPTS)\'|" \
32023202
-e "s|@GIT_TEST_PERL_FATAL_WARNINGS@|\'$(GIT_TEST_PERL_FATAL_WARNINGS)\'|" \
3203-
-e "s|@GIT_TEST_POPATH@|\'$(shell pwd)/po\'|" \
32043203
-e "s|@GIT_TEST_TEMPLATE_DIR@|\'$(shell pwd)/templates/blt\'|" \
32053204
-e "s|@GIT_TEST_TEXTDOMAINDIR@|\'$(shell pwd)/po/build/locale\'|" \
32063205
-e "s|@GIT_TEST_UTF8_LOCALE@|\'$(GIT_TEST_UTF8_LOCALE)\'|" \

ci/install-dependencies.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ ubuntu-*|i386/ubuntu-*|debian-*)
5858
make libssl-dev libcurl4-openssl-dev libexpat-dev wget sudo default-jre \
5959
tcl tk gettext zlib1g-dev perl-modules liberror-perl libauthen-sasl-perl \
6060
libemail-valid-perl libio-pty-perl libio-socket-ssl-perl libnet-smtp-ssl-perl libdbd-sqlite3-perl libcgi-pm-perl \
61-
libpcre2-dev meson ninja-build pkg-config \
61+
libsecret-1-dev libpcre2-dev meson ninja-build pkg-config \
6262
${CC_PACKAGE:-${CC:-gcc}} $PYTHON_PACKAGE
6363

6464
case "$distro" in

ci/lib.sh

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -348,8 +348,11 @@ case "$jobname" in
348348
linux32)
349349
CC=gcc
350350
;;
351-
linux-musl)
352-
MESONFLAGS="$MESONFLAGS -DGIT_TEST_UTF8_LOCALE=C.UTF-8"
351+
linux-meson)
352+
MESONFLAGS="$MESONFLAGS -Dcredential_helpers=libsecret,netrc"
353+
;;
354+
linux-musl-meson)
355+
MESONFLAGS="$MESONFLAGS -Dtest_utf8_locale=C.UTF-8"
353356
;;
354357
linux-leaks|linux-reftable-leaks)
355358
export SANITIZE=leak
@@ -359,6 +362,9 @@ linux-asan-ubsan)
359362
export NO_SVN_TESTS=LetsSaveSomeTime
360363
MAKEFLAGS="$MAKEFLAGS NO_PYTHON=YepBecauseP4FlakesTooOften"
361364
;;
365+
osx-meson)
366+
MESONFLAGS="$MESONFLAGS -Dcredential_helpers=osxkeychain"
367+
;;
362368
esac
363369

364370
MAKEFLAGS="$MAKEFLAGS CC=${CC:-cc}"

contrib/buildsystems/CMakeLists.txt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1169,14 +1169,13 @@ string(REPLACE "@GIT_PERF_MAKE_COMMAND@" "" git_build_options "${git_build_optio
11691169
string(REPLACE "@GIT_PERF_MAKE_OPTS@" "" git_build_options "${git_build_options}")
11701170
string(REPLACE "@GIT_PERF_REPEAT_COUNT@" "" git_build_options "${git_build_options}")
11711171
string(REPLACE "@GIT_PERF_REPO@" "" git_build_options "${git_build_options}")
1172+
string(REPLACE "@GIT_SOURCE_DIR@" "${CMAKE_SOURCE_DIR}" git_build_options "${git_build_options}")
11721173
string(REPLACE "@GIT_TEST_CMP@" "" git_build_options "${git_build_options}")
11731174
string(REPLACE "@GIT_TEST_CMP_USE_COPIED_CONTEXT@" "" git_build_options "${git_build_options}")
11741175
string(REPLACE "@GIT_TEST_GITPERLLIB@" "'${CMAKE_BINARY_DIR}/perl/build/lib'" git_build_options "${git_build_options}")
11751176
string(REPLACE "@GIT_TEST_INDEX_VERSION@" "" git_build_options "${git_build_options}")
1176-
string(REPLACE "@GIT_TEST_MERGE_TOOLS_DIR@" "'${CMAKE_BINARY_DIR}/mergetools'" git_build_options "${git_build_options}")
11771177
string(REPLACE "@GIT_TEST_OPTS@" "" git_build_options "${git_build_options}")
11781178
string(REPLACE "@GIT_TEST_PERL_FATAL_WARNINGS@" "" git_build_options "${git_build_options}")
1179-
string(REPLACE "@GIT_TEST_POPATH@" "'${CMAKE_BINARY_DIR}/po'" git_build_options "${git_build_options}")
11801179
string(REPLACE "@GIT_TEST_TEMPLATE_DIR@" "'${CMAKE_BINARY_DIR}/templates/blt'" git_build_options "${git_build_options}")
11811180
string(REPLACE "@GIT_TEST_TEXTDOMAINDIR@" "'${CMAKE_BINARY_DIR}/po/build/locale'" git_build_options "${git_build_options}")
11821181
string(REPLACE "@GIT_TEST_UTF8_LOCALE@" "" git_build_options "${git_build_options}")

contrib/coccinelle/meson.build

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
spatch = find_program('spatch', required: get_option('coccinelle'))
2+
if not spatch.found()
3+
subdir_done()
4+
endif
5+
6+
third_party_sources = [
7+
':!contrib',
8+
':!compat/inet_ntop.c',
9+
':!compat/inet_pton.c',
10+
':!compat/nedmalloc',
11+
':!compat/obstack.*',
12+
':!compat/poll',
13+
':!compat/regex',
14+
':!sha1collisiondetection',
15+
':!sha1dc',
16+
':!t/unit-tests/clar',
17+
':!t/unit-tests/clar',
18+
':!t/t[0-9][0-9][0-9][0-9]*',
19+
]
20+
21+
rules = [
22+
'array.cocci',
23+
'commit.cocci',
24+
'config_fn_ctx.pending.cocci',
25+
'equals-null.cocci',
26+
'flex_alloc.cocci',
27+
'free.cocci',
28+
'git_config_number.cocci',
29+
'hashmap.cocci',
30+
'index-compatibility.cocci',
31+
'object_id.cocci',
32+
'preincr.cocci',
33+
'qsort.cocci',
34+
'refs.cocci',
35+
'strbuf.cocci',
36+
'swap.cocci',
37+
'the_repository.cocci',
38+
'xcalloc.cocci',
39+
'xopen.cocci',
40+
'xstrdup_or_null.cocci',
41+
'xstrncmpz.cocci',
42+
]
43+
44+
concatenated_rules = custom_target(
45+
command: [
46+
'cat', '@INPUT@',
47+
],
48+
input: rules,
49+
output: 'rules.cocci',
50+
capture: true,
51+
)
52+
53+
sources = [ ]
54+
foreach source : run_command(git, '-C', meson.project_source_root(), 'ls-files', '--deduplicate', '*.c', third_party_sources, check: true).stdout().split()
55+
sources += source
56+
endforeach
57+
58+
headers = [ ]
59+
foreach header : run_command(git, '-C', meson.project_source_root(), 'ls-files', '--deduplicate', '*.h', third_party_sources, check: true).stdout().split()
60+
headers += meson.project_source_root() / header
61+
endforeach
62+
63+
patches = [ ]
64+
foreach source : sources
65+
patches += custom_target(
66+
command: [
67+
spatch,
68+
'--all-includes',
69+
'--sp-file', concatenated_rules,
70+
'--patch', meson.project_source_root(),
71+
'@INPUT@',
72+
],
73+
input: meson.project_source_root() / source,
74+
output: source.underscorify() + '.patch',
75+
capture: true,
76+
depend_files: headers,
77+
)
78+
endforeach
79+
80+
concatenated_patch = custom_target(
81+
command: [
82+
'cat', '@INPUT@',
83+
],
84+
input: patches,
85+
output: 'cocci.patch',
86+
capture: true,
87+
)
88+
89+
alias_target('coccicheck', concatenated_patch)

contrib/contacts/meson.build

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
custom_target(
2+
input: 'git-contacts',
3+
output: 'git-contacts',
4+
command: generate_perl_command,
5+
depends: [git_version_file],
6+
install: true,
7+
install_dir: get_option('libexecdir') / 'git-core',
8+
)
9+
10+
if get_option('docs').contains('man')
11+
contacts_xml = custom_target(
12+
command: asciidoc_common_options + [
13+
'--backend=' + asciidoc_docbook,
14+
'--doctype=manpage',
15+
'--out-file=@OUTPUT@',
16+
'@INPUT@',
17+
],
18+
depends: documentation_deps,
19+
input: 'git-contacts.txt',
20+
output: 'git-contacts.xml',
21+
)
22+
23+
custom_target(
24+
command: [
25+
xmlto,
26+
'-m', '@INPUT@',
27+
'man',
28+
contacts_xml,
29+
'-o',
30+
meson.current_build_dir(),
31+
] + xmlto_extra,
32+
input: [
33+
'../../Documentation/manpage-normal.xsl',
34+
],
35+
output: 'git-contacts.1',
36+
install: true,
37+
install_dir: get_option('mandir') / 'man1',
38+
)
39+
endif
40+
41+
if get_option('docs').contains('html')
42+
custom_target(
43+
command: asciidoc_common_options + [
44+
'--backend=' + asciidoc_html,
45+
'--doctype=manpage',
46+
'--out-file=@OUTPUT@',
47+
'@INPUT@',
48+
],
49+
depends: documentation_deps,
50+
input: 'git-contacts.txt',
51+
output: 'git-contacts.html',
52+
install: true,
53+
install_dir: get_option('datadir') / 'doc/git-doc',
54+
)
55+
endif

contrib/credential/libsecret/git-credential-libsecret.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,10 @@ static void credential_clear(struct credential *c);
5959
/* ----------------- Secret Service functions ----------------- */
6060

6161
static const SecretSchema schema = {
62-
"org.git.Password",
62+
.name = "org.git.Password",
6363
/* Ignore schema name during search for backwards compatibility */
64-
SECRET_SCHEMA_DONT_MATCH_NAME,
65-
{
64+
.flags = SECRET_SCHEMA_DONT_MATCH_NAME,
65+
.attributes = {
6666
/*
6767
* libsecret assumes attribute values are non-confidential and
6868
* unchanging, so we can't include oauth_refresh_token or
@@ -168,7 +168,7 @@ static int keyring_get(struct credential *c)
168168
g_free(c->password);
169169
c->password = g_strdup("");
170170
}
171-
for (int i = 1; i < g_strv_length(parts); i++) {
171+
for (guint i = 1; i < g_strv_length(parts); i++) {
172172
if (g_str_has_prefix(parts[i], "password_expiry_utc=")) {
173173
g_free(c->password_expiry_utc);
174174
c->password_expiry_utc = g_strdup(&parts[i][20]);
@@ -424,7 +424,7 @@ int main(int argc, char *argv[])
424424
struct credential_operation const *try_op = credential_helper_ops;
425425
struct credential cred = CREDENTIAL_INIT;
426426

427-
if (!argv[1]) {
427+
if (argc < 2 || !*argv[1]) {
428428
usage(argv[0]);
429429
exit(EXIT_FAILURE);
430430
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
executable('git-credential-libsecret',
2+
sources: 'git-credential-libsecret.c',
3+
dependencies: [
4+
dependency('glib-2.0'),
5+
dependency('libsecret-1'),
6+
],
7+
install: true,
8+
install_dir: get_option('libexecdir') / 'git-core',
9+
)

contrib/credential/meson.build

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
foreach helper : get_option('credential_helpers')
2+
subdir(helper)
3+
endforeach

contrib/credential/netrc/meson.build

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
credential_netrc = custom_target(
2+
input: 'git-credential-netrc.perl',
3+
output: 'git-credential-netrc',
4+
command: generate_perl_command,
5+
depends: [git_version_file],
6+
install: true,
7+
install_dir: get_option('libexecdir') / 'git-core',
8+
)
9+
10+
credential_netrc_testenv = test_environment
11+
credential_netrc_testenv.set('CREDENTIAL_NETRC_PATH', credential_netrc.full_path())
12+
13+
test('t-git-credential-netrc',
14+
shell,
15+
args: [ meson.current_source_dir() / 't-git-credential-netrc.sh' ],
16+
workdir: meson.current_source_dir(),
17+
env: credential_netrc_testenv,
18+
depends: test_dependencies + bin_wrappers + [credential_netrc],
19+
timeout: 0,
20+
)

contrib/credential/netrc/t-git-credential-netrc.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
export PERL5LIB="$GITPERLLIB"
1717
test_expect_success 'git-credential-netrc' '
18-
perl "$GIT_BUILD_DIR"/contrib/credential/netrc/test.pl
18+
perl "$GIT_SOURCE_DIR"/contrib/credential/netrc/test.pl
1919
'
2020

2121
test_done

contrib/credential/netrc/test.pl

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,11 @@ BEGIN
1515

1616
my @global_credential_args = @ARGV;
1717
my $scriptDir = dirname rel2abs $0;
18-
my ($netrc, $netrcGpg, $gcNetrc) = map { catfile $scriptDir, $_; }
18+
my ($netrc, $netrcGpg) = map { catfile $scriptDir, $_; }
1919
qw(test.netrc
20-
test.netrc.gpg
21-
git-credential-netrc);
20+
test.netrc.gpg);
21+
my $gcNetrc = $ENV{CREDENTIAL_NETRC_PATH} || catfile $scriptDir, qw(git-credential-netrc);
22+
2223
local $ENV{PATH} = join ':'
2324
, $scriptDir
2425
, $ENV{PATH}

contrib/credential/osxkeychain/git-credential-osxkeychain.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -422,7 +422,7 @@ int main(int argc, const char **argv)
422422
const char *usage =
423423
"usage: git credential-osxkeychain <get|store|erase>";
424424

425-
if (!argv[1])
425+
if (argc < 2 || !*argv[1])
426426
die("%s", usage);
427427

428428
if (open(argv[0], O_RDONLY | O_EXLOCK) == -1)
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
executable('git-credential-osxkeychain',
2+
sources: 'git-credential-osxkeychain.c',
3+
dependencies: [
4+
dependency('CoreFoundation'),
5+
dependency('Security'),
6+
],
7+
install: true,
8+
install_dir: get_option('libexecdir') / 'git-core',
9+
)

contrib/credential/wincred/git-credential-wincred.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@
1212

1313
#define ARRAY_SIZE(x) (sizeof(x)/sizeof(x[0]))
1414

15+
#ifndef _MSC_VER
1516
__attribute__((format (printf, 1, 2)))
17+
#endif
1618
static void die(const char *err, ...)
1719
{
1820
char msg[4096];
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
executable('git-credential-wincred',
2+
sources: 'git-credential-wincred.c',
3+
install: true,
4+
install_dir: get_option('libexecdir') / 'git-core',
5+
)

contrib/meson.build

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
foreach feature : get_option('contrib')
22
subdir(feature)
33
endforeach
4+
5+
subdir('coccinelle')
6+
subdir('credential')

meson.build

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -772,7 +772,7 @@ endif
772772
# features. It is optional if you want to neither execute tests nor use any of
773773
# these optional features.
774774
perl_required = get_option('perl')
775-
if get_option('tests') or get_option('gitweb').enabled()
775+
if get_option('tests') or get_option('gitweb').enabled() or 'netrc' in get_option('credential_helpers')
776776
perl_required = true
777777
endif
778778

@@ -1968,10 +1968,9 @@ subdir('contrib')
19681968

19691969
foreach key, value : {
19701970
'DIFF': diff.full_path(),
1971+
'GIT_SOURCE_DIR': meson.project_source_root(),
19711972
'GIT_TEST_CMP': diff.full_path() + ' -u',
19721973
'GIT_TEST_GITPERLLIB': meson.project_build_root() / 'perl',
1973-
'GIT_TEST_MERGE_TOOLS_DIR': meson.project_source_root() / 'mergetools',
1974-
'GIT_TEST_POPATH': meson.project_source_root() / 'po',
19751974
'GIT_TEST_TEMPLATE_DIR': meson.project_build_root() / 'templates',
19761975
'GIT_TEST_TEXTDOMAINDIR': meson.project_build_root() / 'po',
19771976
'PAGER_ENV': get_option('pager_environment'),

0 commit comments

Comments
 (0)