Files versioning with glip

Previous Topic Next Topic
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

Files versioning with glip

François K.
Hi !

As some might know, I played a bit with Glip (, mostly because I was curious to see what could be achieved with it.
Hopefully, the guy that wrote Glip also wrote a Wiki engine -called eWiki- that uses Glip, so, I had a great example :)

*Please keep in mind that this was just testing.*
I still hope it will be useful.

1/ My first goal was to get one file history. There is no 'git log' thing, so I had to reproduce its behaviour.
The result is pretty good, but not the same as the one 'git log -- file' would produce. There are two main reasons for this :
- My small function only returns commits where the content of the considered file has changed,
- It ignores merge commits (normally, we will have one and only one branch, so merge commits shouldn't exist).

The major drawback is that I had to loop through every commit and compare each of them with its parent to see if the file has changed or not. This can be time and resource consuming with big repo. I sadly haven't found another solution.

2/ The second goal was to write "objects" to the repository. This is where things begin to be fun ^^

The first drawback is that the repo has to exist, and a first commit must have been done so that the 'master' branch actually exists. I didn't find a solution to create the branch via PHP, so I did it by hand, for testing purpose. We will have to find a solution for this. Maybe some git expert could help us.

The example given by the eWiki source code shows that the dev has chosen to build a new branch for each commit, and to merge it with the 'master' one. I don't really know why... I decided to keep a single branch. So I update the current tree, build commit details and write everything to the repository. It seems to work quite well. I clearly lack some knowledge in git, and I'd like someone that knows it very well to check if it works well or not. I ran 'git fsck' and it seemd to be OK, yet not sure.

I joined my source code for those who are interested in it. Please excuse me, it's really poor and would need some huge refactor.
This was done on the fly for testing purpose. You'll need Glip to run it.
- index.php is only about reading data from a repo.
- index2.php will try to build a commit for a single file and then show this file history.

In both cases, you will need a repo with a least one commit (so that the master branch exists).
I *strongly* recommend you not to use a working repo if you want to test it. 'git clone' one or build a new one quickly.
For index2.php to work, you will need to 'chmod' the git repo so that your webserver has read/write access to it.

You can edit everything at your own convenience.

And, as always, ideas and comments are welcome.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: index.php
Type: text/php
Size: 2675 bytes
Desc: not available
Url : 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: index2.php
Type: text/php
Size: 3734 bytes
Desc: not available
Url :