commit d3edc09c3f4fdce24d4f66c5a94302cae5d26980 (HEAD, refs/remotes/origin/master) Author: Paul Eggert Date: Wed Apr 13 18:19:04 2016 -0700 Port ‘./autogen.sh git’ to non-clones Problem reported by Angelo Graziosi in: http://lists.gnu.org/archive/html/emacs-devel/2016-04/msg00341.html * autogen.sh (do_git): Default to false when the arg is ‘all’ but there is no ‘.git’. (git_common_dir, hooks): New vars. (git_config, tailored_hooks, sample_hooks): Use them. diff --git a/autogen.sh b/autogen.sh index 2e10a77..cd0accd 100755 --- a/autogen.sh +++ b/autogen.sh @@ -112,7 +112,8 @@ for arg; do --help) exec echo "$0: usage: $0 [all|autoconf|git]";; all) - do_autoconf=true do_git=true;; + do_autoconf=true + test -e .git && do_git=true;; autoconf) do_autoconf=true;; git) @@ -260,7 +261,8 @@ git_config () echo 'Configuring local git repository...' case $cp_options in --backup=*) - cp $cp_options --force .git/config .git/config || exit;; + config=$git_common_dir/config + cp $cp_options --force -- "$config" "$config" || exit;; esac fi echo "git config $name '$value'" @@ -272,6 +274,13 @@ git_config () ## Configure Git, if requested. +# Get location of Git's common configuration directory. For older Git +# versions this is just '.git'. Newer Git versions support worktrees. + +test -e .git && git_common_dir=`git rev-parse --git-common-dir 2>/dev/null` || + git_common_dir=.git +hooks=$git_common_dir/hooks + # Check hashes when transferring objects among repositories. git_config transfer.fsckObjects true @@ -296,12 +305,11 @@ tailored_hooks= sample_hooks= for hook in commit-msg pre-commit; do - cmp build-aux/git-hooks/$hook .git/hooks/$hook >/dev/null 2>&1 || + cmp -- build-aux/git-hooks/$hook "$hooks/$hook" >/dev/null 2>&1 || tailored_hooks="$tailored_hooks $hook" done for hook in applypatch-msg pre-applypatch; do - src=.git/hooks/$hook.sample - cmp "$src" .git/hooks/$hook >/dev/null 2>&1 || + cmp -- "$hooks/$hook.sample" "$hooks/$hook" >/dev/null 2>&1 || sample_hooks="$sample_hooks $hook" done @@ -311,15 +319,15 @@ if test -n "$tailored_hooks$sample_hooks"; then if test -n "$tailored_hooks"; then for hook in $tailored_hooks; do - dst=.git/hooks/$hook - cp $cp_options build-aux/git-hooks/$hook "$dst" || exit - chmod a-w "$dst" || exit + dst=$hooks/$hook + cp $cp_options -- build-aux/git-hooks/$hook "$dst" || exit + chmod -- a-w "$dst" || exit done fi if test -n "$sample_hooks"; then for hook in $sample_hooks; do - cp $cp_options .git/hooks/$hook.sample .git/hooks/$hook || exit + cp $cp_options -- "$hooks/$hook.sample" "$hooks/$hook" || exit chmod a-w .git/hooks/$hook || exit done fi commit 1aebe99145e9ef612cdb272800904e3ba9297196 Author: Paul Eggert Date: Wed Apr 13 11:12:15 2016 -0700 Do not require that .git be a directory Problem reportyed by Phillip Lord. * admin/update_autogen, autogen.sh, build-aux/gitlog-to-emacslog: * configure.ac, make-dist: Do not require that .git be a directory, as 'git worktree' makes it a file and not a directory. diff --git a/admin/update_autogen b/admin/update_autogen index 199a3aa..1e8aae2 100755 --- a/admin/update_autogen +++ b/admin/update_autogen @@ -49,7 +49,7 @@ cd ../ if [ -d .bzr ]; then vcs=bzr -elif [ -d .git ]; then +elif [ -e .git ]; then vcs=git else die "Cannot determine vcs" diff --git a/autogen.sh b/autogen.sh index 9042465..2e10a77 100755 --- a/autogen.sh +++ b/autogen.sh @@ -330,7 +330,7 @@ fi if test ! -f configure; then echo "You can now run '$0 autoconf'." -elif test -d .git && test $git_was_ok = false && test $do_git = false; then +elif test -e .git && test $git_was_ok = false && test $do_git = false; then echo "You can now run '$0 git'." elif test ! -f config.status || test -n "`find src/stamp-h.in -newer config.status`"; then diff --git a/build-aux/gitlog-to-emacslog b/build-aux/gitlog-to-emacslog index 5c187f5..6b9cfc1 100755 --- a/build-aux/gitlog-to-emacslog +++ b/build-aux/gitlog-to-emacslog @@ -68,7 +68,7 @@ if [ -f "$output" ]; then fi # If this is not a Git repository, just generate an empty ChangeLog. -test -d .git || { +test -e .git || { >"$output" exit } diff --git a/configure.ac b/configure.ac index 790ff84..8f311cf 100644 --- a/configure.ac +++ b/configure.ac @@ -874,11 +874,11 @@ AC_ARG_ENABLE([gcc-warnings], gl_gcc_warnings=$enableval], [# By default, use 'warn-only' if it looks like the invoker of 'configure' # is a developer as opposed to a builder. This is most likely true - # if GCC is recent enough and there is a .git subdirectory; + # if GCC is recent enough and there is a .git directory or file; # however, if there is also a .tarball-version file it is probably # just a release imported into Git for patch management. gl_gcc_warnings=no - test -d "$srcdir"/.git && test ! -f "$srcdir"/.tarball-version && + test -e "$srcdir"/.git && test ! -f "$srcdir"/.tarball-version && gl_GCC_VERSION_IFELSE([5], [3], [gl_gcc_warnings=warn-only])] ) diff --git a/make-dist b/make-dist index 1cd1a50..c0b0a04 100755 --- a/make-dist +++ b/make-dist @@ -284,7 +284,7 @@ echo "Creating top directory: '${tempdir}'" mkdir ${tempdir} if [ "$changelog" = yes ]; then - if test -d .git; then + if test -e .git; then echo "Making top-level ChangeLog" make ChangeLog CHANGELOG=${tempdir}/ChangeLog || \ { x=$?; echo "make ChangeLog FAILED (try --no-changelog?)" >&2; exit $x; }