File: git-cherry-pick

package info (click to toggle)
systemd 232-25+deb9u11
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 46,164 kB
  • sloc: ansic: 290,592; xml: 49,217; makefile: 5,503; sh: 4,031; python: 2,596; perl: 1,838
file content (55 lines) | stat: -rwxr-xr-x 1,087 bytes parent folder | download | duplicates (5)
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
#!/bin/bash

set -e

if [ -z "$*" ] ; then
	echo "Usage: $0 [commit [commit ..]]"
	exit 1
fi


curbranch=$(git rev-parse --abbrev-ref HEAD)

# assert we got a branch
[ -n "$curbranch" ]

if [ $curbranch = HEAD ] ; then
	echo "You are not currently on a branch, cannot cherry-pick"
	exit 1
fi

case $curbranch in
	patch-queue/*)
		debbranch=${curbranch/patch-queue\/}
		pqbranch=$curbranch
		;;
	*)
		debbranch=$curbranch
		pqbranch=patch-queue/$curbranch
		;;
esac

commits=$(git rev-parse "$@")

if git rev-parse $pqbranch &>/dev/null ; then
	echo
	echo "Will recreate patch-queue branch $pqbranch"
	echo "It was pointing to" $(git rev-parse $pqbranch)
	echo
fi

gbp pq import --force

echo "Cherry-picking the following commits:"
echo "$commits"

picks=$(echo "$commits" | xargs echo exec git cherry-pick -x --no-edit --commit)

# find the first debian commit
firstdebian=$(git log -i --grep "topic.*debian" --pretty=%h --reverse $debbranch..$pqbranch | head -1)

sedexpr="/$firstdebian/i$picks"

GIT_EDITOR="sed -i -e '$sedexpr'" git rebase --interactive --no-autosquash $debbranch