diff options
author | Sasha Levin <sasha.levin@oracle.com> | 2015-11-01 17:55:37 -0500 |
---|---|---|
committer | Sasha Levin <sasha.levin@oracle.com> | 2015-11-01 17:55:37 -0500 |
commit | 6595a6960f033421fd4ca1738968598af067523e (patch) | |
tree | 8d6c6e01a4b084f1d39d2dc0191c2b41407846f4 | |
parent | 9c5b7d7af59e4cc67e4ff1c9e880fd32f687ce8e (diff) | |
download | stable-tools-6595a6960f033421fd4ca1738968598af067523e.tar.gz |
yank
Yanks a commit out of the current branch.
Signed-off-by: Sasha Levin <sasha.levin@oracle.com>
-rw-r--r-- | README | 6 | ||||
-rwxr-xr-x | stable-yank | 28 |
2 files changed, 34 insertions, 0 deletions
@@ -70,3 +70,9 @@ stable inclusion. This is useful to run with a mainline commit range to audit that all relevant commits marked for stable are in the local branch. + + +5) stable yank <commit sha1> + +Remove a commit out of the current branch. The user will need to fix merge +conflicts if such exist after removing that commit. diff --git a/stable-yank b/stable-yank new file mode 100755 index 0000000..2e4adef --- /dev/null +++ b/stable-yank @@ -0,0 +1,28 @@ +#!/bin/bash +# +# Yank a given commit out of the current branch +# + +if [ "$#" -ne 1 ]; then + echo "Usage: stable yank <commit sha1>" + exit 1 +fi + +# Grab the commit sha1 for the commits before and after the commit we want +# to yank out, we'll just move them together to yank out the commit we want +# to remove. +location=$(git log --pretty="%H" | grep -m1 -C1 $1) +if [ "$location" = "" ]; then + return +fi + +after=$(echo $location | awk {'print $1'}) +before=$(echo $location | awk {'print $3'}) + +# Topmost commit? +if [ "$before" = "" ] + git reset --hard HEAD^ + exit +fi + +git rebase --onto $before $after^ |