[gjs: 3/9] tools: Update clang-format scripts
- From: Philip Chimento <pchimento src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gjs: 3/9] tools: Update clang-format scripts
- Date: Sun, 2 Sep 2018 00:07:42 +0000 (UTC)
commit 7ad357442d78aab68f15001d3af309f4ccf06078
Author: Philip Chimento <philip chimento gmail com>
Date: Sat Aug 18 16:20:46 2018 -0400
tools: Update clang-format scripts
A few bugs have been fixed upstream.
tools/apply-format | 6 +++---
tools/git-pre-commit-format | 27 +++++++++++++++++++++++++--
2 files changed, 28 insertions(+), 5 deletions(-)
---
diff --git a/tools/apply-format b/tools/apply-format
index 9ea3ead5..a601fe58 100755
--- a/tools/apply-format
+++ b/tools/apply-format
@@ -162,7 +162,7 @@ if [ ${#positionals[@]} -gt 0 ]; then
fi
[ -n "$style" ] || \
- error_exit "If you use --style you need to speficy a valid style."
+ error_exit "If you use --style you need to specify a valid style."
#######################################
# Detection of clang-format & friends #
@@ -181,7 +181,7 @@ if [ -z "$format" ]; then
$'On Ubuntu/Debian this is available in the clang-format package or, in\n' \
$'older distro versions, clang-format-VERSION.\n' \
$'On Fedora it\'s available in the clang package.\n' \
- $'You can also speficy your own path for clang-format by setting the\n' \
+ $'You can also specify your own path for clang-format by setting the\n' \
$'$CLANG_FORMAT environment variable.'
fi
@@ -249,7 +249,7 @@ if [ "$whole_file" = false ]; then
$'at https://github.com/barisione/clang-format-hooks/issues with details about\n' \
$'your operating system and setup.\n' \
$'\n' \
- $'You can also speficy your own path for clang-format-diff by setting the\n' \
+ $'You can also specify your own path for clang-format-diff by setting the\n' \
$'$CLANG_FORMAT_DIFF environment variable, for instance:\n' \
$'\n' \
$' CLANG_FORMAT_DIFF="python /.../clang-format-diff.py" \\\n' \
diff --git a/tools/git-pre-commit-format b/tools/git-pre-commit-format
index 36495093..90fcc334 100755
--- a/tools/git-pre-commit-format
+++ b/tools/git-pre-commit-format
@@ -80,6 +80,7 @@ function rel_realpath() {
# Find the top-level git directory (taking into account we could be in a submodule).
declare git_test_dir=.
declare top_dir
+
while true; do
top_dir=$(cd "$git_test_dir" && git rev-parse --show-toplevel) || \
error_exit "You need to be in the git repository to run this script."
@@ -90,8 +91,30 @@ while true; do
if [ -d "$top_dir/.git" ]; then
# We are done! top_dir is the root git directory.
break
- else
- # We are in a submodule if .git is a file!
+ elif [ -f "$top_dir/.git" ]; then
+ # We are in a submodule or git work-tree if .git is a file!
+ if [ -z "$(git rev-parse --show-superproject-working-tree)" ]; then
+ # The --show-superproject-working-tree option is available and we
+ # are in a work tree.
+ gitdir=$(<"$top_dir/.git")
+ gitdir=${gitdir#gitdir: }
+ topdir_basename=${gitdir##*/}
+ git_test_dir=${gitdir%/worktrees/$topdir_basename}
+ break
+ fi
+ # If show-superproject-working-tree returns non-empty string, either:
+ #
+ # 1) --show-superproject-working-tree is not defined for this version of git
+ #
+ # 2) --show-superproject-working-tree is defined and we are in a submodule
+ #
+ # In the first case we will assume it is not a work tree because people
+ # using that advanced technology will be using a recent version of git.
+ #
+ # In second case, we could use the value returned by
+ # --show-superproject-working-tree directly but we do not here because
+ # that would require extra work.
+ #
git_test_dir="$git_test_dir/.."
fi
done
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]