summaryrefslogtreecommitdiff
path: root/make/git.mk
blob: 2c8c8274a496e33b3ffd6ca6b3419c7f18795377 (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. allbranches = $(sort $(master) $(branches))
  8. currentbranch := $(shell git branch | grep ^\| awk '{ print $2 }')
  9. noncurrentbranches := $(filter-out $(currentbranch),$(branches))
  10. #originbranches := $(shell git branch -r | perl -ne 'm,^.\s+'"$$origin"'/([a-z_]\S+)$, && print "$$1\n"' )
  11. localbranches := $(shell git branch | perl -ne 'm,^.\s+([a-z_]\S+)$$, && print "$$1\n"' )
  12. update:
  13.     git fetch $(origin)
  14.     for branch in $(filter-out $(localbranches),$(allbranches)); do \
  15.         git branch $$branch $(origin)/$$branch\
  16.     done
  17.     for branch in $(noncurrentbranches); do \
  18.         git checkout $$branch\
  19.         git pull $(origin); \
  20.     done
  21.     git checkout $(master)
  22.     git pull $(origin)
  23. init:
  24.     git init
  25.     git remote add --"$(master)" origin "$(origin)"
  26.     git merge origin
  27. #   git config remote.origin.push +"refs/heads/$(master)":"refs/heads/$(master)"
  28. .PHONYupdate init