Last active
September 2, 2015 13:54
-
-
Save jeenuv/6eef5533e9317c0eda60 to your computer and use it in GitHub Desktop.
Hands-free git show-branch
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| # | |
| # Script for hands-free use of 'git show-branch', with the option of specifying | |
| # unwanted refs by prefixing with ^ at the command line (syntax elsewhere | |
| # permitted). Refs to be ignored permanently can be added to $sed_script below | |
| # Main upstream branch | |
| upstream="${upstream:-origin/master}" | |
| # Refs pattern to always ignore | |
| sed_script=' | |
| /.stgit$/d | |
| ' | |
| # Process args | |
| for i; do | |
| case "$i" in | |
| ^*) | |
| # Remove all refs at the comand line prefixed with ^ | |
| sed_script="$sed_script;/$i/d" | |
| shift | |
| ;; | |
| esac | |
| done | |
| # Get short names of all head refs, sorted by committer date. Then filter | |
| # through sed | |
| refs="$(git for-each-ref --format='%(refname:short)' --sort='committerdate' refs/heads/\* | sed "$sed_script")" | |
| set -x | |
| git show-branch --sparse $upstream $refs $@ | |
| # vim: set tw=80: |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment