具有相同历史记录的git和Mercurial存储库中的提交会具有相同的哈希值吗? [英] Will commits in git and mercurial repositories with the same history have the same hash?

查看:66
本文介绍了具有相同历史记录的git和Mercurial存储库中的提交会具有相同的哈希值吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用git克隆hg存储库时,或从hg迁移到git时,哈希值是否保持不变?

When using git to clone an hg repository, or when migrating from hg to git, will the hashes remain the same?

推荐答案

通过检查,答案似乎是否".

By inspection, the answer appears to be "no".

汞克隆ssh://some.server.com/path/hgproject/

git clone hg :: ssh://some.server.com/path/hgproject/

其次:

hg log -l 5

git log -n 5

为相同的提交显示不同的提交哈希.

Show different commit hashes for the same commits.

虽然git和hg都使用SHA-1散列,但它们的散列内容(也许是元数据)之间必须有所区别.

While both git and hg use SHA-1 hashes, there must be a difference in what they are hashing, perhaps the metadata.

任何依赖于哈希的工具都需要重写历史记录才能进行迁移.

Any tooling dependent on the hashes will require history rewriting for a migration.

@ngoldbaum&的每条评论 https://www.mercurial-scm.org/wiki/Nodeid :

Per comment by @ngoldbaum & https://www.mercurial-scm.org/wiki/Nodeid:

nodeid = sha1( min(parent1, parent2) + max(parent1, parent2) + contents )

而git 将其计算为:

sha1(
    meta data
        commit message
        committer
        commit date
        author
        authoring date
    hash-of-tree-object (effectively the working directory)
)

映射

如果使用 git-remote-hg 进行视图或转换,则可以在 .git/hg/origin/marks- {hg,git}中找到足够的信息来创建映射.

Mapping

if using git-remote-hg to do the view or conversion you can find enough information to create a mapping in .git/hg/origin/marks-{hg,git}

这篇关于具有相同历史记录的git和Mercurial存储库中的提交会具有相同的哈希值吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆