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-first | |
parent | f727998817f5473acaa9d6806319bf7e812dc2e1 (diff) |
Make them my own.
Diffstat (limited to 'parent-prune-empty-first')
-rwxr-xr-x | parent-prune-empty-first | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/parent-prune-empty-first b/parent-prune-empty-first new file mode 100755 index 0000000..c9d73df --- /dev/null +++ b/parent-prune-empty-first @@ -0,0 +1,21 @@ +#!/usr/bin/env bash +# Usage: git filter-branch -f --parent-filter ~/git-filters/parent-prune-empty-first HEAD + +has_empty_tree() { + [[ "$(git rev-parse "${1}^{tree}")" == 4b825dc642cb6eb9a060e54bf8d69288fbee4904 ]] +} + +has_parents() { + git rev-parse "${1}^" &>/dev/null +} + +for parent in $(cat); do + if [[ "$parent" == '-p' ]]; then + continue + fi + if has_empty_tree "$parent" && ! has_parents "$parent"; then + continue + fi + printf ' -p %s ' "$parent" +done +echo |