xaizek / rocketgit (License: AGPLv3+) (since 2018-12-09)
Light and fast Git hosting solution suitable to serve both as a hub or as a personal code storage with its tickets, pull requests, API and much more.
Commit c2732004dbb1695444be3030111faf4401c83fb1

Improved git_init function
Author: Catalin(ux) M. BOIE
Author date (UTC): 2016-04-06 16:16
Committer name: Catalin(ux) M. BOIE
Committer date (UTC): 2016-04-06 16:16
Parent(s): ec28c883d9f7c9c69d80302a7d70ea1d630b070c
Signing key:
Tree: 688dda155dbe21ae000884bcbeade9f3b1779bd7
File Lines added Lines deleted
inc/git.inc.php 14 9
File inc/git.inc.php changed (mode: 100644) (index 55761de..dc57f96)
... ... function rg_git_init($dst)
130 130 } }
131 131 } }
132 132
133 // TODO: What if the git init does not finish?!
134 // Should we create it in a tmp dir and rename?
135 // Does git has any protection?
133 // TODO: What to do if the creation fails?
136 134 if (!is_dir($dst . "/rocketgit")) { if (!is_dir($dst . "/rocketgit")) {
137 $cmd = "git init --bare " . escapeshellarg($dst);
135 $dst2 = $dst . '.tmp';
136 $cmd = 'git init --bare ' . escapeshellarg($dst2);
138 137 $a = rg_exec($cmd); $a = rg_exec($cmd);
139 138 if ($a['ok'] != 1) { if ($a['ok'] != 1) {
140 139 rg_git_set_error("error on init " . $a['errmsg'] . ")"); rg_git_set_error("error on init " . $a['errmsg'] . ")");
141 140 break; break;
142 141 } }
143 142
144 if (!@mkdir($dst . "/rocketgit")) {
143 if (!@mkdir($dst2 . '/rocketgit')) {
145 144 rg_git_set_error("cannot create '$dst/rocketgit' dir ($php_errormsg)"); rg_git_set_error("cannot create '$dst/rocketgit' dir ($php_errormsg)");
146 145 break; break;
147 146 } }
147
148 $r = @rename($dst2, $dst);
149 if ($r === FALSE) {
150 rg_git_set_error('cannot rename git dir from .tmp');
151 break;
152 }
148 153 } }
149 154
150 155 if (rg_git_install_hooks($dst) !== TRUE) if (rg_git_install_hooks($dst) !== TRUE)
 
... ... function rg_git_ls_tree($repo_path, $tree, $path)
549 554 $cmd = "git --git-dir=" . escapeshellarg($repo_path) $cmd = "git --git-dir=" . escapeshellarg($repo_path)
550 555 . " ls-tree --long" . $op . $tree; . " ls-tree --long" . $op . $tree;
551 556 if (!empty($path)) if (!empty($path))
552 $cmd .= " " . escapeshellarg($path);
553 rg_log("DEBUG: cmd=$cmd");
557 $cmd .= ' ' . escapeshellarg($path);
554 558 $a = rg_exec($cmd); $a = rg_exec($cmd);
555 559 if ($a['ok'] != 1) { if ($a['ok'] != 1) {
556 560 rg_git_set_error("error on ls-tree (" . $a['errmsg'] . ")"); rg_git_set_error("error on ls-tree (" . $a['errmsg'] . ")");
 
... ... function rg_git_log($path, $max, $from, $to, $also_patch)
857 861 . "subject:%s%x00\"\"" . "subject:%s%x00\"\""
858 862 . "body:%b%x00\"\"" . "body:%b%x00\"\""
859 863 . "notes:%N%x00\"\"" . "notes:%N%x00\"\""
860 . "%x00ROCKETGIT_END_OF_VARS%x00\""
861 . ' ' . escapeshellarg($from_to);
864 . "%x00ROCKETGIT_END_OF_VARS%x00\"";
865 if (!empty($from_to))
866 $cmd .= ' ' . escapeshellarg($from_to);
862 867 $a = rg_exec($cmd); $a = rg_exec($cmd);
863 868 if ($a['ok'] != 1) { if ($a['ok'] != 1) {
864 869 rg_internal_error("error on log (" . $a['errmsg'] . ")"); rg_internal_error("error on log (" . $a['errmsg'] . ")");
Hints

Before first commit, do not forget to setup your git environment:
git config --global user.name "your_name_here"
git config --global user.email "your@email_here"

Clone this repository using HTTP(S):
git clone https://code.reversed.top/user/xaizek/rocketgit

Clone this repository using ssh (do not forget to upload a key first):
git clone ssh://rocketgit@code.reversed.top/user/xaizek/rocketgit

You are allowed to anonymously push to this repository.
This means that your pushed commits will automatically be transformed into a pull request:
... clone the repository ...
... make some changes and some commits ...
git push origin master