githelper.git
/
githelper.pike
version
»
Context lines:
10
20
40
80
file
none
3
githelper.git/githelper.pike:134:
break; } } } return 0; } int check_gitattributes_files(array(string) files_to_commit) { foreach(files_to_commit, string filename)
-
if(filename
==
".gitattributes"
||
-
has_suffix
(
filename,
"
/
.gitattributes")
)
-
{
-
string
dir=filename[..sizeof(filename)-15];
-
string diff = run_git("diff", "-p", "-
Sforeign_ident", "
-
-
cached",
-
"--",
filename
);
+
if(
has_suffix(
filename
,
"
/
.gitattributes"
))
{
+
write
(".gitattributes
are not allowed in subdirectories\n
")
;
+
return 1;
+
}
+
+
if(search(files_to_commit,
".gitattributes")>=0)
{
+
string diff = run_git("diff", "-p", "--cached",
+
"--",
".gitattributes"
);
if (sizeof(diff)) { int pos = search(diff, "\n@@"); if (pos >= 0) diff = diff[pos+1..]; foreach(diff/"\n", string line)
-
if(sizeof(line) &&
+
if(sizeof(line) &&
search(line, "foreign_ident")>=0 &&
(line[0]=='+' || line[0]=='-')) { int code, len; string fn; if(sscanf(line, "%c/%s foreign_ident%n", code, fn, len) != 3 || len != sizeof(line)) {
-
write("Unsupported change of foreign_ident in
%s\n
"
,
-
filename
);
+
write("Unsupported change of foreign_ident in
.gitattributes\n
");
return 1; }
-
fn = dir+fn;
+
if (code=='-' && search(files_to_commit, fn)<0) { write("Removed foreign_ident from unstaged file %s\n", fn); return 1; } } } } return 0; }