-
Notifications
You must be signed in to change notification settings - Fork 868
Closed as not planned
Labels
staleIssues/PRs that are marked for closure due to inactivityIssues/PRs that are marked for closure due to inactivity
Description
I expect the diffStagingWithWorktree function will work as git status, and a symlink pointing to a non-existent file will be handled correctly.
Check
$ ln -s /nowhere broken_symlink
$ git add broken_symlink
$ git commit -m "Add symlink"
[master a30a58d] Add symlink
1 file changed, 1 insertion(+)
create mode 120000 broken_symlink
$ git status
On branch master
nothing to commit, working tree clean
$ ./main
broken_symlink: [worktree: Modified, staging: Unmodified]main.go
package main
import (
"fmt"
"github.com/go-git/go-git/v5"
)
var fileStatusMapping = map[git.StatusCode]string{
git.Unmodified: "Unmodified",
git.Untracked: "Untracked",
git.Modified: "Modified",
git.Added: "Added",
git.Deleted: "Deleted",
git.Renamed: "Renamed",
git.Copied: "Copied",
git.UpdatedButUnmerged: "Updated",
}
func main() {
repo, err := git.PlainOpen(".")
if err != nil {
panic(err)
}
tree, err := repo.Worktree()
if err != nil {
panic(err)
}
status, err := tree.Status()
if err != nil {
panic(err)
}
filePath := "broken_symlink"
fileStatus := status.File(filePath)
fmt.Printf("%s: [worktree: %s, staging: %s]\n", filePath, fileStatusMapping[fileStatus.Worktree], fileStatusMapping[fileStatus.Staging])
}joelanford and joshkeegan-form3
Metadata
Metadata
Assignees
Labels
staleIssues/PRs that are marked for closure due to inactivityIssues/PRs that are marked for closure due to inactivity