You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Sep 11, 2020. It is now read-only.
I am working on a CLI tool that uses go-git to wrap git operations. Among other I have the following code that implements the add operation (error handling removed here for simplicity):
func simpleAdd(target string, re *regexp.Regexp, w io.Writer) error {
repo, err := git.PlainOpen(target)
wt, err := repo.Worktree()
status, err := wt.Status()
for p, s := range status {
if s.Worktree != git.Unmodified && re.Match([]byte(p)) {
_, err := wt.Add(p)
fmt.Fprintf(w, "➜ added %c %s\n", s.Worktree, p)
}
}
return nil
}
Invoking this method using the CLI tool followed by git commit using the classical git tool results in the following error:
# geat git:(master) ✗ geat status
➜ in . the state is modified on branch master (origin: [email protected]:silvertern/geat)
unstaged:
M Gopkg.toml
# geat git:(master) ✗ geat add Gopkg.toml
➜ added M Gopkg.toml
# geat git:(master) ✗ geat status
➜ in . the state is modified on branch master (origin: [email protected]:silvertern/geat)
staged:
M Gopkg.toml
# geat git:(master) ✗ git commit -m "Updates go-git revision"
error: invalid object 100644 fe4aec059f97826820d4bf7f4208b7d2f76ee906 for 'Gopkg.toml'
error: invalid object 100644 fe4aec059f97826820d4bf7f4208b7d2f76ee906 for 'Gopkg.toml'
error: Error building trees
Am I doing anything wrong in the above Add code?
To reproduce have any git repo with a change then do:
mkdir -p ${GOPATH}/src/github.com/silvertern
cd ${GOPATH}/src/github.com/silvertern
git clone https://github.com/silvertern/geat
cd geat
dep ensure # latest dep from master
go install
now cd to your repo with a change and do geat add . followed by git commit.
The text was updated successfully, but these errors were encountered:
Yep, I confirm the issue, Worktree.Add is bad implemented, should add the object to the storage, but this is being done at Worktree.Commit. I will do a PR in a few days.
I am working on a CLI tool that uses
go-git
to wrap git operations. Among other I have the following code that implements theadd
operation (error handling removed here for simplicity):Invoking this method using the CLI tool followed by
git commit
using the classicalgit
tool results in the following error:Am I doing anything wrong in the above
Add
code?To reproduce have any git repo with a change then do:
now cd to your repo with a change and do
geat add .
followed bygit commit
.The text was updated successfully, but these errors were encountered: