-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathgit-lazymerge
More file actions
executable file
·52 lines (51 loc) · 1.3 KB
/
git-lazymerge
File metadata and controls
executable file
·52 lines (51 loc) · 1.3 KB
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
#!/bin/bash
# upstream=${2:-upstream/develop}
set -e
set -o pipefail
git diff --exit-code || ( echo "Can't rebase with differences" && exit 1 )
files=()
while [ -f "$1" ]
do
files+=( "$1" )
shift
done
remote=${1:-upstream}
refspec=${2:-develop}
shift 2
git fetch "${remote}"
for b in "${@}"
do
diff="diff.${b//\//.}"
echo -e "\n\nBegin merge: ${b}\n\n"
( [ "$(git rev-parse --abbrev-ref HEAD)" = "${b}" ] || \
git checkout "${b}" ) && \
git diff | tee "${diff}" && \
# Undo any changes that may have been done by the checkout
git reset --hard && \
git pull && \
# git rebase "${upstream}"
# git pull "${remote}" "${refspec}" && \
git merge --edit --log --verbose "${remote}/${refspec}" && \
echo -e "\nPushing ${b}" && \
( ( git signpush &&
( [ "${#files[@]}" -eq 0 ] || \
git rollback "${files[@]}" ) ) || \
( [ "${#files[@]}" -gt 0 ] && \
git rollback "${files[@]}" && \
git diff --exit-code && \
git signpush --no-verify ) ) || \
( echo Failed && exit 1 )
if [ -e "${diff}" ]
then
rm -fv "${diff}"
fi
git status
if [[ "${b}" != "${refspec}" ]] &&
git diff --quiet "${remote}/${refspec}"
then
echo
echo "Identical to ${remote}/${refspec}. Delete, rename, or push manually."
echo
exit 1
fi
done