Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # TODO
- # Fork off of gitify? Make 'git_aliases.sh', store hash in .gitconfig, if it doesn't match, then source it? Might be cumbersome...
- # Can't figure out how to execute exported functions in a submodule foreach... Change git shell from sh to bash?
- # http://stackoverflow.com/questions/6483443/how-to-launch-a-bash-function-using-git-alias
- # Or just invoke 'bash -c' explicitly, if needed
- # The command using 'eval' do not fully escape the sub-commands... Need to figure that out, look at git-submodule.sh
- # Is it because of $@ instead of $* ?
- function git-setup-basic()
- {
- # Config stuff
- # Push to current branch
- # Alternative: 'tracking' (make sure to use `git push -u`?)
- # See: http://longair.net/blog/2011/02/27/an-asymmetry-between-git-pull-and-git-push/
- git config --global push.default current
- # Extras
- git config --global merge.tool meld
- git config --global diff.tool meld
- git config --global color.ui auto
- # Aliases
- git config --global alias.sfe 'submodule foreach'
- git config --global alias.sfer 'submodule foreach --recursive'
- # Add everything (new files, deleted files) and then commit
- git config --global alias.acommit '!git add -A && git commit -m'
- # branch-get based on: http://stackoverflow.com/a/13003854/170413
- git config --global alias.branch-get 'rev-parse --abbrev-ref HEAD'
- }
- # Set and checkout branches defined in .gitmodules
- # TODO
- # Currently working with 1.7.9.5, but latest 1.8.2.rc1 from repo has new submodule branch features as well. Figure out how to integrate...
- # Look at how `git pull` works with the new submodule.$name.update options, namely 'merge'
- # How to make this recursive? Is it worth it?
- # Use the same config style as git-submodule.sh, first check normal git config, then check .gitmodules? Would have to sync though...
- # Look into how to split this up
- # Specifying certain submodules? Or mark a set of submodules as the 'interesting' ones to push, pull, branch, commit, etc?
- # Call in a submodule and know supermodule's path? GitPython?
- # Add these as shell ! aliases?
- function git-sfe-branch-write() { git sfe 'git config -f $toplevel/.gitmodules submodule.$name.branch $(git branch-get)'; }
- function git-sfe-branch-checkout() { git sfe 'if branch=$(git config -f $toplevel/.gitmodules submodule.$name.branch 2>/dev/null); then git checkout $branch; fi'; }
- function git-sfe-acommit { git sfe "git acommit \"$1\" || echo Skip"; }
- # TODO Get these to match up, currently they don't
- # git sfe "git add -A && git commit -m \"'ello\""
- # git-tsfe "git add -A && git commit -m \"'ello\""
- # This one works at top-level, but once it's passed to sfe, it's lost... Not sure why
- # Submodule foreach, depth/child-first recursion
- function git-sfed() { git sfe "git sfe \"$@\" && eval \"$@\""; }
- # Child-first recursion
- function git-tsfe() { git sfe "git sfe \"$@\" && eval \"$@\"" && echo "Entering supermodule '$(basename $PWD)'" && eval "$@"; }
- function git-tsfe-acommit() { git-tsfe "git acommit \"$1\" || echo Skip"; }
- # Instead of 'git add -A ...', make a command that checks if directory is dirty, and if so call up 'git gui' - better practice for knowing what changes?
- # Trying out mb14's suggestion: http://stackoverflow.com/a/14856390/170413
- # Issue with escaping the quotes as well - bash function fun...
- # git-sfed-mb14 "git add -A && git commit -m \"'ello\""
- function git-sfed-mb14()
- {
- git submodule foreach --recursive | tac | sed 's/Entering //' | xargs -n 1 bash -c "cd \$1 && eval \"$@\"" _
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement