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

New GitRepo.dirty doesn't ignore nested empty directories #3196

Closed
kyleam opened this issue Mar 5, 2019 · 0 comments
Closed

New GitRepo.dirty doesn't ignore nested empty directories #3196

kyleam opened this issue Mar 5, 2019 · 0 comments
Assignees

Comments

@kyleam
Copy link
Contributor

@kyleam kyleam commented Mar 5, 2019

git status and GitRepo.is_dirty() ignore an empty subdirectory that is in an otherwise empty directory. The new .dirty based on -revolution's .status reports this scenario as dirty.

demo
#!/bin/sh

set -xe

tmpdir=$(mktemp -dt dl-dirt-XXXXXX)
cd $tmpdir

git init
mkdir -p one/two
git status

python -c "import datalad.api as dl; print(dl.Dataset('.').repo.is_dirty())"
python -c "import datalad.api as dl; print(dl.Dataset('.').repo.dirty)"
+ mktemp -dt dl-dirt-XXXXXX
+ tmpdir=/tmp/dl-dirt-ydExrD
+ cd /tmp/dl-dirt-ydExrD
+ git init
Initialized empty Git repository in /tmp/dl-dirt-ydExrD/.git/
+ mkdir -p one/two
+ git status
On branch master

No commits yet

nothing to commit
+ python -c import datalad.api as dl; print(dl.Dataset('.').repo.is_dirty())
False
+ python -c import datalad.api as dl; print(dl.Dataset('.').repo.dirty)
True
Test case
diff --git a/datalad/support/tests/test_gitrepo.py b/datalad/support/tests/test_gitrepo.py
index b4c78e98b..97f35953f 100644
--- a/datalad/support/tests/test_gitrepo.py
+++ b/datalad/support/tests/test_gitrepo.py
@@ -796,6 +796,13 @@ def test_GitRepo_dirty(path):
     repo.commit("file1.txt modified")
     ok_(not repo.dirty)
 
+    # An empty directory doesn't count as dirty.
+    os.mkdir(op.join(path, "empty"))
+    ok_(not repo.dirty)
+    # Neither does an empty directory with an otherwise empty directory.
+    os.mkdir(op.join(path, "empty", "empty-again"))
+    ok_(not repo.dirty)
+
     # TODO: submodules
@kyleam kyleam changed the title New GitRepo.dirty doesn't ignored nested empty directories New GitRepo.dirty doesn't ignore nested empty directories Mar 5, 2019
@mih mih self-assigned this Mar 6, 2019
@kyleam kyleam closed this in 12e2753 Mar 6, 2019
yarikoptic added a commit to yarikoptic/datalad that referenced this issue Mar 15, 2019
original commit was

    BF: Repo.dirty will not report on nested empty datasets (fixes dataladgh-3196)
    12e2753

but the test passes in 0.11.x so I assume that situation is not relevant to
0.11.x but good to have a test and shouldn't cause conflict - identical
change
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants