Not logged inOpenClonk Forum
Up Topic Development / Developer's Corner / Change to git?
- - By Newton [de] Date 2011-12-16 19:28
The decision to choose hg over git more than 2 years ago was mostly based on the lack of any good windows GUI/explorer integration for git. Now we made a lot of experiences with Mercurial and some also with git so that we can judge better now which version control system is the better one for us. So far, I have only heard of negative comments about hg from different members of the team and I also find some functions of Mercurial/TortoiseHG tiring half-baked.

Speaking for myself, I am for switching to git given that
1. we don't loose the hg history when switching to git
2. there is a more comprehensive/easy-to-use GUI for windows available than for Mercurial
Parent - By Clonkonaut [ie] Date 2011-12-16 19:32
Does that mean we will start with proper branching as well?
Reply
Parent - - By PeterW [gb] Date 2011-12-16 20:10 Edited 2011-12-16 20:13
Well, I consider Git just as half-baked as Mercurial. I'm still really puzzled by having a VCS boast the importance of histories on one hand and promote liberal usage of "git rebase -i" on the other hand. The upsides I see with Git is that it has more under the hood by default, and it has GitHub. On the other hand we'd all need to re-learn for little benefit.

> 2. there is a more comprehensive/easy-to-use GUI for windows available than for Mercurial


Well, which one? Can it do hunk splitting on commit? Does it have good rebasing support?
Parent - - By Luchs [de] Date 2011-12-17 02:06
SmartGit can do both.
Parent - - By PeterW [gb] Date 2011-12-17 02:24
Hm, right, I wanted to try that one out. It is commercial though.
Parent - By PeterW [gb] Date 2011-12-17 03:17
Hm. Looks decent enough if you know what you're doing. Not sure about how suitable it is for newbies though. Also no interactive rebasing, as far as I can see. And what in the world is a reverse merge?
Parent - - By Newton [de] Date 2011-12-17 18:52

> Can it do hunk splitting on commit?


TortoiseHG removed hunk selection in the new version, didn't they? (Thats why I reinstalled the [really] old version after testing the new)
Parent - By PeterW [gb] Date 2011-12-18 01:00
Well, I actually mean hunk splitting - so you can select individual lines from the hunk that you want to commit. That's even finer. It's one of the features of git-gui that I really like.
Parent - - By Günther [de] Date 2011-12-18 03:01

> Well, I consider Git just as half-baked as Mercurial. I'm still really puzzled by having a VCS boast the importance of histories on one hand and promote liberal usage of "git rebase -i" on the other hand.


Given that the data structures underlaying git haven't changed in years (outside of perhaps a few additional fields and a more compact compression scheme), the tools to manipulate the data structures are able to do just about anything conveniently, and the UI is mostly friendly, I consider it fully baked. Git doesn't try to prevent history manipulation by limiting the tools, but by using cryptographic signatures and server access controls. Various people promote different work flows using git, but you don't count my using a mercurial extension and git to edit history that ends up in a mercurial repository as a design flaw of mercurial, which tries really hard to make history editing inconvenient, do you?
Reply
Parent - - By PeterW [gb] Date 2011-12-18 04:07
I'd say Mercurial and Git share the same problems, but they are more visible for Mercurial. Well, my hope is that the next generation of DVCS will do it better.
Parent - - By Günther [de] Date 2011-12-18 18:52
Why do you think there will be a next generation? What do you mean by "problems" and "it"? You'll always be able to edit history that only exists locally on your computer, and I can't see any reason why the next generation would have to make it any more difficult - the UI to make it easy already exists, so somebody will write the tool as soon as the next DVCS becomes popular should it somehow manage to do that without good history editing support.
Reply
Parent - - By PeterW [gb] Date 2011-12-18 23:05 Edited 2011-12-18 23:09
Well, I didn't want to go into details too much. But essentially the VCS should really find a good way to represent the whole work flow. I get the argument that one wants to document how exactly a certain change was made - but on the other hand it's clearly impractical to impose that kind of information on just anyone. So one needs to merge and rebase, which basically makes you wildly edit your patches as well as your history until all that information is lost.

A few examples that I have run into recently:
* I often end up putting new functionality in merge patches because it would just be hard to seperate them out. It's a bit of functionality that was forced by the combination of stuff in both branches. That's only a part of the merge - it's more like a combination patch. How do I represent that? If I put it in the merge it's hard to later recombine it (say, squash it with a bugfix). If I put it seperately, I have to leave some idiotic state in the merge.
* The VCS should track rebasing and cherry-picking. If I rebase and squash my patches, remove something specific to my branch, send it upstream, and the same changes come back at me from there, the VCS shouldn't throw up.
* If I merge a change on one branch, then want to merge in another branch, I have to resolve the very same conflicts again. Why doesn't the VCS know that I merged these particular patches together already?
* And seriously, rebasing interactively over merges should work. I think I wanted to squash two merges - which didn't work.

VCS need to think about patches more independently. Branches aren't series of patches - they are patch sets that change over time. Tag series, so to speak. The patch graph itself has compatibility edges (as in darcs) as well as documenting properties between patches - what got merged how with what (both classic merge as well as "squashes"), what got signed by whom, these kinds of things. You should be able to make all that crypto-secure and decentralized without problems.

I can draw you some pictures at OCM if you want ;)
Parent - By Günther [de] Date 2011-12-22 16:58

> I often end up putting new functionality in merge patches because it would just be hard to seperate them out. It's a bit of functionality that was forced by the combination of stuff in both branches. That's only a part of the merge - it's more like a combination patch. How do I represent that? If I put it in the merge it's hard to later recombine it (say, squash it with a bugfix). If I put it seperately, I have to leave some idiotic state in the merge.


Temporary idiocy isn't bad - you typically mostly need to examine past states to find out where a bug came from, so "building" and "not regressing" is enough. You can put a note in the commit message so nobody will wonder why the "idiotic state" is there, and put the features in the next commit.

> The VCS should track rebasing and cherry-picking. If I rebase and squash my patches, remove something specific to my branch, send it upstream, and the same changes come back at me from there, the VCS shouldn't throw up.


git rebase and merge mostly don't throw up, because they recognize when a patch is already applied, and simply skip it. I don't think you can do much better with version control support - what if upstream accidentally reverts your patch as part of a larger change or something? You would not want rebase to throw away your patch. One could argue that the assumption that git has to work well with plain patches that are transmitted by email is outdated nowadays, but I think the robustness against incomplete VCS metadata is nice.

> If I merge a change on one branch, then want to merge in another branch, I have to resolve the very same conflicts again. Why doesn't the VCS know that I merged these particular patches together already?


Git does. It's called "rerere", and I'm not quite sure why it's not enabled by default, but when it is, it automatically reuses previous conflict resolutions and presents you with a merged file you just have to mark as resolved.

> VCS need to think about patches more independently. Branches aren't series of patches - they are patch sets that change over time


Well, the basic data structure of git comes from the assumption that a commit represents a specific state of the working tree a developer actually had at some point. I think that's a nice property: It basically guarantees that when you check out a specific commit, you get what the committer of that commit had, not something that the VCS dreamed up. Of course, the committer often created that state by applying a patch or rebasing or something, so it isn't automatically a guarantee that the state is anything that actually existed for more than a second, but you can always create bad commits no matter which VCS you use.
A VCS that had patches as the basic data structure would leave me constantly scared that one of my patches would be mismanaged by the VCS so that it looked like I introduced a bug I didn't. With patch signing, you either have no more flexibility than git offers, or you risk making it seem like a patch you signed introduced a hidden back door via unfortunate interaction with a commit by the attacker.
Reply
Parent - By Clonk-Karl [de] Date 2011-12-16 20:36 Edited 2011-12-16 20:38
I much prefer git over hg and would appreciate such a change. It's faster, doesn't require extensions to get stuff done and has a more intuitive handling of tags and branches. Plus it happened to me twice already that I found my hg working copy in an inconsistent state and I needed to clone the repository freshly. This did not happen for me with git yet, and I use git more often than hg.
Reply
Parent - - By Zapper [de] Date 2011-12-16 21:59
I have no strong feelings for either HG or Git (which I never used).
The thing I missed most in HG was being able to do updates on file B when I had local changes on file A. Even though the update would not break anything, HG didn't allow that :(
Parent - By boni [at] Date 2011-12-18 18:50
Commit or Stash changes, Pull Update, Merge with commit, or re-stash them to the file(=also merge)? :I
At least that's how Git works.
Parent - - By Maikel Date 2011-12-16 22:06

>2. there is a more comprehensive/easy-to-use GUI for windows available than for Mercurial


You are still using a version below 2.0, I think 2.1 and above are pretty convenient to use.
So it should be better than that version and not some outdated one you're using, imo.

I am not against git nor hg, so do what you want :)
Parent - By PeterW [gb] Date 2011-12-17 00:49
For the higher versions you can't select hunks anymore for some reason though :/
Parent - By Maikel Date 2011-12-17 19:21
That never bothered me, but I can see your problem.
Parent - - By Isilkor Date 2011-12-17 12:20

> Speaking for myself, I am for switching to git given that
> 1. we don't loose the hg history when switching to git


We don't; we'd use the same process I used when I did the hg-git bridge trial run a couple of months ago.

> 2. there is a more comprehensive/easy-to-use GUI for windows available than for Mercurial


I can't answer that, the only GUI features I used of TortoiseHg was the repository browser.
Reply
Parent - By Günther [de] Date 2011-12-18 02:51

> We don't; we'd use the same process I used when I did the hg-git bridge trial run a couple of months ago.


Well, we could use the opportunity to do some history editing to fix up some hilarious author names and get rid of the extra hg information we wouldn't use anyway, and pretend the documentation was there from the start. (Which would make it easier for me to use git's graft feature to run blame on the documentation using my copy of the redwolf repository.)
Reply
Parent - - By Günther [de] Date 2011-12-18 02:49
I'm already using git for all my version control needs except for pushing and pulling to remote Clonk repositories, and the inconvenience of converting from/to hg when doing that is more than repaid by the various advantages git offers.

As for a windows GUI, git-gui and gitk aren't that bad, and only really lacking (interactive) rebase support. For normal rebase, we can probably just accept some merge commits or use the gitk context menu, though that's a bit awkward and a non-intuitive multi-step process. The few people using mq or the hg interactive-rebase feature are probably able to do "EDITOR=wordpad git rebase -i origin/master" from git bash or pick the patches using gitk. Using these tools has the advantage of not needing to install anything extra and being able to get help here in the forum or in #openclonk-dev. They're not changing too much over time, cross-platform, and we have people familiar with them or who could figure them out from their command line knowledge.
Reply
Parent - - By PeterW [gb] Date 2011-12-18 04:12
I'm really not comfortable with recommending git-gui / gitk. I am using them at work quite a bit now, but my initial experiences with them were frustrating, to say the least.
Parent - - By Günther [de] Date 2011-12-18 15:14
Mine weren't, at all, and they've even improved since.
Reply
Parent - By PeterW [gb] Date 2011-12-18 17:58
They are obviously hacked to death to provide exactly the functionality people working on big projects need. Once you are in that position it is quite natural - if you were putting stuff in, where would you hide it? But for somebody starting to make his own scenario, the whole thing is just daunting.

Same is true for SmartGit, btw: I think we'd need to write a guide which of these many buttons are actually safe to press. And what the hell an "index" is.
Parent - - By Newton [de] Date 2011-12-18 23:28
My normal workflow/use case is: commit to local repository, then synchronize with the main repository - of course I don't want to create branches for normal commits to the repository. With Mercurial, I first commit, then "Pull with Rebase" and then Push. If rebase works so differently in Git, how would my workflow look like in Git then?

Edit: Cause to be honest, the most-used use case for most of us is still the normal checkin into the repository (like svn commit/update) - I want that to be easy, then I am content.
Parent - By PeterW [gb] Date 2011-12-19 00:25
TortoiseGit seems to have a "Fetch & Rebase". Not sure though whether that does the right thing.
Parent - - By Caesar [de] Date 2011-12-19 00:59

> With Mercurial, I first commit, then "Pull with Rebase" and then Push.


I usually don't push directly, but to bitbucket first, have to rebase a second time and get torn apart. Yeah, repositories ftw...
Parent - By PeterW [gb] Date 2011-12-19 01:01
See my rant above ;)
Parent - - By Günther [de] Date 2011-12-22 17:10

> If rebase works so differently in Git, how would my workflow look like in Git then?


git commit
git pull --rebase
git push

My workflow looks like this:
git gui&
<commit with git gui one or more patches, edit/compile/test in between>
hg-to-git (a script using hg-git to pull from hg.openclonk.org via an intermediate hg repos)
git rebase -i hg/master (because I often have some patches I want to push and some that need further edits)
git push hg master (this opens up tortoisehg via a hook in the git repository in the hg repository)

The workflow with pure git would look like this:
git gui&
<commit, fetch from the shared repos in git gui>
git rebase -i origin/master
<push via git gui>

In other words, the only "missing piece" is a GUI rebase button, or ideally a complete interactive rebase GUI. But there's a merge button, and micro-merges aren't that bad.
Reply
Parent - Date 2012-03-12 10:57
Parent - By Günther [de] Date 2012-03-23 17:10
More details for those who want to work with git right now. You need to install hg-git. Then, edit the .hg/hgrc in your mercurial repository and add these lines:
[extensions]
hgext.bookmarks=
hgext.mq=
hgext.git=
[git]
intree = True


(I have the extensions enabled globally, but that should be equivalent.)

Then create a script that runs these commands:
#!/bin/bash
set -e
(
cd /path/to/your/hg/repository
hg pull -u || true
hg book -f -r default master
hg book -f -d stable-5.2 2> /dev/null || true
hg book -f -r stable-5.2 stable-5.2
hg book -f -d stable-5.1 2> /dev/null || true
hg book -f -r stable-5.1 stable-5.1
hg book -f -d controls 2> /dev/null || true
hg book -f -r Controls controls
hg book -f -d heavyresources 2> /dev/null || true
hg book -f -r heavy-resources heavyresources
hg gexport
)
git fetch origin


(I'm not quite sure how necessary the hg book commands are, but they work for me)
Run the script. Initial conversion with hg-git is slow and might take hours, but subsequent updates are tolerable. The script should fail with a no-git-repository-here error. Fix that with a
git clone /path/to/your/hg/repository /path/to/your/git/repository

Then edit /path/to/your/hg/repository/.git/hooks/post-receive (yes, that's a .git in your mercurial repository) and add these lines:
hg gimport
thg sync
Reply
Up Topic Development / Developer's Corner / Change to git?

Powered by mwForum 2.29.7 © 1999-2015 Markus Wichitill