Skip to content

Git update_repo fails when there are only untracked files #395

Closed
@jfpedroza

Description

@jfpedroza

Currenly when using vcspull sync, and a repo has untracked files and no other changes, the command fails with something like

File "/home/jhon/.local/lib/python3.10/site-packages/vcspull/cli/sync.py", line 104, in update_repo
  r.update_repo(set_remotes=True)  # Creates repo if not exists and fetches
File "/home/jhon/.local/lib/python3.10/site-packages/libvcs/projects/git.py", line 465, in update_repo
  self.run(["stash", "pop", "--index", "--quiet"])
File "/home/jhon/.local/lib/python3.10/site-packages/libvcs/projects/base.py", line 154, in run
  return run(
File "/home/jhon/.local/lib/python3.10/site-packages/libvcs/cmd/core.py", line 211, in run
  raise exc.CommandError(output=output, returncode=code, cmd=cmd)
libvcs.exc.CommandError: Command failed with code 1: git stash pop --index --quiet)

That is because git status returns output including the untracked files while git stash save doesn't have the -u flag and so no stash is actually created.

To fix the problem, one of these should be performed:

  • Add --untracked-files=no to git status
  • Add --include-untracked to git stash save
  • Check if a stash was actually created before trying to pop

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions