> Unfortunately, this is hard because I don't believe Git stores this info in their index of files,
I don't know if they keep a work tree on the server side, but if they did, then it would be trivial to store the file size as determined from the file on disk and display it on the front-end regardless of the type of view. Alternatively, they could determine the size from the blob associated with the file in the object store.
Presumably the branch/tag/commit that's currently chosen is stored in the session. You can retrieve the size of a blob by running
git cat-file -s commit:path/to/file
and the tree object has a listing of the blobs and trees it references. I would think they could do this and store the results when a particular commit is chosen from the drop-down menu on the web page.
Just because you can get it, it doesn't mean that this is efficient and fast enough to do when you are browsing through the directories.
Now imagine the slowness, since caching this doesn't even make remotely sense for many repos.
> Just because you can get it, it doesn't mean that this is efficient and fast enough to do when you are browsing through the directories.
It's already doing this for the last time modified value it retrieves or calculates for each file and directory as I'm browsing through the repo. That requires determining which commit last changed each file and in the case of directories, which commit most recently changed one of the files within the directory.
The file sizes, on the other hand, are available by determining which blob is associated with the file. That file to blob mapping available by recursing through the trees associated with the commit that's currently selected. This does not require iterating through multiple commits, unlike the former case, and it shouldn't be any more complex.
I don't know if they keep a work tree on the server side, but if they did, then it would be trivial to store the file size as determined from the file on disk and display it on the front-end regardless of the type of view. Alternatively, they could determine the size from the blob associated with the file in the object store.