Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
350 views
in Technique[技术] by (71.8m points)

git-diff with .gitattributes in a bare repository

I use gitea for storing my code and noticed that it doesn't obey .gitattributes when diffing.

Having looked into this it seems to be an issue with bare repos. I found some information on libgit2 that suggests using the GIT_INDEX_FILE environmental variable.

repo.git # GIT_INDEX_FILE=tmp_index git read-tree --reset -i testing-attributes
repo.git # GIT_INDEX_FILE=tmp_index git check-attr --cached --all ent/actions.go
ent/actions.go: diff: unset
ent/actions.go: merge: unset

This seems to work for check-attr but I can't seem to get it to work with git diff.

GIT_INDEX_FILE=tmp_index git diff c165f76c8c 71ecf0a90b
diff --git a/ent/action.go b/ent/action.go
index 7d4edbe..4b71332 100644
--- a/ent/action.go
+++ b/ent/action.go
@@ -18,6 +18,8 @@ type Action struct {
        ID int `json:"id,omitempty"`
        // Name holds the value of the "name" field.
        Name string `json:"name,omitempty"`
+       // Name1 holds the value of the "name1" field.
+       Name1 string `json:"name1,omitempty"`
        // Edges holds the relations/edges for other nodes in the graph.
        // The values are being populated by the ActionQuery when eager-loading is set.
        Edges        ActionEdges `json:"edges"`

The diff still displays changes in files that have the -diff attribute set on them. I would expect to see

diff --git a/ent/action.go b/ent/action.go
index 7d4edbe..4b71332 100644
Binary files a/ent/action.go and b/ent/action.go differ
question from:https://stackoverflow.com/questions/66064549/git-diff-with-gitattributes-in-a-bare-repository

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...