You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by ti...@apache.org on 2016/01/15 04:05:19 UTC
mesos git commit: Fallback to --git-dir when --git-common-dir not
available.
Repository: mesos
Updated Branches:
refs/heads/master 76c26414c -> e3ab28fe8
Fallback to --git-dir when --git-common-dir not available.
The newly introduced way of finding the .git directory via
--git-common-dir is only supported on newer versions of git. Fallback
to the older --git-dir method if --git-common-dir is not supported.
Review: https://reviews.apache.org/r/42309/
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/e3ab28fe
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/e3ab28fe
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/e3ab28fe
Branch: refs/heads/master
Commit: e3ab28fe88c99b83d73d6143c8f3a0c087f171ba
Parents: 76c2641
Author: Kevin Klues <kl...@gmail.com>
Authored: Fri Jan 15 02:34:07 2016 +0100
Committer: Till Toenshoff <to...@me.com>
Committed: Fri Jan 15 02:40:58 2016 +0100
----------------------------------------------------------------------
bootstrap | 22 ++++++++++++++++++++--
support/post-reviews.py | 16 +++++++++++++++-
2 files changed, 35 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mesos/blob/e3ab28fe/bootstrap
----------------------------------------------------------------------
diff --git a/bootstrap b/bootstrap
index 519090d..4cd5ab7 100755
--- a/bootstrap
+++ b/bootstrap
@@ -31,9 +31,27 @@ relpath() {
echo "${to:-.}"
}
-# Install mesos default hooks and gitignore template.
-_hooksdir=`git rev-parse --git-common-dir`/hooks
+# Grab a reference to the repo's git directory. Usually this is simply .git in
+# the repo's top level directory. However, when submodules are used, it may
+# appear elsewhere. The most up-to-date way of finding this directory is to use
+# `git rev-parse --git-common-dir`. This is necessary to support things like
+# git worktree in addition to git submodules. However, as of January 2016,
+# support for the '--git-common-dir' flag is fairly new, forcing us to fall
+# back to the older '--git-dir' flag if '--git-common-dir' is not supported. We
+# do this by checking the output of `git rev-parse --git-common-dir` and seeing
+# if it gives us a valid directory back. If not, we set the git directory using
+# the '--git-dir' flag instead.
+_gitdir=`git rev-parse --git-common-dir`
+if test ! -d "${_gitdir}"; then
+ _gitdir=`git rev-parse --git-dir`
+fi
+
+# Grab a reference to the git hooks directory as well as the relative path from
+# the git hooks directory to the current directory.
+_hooksdir=${_gitdir}/hooks
_relpath=`relpath "${_hooksdir}" "${PWD}"`
+
+# Install mesos default hooks and gitignore template.
if test ! -e "${_hooksdir}/pre-commit"; then
ln -s "${_relpath}/support/hooks/pre-commit" "${_hooksdir}/pre-commit"
fi
http://git-wip-us.apache.org/repos/asf/mesos/blob/e3ab28fe/support/post-reviews.py
----------------------------------------------------------------------
diff --git a/support/post-reviews.py b/support/post-reviews.py
index ea36101..e4620e8 100755
--- a/support/post-reviews.py
+++ b/support/post-reviews.py
@@ -94,8 +94,22 @@ if diff_stat:
print 'Please commit staged changes before using post-reviews!'
sys.exit(1)
-top_level_dir = execute(['git', 'rev-parse', '--show-toplevel']).strip()
+# Grab a reference to the repo's git directory. Usually this is simply .git in
+# the repo's top level directory. However, when submodules are used, it may
+# appear elsewhere. The most up-to-date way of finding this directory is to use
+# `git rev-parse --git-common-dir`. This is necessary to support things like
+# git worktree in addition to git submodules. However, as of January 2016,
+# support for the '--git-common-dir' flag is fairly new, forcing us to fall
+# back to the older '--git-dir' flag if '--git-common-dir' is not supported. We
+# do this by checking the output of `git rev-parse --git-common-dir` and seeing
+# if it gives us a valid directory back. If not, we set the git directory using
+# the '--git-dir' flag instead.
git_dir = execute(['git', 'rev-parse', '--git-common-dir']).strip()
+if not os.path.isdir(git_dir):
+ git_dir = execute(['git', 'rev-parse', '--git-dir']).strip()
+
+# Grab a reference to the top level directory of this repo.
+top_level_dir = execute(['git', 'rev-parse', '--show-toplevel']).strip()
# Use the tracking_branch specified by the user if exists.
parser = argparse.ArgumentParser(add_help=False)