Skip to content

Git commit ID (SHA-1 hash) is not consistent between the committing repository and others #73

@CheukLeung

Description

@CheukLeung

Hey,

I am using the latest git-remote-hg and Git 2.18.0.
If I make a commit on a hg repository cloned with git-remote-hg and push it back to remote,
the commit ID from Git would not be usable by other people using the same repository.

The following is how I can reproduced it:

$ git clone hg::/tmp/hg-git/testrepo/ testrepo-git
Cloning into 'testrepo-git'...
warning: You appear to have cloned an empty repository.
$ cd testrepo-git/
$ touch a && git add a && git commit -m "Add a"
[master (root-commit) a328f58] Add a
 1 file changed, 0 insertions(+), 0 deletions(-)
 create mode 100644 a

$ git push
To hg::/tmp/hg-git/testrepo/
 * [new branch]      master -> master
$ git rev-parse HEAD
a328f582f9c0764814e48f4a957466fd86e7c4de
$ cd ..
$ git clone hg::/tmp/hg-git/testrepo/ testrepo-git-2
Cloning into 'testrepo-git-2'...
$ cd testrepo-git-2/ && git rev-parse HEAD
57508268690601d470e5aa29a0e6004508d8df73

The hash from the committing repository would not be updated even after pulling, and if another repository is using git-remote-hg for commit and push, it gets even more messier. I can reproduce it with 3 repositories and only 2 commits as below:

testrepo-git$ git log --oneline 
3cff113 (HEAD -> master, origin/master, origin/branches/default, refs/hg/origin/branches/default, refs/hg/origin/bookmarks/master) Add b
a328f58 Add a

testrepo-git-2$ git log --oneline 
a8ac55c (HEAD -> master, origin/master, origin/HEAD, refs/hg/origin/bookmarks/master) Add b
5750826 (origin/branches/default, refs/hg/origin/branches/default) Add a

testrepo-git-3$ git log --oneline 
4b311a5 (HEAD -> master, origin/master, origin/branches/default, origin/HEAD, refs/hg/origin/branches/default, refs/hg/origin/bookmarks/master) Add b
5750826 Add a

This means referencing using the Git commit ID is almost impossible, and it also make the hg repository impossible to be used as submodule in the Git repository, due to how git is referencing the ID for the submodule version.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions