summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVivek Dasmohapatra <vivek@collabora.co.uk>2015-05-29 01:37:06 (GMT)
committerVivek Dasmohapatra <vivek@collabora.co.uk>2015-05-29 01:37:06 (GMT)
commitbad1c94274a663416df3a5f4f4de97efe78f3eed (patch)
treeee2630d70c8504901beff8b21cdd08a72f95c1e5
parent84179539bbf4d390937403ccaa789048d1150031 (diff)
downloadmisc-scripts-bad1c94274a663416df3a5f4f4de97efe78f3eed.tar.gz
misc-scripts-bad1c94274a663416df3a5f4f4de97efe78f3eed.tar.xz
Git helper to turn merge commits into am patch series
-rw-r--r--git-make-patch-series.sh33
1 files changed, 33 insertions, 0 deletions
diff --git a/git-make-patch-series.sh b/git-make-patch-series.sh
new file mode 100644
index 0000000..3ae7ccc
--- /dev/null
+++ b/git-make-patch-series.sh
@@ -0,0 +1,33 @@
+#!/bin/bash
+
+calculate-start-number ()
+{
+ start=$(ls -1 | grep '.patch$' | sort -rn | head -1);
+ start=${start%%-*};
+ start=${start:-0};
+ start=10#$start;
+ start=$((start + 1))
+}
+
+git-commit-to-patches ()
+{
+ commit=$1;
+ read a b x < <(git log -1 --format=%P $commit);
+ git format-patch --start-number=$start ${b:+^}$a ${b:--1};
+}
+
+if [ $# -eq 0 ];
+then
+ echo "Usage: $0 commit-hash0 commit-hash1 …"
+ echo "Given a series of commit hashes, prepare a patch series,"
+ echo "expanding merge commits into their individual commits."
+ exit 1;
+fi;
+
+while [ $# -gt 0 ];
+do
+ calculate-start-number;
+ echo extracting $1 \@ $start;
+ git-commit-to-patches $1;
+ shift;
+done;