forked from nathanchance/env
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfmrg
More file actions
executable file
·59 lines (46 loc) · 1.91 KB
/
fmrg
File metadata and controls
executable file
·59 lines (46 loc) · 1.91 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
53
54
55
56
57
58
59
#!/usr/bin/env bash
#
# Merge Flash Kernel branches into each other
#
# Copyright (C) 2017 Nathan Chancellor
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>
# SOURCE OUR UNIVERSAL FUNCTIONS SCRIPT AND MAC CHECK
source common
# MAKE SURE WE ARE IN A KERNEL TREE
[[ ! -f Makefile ]] && report_error "Please run this in a kernel tree!"
# BRANCH TO MERGE
[[ $# -eq 0 ]] && report_error "Please supply the branch to merge!"
BTM=${1}
# CURRENT BRANCH
CB=$(git rev-parse --abbrev-ref HEAD)
# IF CURRENT BRANCH IS EQUAL TO BRANCH TO MERGE THEN SECOND PARAMETER
# WILL TELL THE SCRIPT TO CHECKOUT THAT BRANCH BEFORE MERGING
if [[ ${BTM} = ${CB} ]]; then
[[ $# -lt 2 ]] && report_error "Currently on ${1}! Please specify a branch to checkout."
CB=${2}
git checkout ${2}
fi
# RANGE
RANGE=${CB}..${BTM}
# NUMBER OF COMMITS DIFFERENT
ND=$(git rev-list --count ${RANGE} 2>/dev/null)
[[ ${ND} -eq 0 ]] && report_error "There is nothing to merge from ${BTM} into ${CB}!"
# MERGE COMMITS
git merge ${BTM} -m "Merge branch '${BTM}' into ${CB}
Changes in ${BTM}: (${ND} commits)
$(git log --reverse --format=" %s" ${RANGE})
Signed-off-by: $(git config --get user.name) <$(git config --get user.email)>"
[[ $? -ne 0 ]] && report_error "Merge needs manual intervention!
Resolve conflicts then run git merge --continue!" || header "${BTM} merged cleanly!" ${GRN}