Skip to content

The check for a file's existence within the worktree in add function is useless. #53

@hanyujie2002

Description

@hanyujie2002

In the add() function, a file's existence within the worktree is checked.

if not (abspath.startswith(worktree) and os.path.isfile(abspath)):
raise Exception(f"Not a file, or outside the worktree: {paths}")

However, this check is redundant because it has already been performed in the rm() function.

def rm(repo, paths, delete=True, skip_missing=False):
# Find and read the index
index = index_read(repo)
worktree = repo.worktree + os.sep
# Make paths absolute
abspaths = set()
for path in paths:
abspath = os.path.abspath(path)
if abspath.startswith(worktree):
abspaths.add(abspath)
else:
raise Exception(f"Cannot remove paths outside of worktree: {paths}")

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions