githelper.git/
githelper.pike
Branch:
Tag:
Non-build tags
All tags
No tags
2018-04-12
2018-04-12 12:05:24 by Marcus Comstedt <marcus@mc.pp.se>
53dd475e35f1dff304380ee1c3ed315052e9e963 (
29
lines) (+
19
/-
10
)
[
Show
|
Annotate
]
Branch:
master
Handle pushing of orphan commits
144:
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))
486:
inherit CommitHookUtils; protected string sha;
+
protected string parent;
string get_file(string filename, int|void allow_empty) {
494:
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)); }
508:
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;