generate_git: fix up autoresume feature
authorPaul Gortmaker <paul.gortmaker@windriver.com>
Fri, 7 Dec 2012 00:47:18 +0000 (19:47 -0500)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 7 Dec 2012 17:23:24 +0000 (09:23 -0800)
The autoresume feature allows you to restart from wherever
your current tree buildup last stopped (i.e. a git am fail
that you have since fixed, etc.)  It does this by looking
for a unique upstream commit ID if there is one in the
current top commit. If not, then it falls back to rummaging
around in the patches for something with a matching diffstat
to the top commit.

This was code I borrowed from another script I wrote, in
which all the patches were peers to the series file, i.e.
no subdirs of patches.  But the LTSI has subdirs.  So
teach autoresume where to find the patches.

An example usage:

  ltsi-test$git reset --hard HEAD~4
  HEAD is now at 4eddc87 codel: use u16 field instead of 31bits for rec_inv_sqrt
  ltsi-test$~/git/ltsi-kernel/scripts/generate_git -a
  resuming from current "patches.codel/codel-use-u16-field-instead-of-31bits-for-rec_inv_sq.patch"
  (671/674) Applying: net/codel: Add missing #include <linux/prefetch.h>
  (672/674) Applying: net: codel: fix build errors
  (673/674) Applying: fq_codel: should use qdisc backlog as threshold
  (674/674) Applying: codel: refine one condition to avoid a nul rec_inv_sqrt
  ltsi-test$

Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
scripts/generate_git

index cb1053d..9cdaf37 100755 (executable)
@@ -60,7 +60,7 @@ if [ -n "$AUTORESUME" ]; then
                DS1=`mktemp`
                DS2=`mktemp`
                git show | diffstat -p0 > $DS1
-               for i in $DIR/*\.patch ; do
+               for i in $DIR/patches\.*/*\.patch ; do
                        cat $i | diffstat -p0 > $DS2
                        cmp -s $DS1 $DS2
                        if [ $? = 0 ]; then
@@ -85,7 +85,7 @@ if [ -n "$AUTORESUME" ]; then
                exit 1
        fi
 
-       START=`basename $START`
+       START=`echo $START|sed 's/^.*patches\./patches./'`
        echo resuming from current \"$START\"
 fi