Skip to content

Commit 2160c2d

Browse files
committed
Skip installing .revision-hash if not running make install from a git checkout
Check --show-prefix rather than --is-inside-work-tree in case we're inside some other git repository (e.g. a ports tree).
1 parent 415e762 commit 2160c2d

File tree

3 files changed

+14
-11
lines changed

3 files changed

+14
-11
lines changed

Makefile

+3-5
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,9 @@ install: all
1818
cp .version zsh-syntax-highlighting.zsh $(SHARE_DIR)
1919
cp COPYING.md README.md changelog.md $(DOC_DIR)
2020
sed -e '1s/ .*//' -e '/^\[build-status-[a-z]*\]: /d' < README.md > $(DOC_DIR)/README.md
21-
if [ x"true" = x"`git rev-parse --is-inside-work-tree 2>/dev/null`" ]; then \
22-
git rev-parse HEAD; \
23-
else \
24-
cat .revision-hash; \
25-
fi > $(SHARE_DIR)/.revision-hash
21+
if prefix=`git rev-parse --show-prefix 2>/dev/null` && [ x"$$prefix" = x ]; then \
22+
git rev-parse HEAD > $(SHARE_DIR)/.revision-hash; \
23+
fi
2624
:
2725
# The [ -e ] check below is to because sh evaluates this with (the moral
2826
# equivalent of) NONOMATCH in effect, and highlighters/*.zsh has no matches.

changelog.md

+3
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,9 @@
7373

7474
- Recognize `env` as a precommand (e.g., `env FOO=bar ls`)
7575

76+
- Skip installing .revision-hash if not running `make install` from a git checkout.
77+
[#723]
78+
7679
# Changes in version 0.7.1
7780

7881
- Remove out-of-date information from the 0.7.0 changelog.

zsh-syntax-highlighting.zsh

+8-6
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,14 @@ builtin unalias -m '[^+]*'
4040
if true; then
4141
# $0 is reliable
4242
typeset -g ZSH_HIGHLIGHT_VERSION=$(<"${0:A:h}"/.version)
43-
typeset -g ZSH_HIGHLIGHT_REVISION=$(<"${0:A:h}"/.revision-hash)
44-
if [[ $ZSH_HIGHLIGHT_REVISION == \$Format:* ]]; then
45-
# When running from a source tree without 'make install', $ZSH_HIGHLIGHT_REVISION
46-
# would be set to '$Format:%H$' literally. That's an invalid value, and obtaining
47-
# the valid value (via `git rev-parse HEAD`, as Makefile does) might be costly, so:
48-
ZSH_HIGHLIGHT_REVISION=HEAD
43+
if [[ -f "${0:A:h}"/.revision-hash ]]; then
44+
typeset -g ZSH_HIGHLIGHT_REVISION=$(<"${0:A:h}"/.revision-hash)
45+
if [[ $ZSH_HIGHLIGHT_REVISION == \$Format:* ]]; then
46+
# When running from a source tree without 'make install', $ZSH_HIGHLIGHT_REVISION
47+
# would be set to '$Format:%H$' literally. That's an invalid value, and obtaining
48+
# the valid value (via `git rev-parse HEAD`, as Makefile does) might be costly, so:
49+
ZSH_HIGHLIGHT_REVISION=HEAD
50+
fi
4951
fi
5052
fi
5153

0 commit comments

Comments
 (0)