[fpc-pascal] [Semi-OT] How to get remote Git revision number (or last update date) using FPC+git executable

Reinier Olislagers reinierolislagers at gmail.com
Thu Aug 4 12:58:56 CEST 2011


Hi all,

I'm working on expanding the LazUpdater tool, so it can download and
compile an entire working installation of FPC&Lazarus from scratch on
Windows. (It downloads binutils, if necessary svn executables etc).
My updates so far on:
http://forge.lazarusforum.de/issues/118

Why? Because I'm fed up writing batch scripts on Windows, and I want to
be able to just click on a program and get a running FPC/Lazarus
environment starting from a clean virtual machine ;)

I'm also extending it to use git (on Linux/OSX as well, after getting it
to work on Windows)
I'm using the git mirrors that Graeme Geldenhuys has set up, as
specified in the wiki:
http://wiki.lazarus.freepascal.org/git_mirrors

1. The program checks for the current git revision "number" (a hex
string in fact) of the local copy. I can do this by issuing
git log -1 --format="%H"
and get something like
a74e3740138d0727af73fbd2be10876c5ed8af0b
(Or, I can do it the dirty way by looking at ORIG_HEAD in the .git
directory)

2. Then it should check the remote revision number.
3. If those are different, it does a git pull to get the two in sync.

How do I find out, using FreePascal and a git executable:
1. (Preferably - so I can match behaviour between the git and svn parts
of the program) the remote git revision
2. If the local copy needs updating, i.e. the remote copy is newer.
3. (Bonus question) the date/time of latest update of local copy
4. (Bonus question 2) the date/time of latest update of remote copy

As if it isn't clear enough already, I'm not an experienced git user (I
use mercurial, and even TortoiseHg).
However, having git support in LazUpdater does make downloading updates
an awful lot quicker, so...

Thanks,
Reinier




More information about the fpc-pascal mailing list