[fpc-other] Git & SVN

Graeme Geldenhuys mailinglists at geldenhuys.co.uk
Tue May 23 16:56:59 CEST 2017


On 2017-05-23 15:09, Mark Morgan Lloyd wrote:
> One question if I may. Subversion has revision numbers like 12345, and
> it's comparatively easy to query that and build it into a piece of
> software's version information.

And the same is true for Git. By design, distributed version control 
systems (any of them, not just Git), can't rely on a sequential number. 
The word "distributed" should say it all. True parallel development; no 
single "server" instance etc.

Saying that, git includes a command 'git describe' which does what you 
need. I find its result also way more useful and informative that a 
single sequential revision number - which only has a mean to a 
developer. Lets use an example:

   [reportdesigner (reportdesigner)]$ git describe
   v1.4.1-787-g45f932c1

What does that output tell me:
   * Whatever code I'm working on is follow on from the "v1.4.1"
     release.
   * This line of [development] history has seen "787" commits
     since the v1.4.1 release.
   * The "g" prefix indications that the Git revision control
     system was used.
   * The "45f932c1" is the SHA1 value of the last commit, that
     uniquely identifies where we are in the whole history of
     the project. Irrespective of having 1 or a 1000 branches.

Now as with anything Git, everything is configurable. So the 
git-describe commands has many optional parameters too. So you can 
change the output to suite your project's needs. Things like should Tag 
names be used in the git-describe output, or only Annotated Tags, or 
only Branch names. Do we want the commit count, do we want the "g" 
prefix, how long SHA1 value do we want etc etc.

Many applications incorporate such output in there version information. 
See attached screenshot of one such example. I've seen plenty of others too.


What does a SubVersion revision r20453 tell you?

   * Which branch are you on?
   * Which release is this work based on?
   * Is it a "hotfix" or new feature.
   * Is it maybe a tag? Though Subversion doesn't really have a
     concept of tags, as they are just branches in a bad disguise.

No, it only tells you that you are using commit number 20453.

So now the next thing you are probably going to tell me is that yeah but 
I can use the revision number in Windows's version numbering as a 
Revision or Build value. Yes and No. Only if your repository has less 
than 65535 commits - the maximum a WORD type supports. So what happens 
if you have more commits that that? Many large projects do.

 > It's also trivial for a developer to
 > look at the revision that he's currently working with, to say whether
 > it's older or newer than revision 12345,

As I just explained. The git-describe output tells you that and more.


 > and to get a log of what the
 > relative changes were by /only/ knowing the revision number.

Nothing new, Git does that too. Git (no surprise) even goes further and 
also tells you the Parent(s) commit that got you there, the 
Child/Children commits following on, what branch it is on and what Tags 
this commit follows.


Regards,
   Graeme

-- 
fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal
http://fpgui.sourceforge.net/

My public PGP key:  http://tinyurl.com/graeme-pgp
-------------- next part --------------
A non-text attachment was scrubbed...
Name: shot.png
Type: image/png
Size: 8531 bytes
Desc: not available
URL: <http://lists.freepascal.org/pipermail/fpc-other/attachments/20170523/e69c348e/attachment-0001.png>


More information about the fpc-other mailing list