[MERGED] osmo-ttcn3-hacks[master]: preserve uncommitted local changes in ttcn3 deps repositories

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

Harald Welte gerrit-no-reply at lists.osmocom.org
Thu Mar 22 12:56:54 UTC 2018


Harald Welte has submitted this change and it was merged.

Change subject: preserve uncommitted local changes in ttcn3 deps repositories
......................................................................


preserve uncommitted local changes in ttcn3 deps repositories

The previous Makefile rules would always overwrite uncommitted
local changes within repositories under the deps directory.

Let's assume that somebody who has local changes inside dependencies
knows what they are doing, and eliminate the risk of discarding
results of their work. Always skip repositories which contain
local changes. Only print a warning about such repositories.

Nothing changes for people who do not modify dependencies.

While testing this change, I noticed that the 'make distclean' target
was not reachable via 'make distclean', and I've fixed this as well.

Related: OS#3090
Change-Id: I0ee4ed70868b1c1efa39ad2bf200bf59ae2a2019
---
M deps/Makefile
1 file changed, 14 insertions(+), 1 deletion(-)

Approvals:
  Harald Welte: Looks good to me, approved
  Jenkins Builder: Verified



diff --git a/deps/Makefile b/deps/Makefile
index b448c73..d607874 100644
--- a/deps/Makefile
+++ b/deps/Makefile
@@ -50,7 +50,6 @@
 # Tag names from 'git-describe --tags'; if not available, a commit hash may be used instead.
 # In order to keep local changes in the repository of a dependency, set its commit to the
 # name of a local branch here (e.g. 'master').
-# CAREFUL: 'make clean' WILL DISCARD UNCOMMITTED CHANGES IN THESE REPOSITORIES!
 titan.Libraries.TCCUsefulFunctions_commit=	R.30.A
 titan.ProtocolEmulations.M3UA_commit=		R.2.A
 titan.ProtocolEmulations.SCCP_commit=	 	724c83fd2794e8ea362d08c42d9fc10fc1885ef1
@@ -93,30 +92,44 @@
 
 all: $(foreach dir,$(ALL_REPOS),$(dir)/update)
 clean: $(foreach dir,$(ALL_REPOS),$(dir)/clean)
+distclean: $(foreach dir,$(ALL_REPOS),$(dir)/distclean)
 
 define GIT_template
 $(1)_ORIGIN!=	if [ -d $(1) ]; then cd $(1) && git remote get-url origin; fi
 $(1)_HEAD!=	if [ -d $(1) ]; then cd $(1) && git describe --tags 2>/dev/null || git rev-parse HEAD; fi
+$(1)_MODIFIED!=	if [ -d $(1) ]; then cd $(1) && git diff --quiet --exit-code || echo -n "1"; fi
 
 $(1):
 	git clone $(2)/$(1)
 
 .PHONY: $(1)/update
 $(1)/update: $(1)
+ifeq ($$($(1)_MODIFIED),1)
+	@echo "WARNING: $(1) skipped because it contains uncommitted modifications!"
+else
 ifneq ($$($(1)_ORIGIN),$(2)/$(1))
 	cd $(1) && git remote set-url origin $(2)/$(1) && git fetch
 endif
 ifneq ($$($(1)_HEAD),$($(1)_commit))
 	cd $(1) && git checkout -q -f "$($(1)_commit)"
 endif
+endif
 
 .PHONY: $(1)/clean
 $(1)/clean: $(1)
+ifeq ($$($(1)_MODIFIED),1)
+	@echo "WARNING: $(1) skipped because it contains uncommitted modifications!"
+else
 	cd $(1) && git checkout -q -f "$($(1)_commit)" && git reset --hard
+endif
 
 .PHONY: $(1)/distclean
 $(1)/distclean:
+ifeq ($$($(1)_MODIFIED),1)
+	@echo "WARNING: $(1) skipped because it contains uncommitted modifications!"
+else
 	@rm -rf $(1)
+endif
 endef
 
 $(foreach dir,$(ECLIPSEGIT_REPOS), \

-- 
To view, visit https://gerrit.osmocom.org/7442
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I0ee4ed70868b1c1efa39ad2bf200bf59ae2a2019
Gerrit-PatchSet: 2
Gerrit-Project: osmo-ttcn3-hacks
Gerrit-Branch: master
Gerrit-Owner: Stefan Sperling <ssperling at sysmocom.de>
Gerrit-Reviewer: Harald Welte <laforge at gnumonks.org>
Gerrit-Reviewer: Jenkins Builder



More information about the gerrit-log mailing list