1

I am trying to migrate from StarTeam to git and I am facing some issues...

When I import the data from my existing StarTeam multiple times, the commit checksums are different everytime I try.

I can only import each branch as separate repo, then push the branch to my main repo as branch locally using git. Since the checksums are different, I think git is having difficulties creating correct history tree.

using git cat-file commit I found that the parents sha1 are different.

Is there a way to force git to make them the same commits if the contents are the same?

hoistyler
  • 222
  • 3
  • 12

3 Answers3

3

Is there a way to force git to make them the same commits if the contents are the same?

No, the SHA-1 calculation includes the id of the parent commits as well.

Csq
  • 5,775
  • 6
  • 26
  • 39
2

The commit id depends on content and parentage but also name, email, and timestamp for both author and committer. It looks very much like your importer isn't applying one or more timestamps, at a guess the committer timestamp since tracking author and committer separately is not common.

To check this, do git cat-file -pcommit_id for two commits you think should be the same. Differences in the parent ids will be fallout from whatever's causing this, check the timestamps at the end of the author and committer lines and also the tree hash to verify that the content really is identical.

If everything matches but the timestamps and parent id's you can use git filter-branch to do a mass rewrite, it's built to clean up messes like this. In the simplest case you might be able to get away with git filter-branch --env-filter='export GIT_COMMITTER_DATE="$GIT_AUTHOR_DATE"' -- --all

jthill
  • 55,082
  • 5
  • 77
  • 137
1

Is there a way to force git to make them the same commits if the contents are the same?

You can fetch those branches and then manually set the correct parent of a branch with grafts points.
Although now git replace + git filter-branch is the way to replace a parent commit.
Or just git replace.

You could also, in your case, rebase your imported branch on top of the correct parent.

Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250