Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add git-{merged,unmerged,merge-status}.
- Loading branch information
Showing
4 changed files
with
89 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
#!/bin/sh | ||
#!/bin/sh | ||
set -e | ||
|
||
usage () { | ||
echo "usage: git merge-status [-h] [<branch>]" >&2 | ||
echo >&2 | ||
echo "Shows merge status of all local branches against branch (defaults to master)." >&2 | ||
echo >&2 | ||
echo "Options:" >&2 | ||
echo "-h Show this help" >&2 | ||
} | ||
|
||
while getopts h flag; do | ||
case "$flag" in | ||
h) usage; exit 2;; | ||
esac | ||
done | ||
shift $(($OPTIND - 1)) | ||
|
||
bulletize () { | ||
sed -Ee 's/^/ - &/' | ||
} | ||
|
||
fail_if_empty () { | ||
empty=1 | ||
while read line; do | ||
echo "$line" | ||
empty=0 | ||
done | ||
test $empty -eq 0 | ||
} | ||
|
||
base="${1-master}" | ||
|
||
echo "Merged into $base:" | ||
if ! git merged "$base" | bulletize | fail_if_empty; then | ||
echo "(no branches)" | ||
fi | ||
|
||
echo | ||
echo "Not merged into $base:" | ||
if ! git merged -u "$base" | bulletize | fail_if_empty; then | ||
echo "(no branches)" | ||
fi |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#!/bin/sh | ||
set -e | ||
|
||
usage () { | ||
echo "usage: git merged [-uh] [<branch>]" >&2 | ||
echo >&2 | ||
echo "Shows what local branches have been merged into branch (defaults to master)." >&2 | ||
echo >&2 | ||
echo "Options:" >&2 | ||
echo "-u Show unmerged branches instead of merged branches" >&2 | ||
echo "-h Show this help" >&2 | ||
} | ||
|
||
unmerged=0 | ||
while getopts uh flag; do | ||
case "$flag" in | ||
u) unmerged=1;; | ||
h) usage; exit 2;; | ||
esac | ||
done | ||
shift $(($OPTIND - 1)) | ||
|
||
if [ $unmerged -eq 1 ]; then | ||
opts="--no-merged" | ||
else | ||
opts="--merged" | ||
fi | ||
|
||
base="${1-master}" | ||
git branch $opts "$base" | cut -c3- | grep -vxF "$base" |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#!/bin/sh | ||
set -e | ||
git merged -u "$@" |