Merge branch 'bs/bsd-wo-specific-xopen-source'

Build fix for BSDs.

* bs/bsd-wo-specific-xopen-source:
  compat: fixes for header handling with OpenBSD / NetBSD
diff --git a/Documentation/RelNotes/2.50.0.adoc b/Documentation/RelNotes/2.50.0.adoc
index c3d5dad..95349ea 100644
--- a/Documentation/RelNotes/2.50.0.adoc
+++ b/Documentation/RelNotes/2.50.0.adoc
@@ -300,7 +300,7 @@
    (merge e7ef4be7c2 mh/left-right-limited later to maint).
 
  * Document the convention to disable hooks altogether by setting the
-   hooksPath configuration variable to /dev/nulll
+   hooksPath configuration variable to /dev/null.
    (merge 1b2eee94f1 ds/doc-disable-hooks later to maint).
 
  * Make sure outage of third-party sites that supply P4, Git-LFS, and
@@ -318,6 +318,7 @@
 
  * Update to arm64 Windows port.
    (merge 436a42215e js/windows-arm64 later to maint).
+
  * hashmap API clean-up to ensure hashmap_clear() leaves a cleared map
    in a reusable state.
    (merge 9481877de3 en/hashmap-clear-fix later to maint).
@@ -351,7 +352,7 @@
    (merge 5dbaec628d pw/sequencer-reflog-use-after-free later to maint).
 
  * win+Meson CI pipeline, unlike other pipelines for Windows,
-   used to build artifacts in develper mode, which has been changed to
+   used to build artifacts in developer mode, which has been changed to
    build them in release mode for consistency.
    (merge 184abdcf05 js/ci-build-win-in-release-mode later to maint).
 
@@ -379,6 +380,15 @@
    reverse failed to give the mode bits of the path "removed" by the
    patch to the file it creates, which has been corrected.
 
+ * "git verify-refs" (and hence "git fsck --reference") started
+   erroring out in a repository in which secondary worktrees were
+   prepared with Git 2.43 or lower.
+   (merge d5b3c38b8a sj/ref-contents-check-fix later to maint).
+
+ * Update total_ram() functrion on BSD variants.
+
+ * Update online_cpus() functrion on BSD variants.
+
  * Other code cleanup, docfix, build fix, etc.
    (merge 227c4f33a0 ja/doc-block-delimiter-markup-fix later to maint).
    (merge 2bfd3b3685 ab/decorate-code-cleanup later to maint).
diff --git a/Documentation/config/gitcvs.adoc b/Documentation/config/gitcvs.adoc
index 02da427..31d7be3 100644
--- a/Documentation/config/gitcvs.adoc
+++ b/Documentation/config/gitcvs.adoc
@@ -47,7 +47,8 @@
 	May not contain double colons (`:`). Default: 'SQLite'.
 	See linkgit:git-cvsserver[1].
 
-gitcvs.dbUser, gitcvs.dbPass::
+gitcvs.dbUser::
+gitcvs.dbPass::
 	Database user and password. Only useful if setting `gitcvs.dbDriver`,
 	since SQLite has no concept of database users and/or passwords.
 	'gitcvs.dbUser' supports variable substitution (see
diff --git a/Documentation/config/http.adoc b/Documentation/config/http.adoc
index 6739328..9da5c29 100644
--- a/Documentation/config/http.adoc
+++ b/Documentation/config/http.adoc
@@ -289,7 +289,8 @@
 significantly since the entire buffer is allocated even for small
 pushes.
 
-http.lowSpeedLimit, http.lowSpeedTime::
+http.lowSpeedLimit::
+http.lowSpeedTime::
 	If the HTTP transfer speed, in bytes per second, is less than
 	'http.lowSpeedLimit' for longer than 'http.lowSpeedTime' seconds,
 	the transfer is aborted.
diff --git a/Documentation/git-column.adoc b/Documentation/git-column.adoc
index 5a4f2b6..8e00472 100644
--- a/Documentation/git-column.adoc
+++ b/Documentation/git-column.adoc
@@ -50,7 +50,7 @@
 --------
 
 Format data by columns:
-+
+
 ------------
 $ seq 1 24 | git column --mode=column --padding=5
 1      4      7      10     13     16     19     22
@@ -59,7 +59,7 @@
 ------------
 
 Format data by rows:
-+
+
 ------------
 $ seq 1 21 | git column --mode=row --padding=5
 1      2      3      4      5      6      7
@@ -68,7 +68,7 @@
 ------------
 
 List some tags in a table with unequal column widths:
-+
+
 ------------
 $ git tag --list 'v2.4.*' --column=row,dense
 v2.4.0  v2.4.0-rc0  v2.4.0-rc1  v2.4.0-rc2  v2.4.0-rc3
diff --git a/GIT-VERSION-GEN b/GIT-VERSION-GEN
index cea2a13..1047b8d 100755
--- a/GIT-VERSION-GEN
+++ b/GIT-VERSION-GEN
@@ -1,6 +1,6 @@
 #!/bin/sh
 
-DEF_VER=v2.50.0-rc0
+DEF_VER=v2.50.0-rc1
 
 LF='
 '
diff --git a/builtin/gc.c b/builtin/gc.c
index e33ba94..7dc94f2 100644
--- a/builtin/gc.c
+++ b/builtin/gc.c
@@ -516,7 +516,7 @@ static uint64_t total_ram(void)
 			total *= (uint64_t)si.mem_unit;
 		return total;
 	}
-#elif defined(HAVE_BSD_SYSCTL) && (defined(HW_MEMSIZE) || defined(HW_PHYSMEM))
+#elif defined(HAVE_BSD_SYSCTL) && (defined(HW_MEMSIZE) || defined(HW_PHYSMEM) || defined(HW_PHYSMEM64))
 	int64_t physical_memory;
 	int mib[2];
 	size_t length;
@@ -524,6 +524,8 @@ static uint64_t total_ram(void)
 	mib[0] = CTL_HW;
 # if defined(HW_MEMSIZE)
 	mib[1] = HW_MEMSIZE;
+# elif defined(HW_PHYSMEM64)
+	mib[1] = HW_PHYSMEM64;
 # else
 	mib[1] = HW_PHYSMEM;
 # endif
diff --git a/config.mak.uname b/config.mak.uname
index 7fc2c5b..3e26bb0 100644
--- a/config.mak.uname
+++ b/config.mak.uname
@@ -301,17 +301,14 @@
 	FILENO_IS_A_MACRO = UnfortunatelyYes
 endif
 ifeq ($(uname_S),OpenBSD)
-	NO_STRCASESTR = YesPlease
-	NO_MEMMEM = YesPlease
+	DIR_HAS_BSD_GROUP_SEMANTICS = YesPlease
 	USE_ST_TIMESPEC = YesPlease
 	NEEDS_LIBICONV = YesPlease
 	BASIC_CFLAGS += -I/usr/local/include
 	BASIC_LDFLAGS += -L/usr/local/lib
 	HAVE_PATHS_H = YesPlease
 	HAVE_BSD_SYSCTL = YesPlease
-	HAVE_BSD_KERN_PROC_SYSCTL = YesPlease
 	CSPRNG_METHOD = arc4random
-	PROCFS_EXECUTABLE_PATH = /proc/curproc/file
 	FREAD_READS_DIRECTORIES = UnfortunatelyYes
 	FILENO_IS_A_MACRO = UnfortunatelyYes
 endif
diff --git a/generate-configlist.sh b/generate-configlist.sh
index b06da53..9d2ad61 100755
--- a/generate-configlist.sh
+++ b/generate-configlist.sh
@@ -19,7 +19,6 @@
 	s/::$//;
 	s/`//g;
 	s/^.*$/	"&",/;
-	s/,  */",\n	"/g;
 	p;};
 d' \
 	    "$SOURCE_DIR"/Documentation/*config.adoc \
diff --git a/git-gui/generate-tclindex.sh b/git-gui/generate-tclindex.sh
index 36e3a0b..0b031d8 100755
--- a/git-gui/generate-tclindex.sh
+++ b/git-gui/generate-tclindex.sh
@@ -23,7 +23,7 @@
 	: ok
 else
 	 echo >&2 "    * $TCL_PATH failed; using unoptimized loading"
-	 rm -f $@
+	 rm -f lib/tclIndex
 	 echo '# Autogenerated by git-gui Makefile' >lib/tclIndex
 	 echo >>lib/tclIndex
 	 echo "class.tcl" >>lib/tclIndex
diff --git a/refs/files-backend.c b/refs/files-backend.c
index 4d1f65a..bf6f89b 100644
--- a/refs/files-backend.c
+++ b/refs/files-backend.c
@@ -3762,6 +3762,9 @@ static int files_fsck_refs_dir(struct ref_store *ref_store,
 
 	iter = dir_iterator_begin(sb.buf, 0);
 	if (!iter) {
+		if (errno == ENOENT && !is_main_worktree(wt))
+			goto out;
+
 		ret = error_errno(_("cannot open directory %s"), sb.buf);
 		goto out;
 	}
diff --git a/t/t0602-reffiles-fsck.sh b/t/t0602-reffiles-fsck.sh
index f671ac4..0ef4836 100755
--- a/t/t0602-reffiles-fsck.sh
+++ b/t/t0602-reffiles-fsck.sh
@@ -110,6 +110,25 @@
 	)
 '
 
+test_expect_success 'no refs directory of worktree should not cause problems' '
+	test_when_finished "rm -rf repo" &&
+	git init repo &&
+	(
+		cd repo &&
+		test_commit initial &&
+		git worktree add --detach ./worktree &&
+
+		(
+			cd worktree &&
+			worktree_refdir="$(git rev-parse --git-dir)/refs" &&
+			# Simulate old directory layout
+			rmdir "$worktree_refdir" &&
+			git refs verify 2>err &&
+			test_must_be_empty err
+		)
+	)
+'
+
 test_expect_success 'ref name check should work for multiple worktrees' '
 	test_when_finished "rm -rf repo" &&
 	git init repo &&
diff --git a/t/t5410-receive-pack.sh b/t/t5410-receive-pack.sh
index f76a229..09d6bfd 100755
--- a/t/t5410-receive-pack.sh
+++ b/t/t5410-receive-pack.sh
@@ -41,7 +41,19 @@
 	test_cmp expect actual.haves
 '
 
-test_expect_success 'receive-pack missing objects fails connectivity check' '
+# The `tee.exe` shipped in Git for Windows v2.49.0 is known to hang frequently
+# when spawned from `git.exe` and piping its output to `git.exe`. This seems
+# related to MSYS2 runtime bug fixes regarding the signal handling; Let's just
+# skip the tests that need to exercise this when the faulty MSYS2 runtime is
+# detected; The test cases are exercised enough in other matrix jobs of the CI
+# runs.
+test_lazy_prereq TEE_DOES_NOT_HANG '
+	test_have_prereq !MINGW &&
+	case "$(uname -a)" in *3.5.7-463ebcdc.x86_64*) false;; esac
+'
+
+test_expect_success TEE_DOES_NOT_HANG \
+	'receive-pack missing objects fails connectivity check' '
 	test_when_finished rm -rf repo remote.git setup.git &&
 
 	git init repo &&
@@ -62,7 +74,8 @@
 	test_must_fail git -C remote.git cat-file -e $(git -C repo rev-parse HEAD)
 '
 
-test_expect_success 'receive-pack missing objects bypasses connectivity check' '
+test_expect_success TEE_DOES_NOT_HANG \
+	'receive-pack missing objects bypasses connectivity check' '
 	test_when_finished rm -rf repo remote.git setup.git &&
 
 	git init repo &&
diff --git a/thread-utils.c b/thread-utils.c
index 1f89ffa..374890e 100644
--- a/thread-utils.c
+++ b/thread-utils.c
@@ -46,11 +46,11 @@ int online_cpus(void)
 	mib[0] = CTL_HW;
 #  ifdef HW_AVAILCPU
 	mib[1] = HW_AVAILCPU;
-	len = sizeof(cpucount);
-	if (!sysctl(mib, 2, &cpucount, &len, NULL, 0))
-		return cpucount;
-#  endif /* HW_AVAILCPU */
+#  elif defined(HW_NCPUONLINE)
+	mib[1] = HW_NCPUONLINE;
+#  else
 	mib[1] = HW_NCPU;
+#  endif /* HW_AVAILCPU */
 	len = sizeof(cpucount);
 	if (!sysctl(mib, 2, &cpucount, &len, NULL, 0))
 		return cpucount;