felipec / git

Fork of Junio Hamano's git for users
Other
204 stars 34 forks source link

Git commit IDs change in unwanted way #31

Closed vedranmiletic closed 11 years ago

vedranmiletic commented 11 years ago

Hi,

I'm trying to sync https://github.com/nsnam/ns-3-dev-git with http://code.nsnam.org/ns-3-dev the following way

$ git clone https://github.com/nsnam/ns-3-dev-git
$ cd ns-3-dev-git

Last two commits are commit d88765d33826d4bc0b78cc0ae9e2a21090a5290e and commit 816c48ce8457e8996066bae0150726b5119bb6de.

Fine, let's add Hg remote repo.

$ git remote add code-nsnam hg::http://code.nsnam.org/ns-3-dev
$ git fetch code-nsnam
$ git checkout code-nsnam/master

Same commits now have IDs 72150d331d917fd606a786070f0611c481058ae9 and 9de0a52639373183e751a36bd1fc3f5f5034a0d3.

Why does this happen? Is this by design, or is it a bug? If it's a bug, can it be fixed?

felipec commented 11 years ago

So the first repository was converted with another tool; it's bound to be different. Git and Mercurial are different, and different tools have different strategies to map the Mercurial differences into Git, which generates different results. A small example is one project choosing to map the author "john" to "john ", and the other to "< john>", the result is a different repository and a different SHA-1.

The only other git<->hg tool that remote-hg supports, is hg-git, and you can enable compatibility for it with:

% git config --global remote-hg.hg-git-compat true

Adding support to any other tool would probably be a waste of time, and futile effort trying to reproduce bugs in other tools.

felipec commented 11 years ago

That being said, if you have a list of Git SHA-1's to Mercurial SHA-1's for the repository, it should be possible for remote-hg to use https://github.com/nsnam/ns-3-dev-git as a basis, and work on top of that.

vedranmiletic commented 11 years ago

Understood, even though I'm pretty sure that it was converted using git-remote-hg. Let me do some experiments with conversion to see if I can make it break.

felipec commented 11 years ago

There are different remote-hg's, this is the other one:

https://github.com/msysgit/msysgit/wiki/Guide-to-git-remote-hg

cawka commented 11 years ago

I think there is a small issue with git-remote-hg (I got it from hg-next branch). In particular, the mercurial repository contains a commit http://code.nsnam.org/ns-3-dev/rev/e53ac3c458e9 which does not fully and correctly specify AUTHOR field (in this particular case, there is only email, which is not included in <>). This case, and may be some others (I remember having similar issue with name fields, where name and email in <> are not separated with a space).

So, what is happening. Commit https://github.com/nsnam/ns-3-dev-git/commit/81939255a3fab70ec1f644b364e97ab22101498a got the email field fully converted this way:

commit ccbab6e7da274fa08acdc2707470aaa3579f0cfb
Author: tomh@powerbook.local <tomh@powerbook.local>
Date:   Sat Aug 26 14:20:18 2006 -0700

    test of commit

, but when I'm cloning with git-remote-hg from the hg-next branch, I'm seeing:

commit 389be32102bef7481c8ff02e52222e8f7dd307a6
Author: Unknown <tomh@powerbook.local>
Date:   Sat Aug 26 14:20:18 2006 -0700

    test of commit

Personally, I would prefer having former Author field format, since it will at least show as email, not just as Unknown on github and other systems which show only author name.

felipec commented 11 years ago

Everybody has different opinions on the author sanitation stuff. Personally I prefer Unknown, but either way, the current function is quite convoluted, and I wouldn't want to complicate it more.

I think what is most sensible is to have an author map, so every user can map mercurial authors to whatever they want. It shouldn't be too complicated and should fit everyone's needs.

felipec commented 11 years ago

All right. If you want support for custom author mapping, open another issue ticket, I think the questions here have been basically resolved.