-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgit-lfs-compare.sh
More file actions
executable file
·47 lines (40 loc) · 1.25 KB
/
git-lfs-compare.sh
File metadata and controls
executable file
·47 lines (40 loc) · 1.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#!/usr/bin/env bash
# git-lfs-compare.sh - Compare the files in a Git repository with the files in Git LFS
set -eu
[ "${DEBUG:-0}" = "1" ] && set -x
declare -A lfsfilaa localfilaa
c_local_on_lfs=0
c_lfs_on_local=0
while read -r F ; do
lfsfilaa["$F"]=1
done < <(git lfs ls-files -n)
for ext in $(cat .gitattributes | awk '{print $1}') ; do
while read -r F ; do
f="${F##./}"
localfilaa["$f"]=1
done < <(find . -type f -iname "$ext")
done
for f in "${!localfilaa[@]}" ; do
if [ -n "${lfsfilaa["$f"]+1}" ] ; then
echo "EXISTS: Local on LFS: $f"
c_local_on_lfs="$((c_local_on_lfs+1))"
else
echo "NOEXIST: Local on LFS: $f"
fi
done
for f in "${!lfsfilaa[@]}" ; do
if [ -n "${localfilaa["$f"]+1}" ] ; then
echo "EXISTS: LFS on Local: $f"
c_lfs_on_local="$((c_lfs_on_local+1))"
else
echo "NOEXIST: LFS on Local: $f"
fi
done
echo ""
echo "Locally matched files: ${#localfilaa[@]}"
echo "Local files that exist in LFS: $c_local_on_lfs"
echo "Local files not in LFS: $((${#localfilaa[@]}-$c_local_on_lfs))"
echo ""
echo "LFS files: ${#lfsfilaa[@]}"
echo "LFS files that exist locally: $c_lfs_on_local"
echo "LFS files don't exist locally: $((${#lfsfilaa[@]}-$c_lfs_on_local))"