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'] . ")"); |