diff options
| author | Paul Eggert | 2016-04-13 18:19:04 -0700 |
|---|---|---|
| committer | Paul Eggert | 2016-04-13 18:19:33 -0700 |
| commit | d3edc09c3f4fdce24d4f66c5a94302cae5d26980 (patch) | |
| tree | 97da3745f884b5a62a8bdf226a99757c9ff0ea65 | |
| parent | 1aebe99145e9ef612cdb272800904e3ba9297196 (diff) | |
| download | emacs-d3edc09c3f4fdce24d4f66c5a94302cae5d26980.tar.gz emacs-d3edc09c3f4fdce24d4f66c5a94302cae5d26980.zip | |
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.
| -rwxr-xr-x | autogen.sh | 26 |
1 files changed, 17 insertions, 9 deletions
diff --git a/autogen.sh b/autogen.sh index 2e10a77cb37..cd0accd6793 100755 --- a/autogen.sh +++ b/autogen.sh | |||
| @@ -112,7 +112,8 @@ for arg; do | |||
| 112 | --help) | 112 | --help) |
| 113 | exec echo "$0: usage: $0 [all|autoconf|git]";; | 113 | exec echo "$0: usage: $0 [all|autoconf|git]";; |
| 114 | all) | 114 | all) |
| 115 | do_autoconf=true do_git=true;; | 115 | do_autoconf=true |
| 116 | test -e .git && do_git=true;; | ||
| 116 | autoconf) | 117 | autoconf) |
| 117 | do_autoconf=true;; | 118 | do_autoconf=true;; |
| 118 | git) | 119 | git) |
| @@ -260,7 +261,8 @@ git_config () | |||
| 260 | echo 'Configuring local git repository...' | 261 | echo 'Configuring local git repository...' |
| 261 | case $cp_options in | 262 | case $cp_options in |
| 262 | --backup=*) | 263 | --backup=*) |
| 263 | cp $cp_options --force .git/config .git/config || exit;; | 264 | config=$git_common_dir/config |
| 265 | cp $cp_options --force -- "$config" "$config" || exit;; | ||
| 264 | esac | 266 | esac |
| 265 | fi | 267 | fi |
| 266 | echo "git config $name '$value'" | 268 | echo "git config $name '$value'" |
| @@ -272,6 +274,13 @@ git_config () | |||
| 272 | 274 | ||
| 273 | ## Configure Git, if requested. | 275 | ## Configure Git, if requested. |
| 274 | 276 | ||
| 277 | # Get location of Git's common configuration directory. For older Git | ||
| 278 | # versions this is just '.git'. Newer Git versions support worktrees. | ||
| 279 | |||
| 280 | test -e .git && git_common_dir=`git rev-parse --git-common-dir 2>/dev/null` || | ||
| 281 | git_common_dir=.git | ||
| 282 | hooks=$git_common_dir/hooks | ||
| 283 | |||
| 275 | # Check hashes when transferring objects among repositories. | 284 | # Check hashes when transferring objects among repositories. |
| 276 | 285 | ||
| 277 | git_config transfer.fsckObjects true | 286 | git_config transfer.fsckObjects true |
| @@ -296,12 +305,11 @@ tailored_hooks= | |||
| 296 | sample_hooks= | 305 | sample_hooks= |
| 297 | 306 | ||
| 298 | for hook in commit-msg pre-commit; do | 307 | for hook in commit-msg pre-commit; do |
| 299 | cmp build-aux/git-hooks/$hook .git/hooks/$hook >/dev/null 2>&1 || | 308 | cmp -- build-aux/git-hooks/$hook "$hooks/$hook" >/dev/null 2>&1 || |
| 300 | tailored_hooks="$tailored_hooks $hook" | 309 | tailored_hooks="$tailored_hooks $hook" |
| 301 | done | 310 | done |
| 302 | for hook in applypatch-msg pre-applypatch; do | 311 | for hook in applypatch-msg pre-applypatch; do |
| 303 | src=.git/hooks/$hook.sample | 312 | cmp -- "$hooks/$hook.sample" "$hooks/$hook" >/dev/null 2>&1 || |
| 304 | cmp "$src" .git/hooks/$hook >/dev/null 2>&1 || | ||
| 305 | sample_hooks="$sample_hooks $hook" | 313 | sample_hooks="$sample_hooks $hook" |
| 306 | done | 314 | done |
| 307 | 315 | ||
| @@ -311,15 +319,15 @@ if test -n "$tailored_hooks$sample_hooks"; then | |||
| 311 | 319 | ||
| 312 | if test -n "$tailored_hooks"; then | 320 | if test -n "$tailored_hooks"; then |
| 313 | for hook in $tailored_hooks; do | 321 | for hook in $tailored_hooks; do |
| 314 | dst=.git/hooks/$hook | 322 | dst=$hooks/$hook |
| 315 | cp $cp_options build-aux/git-hooks/$hook "$dst" || exit | 323 | cp $cp_options -- build-aux/git-hooks/$hook "$dst" || exit |
| 316 | chmod a-w "$dst" || exit | 324 | chmod -- a-w "$dst" || exit |
| 317 | done | 325 | done |
| 318 | fi | 326 | fi |
| 319 | 327 | ||
| 320 | if test -n "$sample_hooks"; then | 328 | if test -n "$sample_hooks"; then |
| 321 | for hook in $sample_hooks; do | 329 | for hook in $sample_hooks; do |
| 322 | cp $cp_options .git/hooks/$hook.sample .git/hooks/$hook || exit | 330 | cp $cp_options -- "$hooks/$hook.sample" "$hooks/$hook" || exit |
| 323 | chmod a-w .git/hooks/$hook || exit | 331 | chmod a-w .git/hooks/$hook || exit |
| 324 | done | 332 | done |
| 325 | fi | 333 | fi |