Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tests paths from a subdirectory of the Git repo #405

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

jdblischak
Copy link
Contributor

I added some tests related to the observations in Issue #394.

Currently the behavior of functions like add(), rm_file(), and commits(path) change based on the operating system, the current working directory, whether or not the file exists, and the type of file path (relative versus absolute).

As an example, when the file exists, the commands commits(repo, path = "../root.txt") and commits(repo, path = "root.txt") both return the commits that touch the file root.txt in the root of the Git repo. After the file has been removed, commits(repo, path = "../root.txt") returns an empty list, but commits(repo, path = "root.txt") still works.

> file.exists("../root.txt")
[1] TRUE
> commits(repo, path = "../root.txt")
[[1]]
[a7f30ea] 2019-11-07: Add files

> commits(repo, path = "root.txt")
[[1]]
[a7f30ea] 2019-11-07: Add files

> ## Remove and commit
> rm_file(repo, c(root, sub))
> commit(repo, "Remove files")
[1d77e3b] 2019-11-07: Remove files
> # after removing the file
> file.exists("../root.txt")
[1] FALSE
> commits(repo, path = "../root.txt")
list()
> commits(repo, path = "root.txt")
[[1]]
[1d77e3b] 2019-11-07: Remove files

[[2]]
[a7f30ea] 2019-11-07: Add files

The crux of the problem is that relative paths are interpreted in 2 distinct ways: relative to the current working directory or relative to the root of the Git repository.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant