Thursday, May 26, 2011

#listing files in a remote git repository

here is a small batch script for windows (msysgit) that will list the files from a certain branch in a remote git repository. i wrote the initial script some time ago because i wanted git have this functionality with a single cmd line, but finished it just yesterday.

it works as follows:
git_lrt some-url some-branch
git_lrt some-url some-branch > logfile.log

if no branch is given 'master' will be used.

what it does is (if you want to port to linux bash for example):
- create local temp folder
- init a git repository in there
- add remote from url
- fetch objects
- list remote files for branch
- clear local temp folder (& repository)

you may find the script useful to check the contents before cloning a small repository to your local windows hard drive. it seems there might be a possible vulnerability in msysgit where files that are part of the repository can be written to system folders. an example that mr. tale gives:
cockos forum post