1 #!/bin/sh
2 # Copyright (c) 2010 Mirco Bauer <meebey@debian.org>
3 #
4 # Full GPL License: <http://www.gnu.org/licenses/gpl.txt>
5 #
6 # This program is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 2 of the License, or
9 # (at your option) any later version.
10 #
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
15 #
16 # You should have received a copy of the GNU General Public License
17 # along with this program; if not, write to the Free Software
18 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 CURRENT_BRANCH=$(git branch -l | egrep '^\* ' | cut -d ' ' -f 2)
21 UPSTREAM_BRANCH=$(grep -h upstream-branch $(git rev-parse --show-cdup)./debian/gbp.conf ~/.gbp.conf 2> /dev/null | head -n 1 | cut -d '=' -f 2)
22 DEBIAN_PATCHES=$(git branch -l | egrep '\s+debian/patches/')
23 if [ ! -z $UPSTREAM_BRANCH ]; then
24 git checkout $UPSTREAM_BRANCH
25 if [ $? != 0 ]; then
26 echo "Failed to swtich to upstream branch: $UPSTREAM_BRANCH, bailing out...";
27 exit 1
28 fi
29 fi
30 for DEBIAN_PATCH in $DEBIAN_PATCHES; do
31 git merge --no-commit --no-ff $DEBIAN_PATCH > /dev/null 2>&1
32 if [ $? != 0 ]; then
33 echo "ERROR: Test merge of $DEBIAN_PATCH failed, branch needs update!"
34 else
35 DELTA=$(git diff --no-ext-diff HEAD | wc -l)
36 if [ $DELTA = 0 ]; then
37 echo "WARNING: delta of $DEBIAN_PATCH is 0! Patch already applied upstream, drop branch!"
38 fi
39 fi
40 git reset --hard > /dev/null
41 done
42 git checkout $CURRENT_BRANCH
