Skip to content

Commit

Permalink
Merge branch 'ps/platform-compat-fixes' into jch
Browse files Browse the repository at this point in the history
Various platform compatibility fixes split out of the larger effort
to use Meson as the primary build tool.

* ps/platform-compat-fixes:
  http: fix build error on FreeBSD
  builtin/credential-cache: fix missing parameter for stub function
  t7300: work around platform-specific behaviour with long paths on MinGW
  t5500, t5601: skip tests which exercise paths with '[::1]' on Cygwin
  t3404: work around platform-specific behaviour on macOS 10.15
  t1401: make invocation of tar(1) work with Win32-provided one
  t/lib-gpg: fix setup of GNUPGHOME in MinGW
  t/lib-gitweb: test against the build version of gitweb
  t/test-lib: wire up NO_ICONV prerequisite
  t/test-lib: fix quoting of TEST_RESULTS_SAN_FILE
  • Loading branch information
ttaylorr committed Oct 18, 2024
2 parents f8cc52b + 80ebd91 commit 2490df0
Show file tree
Hide file tree
Showing 30 changed files with 273 additions and 136 deletions.
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3176,6 +3176,7 @@ GIT-BUILD-OPTIONS: FORCE
@echo PYTHON_PATH=\''$(subst ','\'',$(PYTHON_PATH_SQ))'\' >>$@+
@echo TAR=\''$(subst ','\'',$(subst ','\'',$(TAR)))'\' >>$@+
@echo NO_CURL=\''$(subst ','\'',$(subst ','\'',$(NO_CURL)))'\' >>$@+
@echo NO_ICONV=\''$(subst ','\'',$(subst ','\'',$(NO_ICONV)))'\' >>$@+
@echo NO_EXPAT=\''$(subst ','\'',$(subst ','\'',$(NO_EXPAT)))'\' >>$@+
@echo USE_LIBPCRE2=\''$(subst ','\'',$(subst ','\'',$(USE_LIBPCRE2)))'\' >>$@+
@echo NO_PERL=\''$(subst ','\'',$(subst ','\'',$(NO_PERL)))'\' >>$@+
Expand Down
3 changes: 2 additions & 1 deletion builtin/credential-cache.c
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,8 @@ int cmd_credential_cache(int argc,

#else

int cmd_credential_cache(int argc, const char **argv, const char *prefix)
int cmd_credential_cache(int argc, const char **argv, const char *prefix,
struct repository *repo UNUSED)
{
const char * const usage[] = {
"git credential-cache [options] <action>",
Expand Down
6 changes: 6 additions & 0 deletions contrib/buildsystems/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1109,6 +1109,7 @@ set(DIFF diff)
set(PYTHON_PATH /usr/bin/python)
set(TAR tar)
set(NO_CURL )
set(NO_ICONV )
set(NO_EXPAT )
set(USE_LIBPCRE2 )
set(NO_PERL )
Expand All @@ -1122,6 +1123,10 @@ if(NOT CURL_FOUND)
set(NO_CURL 1)
endif()

if(NOT Iconv_FOUND)
SET(NO_ICONV 1)
endif()

if(NOT EXPAT_FOUND)
set(NO_EXPAT 1)
endif()
Expand All @@ -1145,6 +1150,7 @@ file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "DIFF='${DIFF}'\n")
file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "PYTHON_PATH='${PYTHON_PATH}'\n")
file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "TAR='${TAR}'\n")
file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "NO_CURL='${NO_CURL}'\n")
file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "NO_ICONV='${NO_ICONV}'\n")
file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "NO_EXPAT='${NO_EXPAT}'\n")
file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "NO_PERL='${NO_PERL}'\n")
file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "NO_PTHREADS='${NO_PTHREADS}'\n")
Expand Down
10 changes: 6 additions & 4 deletions http.c
Original file line number Diff line number Diff line change
Expand Up @@ -2232,17 +2232,19 @@ static int http_request_reauth(const char *url,
case HTTP_REQUEST_STRBUF:
strbuf_reset(result);
break;
case HTTP_REQUEST_FILE:
if (fflush(result)) {
case HTTP_REQUEST_FILE: {
FILE *f = result;
if (fflush(f)) {
error_errno("unable to flush a file");
return HTTP_START_FAILED;
}
rewind(result);
if (ftruncate(fileno(result), 0) < 0) {
rewind(f);
if (ftruncate(fileno(f), 0) < 0) {
error_errno("unable to truncate a file");
return HTTP_START_FAILED;
}
break;
}
default:
BUG("Unknown http_request target");
}
Expand Down
4 changes: 2 additions & 2 deletions t/lib-gitweb.sh
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ EOF
test -f "$SCRIPT_NAME" ||
error "Cannot find gitweb at $GITWEB_TEST_INSTALLED."
say "# Testing $SCRIPT_NAME"
else # normal case, use source version of gitweb
SCRIPT_NAME="$GIT_BUILD_DIR/gitweb/gitweb.perl"
else # normal case, use built version of gitweb
SCRIPT_NAME="$GIT_BUILD_DIR/gitweb/gitweb.cgi"
fi
export SCRIPT_NAME
}
Expand Down
2 changes: 1 addition & 1 deletion t/lib-gpg.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
# executed in an eval'ed subshell that changes the working directory to a
# temporary one.

GNUPGHOME="$PWD/gpghome"
GNUPGHOME="$(pwd)/gpghome"
export GNUPGHOME

test_lazy_prereq GPG '
Expand Down
6 changes: 6 additions & 0 deletions t/t0028-working-tree-encoding.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@ TEST_CREATE_REPO_NO_TEMPLATE=1

GIT_TRACE_WORKING_TREE_ENCODING=1 && export GIT_TRACE_WORKING_TREE_ENCODING

if ! test_have_prereq ICONV
then
skip_all='skipping working tree encoding tests; iconv not available'
test_done
fi

test_expect_success 'setup test files' '
git config core.eol lf &&
Expand Down
2 changes: 1 addition & 1 deletion t/t1401-symbolic-ref.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ reset_to_sane() {
test_expect_success 'setup' '
git symbolic-ref HEAD refs/heads/foo &&
test_commit file &&
"$TAR" cf .git.tar .git/
"$TAR" cf .git.tar .git
'

test_expect_success 'symbolic-ref read/write roundtrip' '
Expand Down
2 changes: 1 addition & 1 deletion t/t2082-parallel-checkout-attributes.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ test_expect_success 'parallel-checkout with ident' '
)
'

test_expect_success 'parallel-checkout with re-encoding' '
test_expect_success ICONV 'parallel-checkout with re-encoding' '
set_checkout_config 2 0 &&
git init encoding &&
(
Expand Down
26 changes: 12 additions & 14 deletions t/t3404-rebase-interactive.sh
Original file line number Diff line number Diff line change
Expand Up @@ -1942,18 +1942,17 @@ test_expect_success '--update-refs updates refs correctly' '
test_cmp_rev HEAD~1 refs/heads/third &&
test_cmp_rev HEAD refs/heads/no-conflict-branch &&
cat >expect <<-\EOF &&
q_to_tab >expect <<-\EOF &&
Successfully rebased and updated refs/heads/update-refs.
Updated the following refs with --update-refs:
refs/heads/first
refs/heads/no-conflict-branch
refs/heads/second
refs/heads/third
Qrefs/heads/first
Qrefs/heads/no-conflict-branch
Qrefs/heads/second
Qrefs/heads/third
EOF
# Clear "Rebasing (X/Y)" progress lines and drop leading tabs.
sed -e "s/Rebasing.*Successfully/Successfully/g" -e "s/^\t//g" \
<err >err.trimmed &&
sed "s/Rebasing.*Successfully/Successfully/g" <err >err.trimmed &&
test_cmp expect err.trimmed
'

Expand Down Expand Up @@ -2203,19 +2202,18 @@ test_expect_success '--update-refs: check failed ref update' '
test_must_fail git rebase --continue 2>err &&
grep "update_ref failed for ref '\''refs/heads/second'\''" err &&
cat >expect <<-\EOF &&
q_to_tab >expect <<-\EOF &&
Updated the following refs with --update-refs:
refs/heads/first
refs/heads/no-conflict-branch
refs/heads/third
Qrefs/heads/first
Qrefs/heads/no-conflict-branch
Qrefs/heads/third
Failed to update the following refs with --update-refs:
refs/heads/second
Qrefs/heads/second
EOF
# Clear "Rebasing (X/Y)" progress lines and drop leading tabs.
tail -n 6 err >err.last &&
sed -e "s/Rebasing.*Successfully/Successfully/g" -e "s/^\t//g" \
<err.last >err.trimmed &&
sed "s/Rebasing.*Successfully/Successfully/g" <err.last >err.trimmed &&
test_cmp expect err.trimmed
'

Expand Down
6 changes: 6 additions & 0 deletions t/t3434-rebase-i18n.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@ export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
TEST_PASSES_SANITIZE_LEAK=true
. ./test-lib.sh

if ! test_have_prereq ICONV
then
skip_all='skipping rebase i18n tests; iconv not available'
test_done
fi

compare_msg () {
iconv -f "$2" -t "$3" "$TEST_DIRECTORY/t3434/$1" >expect &&
git cat-file commit HEAD >raw &&
Expand Down
6 changes: 6 additions & 0 deletions t/t3900-i18n-commit.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@ test_description='commit and log output encodings'
TEST_PASSES_SANITIZE_LEAK=true
. ./test-lib.sh

if ! test_have_prereq ICONV
then
skip_all='skipping commit i18n tests; iconv not available'
test_done
fi

compare_with () {
git show -s $1 | sed -e '1,/^$/d' -e 's/^ //' >current &&
case "$3" in
Expand Down
6 changes: 6 additions & 0 deletions t/t3901-i18n-patch.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@ export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
TEST_PASSES_SANITIZE_LEAK=true
. ./test-lib.sh

if ! test_have_prereq ICONV
then
skip_all='skipping patch i18n tests; iconv not available'
test_done
fi

check_encoding () {
# Make sure characters are not corrupted
cnt="$1" header="$2" i=1 j=0
Expand Down
16 changes: 11 additions & 5 deletions t/t4041-diff-submodule-option.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,18 @@ export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
TEST_PASSES_SANITIZE_LEAK=true
. ./test-lib.sh

# Tested non-UTF-8 encoding
test_encoding="ISO8859-1"
# Test non-UTF-8 encoding in case iconv is available.
if test_have_prereq ICONV
then
test_encoding="ISO8859-1"
# String "added" in German (translated with Google Translate), encoded in UTF-8,
# used in sample commit log messages in add_file() function below.
added=$(printf "hinzugef\303\274gt")
else
test_encoding="UTF-8"
added="added"
fi

# String "added" in German (translated with Google Translate), encoded in UTF-8,
# used in sample commit log messages in add_file() function below.
added=$(printf "hinzugef\303\274gt")
add_file () {
(
cd "$1" &&
Expand Down
16 changes: 11 additions & 5 deletions t/t4059-diff-submodule-not-initialized.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,18 @@ initialized previously but the checkout has since been removed.
TEST_PASSES_SANITIZE_LEAK=true
. ./test-lib.sh

# Tested non-UTF-8 encoding
test_encoding="ISO8859-1"

# String "added" in German (translated with Google Translate), encoded in UTF-8,
# used in sample commit log messages in add_file() function below.
added=$(printf "hinzugef\303\274gt")
# Test non-UTF-8 encoding in case iconv is available.
if test_have_prereq ICONV
then
test_encoding="ISO8859-1"
# String "added" in German (translated with Google Translate), encoded in UTF-8,
# used in sample commit log messages in add_file() function below.
added=$(printf "hinzugef\303\274gt")
else
test_encoding="UTF-8"
added="added"
fi

add_file () {
(
Expand Down
17 changes: 11 additions & 6 deletions t/t4060-diff-submodule-option-diff-format.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,17 @@ This test tries to verify the sanity of --submodule=diff option of git diff.
TEST_PASSES_SANITIZE_LEAK=true
. ./test-lib.sh

# Tested non-UTF-8 encoding
test_encoding="ISO8859-1"

# String "added" in German (translated with Google Translate), encoded in UTF-8,
# used in sample commit log messages in add_file() function below.
added=$(printf "hinzugef\303\274gt")
# Test non-UTF-8 encoding in case iconv is available.
if test_have_prereq ICONV
then
test_encoding="ISO8859-1"
# String "added" in German (translated with Google Translate), encoded in UTF-8,
# used in sample commit log messages in add_file() function below.
added=$(printf "hinzugef\303\274gt")
else
test_encoding="UTF-8"
added="added"
fi

add_file () {
(
Expand Down
8 changes: 4 additions & 4 deletions t/t4201-shortlog.sh
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ test_expect_success 'output from user-defined format is re-wrapped' '
test_cmp expect log.predictable
'

test_expect_success !MINGW 'shortlog wrapping' '
test_expect_success !MINGW,ICONV 'shortlog wrapping' '
cat >expect <<\EOF &&
A U Thor (5):
Test
Expand All @@ -126,13 +126,13 @@ EOF
test_cmp expect out
'

test_expect_success !MINGW 'shortlog from non-git directory' '
test_expect_success !MINGW,ICONV 'shortlog from non-git directory' '
git log --no-expand-tabs HEAD >log &&
GIT_DIR=non-existing git shortlog -w <log >out &&
test_cmp expect out
'

test_expect_success !MINGW 'shortlog can read --format=raw output' '
test_expect_success !MINGW,ICONV 'shortlog can read --format=raw output' '
git log --format=raw HEAD >log &&
GIT_DIR=non-existing git shortlog -w <log >out &&
test_cmp expect out
Expand Down Expand Up @@ -186,7 +186,7 @@ $DSCHO (2):
EOF

test_expect_success !MINGW 'shortlog encoding' '
test_expect_success !MINGW,ICONV 'shortlog encoding' '
git reset --hard "$commit" &&
git config --unset i18n.commitencoding &&
echo 2 > a1 &&
Expand Down
Loading

0 comments on commit 2490df0

Please sign in to comment.