summaryrefslogtreecommitdiff
path: root/make/git.mk
blob: 068e7f319509f76029a1c29efe7daffadca8cbb7 (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.     git fetch $(origin)
  11.     $(if $(filter $(currentbranch),$(master)),,git branch -"$(master)" "$(origin)/$(master)" && git checkout "$(master)")
  12.     git merge --no-commit "$(origin)"
  13.     $(if $(noncurrentbranches),$(foreach branch,$(noncurrentbranches),git branch -"$(branch)" "$(origin)/$(branch)" && git checkout "$(branch)" && git merge --no-commit "$(origin)" &&) git checkout "$(master)")
  14. init:
  15. # Assume that initial cloning is done already when invoking this target
  16. #   git init
  17. #   git remote add -f -t "$(master)" -m "$(master)" origin "$(origin)"
  18. #   git merge origin
  19. #   git config remote.origin.push +"refs/heads/$(master)":"refs/heads/$(master)"
  20.     $(if $(filter $(currentbranch),$(master)),,git branch -"$(master)" "$(origin)/$(master)")
  21.     $(if $(noncurrentbranches),$(foreach branch,$(noncurrentbranches),git branch -"$(branch)" "$(origin)/$(branch)" &&) true)
  22.     $(if $(filter $(currentbranch),$(master)),,git checkout -"$(master)")
  23. .PHONYupdate init