git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: Creating something like increasing revision numbers

From
Junio C Hamano <gitster@pobox.com>
Date
Oct 18, 2009, 22:47 UTC
Message-ID
<7vfx9gnwtw.fsf@alter.siamese.dyndns.org>
In-Reply-To
<20091018152054.GA3956@gamma.logic.tuwien.ac.at>
Norbert Preining <preining@logic.at> writes:
Show 11 quoted lines
> On So, 18 Okt 2009, Johan Herland wrote:
>> A global, increasing version number ala SVN is fundamentally impossible in 
>> any distributed version control system (like Git).
>
> Yes, agreed. 
>
> The point is that I do not actually need the "distributed" part of git.
> I want one central repository and all collaborators commit to that.
> Yes, that is subversion, I know.
>
> We have no branches, no tags, nothing of that. Only trunk.

No, it is not subversion at all. Don't say "I know" until you really know. Anybody who thinks that is not distributed does not understand distributedness of git.

Distributedness does _not_ come from not having a central shared repository, nor not using more than one branch.

Distrubutedness comes the moment any and all of your people can make their commits _locally_. And the fundamental lack of "increasing global version number" is one implication of the distributedness.

Suppose you and Alice collaborate that way. You make the initial commit, that is pushed to the central shared repository, and alice clones.

    norb$ git commit -m 'first one'
    norb$ git push
    alice$ git clone $central

Now Norb and Alice share that the 'first one' is the current and only commit at the tip of their history. The central repository also shares that notion. You work and produce a few commits.

    norb$ edit; git commit -a -m 'second norb'
    norb$ edit; git commit -a -m 'third norb'
    norb$ edit; git commit -a -m 'fourth norb'
while Alice does the same.
    
    alice$ edit; git commit -a -m 'second alice'
    alice$ edit; git commit -a -m 'third alice'
You happened to push first:
    norb$ git push

You and the central repository shares the view of the history in which the mapping between "revision sequence number" and commits looks like:

    1. first one
    2. second norb
    3. third norb
    4. fourth norb

Imagine what view of the history Alice has at this point and think for a while. Recall Alice hasn't pulled from the central repository since she cloned. There are two possible things you may want to do.

 #1 Some sequential number is given but that is useless as global
    identifier.
    1. first one
    2. second alice
    3. third alice
 #2 Do not give such sequential number locally; the central repository is
    the _only_ place that assigns such a number.  '?' stands for
    'unnumbered'
    1. first one
    ?. second alice
    ?. third alice

Then Alice fetches from the central and integrates her history with it. She can do one of two things. "pull" to create a non-linear history by merging, or "pull --rebase" to keep the history linear.

Since you are imitating subversion, you may choose the latter route to rebase, and now the linearlized history would become:

    1. first one
    2. second norb
    3. third norb
    4. fourth norb
    ?. second alice
    ?. third alice

Alice's two commits may stay unnumbered (if you chose #2---no local versions), or changes from 2/3 to 5/6 (if you chose #1).

If you instead use merges, then there won't be 'sequence' number you can usefully compare anymore.

                    1 first one
                   /|
  second alice    2 2     second norb
                  | |
                  | 3     third norb
                  | |
   third alice    3 4     fourth norb
                  |/
   fourth alice   5

Scheme #1 inherently cannot give you stable and unique numbers in a distributed environment where you can commit locally without talking to the central "number naming authority". By rebasing, you can keep the long-term numbering unique (by renaming some new ones), but rebase has its own downsides besides the name of the commit.

Scheme #2 is a way to get some stablility; give the authority of numbering to the central repository and commits that haven't hit the central repository are left unnumbered. But that is generally not very useful for your purpose of giving incrementing version number for building (the developers would want to build for testing before finally committing to publish the result to the central place).

Running describe using one tag on the 'initial' would give you a rough equivalent of #1 (i.e. you get tentative numbers on the local commits), both in the case you rebase (i.e. your numbers change) and you merge (i.e. you can have more than one "second" commits and numbers are not unique), which would be the best compromise you can get.

Previous: Nicolas PitreNext: Norbert Preining
Message 7 of 23 in “Creating something like increasing revision numbers”
  1. Norbert PreiningOct 18, 2009
  2. Johan HerlandOct 18, 2009
  3. Norbert PreiningOct 18, 2009
  4. Johan HerlandOct 18, 2009
  5. alexandrulOct 18, 2009
  6. Nicolas PitreOct 19, 2009
  7. Junio C HamanoOct 18, 2009
  8. Norbert PreiningOct 19, 2009
  9. alexandrulOct 18, 2009
  10. demerphqOct 18, 2009
  11. Norbert PreiningOct 18, 2009
  12. demerphqOct 18, 2009
  13. alexandrulOct 18, 2009
  14. Jon SmirlOct 18, 2009
  15. Daniel BarkalowOct 18, 2009
  16. Norbert PreiningOct 19, 2009
  17. Daniel BarkalowOct 19, 2009
  18. Norbert PreiningOct 19, 2009
  19. Daniel BarkalowOct 19, 2009
  20. Nicolas PitreOct 19, 2009
  21. Norbert PreiningOct 19, 2009
  22. Johannes SixtOct 19, 2009
  23. David AguilarOct 21, 2009

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.