]> rtime.felk.cvut.cz Git - sojka/duhome.git/commitdiff
Show correct information even after removing a home directory
authorMichal Sojka <michal.sojka@cvut.cz>
Fri, 27 Jul 2018 11:54:31 +0000 (13:54 +0200)
committerMichal Sojka <michal.sojka@cvut.cz>
Fri, 27 Jul 2018 11:54:31 +0000 (13:54 +0200)
Now, save removes all the old data and recreates them according to the
current state.

Status shows the data last commited, not the data from the work tree,
which might be deleted due to `save` running in parallel.

duhome

diff --git a/duhome b/duhome
index 15896fe13f76216fafcf6030c52d47fbcdfc824d..09e8ff3d5a7c1270d679d279854ef13782561f44 100755 (executable)
--- a/duhome
+++ b/duhome
@@ -12,6 +12,7 @@ case "$1" in
        ;;
     save)
        cd $DATA
+       git rm '*' # Remove old data - perhaps, some homes were removed
        for i in /home/*; do
            du -shx $i | cut -f1 > ${i#/home/};
            git add ${i#/home/}
@@ -26,6 +27,9 @@ case "$1" in
     status)
        cd $DATA
        grep . *|sort -h -k2 -t:
+       git ls-files --with-tree=HEAD | while read f; do
+           echo "$f:$(git show "HEAD:$f")"
+       done | sort -h -k2 -t:
        ;;
     log)
        cd $DATA