Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2011-08

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

3 messages · 2 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Reinier Olislagers

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

Reply by email

Graeme
to Reinier Olislagers
Reinier Olislagers wrote
1. The program checks for the current git revision "number" (a hex string in fact) of the local copy.

I believe you are referring to the SHA1 value.

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.

Why check for it first, why not just do a 'git pull origin' and be done with it.

But, if you really want to inspect the HEAD revision's SHA1 value of a remote repository, you can use the following command:

  $ git ls-remote origin HEAD

If you wanted to know every HEAD of every branch/tag on the remote repository, then just do:

  $ git ls-remote origin

For more information see the following help for the 'git ls-remote' command:

http://www.kernel.org/pub/software/scm/git/docs/git-ls-remote.html

However, having git support in LazUpdater does make downloading updates an awful lot quicker, so...

+1

Graeme.

Reply by email

Reinier Olislagers
to Graeme
Graeme wrote 5 lines
On 4 August 2011 12:58, Reinier Olislagers wrote: > > 1. The program checks for the current git revision "number" (a hex > string in fact) of the local copy. I believe you are referring to the SHA1 value.

I think you believe correctly ;)

Show quoted text 7 lines
> 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. Why check for it first, why not just do a 'git pull origin' and be done with it.

I'd like to, but the program as used for svn currently shows current local revision and only updates if there are differences with a remote revision.
If possible, I'd like to keep behaviour the same for git... But I agree, it might be simpler just to do a pull..

Show quoted text 5 lines
But, if you really want to inspect the HEAD revision's SHA1 value of a remote repository, you can use the following command: $ git ls-remote origin HEAD

Exactly what I needed, thanks. I knew it must be possible, but just couldn't find it.

Dankie,
Reinier

Reply by email