diff options
author | Luke Shumaker <lukeshu@lukeshu.com> | 2019-02-17 17:13:15 -0500 |
---|---|---|
committer | Luke Shumaker <lukeshu@lukeshu.com> | 2019-02-17 17:13:15 -0500 |
commit | 895c04be3d78cf24bc2e30586edace3cb59df7d1 (patch) | |
tree | f2e81927f1e34358e8352fbc2bf6e07b8fde0a0f | |
parent | 3fe2af5d78601bc0211fc6d3ffe8c57cd18eaf2b (diff) |
fi-prune-empty: fix?
-rw-r--r-- | fi-prune-empty/main.go | 24 |
1 files changed, 18 insertions, 6 deletions
diff --git a/fi-prune-empty/main.go b/fi-prune-empty/main.go index e56250c..569e3cf 100644 --- a/fi-prune-empty/main.go +++ b/fi-prune-empty/main.go @@ -134,7 +134,7 @@ func (h *PruneEmpty) pruneParents(commits []string) []string { var ret []string for _, c := range commits { c = h.fixupMark(c) - if !h.subsumedBy(c, commits) { + if c != "" && h.subsumedBy(c, commits) { ret = append(ret, c) } } @@ -155,17 +155,29 @@ func (h *PruneEmpty) CmdCommitEnd(cmd libfastimport.CmdCommitEnd) error { sort.Stable(h.commitFile) // decide whether to skip this commit - if len(parents) == 1 && TreesEqual(h.trees[parents[0]], h.commitFile) { - h.replace[mark] = parents[0] - return nil + switch len(parents) { + case 0: + if len(h.commitFile) == 0 { + h.replace[mark] = "" + return nil + } + h.commitMeta.From = "" + h.commitMeta.Merge = nil + case 1: + if TreesEqual(h.trees[parents[0]], h.commitFile) { + h.replace[mark] = parents[0] + return nil + } + fallthrough + default: + h.commitMeta.From = parents[0] + h.commitMeta.Merge = parents[1:] } // remember the commit h.addCommit(mark, parents, h.commitFile) // emit the commit - h.commitMeta.From = parents[0] - h.commitMeta.Merge = parents[1:] if err := h.backend.Do(h.commitMeta); err != nil { return err } |