build.sh: add support for git worktree

Git supports multiple working trees attached to the same repository,
with the git-worktree(1) subcommand.

When building from a Git working tree, the repository metadata in .git
from the top source directory is a file (containing the actual location
of the metadata) instead of the usual directory structure. With this
change, build.sh allows .git to be a directory or a regular file
instead, therefore letting the sources build as expected from a Git
working tree.

To test: (without this patch)

    src$ git worktree add ../src-clean-tree
    [...]
    src$ (cd ../src-clean-tree && ./build.sh tools)
    [...]
    ERROR: Cannot determine VCS for '.../src-clean-tree/'

XXX: pullup-10 pullup-9
This commit is contained in:
khorben 2023-09-04 02:21:17 +00:00
parent e2869ef114
commit 599f59ef37
1 changed files with 3 additions and 3 deletions

View File

@ -1,5 +1,5 @@
#! /usr/bin/env sh #! /usr/bin/env sh
# $NetBSD: build.sh,v 1.373 2023/07/18 16:59:57 lukem Exp $ # $NetBSD: build.sh,v 1.374 2023/09/04 02:21:17 khorben Exp $
# #
# Copyright (c) 2001-2023 The NetBSD Foundation, Inc. # Copyright (c) 2001-2023 The NetBSD Foundation, Inc.
# All rights reserved. # All rights reserved.
@ -2030,7 +2030,7 @@ createmakewrapper()
eval cat <<EOF ${makewrapout} eval cat <<EOF ${makewrapout}
#! ${HOST_SH} #! ${HOST_SH}
# Set proper variables to allow easy "make" building of a NetBSD subtree. # Set proper variables to allow easy "make" building of a NetBSD subtree.
# Generated from: \$NetBSD: build.sh,v 1.373 2023/07/18 16:59:57 lukem Exp $ # Generated from: \$NetBSD: build.sh,v 1.374 2023/09/04 02:21:17 khorben Exp $
# with these arguments: ${_args} # with these arguments: ${_args}
# #
@ -2404,7 +2404,7 @@ setup_mkrepro()
t=$("${cvslatest}" ${cvslatestflags} "${d}") t=$("${cvslatest}" ${cvslatestflags} "${d}")
vcs=cvs vcs=cvs
elif [ -d "${d}.git" ]; then elif [ -d "${d}.git" -o -f "${d}.git" ]; then
t=$(cd "${d}" && git log -1 --format=%ct) t=$(cd "${d}" && git log -1 --format=%ct)
vcs=git vcs=git
elif [ -d "${d}.hg" ]; then elif [ -d "${d}.hg" ]; then