简体   繁体   中英

What does the word TREESAME mean in the context of git?

I saw many references to TREESAME in the git log manual. But I did not know what it meant.

As defined in the same git-log manual you mentioned:

Suppose you specified foo as the <paths> . We shall call commits that modify foo !TREESAME, and the rest TREESAME. (In a diff filtered for foo, they look different and equal, respectively.)

Given two or more trees, a pathspec is considered TREESAME if and only if there is no discernible difference for the pathspec among the respective trees.

More intuitively, one could think of TREESAME as meaning the same between trees .

Primer: Git tree objects and references

Every commit in git includes 4 fundamental pieces of data:

  1. The commit hash.
  2. Any parent commits (an empty set for the initial commit).
  3. Commit metadata including author, committer, and the commit message.
  4. A tree object reference.

Most developers are familiar with the first 3, but the tree object reference isn't well known, probably because it's very well hidden by default - it doesn't even show with --format=full or --format=fuller options to git show / git log / etc.

To see the tree hash associated with each commit, use the --format=raw option (or include %T / %t in your format spec) in commands such as git show --format=raw or git log --format="format:commit:%h tree:%T %s" .

Separate commits can reference any tree object in the repository, including those referenced by other commits.

The git ls-tree <tree-ish> command shows you the contents of a tree object. The output format is <mode> SP <type> SP <object> TAB <file> . Mode reflects the file type (eg: regular file or symlink), permissions (eg: user/group/world read/write/execute), etc. Type is either tree for directories (trees are recursive structures), or blob for everything else. Use git cat-file -p <object> to pretty-print the content of any object. Keen observers will note the lack of any time related metadata, and hence why file modified/created times aren't updated by git.

Now that you're up to speed on how commits relate to trees, and what's in a tree, we can truly understand the answer to your question.

What does the word TREESAME mean in the context of git?

Any commits that reference the same tree object (with the same tree hash) are TREESAME.

The TREESAME concept can also be applied to specific paths within a tree - this is how git log <path> chooses which commits to show for a given path. See the section on History Simplification in the git docs for more details.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM