Oxen-AI / Oxen

Oxen.ai's core rust library, server, and CLI
https://oxen.ai
Apache License 2.0
201 stars 12 forks source link

Incorrect/Inconsistent handling of empty directories #460

Open rockenbf opened 2 weeks ago

rockenbf commented 2 weeks ago

Currently empty directories are not properly handled as shown in the example below. I see two possible solutions: 1) Have the same behaviour as git and don't track empty directories at all. (my personal recommendation) 2) Consider empty directories as part of the data and track them properly.

Oxen version: 0.19.6 / 0.19.4 OS version: Pop!_OS 22.04 LTS

Minimal example to reproduce the problem:

user@machine:/tmp$ mkdir test-repo && cd test-repo
user@machine:/tmp/test-repo$ oxen init 
๐Ÿ‚ repository initialized at: "/tmp/test-repo"
user@machine:/tmp/test-repo$ mkdir test-dir
user@machine:/tmp/test-repo$ oxen status 
Untracked Directories
  (use "oxen add <dir>..." to update what will be committed)
  test-dir/ (0 items)

user@machine:/tmp/test-repo$ oxen add test-dir && oxen commit -m "test-commit"
๐Ÿ‚ oxen added 0 files (0 B) in 32ms
Committing with message: test-commit
๐Ÿ‚ commit 8f3912678987072c9b7226bdfb488fb6 -> 'test-commit' in 26ms
user@machine:/tmp/test-repo$ oxen status
On branch main -> 8f3912678987072c9b7226bdfb488fb6

Untracked Directories
  (use "oxen add <dir>..." to update what will be committed)
  test-dir/ (0 items)

extension for nested empty directories:

user@machine:/tmp/test-repo$ mkdir -p  test-dir2/another-dir
user@machine:/tmp/test-repo$ oxen status 
On branch main -> 8f3912678987072c9b7226bdfb488fb6

Untracked Directories
  (use "oxen add <dir>..." to update what will be committed)
  test-dir/  (0 items)
  test-dir2/ (0 items)

user@machine:/tmp/test-repo$ oxen add test-dir2/another-dir
๐Ÿ‚ oxen added 0 files (0 B) in 32ms
fuser@machine:/tmp/test-repo$ oxen status 
On branch main -> 8f3912678987072c9b7226bdfb488fb6

Directories to be committed
  added: test-dir2/another-dir

Untracked Directories
  (use "oxen add <dir>..." to update what will be committed)
  test-dir/  (0 items)
  test-dir2/ (0 items)

user@machine:/tmp/test-repo$ oxen commit -m "test-commit 2"
Committing with message: test-commit 2
๐Ÿ‚ commit fc89bb8af681f4c77eae8430b4f0babe -> 'test-commit 2' in 42ms
user@machine:/tmp/test-repo$ oxen status 
On branch main -> fc89bb8af681f4c77eae8430b4f0babe

Untracked Directories
  (use "oxen add <dir>..." to update what will be committed)
  test-dir/  (0 items)
  test-dir2/ (0 items)

user@machine:/tmp/test-repo$ oxen add test-dir2
๐Ÿ‚ oxen added 0 files (0 B) in 20ms
user@machine:/tmp/test-repo$ oxen status 
On branch main -> fc89bb8af681f4c77eae8430b4f0babe

Directories to be committed
  added: test-dir2/another-dir

Untracked Directories
  (use "oxen add <dir>..." to update what will be committed)
  test-dir/ (0 items)

user@machine:/tmp/test-repo$ oxen commit -m "test-commit 3"
Committing with message: test-commit 3
๐Ÿ‚ commit 6fee636a1158b9d69a4e67584b686795 -> 'test-commit 3' in 62ms
user@machine:/tmp/test-repo$ oxen status 
On branch main -> 6fee636a1158b9d69a4e67584b686795

Untracked Directories
  (use "oxen add <dir>..." to update what will be committed)
  test-dir/  (0 items)
  test-dir2/ (0 items)

user@machine:/tmp/test-repo$ oxen tree
[Commit] 6fee636a1158b9d69a4e67584b686795 "test-commit 3" -> Test User user@test.ai parent_ids "fc89bb8af681f4c77eae8430b4f0babe"
  [Dir] d2ae091bb0 "" (0 B) (0 files) (commit 6fee636a11)  (1 children)
    [VNode] 6ab93c9bb4  (1 children)
      [Dir] 7b0849c601 "test-dir2" (0 B) (0 files) (commit 6fee636a11)  (1 children)
        [VNode] b1dc63dc12  (1 children)
          [Dir] e5378f1928 "another-dir" (0 B) (0 files) (commit 6fee636a11)  (0 children)
Time to load tree: 1.06298ms
Time to print tree: 30.118ยตs