예제 #1
0
function git_rev_list($proj, $head, $count = NULL, $skip = NULL, $header = FALSE, $parents = FALSE, $greptype = NULL, $search = NULL)
{
    $cmd = GIT_REV_LIST . " ";
    if ($header) {
        $cmd .= "--header ";
    }
    if ($parents) {
        $cmd .= "--parents ";
    }
    if ($count) {
        $cmd .= "--max-count=" . $count . " ";
    }
    if ($skip) {
        $cmd .= "--skip=" . $skip . " ";
    }
    if ($greptype && $search) {
        if ($greptype == "commit") {
            $cmd .= "--grep=" . $search . " ";
        } else {
            if ($greptype == "author") {
                $cmd .= "--author=" . $search . " ";
            } else {
                if ($greptype == "committer") {
                    $cmd .= "--committer=" . $search . " ";
                }
            }
        }
        $cmd .= "--regexp-ignore-case ";
    }
    return git_exec($proj, $cmd . " " . $head);
}
예제 #2
0
function git_diff_tree($proj, $hashes, $renames = FALSE)
{
    $cmd = GIT_DIFF_TREE . " -r ";
    if ($renames) {
        $cmd .= "-M ";
    }
    return git_exec($proj, $cmd . $hashes);
}
예제 #3
0
function git_version()
{
    $verstr = explode(" ", git_exec(null, "--version"));
    if ($verstr[0] == "git" && $verstr[1] == "version") {
        return $verstr[2];
    }
    return null;
}
예제 #4
0
function git_cat_file($proj, $hash, $pipeto = NULL, $type = "blob")
{
    $cmd = GIT_CAT_FILE . " " . $type . " " . $hash;
    if ($pipeto) {
        $cmd .= " > " . $pipeto;
    }
    return git_exec($proj, $cmd);
}
예제 #5
0
function git_archive($proj, $hash, $rname = NULL, $fmt = "tar")
{
    $cmd = GIT_ARCHIVE . " --format=" . $fmt;
    if ($rname) {
        $cmd .= " --prefix=" . $rname . "/";
    }
    $cmd .= " " . $hash;
    return git_exec($proj, $cmd);
}
예제 #6
0
function git_ls_tree($proj, $hash, $nullterm = FALSE, $recurse = FALSE)
{
    $cmd = GIT_LS_TREE;
    if ($nullterm) {
        $cmd .= " -z";
    }
    if ($recurse) {
        $cmd .= " -r -t --full-name";
    }
    return git_exec($proj, $cmd . " " . $hash);
}
예제 #7
0
function git_grep($project, $hash, $search, $case = false, $binary = false, $fullname = true)
{
    $cmd = GIT_GREP;
    if (!$binary) {
        $cmd .= " -I";
    }
    if ($fullname) {
        $cmd .= " --full-name";
    }
    if (!$case) {
        $cmd .= " --ignore-case";
    }
    $cmd .= " -e " . $search;
    return git_exec($project, $cmd . " " . $hash);
}
예제 #8
0
function read_info_ref($project, $type = "")
{
    $refs = array();
    $cmd = GIT_SHOW_REF . " --dereference";
    $showrefs = git_exec($project, $cmd);
    $lines = explode("\n", $showrefs);
    foreach ($lines as $no => $line) {
        if (preg_match("`^([0-9a-fA-F]{40}) .*" . $type . "/([^\\^]+)`", $line, $regs)) {
            if (isset($refs[$regs[1]])) {
                $refs[$regs[1]] .= " / " . $regs[2];
            } else {
                $refs[$regs[1]] = $regs[2];
            }
        }
    }
    return $refs;
}
예제 #9
0
function git_history_list($proj, $hash, $file)
{
    global $gitphp_conf;
    $cmd = GIT_REV_LIST . " " . $hash . " | " . $gitphp_conf['gitbin'] . " --git-dir=" . $proj . " " . GIT_DIFF_TREE . " -r --stdin -- " . $file;
    return git_exec($proj, $cmd);
}
예제 #10
0
function git_read_head($proj)
{
    $cmd = GIT_REV_PARSE . " --verify HEAD";
    return trim(git_exec($proj, $cmd));
}
예제 #11
0
파일: loader.php 프로젝트: plepe/geowiki
function ajax_save_remove_feature($param, $postdata)
{
    global $data_path;
    if (!check_param($param)) {
        return array('saved' => false, 'error' => 'Invalid ID');
    }
    git_init();
    if (array_key_exists('rev', $param)) {
        git_checkout($param['rev']);
    }
    // create directory for map data
    $path = "{$data_path}/{$param['id']}";
    if (!is_dir($path)) {
        mkdir($path);
    }
    $feature_id = $postdata;
    git_exec("rm " . shell_escape("{$param['id']}/_" . $feature_id . '.json'));
    git_commit("remove feature");
    $rev = git_rev();
    if (!git_merge()) {
        return array('saved' => false, 'rev' => $rev, 'error' => "Conflict when merging changes. Please reload and re-do changes.");
    }
    return array('saved' => true, 'rev' => $rev);
}