githelper.git / githelper.pike

version» Context lines:

githelper.git/githelper.pike:137:    int sysclock = time() + 60;    if(3 != sscanf(run_git("log", "-n", "1", "--format=%ct %at %P", commit),    "%d %d %s\n", cct, cat, parents))    fail("Unexpected output from git log");    if (cat > sysclock)    return "Author time is in the future";    if (cct > sysclock)    return "Commit time is in the future";    if (cat > cct)    return "Author time is later than commit time"; +  if (sizeof(parents))    foreach(parents/" ", string parent) {    if(2 != sscanf(run_git("log", "-n", "1", "--format=%ct %at", parent),    "%d %d", pct, pat))    fail("Unexpected output from git log");    if (cct < pct)    return "Commit time is before that of parent "+parent;    }    return 0;   }   
githelper.git/githelper.pike:479:    }    return err;    }   }      class CommitHookUtilsRepo   {    inherit CommitHookUtils;       protected string sha; +  protected string parent;       string get_file(string filename, int|void allow_empty)    {    return get_committed_file(sha, filename, allow_empty);    }       string get_old_file(string filename, int|void allow_empty)    { -  return get_committed_file(sha+"^", filename, allow_empty); +  return get_committed_file(parent, filename, allow_empty);    }       int entry_is_new(string filename)    { -  return (!sizeof(run_git("ls-tree", sha+"^", "--", filename))) && +  return (!sizeof(run_git("ls-tree", parent, "--", filename))) &&    sizeof(run_git("ls-tree", sha, "--", filename));    }       int check_commit(string sha)    {    if (!has_prefix(sha, "HEAD"))    write("Checking commit %s\n", sha);    this_program::sha = sha; -  +  array(string) parents = split_lf(run_git("rev-list", "--parents", +  "-n", "1", sha))[0] / " "; +  if (sizeof(parents) > 1) +  parent = parents[1]; // First parent, sha^ +  else +  parent = String.trim_all_whites(run_git("hash-object", "-t", "tree", "/dev/null")); // Empty tree    files_to_commit = -  split_z(run_git("diff", "--name-only", "-z", sha, sha+"^")); +  split_z(run_git("diff", "--name-only", "-z", sha, parent));    attrs = GitAttributes(get_file(".gitattributes", 1));    string ts_test = check_commit_timestamps(sha);    int err = 0;    if (ts_test) {    write("Invalid timestamps: %s\n", ts_test);    err = 1;    }    string cm_test = check_commit_msg(sha);    if (cm_test) {    write("Commit message encoding problem:\n%s", cm_test);