summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuke Shumaker <lukeshu@lukeshu.com>2019-02-18 19:17:31 -0500
committerLuke Shumaker <lukeshu@lukeshu.com>2019-02-18 19:17:31 -0500
commit04e08c2176065f22bf8b09967cb37f789a07a7db (patch)
treed69f851e35da3dbcf77b79c71768bffd0dbcc424
parent19290114fc022f7ff8e08338411c885251d206dd (diff)
fi-prune-empty: Whoops, some merges weren't being pruned
If 2 parents both mapped to the same commit, it would emit a commit with 2 of the same parent, bypassing the no-change logic.
-rw-r--r--fi-prune-empty/main.go10
1 files changed, 9 insertions, 1 deletions
diff --git a/fi-prune-empty/main.go b/fi-prune-empty/main.go
index 7c1ea5d..fb25794 100644
--- a/fi-prune-empty/main.go
+++ b/fi-prune-empty/main.go
@@ -149,11 +149,19 @@ func (h *PruneEmpty) subsumedBy(c string, commits []string) bool {
}
return false
}
+func inArray(needle string, haystack []string) bool {
+ for _, straw := range haystack {
+ if straw == needle {
+ return true
+ }
+ }
+ return false
+}
func (h *PruneEmpty) pruneParents(commits []string) []string {
var ret []string
for _, c := range commits {
c = h.fixupMark(c)
- if c != "" && !h.subsumedBy(c, commits) {
+ if c != "" && !h.subsumedBy(c, commits) && !inArray(c, ret) {
ret = append(ret, c)
}
}