summaryrefslogtreecommitdiff
path: root/make/git.mk
diff options
context:
space:
mode:
Diffstat (limited to 'make/git.mk')
-rw-r--r--make/git.mk20
1 files changed, 15 insertions, 5 deletions
diff --git a/make/git.mk b/make/git.mk
index 072617e..2c8c827 100644
--- a/make/git.mk
+++ b/make/git.mk
@@ -7,14 +7,24 @@ branches = $(master)
# local name of origin
origin = origin
-currentbranch = $(shell git branch | grep ^\* | awk '{ print $2 }')
-noncurrentbranches = $(filter-out $(currentbranch),$(branches))
+allbranches = $(sort $(master) $(branches))
+currentbranch := $(shell git branch | grep ^\* | awk '{ print $2 }')
+noncurrentbranches := $(filter-out $(currentbranch),$(branches))
+
+#originbranches := $(shell git branch -r | perl -ne 'm,^.\s+'"$$origin"'/([a-z_]\S+)$, && print "$$1\n"' )
+localbranches := $(shell git branch | perl -ne 'm,^.\s+([a-z_]\S+)$$, && print "$$1\n"' )
update:
git fetch $(origin)
- $(if $(filter $(currentbranch),$(master)),,git branch -f "$(master)" "$(origin)/$(master)" && git checkout "$(master)")
- git pull "$(origin)"
- $(if $(noncurrentbranches),$(foreach branch,$(noncurrentbranches),git branch -f "$(branch)" "$(origin)/$(branch)" && git checkout "$(branch)" && git pull "$(origin)" &&) git checkout "$(master)")
+ for branch in $(filter-out $(localbranches),$(allbranches)); do \
+ git branch $$branch $(origin)/$$branch; \
+ done
+ for branch in $(noncurrentbranches); do \
+ git checkout $$branch; \
+ git pull $(origin); \
+ done
+ git checkout $(master)
+ git pull $(origin)
init:
git init