Skip to content

Commit

Permalink
git/githistory: only save change commits
Browse files Browse the repository at this point in the history
  • Loading branch information
ttaylorr committed Aug 30, 2017
1 parent cd22089 commit 7aeeec2
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions git/githistory/rewriter.go
Original file line number Diff line number Diff line change
Expand Up @@ -215,28 +215,37 @@ func (r *Rewriter) Rewrite(opt *RewriteOptions) ([]byte, error) {

// Construct a new commit using the original header information,
// but the rewritten set of parents as well as root tree.
rewrittenCommit, err := r.db.WriteCommit(&odb.Commit{
rewrittenCommit := &odb.Commit{
Author: original.Author,
Committer: original.Committer,
ExtraHeaders: original.ExtraHeaders,
Message: original.Message,

ParentIDs: rewrittenParents,
TreeID: rewrittenTree,
})
if err != nil {
return nil, err
}

var newSha []byte

if original.Equal(rewrittenCommit) {
newSha = make([]byte, len(oid))
copy(newSha, oid)
} else {
newSha, err = r.db.WriteCommit(rewrittenCommit)
if err != nil {
return nil, err
}
}

// Cache that commit so that we can reassign children of this
// commit.
r.cacheCommit(oid, rewrittenCommit)
r.cacheCommit(oid, newSha)

// Increment the percentage displayed in the terminal.
p.Count(1)

// Move the tip forward.
tip = rewrittenCommit
tip = newSha
}

if opt.UpdateRefs {
Expand Down

0 comments on commit 7aeeec2

Please sign in to comment.