Skip to content

File reported as Untracked while it is commited (i.e. Unmodified) #119

@pantelis-karamolegkos

Description

@pantelis-karamolegkos

Assuming my full path to repo is /Users/panteliskaramolegkos/myrepo, I am going through the following steps to check the status of a specific file (code below is part of a specific function)

	repo, err := git.PlainOpen(fullPathToRepo)
	if err != nil {
		return false, fmt.Errorf("ERROR: Unable to open repository %s\n%s", fullPathToRepo, err)
	}

	workTree, err := repo.Worktree()
	if err != nil {
		return false, fmt.Errorf("ERROR: Unable to open worktree for repository %s\n%s", fullPathToRepo, err)
	}
	workTreeStatus, err := workTree.Status()
	if err != nil {
		return false, fmt.Errorf("ERROR: Unable to retrieve worktree status for repository %s\n%s", fullPathToRepo, err)
	}
	fmt.Printf("%q\n", workTreeStatus.File("relative/path/to/file.yaml").Worktree)
	fmt.Printf("%q\n", workTreeStatus.File("/Users/panteliskaramolegkos/full/path/to/file.yaml").Worktree)

In both cases (i.e. using full or relative path, the following gets printed out

'?'
'?'

According to the documentation, this corresponds to status Untracked

However the file is committed (and pushed to the remote, but I guess this is irrelevant)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinggood first issueGood for newcomershelp wantedExtra attention is neededstaleIssues/PRs that are marked for closure due to inactivity

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions