summaryrefslogtreecommitdiff
path: root/make/git.mk
blob: 332d82f59a14864a81002159a6a6baeed9000398 (plain)
  1. # main local branch (the one we want checked out)
  2. master = master
  3. # all local branches (including those needed by child clones)
  4. branches = $(master)
  5. # local name of origin
  6. origin = origin
  7. currentbranch := $(shell git branch | grep ^\* | awk '{ print $2 }')
  8. noncurrentbranches = $(filter-out $(currentbranch),$(branches))
  9. update:
  10. $(if $(filter $(currentbranch),$(master)),,git checkout "$(master)")
  11. git pull
  12. init:
  13. # Assume that initial cloning is done already when invoking this target
  14. # git init
  15. # git remote add -f -t "$(master)" -m "$(master)" origin "$(origin)"
  16. # git merge origin
  17. # git config remote.origin.push +"refs/heads/$(master)":"refs/heads/$(master)"
  18. $(if $(filter $(currentbranch),$(master)),,git branch -f "$(master)" "$(origin)/$(master)")
  19. $(if $(noncurrentbranches),$(foreach branch,$(noncurrentbranches),git branch -f "$(branch)" "$(origin)/$(branch)" &&) true)
  20. $(if $(filter $(currentbranch),$(master)),,git checkout -f "$(master)")
  21. .PHONY: update init