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

Re: [problem with name-rev]

From
UBUwe Brauer <oub@mat.ucm.es>
Date
Aug 20, 2019, 19:34 UTC
Message-ID
<87k1b7k4w1.fsf@mat.ucm.es>
In-Reply-To
<xmqqh86bvgsz.fsf@gitster-ct.c.googlers.com>
>>> "JCH" == Junio C Hamano <gitster@pobox.com> writes:
   > Uwe Brauer <oub@mat.ucm.es> writes:
   >> Gives
   >> *   changeset: ae68dbe:master
   >> |\  user:      Uwe Brauer
   >> | | date:      Tue Aug 20 16:25:53 2019 +0200
   >> | | summary:   1.2.1/1.1
   >> | |
   >> | * changeset: c00bb5d:master^2
   >> | | user:      Uwe Brauer
   >> | | date:      Tue Aug 20 16:25:53 2019 +0200
   >> | | summary:   1.2.1
   >> | |
   >> | * changeset: 54c9230:master^2~1
   >> | | user:      Uwe Brauer
   >> | | date:      Tue Aug 20 16:25:53 2019 +0200
   >> | | summary:   1.2
   >> | |
   >> * | changeset: da0712f:master~1
   >> |/  user:      Uwe Brauer
   >> |   date:      Tue Aug 20 16:25:53 2019 +0200
   >> |   summary:   1.1
   >> |
   >> * changeset: 8eb999d:master~2
   >> user:      Uwe Brauer
   >> date:      Tue Aug 20 16:25:53 2019 +0200
   >> summary:   1
   >> 
   >> That looks odd.
   >> 
   >> Any comments?
   > When you make a merge like the ae68dbe, merging a topic with two
   > commits 54c9230 and c00bb5d into the then-current tip of the master
   > branch da0712f, _all_ direct parents are recorded in the resulting
   > merge commit, so the first parent of it is denoted as ae68dbe~1
   > (which is da0712f) and the second parent of it ae68dbe^2 (which is
   > c00bb5d).
   > There is no linear ordering between these two commits, so c00bb5d
   > will *never* be named as master~<some-number>.  As a commit on a
   > side branch, its description from the tip of 'master' will always
   > involve some ^2 (the second parent of some merge commit) somewhere
   > in its name-rev result.

Hm I realize that I understand git much less than I thought (I thought it is like mercurial, where git branches are mercurial bookmarks more or less). It turns out that this is not the case.

Take the following part of what I did

git init echo 1 > 1 git add 1 git commit -m 1 echo 1.1 > 1 git add . git commit -m 1.1 git checkout -b foo master~1 echo 1.2 > 1 git add . git commit -m 1.2 echo 1.2.1 > 1 git add . git commit -m 1.2.1 git checkout master

There are 4  commits.
But 
Git --log --graph --decorate 
Returns
* commit 98922f82932cd1bef58bebf0229367922bca45fc (HEAD -> master)
| Author: Uwe Brauer <oub@mat.ucm.es>
| Date:   Tue Aug 20 21:19:59 2019 +0200
|
|     1.1
|
* commit 8f565d59c356a6038e3d8a7f5dcd2e4a39ae1bb4
  Author: Uwe Brauer <oub@mat.ucm.es>
  Date:   Tue Aug 20 21:19:59 2019 +0200

If I would do the same with mercurial (either with bookmarks or with named branches) I receive

hg init echo 1 > 1 hg add 1 hg commit -m 1 hg branch foo echo 1.1 > 1 hg add . hg commit -m 1.1 hg branch master echo 1.2 > 1 hg add . hg commit -m 1.2 echo 1.2.1 > 1 hg add . hg commit -m 1.2.1 hg checkout master

@  changeset:   3:9ebcc17a6389
|  branch:      master
|  tag:         tip
|  user:        Uwe Brauer <oub@mat.ucm.es>
|  date:        Tue Aug 20 21:27:05 2019 +0200
|  summary:     1.2.1
|
o  changeset:   2:e02d297e2f75
|  branch:      master
|  user:        Uwe Brauer <oub@mat.ucm.es>
|  date:        Tue Aug 20 21:27:04 2019 +0200
|  summary:     1.2
|
o  changeset:   1:7ddaef206d57
|  branch:      foo
|  user:        Uwe Brauer <oub@mat.ucm.es>
|  date:        Tue Aug 20 21:27:04 2019 +0200
|  summary:     1.1
|
o  changeset:   0:dbf3c9975cf3
   user:        Uwe Brauer <oub@mat.ucm.es>
   date:        Tue Aug 20 21:27:03 2019 +0200
   summary:     1

Funny enough if I convert the git repo, to a hg repo either with hg convert or with hg clone (and the hg-git plugin)

I receive a different graph
o  changeset:   3:e7b2696c94fb
|  bookmark:    master
|  tag:         tip
|  parent:      0:5dfd9027787a
|  user:        Uwe Brauer <oub@mat.ucm.es>
|  date:        Tue Aug 20 21:19:59 2019 +0200
|  summary:     1.1
|
| o  changeset:   2:277f6423b9c8
| |  bookmark:    foo
| |  user:        Uwe Brauer <oub@mat.ucm.es>
| |  date:        Tue Aug 20 21:19:59 2019 +0200
| |  summary:     1.2.1
| |
| o  changeset:   1:3529c82f37ae
|/   user:        Uwe Brauer <oub@mat.ucm.es>
|    date:        Tue Aug 20 21:19:59 2019 +0200
|    summary:     1.2
|
o  changeset:   0:5dfd9027787a
   user:        Uwe Brauer <oub@mat.ucm.es>
   date:        Tue Aug 20 21:19:59 2019 +0200
   summary:     1

Anyhow, I don't want this message to be interpreted as a flamewar of sorts.

I don't really know how the import functions work, but I see that git and mercurial treat commits which look simple to me very differently.

Uwe Brauer 
Previous: Junio C HamanoNext: Phil Hord
Message 10 of 13 in “git log --graph with a sort of local revision number”
  1. Uwe BrauerAug 15, 2019
  2. Rafael AscensãoAug 18, 2019
  3. Uwe BrauerAug 18, 2019
  4. Uwe BrauerAug 18, 2019
  5. [SOLVED] (was: git log --graph with a sort of local revision number)Uwe Brauer, Aug 18, 2019
  6. [problem with name-rev] (was: git log --graph with a sort of local revision number)Uwe Brauer, Aug 20, 2019
  7. SZEDER GáborAug 20, 2019
  8. Rafael AscensãoAug 20, 2019
  9. Junio C HamanoAug 20, 2019
  10. Uwe BrauerAug 20, 2019
  11. Phil HordAug 20, 2019
  12. Uwe BrauerAug 21, 2019
  13. Uwe BrauerAug 21, 2019

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.