From a6d7d5da07dbf54bfa896618a21f91635fe9b924 Mon Sep 17 00:00:00 2001 From: Christian Helmuth Date: Tue, 4 Sep 2018 12:03:30 +0200 Subject: [PATCH] tool/port: limit destructive git operations to port Issue #2959 --- tool/ports/mk/common.inc | 3 +++ tool/ports/mk/install.mk | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/tool/ports/mk/common.inc b/tool/ports/mk/common.inc index f2bbcc1e8..1c80f09e5 100644 --- a/tool/ports/mk/common.inc +++ b/tool/ports/mk/common.inc @@ -8,6 +8,9 @@ SHELL := bash VERBOSE ?= @ ECHO := echo -e +# limit destructive git operations (e.g., reset) to local directory +GIT := git --git-dir=.git + BRIGHT_COL ?= \x1b[01;33m DARK_COL ?= \x1b[00;33m DEFAULT_COL ?= \x1b[0m diff --git a/tool/ports/mk/install.mk b/tool/ports/mk/install.mk index bb1aeadcc..efb40cc3b 100644 --- a/tool/ports/mk/install.mk +++ b/tool/ports/mk/install.mk @@ -162,7 +162,7 @@ _git_dir = $(call _assert,$(DIR($1)),Missing declaration of DIR($*)) test -d $$dir || $(MSG_DOWNLOAD)$(URL($*)); \ test -d $$dir || git clone $(URL($*)) $$dir &> >(sed 's/^/$(MSG_GIT)/'); \ $(MSG_UPDATE)$$dir; \ - cd $$dir && git fetch && git reset -q --hard HEAD && git checkout -q $(REV($*)) + cd $$dir && $(GIT) fetch && $(GIT) reset -q --hard HEAD && $(GIT) checkout -q $(REV($*)) ##