Open mflendrich opened 4 years ago
This bug looks similar to #814 but affects AddGlob rather than Add.
AddGlob
Add
Execute this code
repo, err := git.PlainInit("/some/dir", false) if err != nil { return errors.Wrap(err, "git init") } // (put files in /some/dir) wt, err := repo.Worktree() if err != nil { return errors.Wrap(err, "worktree") } if err := wt.AddGlob("*"); err != nil { return errors.Wrap(err, "AddGlob") } co := git.CommitOptions{ Author: &object.Signature{ Name: "somebody", Email: "somewhere@aa.bb", When: time.Now(), }, } if _, err := wt.Commit("initial commit", &co); err != nil { return errors.Wrap(err, "initial commit") }
.git
$ git -C /some/dir rev-list --objects --all f99c70ad6ad44782839e9248dcc6cdb8270d6bb5 4756d7c1a705171a7b08424975a952d69382753f f73163ae5843aa96729746da9fdd072cdb9ee683 b81cb5bdf00b207ae19bb4a7276723ac90597d02 .git cb089cd89a3d7686d284d8761201649346b5aa1c .git/HEAD 24d50854b1bbfdba94e035b02c4f4b6589878e3b .git/objects 75c0fa091470ab437664f51c46b34bffafccfd1d .git/objects/84 d20258d48fcfcd0a06eb242a150d96a94cac9646 .git/objects/84/4a084e76baea8fe3fb79b8789f685f09d63f6c e30b22d468a87a57704f522b698df0c60ab819bb .git/objects/cb ed4e0ce2940e218f40461b8fe76e8e37040a39b2 .git/objects/cb/089cd89a7d7686d284d8761251649346b5aa1c d7806218c87724c0ac16f1895b3eeab751c6e96c legit-file1.txt d729657ed22be0a69b49765ba6db262850723a97 legit-file2.txt
Either of:
AddGlob("*")
/.git
Add(".")
git add -A
you can use AddGlob(".") instead of AddGLob("*"), AddGLob(".") will not add .git
AddGlob(".")
AddGLob("*")
AddGLob(".")
@jk2K thx for your comment, it really helps.
This bug looks similar to #814 but affects
AddGlob
rather thanAdd
.Reproduction Steps
Execute this code
.git
has been committedExpected behavior
Either of:
AddGlob("*")
does not add the contents of/.git
to the index (IIUC that means being equivalent toAdd(".")
after #815)AddGlob("*")
adds the contents of/.git
to the index, but the documentation says that (and recommends a way to achieve the equivalent ofgit add -A
)Actual behavior
AddGlob("*")
adds the contents of/.git
to the index