forked from kollerma/git-submodule-tools
-
Notifications
You must be signed in to change notification settings - Fork 0
/
git-bfetch
executable file
·46 lines (37 loc) · 955 Bytes
/
git-bfetch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#!/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
## from the git mailinglist:
function git
{
LC_MESSAGES=C command git "$@"
}
export git
## 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