mktar: Use `wc` instead of `du` in summary message
[sunny256-utils.git] / git-lc
blobb66cb0e91b0b52dd0da311a4c0d4df506ccaf66a
1 #!/usr/bin/env bash
3 #=======================================================================
4 # git-lc
5 # File ID: 81eb015e-87fb-11e0-9674-fefdb24f8e10
6 # List all Git branches where all the specified refs exists
7 # License: GNU General Public License version 2 or later.
8 #=======================================================================
10 urevs=$*
11 test -z "$urevs" && urevs=HEAD
12 count=0
13 unset revs
14 for u in $urevs; do
15 git log -1 $u &>/dev/null || { echo $u: Invalid ref >&2; exit 1; }
16 revs="$revs $(
17 git branch -a --contains=$u |
18 cut -c3- |
19 grep -v -e '(no branch)' -e '->' -e "^$u\$"
21 count=$[$count + 1]
22 done
23 echo $revs | fmt -1 | tr -d ' ' | sort | uniq -c | tr -s ' ' \
24 | grep "^ $count " | cut -f 3 -d ' ' | sort