Permalink
Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
executable file 39 lines (31 sloc) 860 Bytes
#!/bin/bash -e
## Check for updates, does a fetch (dry-run)
## but only for the current branch
## read input, display help if necessary
if [[ "$@" == *--help* ]]; then
cat<<EOF
Fetch and display output for the current branch
This command fetches changes from origin just like "git fetch",
but swallows all output that does not belong to the currently
checked out branch.
Usage:
git bfetch [--dry-run]
--dry-run: show what would be done without making
any changes.
EOF
exit 0;
fi
if [[ "$1" ]]; then
if [[ "$1" == "--dry-run" ]]; then
dryrun="--dry-run"
else
cat >&2 <<EOF
Error: bfetch does only accept the argument --dry-run, nothing else.
EOF
exit 1
fi
fi
## get current branch
branch=`git name-rev --name-only HEAD`
## do the fetch and filter the result
git fetch $dryrun 2>&1 | grep " $branch " | cat