Search code examples
githistorygit-logsimplification

Git log history simplification, elaborations example in git log's manual


All of you comfortable with example and elaborations in git log's help for history simplification? I encounter some burdens on understanding when using this help/manual and the named example.

  .-A---M---N---O---P---Q
 /     /   /   /   /   /
I     B   C   D   E   Y
 \   /   /   /   /   /
  `-------------'   X
  • I is the initial commit... foo exists with contents “asdf”, and a file quux exists with contents “quux”....
  • In A, foo contains just “foo”...
  • B contains the same change as A...
  • C does not change foo, but its merge N changes it to “foobar”...
  • P is TREESAME to O...
  • The sense of a merge with a change not present in any of its parents included? See merge's N description in git log's help
  • The file's quux undergoes some modifications on the transition from O to merge P, why do the elaborations in help qualify P as treesame against O?

It looks like the terms TREESAME and !TREESAME are to be seen in scope of a single file/directory. Not to be used to express commit property for multiple files. Is this true?


Solution

  • The TREESAME expressions in the description are applied to the trees of each commit (pairwise as they are being compared) after doing any file-specific filtering from your git log command. For instance:

    git log --simplify-merges
    

    compares every file in each tree to decide whether two commit trees are "the same", while:

    git log --simplify-merges -- README
    

    compares only the README file in each tree, and:

    git log --simplify-merges -- README dir1 dir2
    

    leaves README and any files within the two directories in the tree before comparing the trees.