[git] Using a local repo to update the game on my computer

For topics that do not fit in another sub-forum.
Post Reply
Message
Author
Jaumito
Space Kraken
Posts: 158
Joined: Tue May 16, 2017 3:42 am
Location: Catalonia, France, Europe, Earth, Sol, Orion Arm, Milky Way, Virgo Cluster

[git] Using a local repo to update the game on my computer

#1 Post by Jaumito » Sun Sep 09, 2018 2:09 pm

Following Dilvish's advice, I'm getting started with git at last.

The basic idea would be to clone the version of the game I'm playing in a working directory, do some changes (custom species mainly), and then update my own game (/usr/share/games/freeorion). I'm still not sure how to do that last part.
Dilvish wrote:
Sun May 20, 2018 5:07 pm
Jaumito wrote:I just need to remember which ones I had to alter - stringtables, the pedia, the common macros stuff, etc. - I think there's about a dozen of them.
Since you are thinking about contributing to the project, I'd highly recommend you read up a little bit on using Git. That tool (via github) is the way such contributions get submitted, and using it would also automatically track your modified files.

I am pretty sure if you make a local git repo, and then make a branch checking out the exact same commit as corrsponds to the version of FO you are playing now (either the version number tag or a sufficient portion of the relevant commit will be embedded into the version name displayed ingame), then you could just copy your entire modified 'default' directory over the one in your local git repo, and git would automatically figure out which files had been modified (and what those modifications were).
This part I don't understand. How would git know that if I just copy (I guess you mean manually, e.g. with cp) files to a directory that's not part of a git project?

What I'd like would be to make git aware I'm supposed to commit (and undo) changes to my local version of the game. Isn't there a way to do that? Or should I just build a second freeorion from my local repo?

o01eg
Space Kraken
Posts: 178
Joined: Sat Dec 10, 2011 5:46 am

Re: [git] Using a local repo to update the game on my computer

#2 Post by o01eg » Sun Sep 09, 2018 3:21 pm

If you have a modification in default directory you could simple choose it with --resource.path option instead of system one.
Gentoo Linux x64, gcc-7.3, boost-1.65.0
Ubuntu Server 18.04 x64, gcc-7.3, boost-1.65.1
Welcome to multiplayer server at freeorion-test.dedyn.io.Version 0.4.8
Donates are welcome: BTC:14XLekD9ifwqLtZX4iteepvbLQNYVG87zK

User avatar
Oberlus
Small Juggernaut
Posts: 738
Joined: Mon Apr 10, 2017 4:25 pm

Re: [git] Using a local repo to update the game on my computer

#3 Post by Oberlus » Sun Sep 09, 2018 3:59 pm

Jaumito wrote:
Sun Sep 09, 2018 2:09 pm
Dilvish wrote:then you could just copy your entire modified 'default' directory over the one in your local git repo, and git would automatically figure out which files had been modified (and what those modifications were).
How would git know that if I just copy (I guess you mean manually, e.g. with cp) files to a directory that's not part of a git project?
What I'd like would be to make git aware I'm supposed to commit (and undo) changes to my local version of the game. Isn't there a way to do that? Or should I just build a second freeorion from my local repo?
If I understand it correctly (Dilvish may correct me)...

The context:
You already have a FO installation, with your own modifications. That one is not linked in any way to github or your repo (unless when you create your git project for FO, you do as o01eg told with --resource.path, but assuming you don't...).
To make PRs it's advisable you do it from a fork of the FO repo (created via fork), that will be your "repo" (your_github_user/freeorion, probably, and the main freeorion/freeorion repo will be "upstream").
Then, in your local machine, you (will) have a different folder where you will clone your repo, and that will be your working directory (linked to your repo and to upstream). You can have several branches, one should be your master (intended to exactly mirror the master of your repo, that in turn will mirror the master of upstream) and you should create one for your modifications (one branch could be Nerada, initially a copy of master branch), and do git checkout Nerada.

...If you copy over (or manually change in any other way, e.g. via a local text editor) a file of your working directory, git will know and identify the changes once you do a git checkout. Git will understand that the changes apply to the current branch, so make sure you do git checkout Nerada before copying the default folder. Git keeps a data structure with all the history of changes made to any file of any branch, and when you do a "git checkout <branch>", it updates the actual files in the working directory (so that the next time you open a file, it will correspond to the version of it in <branch>).

So answering your question in bold letter, git will know nothing about any changes made in your regular game installation that is not linked to your repo nor is your working directory (unless you do it that way when creating your working directory). But Dilvish said to copy your modified default directory from your installation folder over your working directory, that is indeed linked to your github repo (if you created it right). And when you do changes in your working directory, git will know about them when you invoke it but not automatically.

Jaumito
Space Kraken
Posts: 158
Joined: Tue May 16, 2017 3:42 am
Location: Catalonia, France, Europe, Earth, Sol, Orion Arm, Milky Way, Virgo Cluster

Re: [git] Using a local repo to update the game on my computer

#4 Post by Jaumito » Sun Sep 09, 2018 6:26 pm

Thanks everyone. I realize now I actually misunderstood what Dilvish wrote (I thought he was telling me to overwrite the game default folder with my changes in the local repo - duh!)

User avatar
Dilvish
AI Lead, Programmer
Posts: 4736
Joined: Sat Sep 22, 2012 6:25 pm

Re: [git] Using a local repo to update the game on my computer

#5 Post by Dilvish » Sun Sep 09, 2018 6:51 pm

just to add slightly to the previous responses:
Jaumito wrote:
Sun Sep 09, 2018 2:09 pm
The basic idea would be to clone the version of the game I'm playing in a working directory, do some changes (custom species mainly), and then update my own game (/usr/share/games/freeorion). I'm still not sure how to do that last part.
If you are wanting to keep using some menu entry for freeorion, which currently points to /usr/share/games/freeorion, you could simply make any appropriate changes to the command for that menu entry (in Ubuntu, with the Unity application launcher, you can just right-click on a menu entry and select 'Edit Application'). If you were only making content changes, a simple and fine edit could be to just add the --resource.path option to the specified command line as o0leg suggested above. Since I think you are making more changes than just to the content, I think you'd probably want to edit that entry so that it just points to your git repo version of freeorion, and just ignore the version at /usr/share/games/freeorion from here on out. Or, you could do like I do and just run it from the command line in a terminal. There are some error messages that only get output to the terminal, so when debugging problems it can sometimes be better to run that way. Also, it fits easily with having different build directories for slightly different versions of FO-- I do that to make it easy to switch between testing something out with the current master version of FO and some particular local branch without having to recompile when switching (even with ccache, if there are a lot of differences between the branches then recompiling could add an extra minute or two or more that I don't want to waste). I just use git to select which branch I want to work with, so ensure that the content folders will be structured correctly for the executable, then go to the build directory ('standard', 'testing1', 'my_mods' etc) that I want to work with and invoke FO there. Note that the build directories should not be added to git; I keep mine out of the repo tree entirely, in a 'freeorion_builds' folder that sits next to the repo directory. I think out main 'Build' instructions contemplate a build directory being within the repo directory tree but just not added to git; the location difference means you need to use a slightly different path when making the link to the 'default' directory.
This part I don't understand. How would git know that if I just copy (I guess you mean manually, e.g. with cp) files to a directory that's not part of a git project?
(emphasis added)
My above explanation hopefully makes more clear, I was not talking about copying any files back into some directory that is not part of a git project.
What I'd like would be to make git aware I'm supposed to commit (and undo) changes to my local version of the game. Isn't there a way to do that? Or should I just build a second freeorion from my local repo?
You might be able to clone the git repo into your /usr/share/games/freeorion space, but that doesn't really seem like good practice to me. Or you might be able to replace various files & folders at /usr/share/games/freeorion with links to your new folder, but that seems likely to be at best messy, to me at least-- perhaps it is just personal preference but I'd recommend just building a second freeorion from your local repo (and if you want, editing your application launcher menu entry for freeorion to point to that new location).
If I provided any code, scripts or other content here, it's released under GPL 2.0 and CC-BY-SA 3.0

Post Reply