List of commits:
Subject Hash Author Date (UTC)
Some git tweaks to deal with empty repositories c42a22e41cd6d29862e13077e60374ceb7b0c946 Catalin(ux) M. BOIE 2019-11-14 03:30:12
Texts updates + cosmetic 70246eecb7b63460d28f20b5e2f3c9c1c50852ae Catalin(ux) M. BOIE 2019-11-14 03:29:33
Docker updates aa4cf359af2c7c1e20e4f33c478f2bbcd134f081 Catalin(ux) M. BOIE 2019-11-14 03:24:05
Because of docker, we are now using HTTP_HOST insead of SERVER_NAME 9cf31231d760daac43e1c3454c5a308d69ea4898 Catalin(ux) M. BOIE 2019-11-14 03:22:37
Corrected stupid space char inside cache key 5958389c03b7536d6332a51e30b112ad3a520571 Catalin(ux) M. BOIE 2019-11-10 21:15:32
nginx: remove text/html because it is always added to gzip_types f8717bc9ac127e806696f088389c2911a6d37e28 Catalin(ux) M. BOIE 2019-11-09 13:05:54
vm: get rid of i386 (we move to x86_64) 67662a7b71f1b21f53fe7fa819afdf366ad3b4b4 Catalin(ux) M. BOIE 2019-11-09 07:58:05
SELinux: allow httpd_t to map rocketgit_exec_t files 6d3550736af317791be3d6355dd90bf64de323f5 Catalin(ux) M. BOIE 2019-11-09 00:36:03
Added rg_git_repo_is_empty function plus func test a13c5439fceffd8b1474f1105ca37c7b703d2fc9 Catalin(ux) M. BOIE 2019-11-08 04:34:34
TODO updates, user_min/max defaults changed d2f35a43f5de793565e0df9889d587c524df5f20 Catalin(ux) M. BOIE 2019-11-06 16:32:08
More rg_exec2 fixes 808297884e42942c83762040c4247c7cf9a593e8 Catalin(ux) M. BOIE 2019-11-06 16:31:09
Always set rg[hostname] - used also for ssh connections for TOTP 1a7a693617ac521967b8df73245cd704004b76b5 Catalin(ux) M. BOIE 2019-11-06 04:10:59
White space corrections 92a1b944842439b9476a954daa2a65c5acfca85c Catalin(ux) M. BOIE 2019-11-05 18:52:08
README updates b57e3765de34c5e4ed7afa8384f24b6337352b17 Catalin(ux) M. BOIE 2019-11-01 03:18:48
download page updates 0185da40f7b2779c886b9c3e67b10fe69b1b112c Catalin(ux) M. BOIE 2019-11-01 03:13:14
css: small updates 59ae919c798d64f74ed8bdeb08241e4e76840afe Catalin(ux) M. BOIE 2019-10-30 21:33:37
comparison: updated pagespeed and other changes 3f423b7b0a98c0342e5d855c254812d37a03a5b8 Catalin(ux) M. BOIE 2019-10-30 21:27:20
html: specify logo size to avoid re-render b2ce82a59029e93438e9e6792f6aa6f7e44741c7 Catalin(ux) M. BOIE 2019-10-30 21:15:10
git(rocketgit_t) needs to map rocketgit_var_t files 2b10062807dd4f478e136aea1c239e117b46caed Catalin(ux) M. BOIE 2019-10-30 21:02:18
css: gravatar is displayed as block to get rid of below extra space b02dc575be2ccd8b99eff7509f8a7e62c57654a6 Catalin(ux) M. BOIE 2019-10-30 20:58:03
Commit c42a22e41cd6d29862e13077e60374ceb7b0c946 - Some git tweaks to deal with empty repositories
Author: Catalin(ux) M. BOIE
Author date (UTC): 2019-11-14 03:30
Committer name: Catalin(ux) M. BOIE
Committer date (UTC): 2019-11-14 03:30
Parent(s): 70246eecb7b63460d28f20b5e2f3c9c1c50852ae
Signer:
Signing key:
Signing status: N
Tree: 46be0df4356b093f12e552551d20d94209022682
File Lines added Lines deleted
inc/git.inc.php 45 15
File inc/git.inc.php changed (mode: 100644) (index d580e10..1a16e22)
... ... function rg_git_repo_is_empty($repo_path)
64 64 if (empty($scan)) if (empty($scan))
65 65 return TRUE; return TRUE;
66 66
67 rg_log_ml('DEBUG: scan: ' . print_r($scan, TRUE));
68 return FALSE;
69 }
70
71 /*
72 * Returns true if the branch contains no commit
73 */
74 function rg_git_branch_is_empty($repo_path, $ref)
75 {
76 if (empty($repo_path))
77 $repo_path = '.';
78
79 if (file_exists($repo_path . '/.git'))
80 $repo_path .= '/.git';
81
82 if (!file_exists($repo_path . '/refs/heads/' . $ref))
83 return TRUE;
84
67 85 return FALSE; return FALSE;
68 86 } }
69 87
 
... ... function rg_git_merge_base($repo_path, $a, $b)
621 639
622 640 $ret = FALSE; $ret = FALSE;
623 641 while (1) { while (1) {
624 if (rg_git_repo_is_empty($repo_path)) {
625 $ret = $rg_git_zero;
642 if (rg_git_branch_is_empty($repo_path, $a)) {
643 $ret = $rg_git_empty;
626 644 break; break;
627 645 } }
628 646
 
... ... function rg_git_ls_tree($repo_path, $tree, $path)
761 779
762 780 $ret = FALSE; $ret = FALSE;
763 781 while (1) { while (1) {
782 if (rg_git_repo_is_empty($repo_path)) {
783 $ret = array();
784 break;
785 }
786
764 787 $op = " "; $op = " ";
765 788 if (empty($tree)) { if (empty($tree)) {
766 789 $op = " --full-tree"; $op = " --full-tree";
 
... ... function rg_git_log_simple($repo_path, $max, $from, $to, $also_patch, $files,
1163 1186
1164 1187 $ret = FALSE; $ret = FALSE;
1165 1188 while (1) { while (1) {
1166 if (rg_git_repo_is_empty($repo_path)) {
1167 rg_log('Repo is empty.');
1168 $ret = array();
1169 break;
1170 }
1171
1172 1189 $max_count = ($max == 0) ? "" : " --max-count=$max"; $max_count = ($max == 0) ? "" : " --max-count=$max";
1173 1190 $patches = $also_patch ? " --patch" : ""; $patches = $also_patch ? " --patch" : "";
1174 1191 $from_to = rg_git_from_to($from, $to); $from_to = rg_git_from_to($from, $to);
 
... ... function rg_git_merge_tree($repo_path, $base, $a, $b)
2479 2496
2480 2497 $ret = FALSE; $ret = FALSE;
2481 2498 while (1) { while (1) {
2499 if (rg_git_repo_is_empty($repo_path))
2500 $a = $rg_git_empty;
2501
2482 2502 $head = rg_git_load_ref($repo_path, $a); $head = rg_git_load_ref($repo_path, $a);
2483 2503 if ($head === FALSE) if ($head === FALSE)
2484 2504 break; break;
2505
2485 2506 $key = 'git' $key = 'git'
2486 2507 . '::' . sha1($repo_path) . '::' . sha1($repo_path)
2487 2508 . '::' . 'merge-tree' . '::' . 'merge-tree'
 
... ... function rg_git_merge_tree($repo_path, $base, $a, $b)
2495 2516 $cmd = RG_GIT_CMD . ' --git-dir=' . escapeshellarg($repo_path) $cmd = RG_GIT_CMD . ' --git-dir=' . escapeshellarg($repo_path)
2496 2517 . ' merge-tree' . ' merge-tree'
2497 2518 . ' ' . escapeshellarg($base) . ' ' . escapeshellarg($base)
2498 . ' ' . escapeshellarg($a)
2519 . ' ' . escapeshellarg($head)
2499 2520 . ' ' . escapeshellarg($b); . ' ' . escapeshellarg($b);
2500 2521 $a = rg_exec($cmd, '', FALSE, FALSE, FALSE); $a = rg_exec($cmd, '', FALSE, FALSE, FALSE);
2501 2522 if ($a['ok'] != 1) { if ($a['ok'] != 1) {
 
... ... function rg_git_merge($repo_path, $ref_name, $new, $ff, $msg)
2576 2597
2577 2598 $ret = FALSE; $ret = FALSE;
2578 2599 while (1) { while (1) {
2600 if (rg_git_repo_is_empty($repo_path))
2601 $ref_name_tmp = $rg_git_empty;
2602 else
2603 $ref_name_tmp = $ref_name;
2604
2579 2605 // TODO: this must go away - the cache will malfunction? // TODO: this must go away - the cache will malfunction?
2580 2606 if (empty($repo_path)) if (empty($repo_path))
2581 2607 $add = ''; $add = '';
 
... ... function rg_git_merge($repo_path, $ref_name, $new, $ff, $msg)
2592 2618 break; break;
2593 2619 } }
2594 2620
2595 $mb = rg_git_merge_base($repo_path, $ref_name, $new);
2621 $mb = rg_git_merge_base($repo_path, $ref_name_tmp, $new);
2596 2622 if ($mb === FALSE) if ($mb === FALSE)
2597 2623 break; break;
2598 2624 rg_log('DEBUG: merge-base=' . $mb); rg_log('DEBUG: merge-base=' . $mb);
2599 2625
2600 $cur = rg_git_load_ref($repo_path, $ref_name);
2626 $cur = rg_git_load_ref($repo_path, $ref_name_tmp);
2601 2627 if ($cur === FALSE) if ($cur === FALSE)
2602 2628 break; break;
2603 2629 rg_log('DEBUG: ref_name points to ' . $cur); rg_log('DEBUG: ref_name points to ' . $cur);
2604 2630
2631 // If repo was empty, we are forced to do a ff
2632 if (strcmp($mb, $rg_git_empty) == 0)
2633 $ff = 1;
2634
2605 2635 if (($ff == 1) && (strcmp($mb, $cur) == 0)) { if (($ff == 1) && (strcmp($mb, $cur) == 0)) {
2606 2636 rg_log('DEBUG: we can do a fast forward...'); rg_log('DEBUG: we can do a fast forward...');
2607 2637 $commit = $new; $commit = $new;
2608 2638 } else { } else {
2609 rg_log('DEBUG: we cannot do a fast forward.');
2639 rg_log('DEBUG: we must not do a fast forward.');
2610 2640 $e_mb = escapeshellarg($mb); $e_mb = escapeshellarg($mb);
2611 $e_ref_name = escapeshellarg($ref_name);
2641 $e_ref_name_tmp = escapeshellarg($ref_name_tmp);
2612 2642 $e_new = escapeshellarg($new); $e_new = escapeshellarg($new);
2613 2643
2614 2644 $cmd = RG_GIT_CMD $cmd = RG_GIT_CMD
2615 2645 . $add . ' read-tree -i -m ' . $add . ' read-tree -i -m '
2616 . $e_mb . ' ' . $e_ref_name . ' ' . $e_new;
2646 . $e_mb . ' ' . $e_ref_name_tmp . ' ' . $e_new;
2617 2647 $r = rg_exec($cmd, '', FALSE, FALSE, FALSE); $r = rg_exec($cmd, '', FALSE, FALSE, FALSE);
2618 2648 if ($r['ok'] != 1) { if ($r['ok'] != 1) {
2619 2649 rg_git_set_error('error on merge (read-tree) (' rg_git_set_error('error on merge (read-tree) ('
 
... ... function rg_git_merge($repo_path, $ref_name, $new, $ff, $msg)
2632 2662
2633 2663 $cmd = RG_GIT_CMD . $add . ' commit-tree ' $cmd = RG_GIT_CMD . $add . ' commit-tree '
2634 2664 . escapeshellarg($tree) . escapeshellarg($tree)
2635 . ' -p ' . $e_ref_name . ' -p ' . $e_new
2665 . ' -p ' . $e_ref_name_tmp . ' -p ' . $e_new
2636 2666 . ' -m ' . escapeshellarg($msg); . ' -m ' . escapeshellarg($msg);
2637 2667 $r = rg_exec($cmd, '', FALSE, FALSE, FALSE); $r = rg_exec($cmd, '', FALSE, FALSE, FALSE);
2638 2668 if ($r['ok'] != 1) { if ($r['ok'] != 1) {
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://rocketgit.com/user/catalinux/rocketgit

Clone this repository using ssh (do not forget to upload a key first):
git clone ssh://rocketgit@ssh.rocketgit.com/user/catalinux/rocketgit

Clone this repository using git:
git clone git://git.rocketgit.com/user/catalinux/rocketgit

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