Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
CheukLeung opened this issue Jul 4, 2018 · 2 comments

Comments

@CheukLeung
Copy link

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.

@catskul
Copy link

catskul commented Apr 30, 2019

did you ever resolve/find a work around for this issue?

@felipec
Copy link
Owner

felipec commented Jun 4, 2019

The following is how I can reproduced it:

hg init /tmp/hg-git/testrepo &&
git clone -q hg::/tmp/hg-git/testrepo testrepo-git-1 &&
(cd testrepo-git-1 &&
 touch a && git add a && git commit -q -m "Add a" &&
 git push -q
) &&
git clone -q hg::/tmp/hg-git/testrepo testrepo-git-2 &&
git --git-dir=testrepo-git-1/.git/ rev-parse master &&
git --git-dir=testrepo-git-2/.git/ rev-parse master

I modified your steps a little bit, and I don't see the same problem. Maybe in your case HEAD is pointing to another ref?

I get:

warning: You appear to have cloned an empty repository.
3b3c1ee66e17361cf3e96156275b37dc3974c8a5
3b3c1ee66e17361cf3e96156275b37dc3974c8a5

Please try with the latest release (v0.4). Also, check that the output of git cat-file -p master is exactly the same in both repositories. The difference should give you a clue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants
@felipec @catskul @CheukLeung and others