forked from kollerma/git-submodule-tools
-
Notifications
You must be signed in to change notification settings - Fork 0
/
git-rfetch
executable file
·62 lines (55 loc) · 1.37 KB
/
git-rfetch
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#!/bin/bash -e
## Check for updates, is an alias for
## git fetch --recurse-submodule=yes
## with some modifications of the output.
## read input, display help if necessary
if [[ "$@" == *--help* ]]; then
cat<<EOF
Recursive fetch
This command recursively fetches changes from origin.
(Up to output it is equal to running
git fetch --recurse-submodules=yes.)
Usage:
git rfetch ...
...: same arguments as git fetch
EOF
exit 0;
fi
## from the git mailinglist:
function git
{
LC_MESSAGES=C command git "$@"
}
export git
## run fetch
tmp=`git fetch --recurse-submodules=yes "$@" 2>&1`
## and process output
last="_start_"
output=""
while read line; do
if [[ "${line:0:5}" == "Fetch" ]]; then
last="$line"
elif [[ "${line:0:4}" == "From" ]]; then
if [[ "$last" == "_start_" ]]; then
output="${output}There are updates available for the current repository.
"
elif [[ "$last" != "" ]]; then
output="${output}There are updates available for ${last:19}.
"
fi
last=""
fi
done <<< "$tmp"
if [[ "$output" ]]; then
if [[ "$@" == "--dry-run" ]]; then
cat<<EOF
${output}Use "git rfetch" to fetch updates.
Then go to the innermost submodules and use "git rpull" to merge the updates.
EOF
else
cat<<EOF
${output}Fetched updates. Now use "git rdiff" to show the differing files.
Then "git rpull" in the correct folder to merge updates.
EOF
fi
fi