diff options
author | Luke Shumaker <lukeshu@sbcglobal.net> | 2017-01-14 20:34:23 -0500 |
---|---|---|
committer | Luke Shumaker <lukeshu@sbcglobal.net> | 2017-01-14 20:34:40 -0500 |
commit | 44cacd6b1cee00c3326d28bffdf18df0356b7204 (patch) | |
tree | 9599befa07f06275d4820e5f1bbebb77dd6ec62d /parent-prune-empty-merge | |
parent | f727998817f5473acaa9d6806319bf7e812dc2e1 (diff) |
Make them my own.
Diffstat (limited to 'parent-prune-empty-merge')
-rwxr-xr-x | parent-prune-empty-merge | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/parent-prune-empty-merge b/parent-prune-empty-merge new file mode 100755 index 0000000..10e9fb8 --- /dev/null +++ b/parent-prune-empty-merge @@ -0,0 +1,20 @@ +#!/usr/bin/env ruby +# Usage: git filter-branch -f --parent-filter ~/git-filters/parent-prune-empty-merge HEAD + +# Function to determine if commit 'c' already an ancestor of any of +# the commits given in 'commits' +def subsumed_by(c,commits) + commits.any? do |c2| + c!=c2 && c==`git merge-base #{c} #{c2}`.chomp() + end +end + +# Get the current list of parents +parents = $stdin.read.split.select{|a|a!='-p'} + +# Pnly keep parents that are not subsumed by other parents. +parents = parents.select do |p| + not subsumed_by(p,parents) +end + +puts parents.uniq.map{|p|"-p #{p}"}.join(' ') |