* [PATCH 3/5] Docs - include README in git.txt
From: David Greaves @ 2005-05-22 17:44 UTC (permalink / raw)
To: Linus Torvalds; +Cc: git
Include the README in the git.txt
Signed-off-by: David Greaves <david@dgreaves.com>
---
commit e6d7c5341942fdd07d966efe36fde653167e84f0
tree 03ae742170ebaef9040fa8234e1d6752bad140ab
parent 6f657e57d7a5b941ed401365e23d78ff77f5ebcf
author David Greaves <david@dgreaves.com> Sat, 21 May 2005 21:27:41 +0100
committer David Greaves <david@dgreaves.com> Sat, 21 May 2005 21:27:41 +0100
Documentation/git.txt | 46 +++++++++++++++++++++-------------------------
1 files changed, 21 insertions(+), 25 deletions(-)
Index: Documentation/git.txt
===================================================================
--- c081754f951815c43bdd973ddc7e23365793e75e/Documentation/git.txt (mode:100644)
+++ 03ae742170ebaef9040fa8234e1d6752bad140ab/Documentation/git.txt (mode:100644)
@@ -1,6 +1,6 @@
git(7)
======
-v0.1, May 2005
+May 2005
NAME
----
@@ -16,9 +16,10 @@
This is reference information for the core git commands.
-The link:README[] contains much useful definition and clarification
-info - read that first. And of the commands, I suggest reading
-'git-update-cache' and 'git-read-tree' first - I wish I had!
+The Discussion section below contains much useful definition and
+clarification info - read that first. And of the commands, I suggest
+reading link:git-update-cache.html[git-update-cache] and
+link:git-read-tree.html[git-read-tree] first - I wish I had!
David Greaves <david@dgreaves.com>
08/05/05
@@ -157,14 +158,10 @@
-Terminology
------------
-see README for description
-
-Identifier terminology
+Identifier Terminology
----------------------
<object>::
- Indicates any object sha1 identifier
+ Indicates the sha1 identifier for any type of object
<blob>::
Indicates a blob object sha1 identifier
@@ -176,11 +173,10 @@
Indicates a commit object sha1 identifier
<tree-ish>::
- Indicates a tree, commit or tag object sha1 identifier.
- A command that takes a <tree-ish> argument ultimately
- wants to operate on a <tree> object but automatically
- dereferences <commit> and <tag> that points at a
- <tree>.
+ Indicates a tree, commit or tag object sha1 identifier. A
+ command that takes a <tree-ish> argument ultimately wants to
+ operate on a <tree> object but automatically dereferences
+ <commit> and <tag> objects that point at a <tree>.
<type>::
Indicates that an object type is required.
@@ -192,10 +188,12 @@
Symbolic Identifiers
--------------------
-Any git comand accepting any <object> can also use the following symbolic notation:
+Any git comand accepting any <object> can also use the following
+symbolic notation:
HEAD::
- indicates the head of the repository (ie the contents of `$GIT_DIR/HEAD`)
+ indicates the head of the repository (ie the contents of
+ `$GIT_DIR/HEAD`)
<tag>::
a valid tag 'name'+
(ie the contents of `$GIT_DIR/refs/tags/<tag>`)
@@ -230,18 +228,12 @@
Terminology
-----------
-Each line contains terms used interchangeably
+Each line contains terms which you may see used interchangeably
object database, .git directory
directory cache, index
id, sha1, sha1-id, sha1 hash
type, tag
- blob, blob object
- tree, tree object
- commit, commit object
- parent
- root object
- changeset
Environment Variables
@@ -295,9 +287,13 @@
link:git-diff-files.html[git-diff-files];
link:git-diff-tree.html[git-diff-tree]
+Discussion
+----------
+include::../README[]
+
Author
------
-Written by Linus Torvalds <torvalds@osdl.org>
+Written by Linus Torvalds <torvalds@osdl.org> and the git-list <git@vger.kernel.org>.
Documentation
--------------
^ permalink raw reply
* [PATCH 2/5] Docs - asciidoc changes
From: David Greaves @ 2005-05-22 17:44 UTC (permalink / raw)
To: Linus Torvalds; +Cc: git
Whitespace and asciidoc formatting changes only in preparation for
content changes.
Signed-off-by: David Greaves <david@dgreaves.com>
---
commit 6f657e57d7a5b941ed401365e23d78ff77f5ebcf
tree c081754f951815c43bdd973ddc7e23365793e75e
parent 4a137fb4f4d7e04ae0fb72b3f4910dc487f39c8a
author David Greaves <david@dgreaves.com> Sat, 21 May 2005 21:26:22 +0100
committer David Greaves <david@dgreaves.com> Sat, 21 May 2005 21:26:22 +0100
README | 606 ++++++++++++++++++++++++++++++++---------------------------------
1 files changed, 304 insertions(+), 302 deletions(-)
Index: README
===================================================================
--- 72336a9478877b0708833f0e61cfd27574f24417/README (mode:100644)
+++ c081754f951815c43bdd973ddc7e23365793e75e/README (mode:100644)
@@ -1,9 +1,8 @@
-
-
+////////////////////////////////////////////////////////////////
GIT - the stupid content tracker
-
+////////////////////////////////////////////////////////////////
"git" can mean anything, depending on your mood.
- random three-letter combination that is pronounceable, and not
@@ -22,16 +21,13 @@
There are two object abstractions: the "object database", and the
"current directory cache" aka "index".
-
-
- The Object Database (GIT_OBJECT_DIRECTORY)
-
-
+The Object Database
+~~~~~~~~~~~~~~~~~~~
The object database is literally just a content-addressable collection
of objects. All objects are named by their content, which is
approximated by the SHA1 hash of the object itself. Objects may refer
-to other objects (by referencing their SHA1 hash), and so you can build
-up a hierarchy of objects.
+to other objects (by referencing their SHA1 hash), and so you can
+build up a hierarchy of objects.
All objects have a statically determined "type" aka "tag", which is
determined at object creation time, and which identifies the format of
@@ -62,12 +58,17 @@
just going to confuse people. So aim for the notion of "one root object
per project", even if git itself does not enforce that.
+A "tag" object symbolically identifies and can be used to sign other
+objects. It contains the identifier and type of another object, a
+symbolic name (of course!) and, optionally, a signature.
+
Regardless of object type, all objects are share the following
characteristics: they are all in deflated with zlib, and have a header
that not only specifies their tag, but also size information about the
data in the object. It's worth noting that the SHA1 hash that is used
-to name the object is always the hash of this _compressed_ object, not
-the original data.
+to name the object is the hash of the original data (historical note:
+in the dawn of the age of git this was the sha1 of the _compressed_
+object)
As a result, the general consistency of an object can always be tested
independently of the contents or the type of the object: all objects can
@@ -76,157 +77,162 @@
forms a sequence of <ascii tag without space> + <space> + <ascii decimal
size> + <byte\0> + <binary object data>.
-The structured objects can further have their structure and connectivity
-to other objects verified. This is generally done with the "fsck-cache"
-program, which generates a full dependency graph of all objects, and
-verifies their internal consistency (in addition to just verifying their
-superficial consistency through the hash).
+The structured objects can further have their structure and
+connectivity to other objects verified. This is generally done with
+the "fsck-cache" program, which generates a full dependency graph of
+all objects, and verifies their internal consistency (in addition to
+just verifying their superficial consistency through the hash).
The object types in some more detail:
- BLOB: A "blob" object is nothing but a binary blob of data, and
- doesn't refer to anything else. There is no signature or any
- other verification of the data, so while the object is
- consistent (it _is_ indexed by its sha1 hash, so the data itself
- is certainly correct), it has absolutely no other attributes.
- No name associations, no permissions. It is purely a blob of
- data (i.e. normally "file contents").
-
- In particular, since the blob is entirely defined by its data,
- if two files in a directory tree (or in multiple different
- versions of the repository) have the same contents, they will
- share the same blob object. The object is totally independent
- of it's location in the directory tree, and renaming a file does
- not change the object that file is associated with in any way.
-
- TREE: The next hierarchical object type is the "tree" object. A tree
- object is a list of mode/name/blob data, sorted by name.
- Alternatively, the mode data may specify a directory mode, in
- which case instead of naming a blob, that name is associated
- with another TREE object.
-
- Like the "blob" object, a tree object is uniquely determined by
- the set contents, and so two separate but identical trees will
- always share the exact same object. This is true at all levels,
- i.e. it's true for a "leaf" tree (which does not refer to any
- other trees, only blobs) as well as for a whole subdirectory.
-
- For that reason a "tree" object is just a pure data abstraction:
- it has no history, no signatures, no verification of validity,
- except that since the contents are again protected by the hash
- itself, we can trust that the tree is immutable and its contents
- never change.
-
- So you can trust the contents of a tree to be valid, the same
- way you can trust the contents of a blob, but you don't know
- where those contents _came_ from.
-
- Side note on trees: since a "tree" object is a sorted list of
- "filename+content", you can create a diff between two trees
- without actually having to unpack two trees. Just ignore all
- common parts, and your diff will look right. In other words,
- you can effectively (and efficiently) tell the difference
- between any two random trees by O(n) where "n" is the size of
- the difference, rather than the size of the tree.
-
- Side note 2 on trees: since the name of a "blob" depends
- entirely and exclusively on its contents (i.e. there are no names
- or permissions involved), you can see trivial renames or
- permission changes by noticing that the blob stayed the same.
- However, renames with data changes need a smarter "diff" implementation.
-
-CHANGESET: The "changeset" object is an object that introduces the
- notion of history into the picture. In contrast to the other
- objects, it doesn't just describe the physical state of a tree,
- it describes how we got there, and why.
-
- A "changeset" is defined by the tree-object that it results in,
- the parent changesets (zero, one or more) that led up to that
- point, and a comment on what happened. Again, a changeset is
- not trusted per se: the contents are well-defined and "safe" due
- to the cryptographically strong signatures at all levels, but
- there is no reason to believe that the tree is "good" or that
- the merge information makes sense. The parents do not have to
- actually have any relationship with the result, for example.
-
- Note on changesets: unlike real SCM's, changesets do not contain
- rename information or file mode change information. All of that
- is implicit in the trees involved (the result tree, and the
- result trees of the parents), and describing that makes no sense
- in this idiotic file manager.
-
-TRUST: The notion of "trust" is really outside the scope of "git", but
- it's worth noting a few things. First off, since everything is
- hashed with SHA1, you _can_ trust that an object is intact and
- has not been messed with by external sources. So the name of an
- object uniquely identifies a known state - just not a state that
- you may want to trust.
-
- Furthermore, since the SHA1 signature of a changeset refers to
- the SHA1 signatures of the tree it is associated with and the
- signatures of the parent, a single named changeset specifies
- uniquely a whole set of history, with full contents. You can't
- later fake any step of the way once you have the name of a
- changeset.
-
- So to introduce some real trust in the system, the only thing
- you need to do is to digitally sign just _one_ special note,
- which includes the name of a top-level changeset. Your digital
- signature shows others that you trust that changeset, and the
- immutability of the history of changesets tells others that they
- can trust the whole history.
-
- In other words, you can easily validate a whole archive by just
- sending out a single email that tells the people the name (SHA1
- hash) of the top changeset, and digitally sign that email using
- something like GPG/PGP.
-
- In particular, you can also have a separate archive of "trust
- points" or tags, which document your (and other peoples) trust.
- You may, of course, archive these "certificates of trust" using
- "git" itself, but it's not something "git" does for you.
-
-Another way of saying the last point: "git" itself only handles content
-integrity, the trust has to come from outside.
+Blob Object
+~~~~~~~~~~~
+A "blob" object is nothing but a binary blob of data, and doesn't
+refer to anything else. There is no signature or any other
+verification of the data, so while the object is consistent (it _is_
+indexed by its sha1 hash, so the data itself is certainly correct), it
+has absolutely no other attributes. No name associations, no
+permissions. It is purely a blob of data (i.e. normally "file
+contents").
+
+In particular, since the blob is entirely defined by its data, if two
+files in a directory tree (or in multiple different versions of the
+repository) have the same contents, they will share the same blob
+object. The object is totally independent of it's location in the
+directory tree, and renaming a file does not change the object that
+file is associated with in any way.
+
+Tree Object
+~~~~~~~~~~~
+The next hierarchical object type is the "tree" object. A tree object
+is a list of mode/name/blob data, sorted by name. Alternatively, the
+mode data may specify a directory mode, in which case instead of
+naming a blob, that name is associated with another TREE object.
+
+Like the "blob" object, a tree object is uniquely determined by the
+set contents, and so two separate but identical trees will always
+share the exact same object. This is true at all levels, i.e. it's
+true for a "leaf" tree (which does not refer to any other trees, only
+blobs) as well as for a whole subdirectory.
+
+For that reason a "tree" object is just a pure data abstraction: it
+has no history, no signatures, no verification of validity, except
+that since the contents are again protected by the hash itself, we can
+trust that the tree is immutable and its contents never change.
+
+So you can trust the contents of a tree to be valid, the same way you
+can trust the contents of a blob, but you don't know where those
+contents _came_ from.
+
+Side note on trees: since a "tree" object is a sorted list of
+"filename+content", you can create a diff between two trees without
+actually having to unpack two trees. Just ignore all common parts,
+and your diff will look right. In other words, you can effectively
+(and efficiently) tell the difference between any two random trees by
+O(n) where "n" is the size of the difference, rather than the size of
+the tree.
+
+Side note 2 on trees: since the name of a "blob" depends entirely and
+exclusively on its contents (i.e. there are no names or permissions
+involved), you can see trivial renames or permission changes by
+noticing that the blob stayed the same. However, renames with data
+changes need a smarter "diff" implementation.
+
+
+Changeset Object
+~~~~~~~~~~~~~~~~
+The "changeset" object is an object that introduces the notion of
+history into the picture. In contrast to the other objects, it
+doesn't just describe the physical state of a tree, it describes how
+we got there, and why.
+
+A "changeset" is defined by the tree-object that it results in, the
+parent changesets (zero, one or more) that led up to that point, and a
+comment on what happened. Again, a changeset is not trusted per se:
+the contents are well-defined and "safe" due to the cryptographically
+strong signatures at all levels, but there is no reason to believe
+that the tree is "good" or that the merge information makes sense.
+The parents do not have to actually have any relationship with the
+result, for example.
+
+Note on changesets: unlike real SCM's, changesets do not contain
+rename information or file mode change information. All of that is
+implicit in the trees involved (the result tree, and the result trees
+of the parents), and describing that makes no sense in this idiotic
+file manager.
+
+Trust Object
+~~~~~~~~~~~~
+The notion of "trust" is really outside the scope of "git", but it's
+worth noting a few things. First off, since everything is hashed with
+SHA1, you _can_ trust that an object is intact and has not been messed
+with by external sources. So the name of an object uniquely
+identifies a known state - just not a state that you may want to
+trust.
+
+Furthermore, since the SHA1 signature of a changeset refers to the
+SHA1 signatures of the tree it is associated with and the signatures
+of the parent, a single named changeset specifies uniquely a whole set
+of history, with full contents. You can't later fake any step of the
+way once you have the name of a changeset.
+
+So to introduce some real trust in the system, the only thing you need
+to do is to digitally sign just _one_ special note, which includes the
+name of a top-level changeset. Your digital signature shows others
+that you trust that changeset, and the immutability of the history of
+changesets tells others that they can trust the whole history.
+
+In other words, you can easily validate a whole archive by just
+sending out a single email that tells the people the name (SHA1 hash)
+of the top changeset, and digitally sign that email using something
+like GPG/PGP.
+
+In particular, you can also have a separate archive of "trust points"
+or tags, which document your (and other peoples) trust. You may, of
+course, archive these "certificates of trust" using "git" itself, but
+it's not something "git" does for you.
+Another way of saying the last point: "git" itself only handles
+content integrity, the trust has to come from outside.
- The "index" aka "Current Directory Cache" (".git/index")
+The "index" aka "Current Directory Cache"
+-----------------------------------------
The index is a simple binary file, which contains an efficient
representation of a virtual directory content at some random time. It
does so by a simple array that associates a set of names, dates,
permissions and content (aka "blob") objects together. The cache is
always kept ordered by name, and names are unique (with a few very
specific rules) at any point in time, but the cache has no long-term
-meaning, and can be partially updated at any time.
+meaning, and can be partially updated at any time.
In particular, the index certainly does not need to be consistent with
the current directory contents (in fact, most operations will depend on
different ways to make the index _not_ be consistent with the directory
hierarchy), but it has three very important attributes:
- (a) it can re-generate the full state it caches (not just the directory
- structure: it contains pointers to the "blob" objects so that it
- can regenerate the data too)
-
- As a special case, there is a clear and unambiguous one-way mapping
- from a current directory cache to a "tree object", which can be
- efficiently created from just the current directory cache without
- actually looking at any other data. So a directory cache at any
- one time uniquely specifies one and only one "tree" object (but
- has additional data to make it easy to match up that tree object
- with what has happened in the directory)
-
- (b) it has efficient methods for finding inconsistencies between that
- cached state ("tree object waiting to be instantiated") and the
- current state.
-
- (c) it can additionally efficiently represent information about merge
- conflicts between different tree objects, allowing each pathname to
- be associated with sufficient information about the trees involved
- that you can create a three-way merge between them.
+'(a) it can re-generate the full state it caches (not just the
+directory structure: it contains pointers to the "blob" objects so
+that it can regenerate the data too)'
+
+As a special case, there is a clear and unambiguous one-way mapping
+from a current directory cache to a "tree object", which can be
+efficiently created from just the current directory cache without
+actually looking at any other data. So a directory cache at any one
+time uniquely specifies one and only one "tree" object (but has
+additional data to make it easy to match up that tree object with what
+has happened in the directory)
+
+'(b) it has efficient methods for finding inconsistencies between that
+cached state ("tree object waiting to be instantiated") and the
+current state.'
+
+'(c) it can additionally efficiently represent information about merge
+conflicts between different tree objects, allowing each pathname to be
+associated with sufficient information about the trees involved that
+you can create a three-way merge between them.'
Those are the three ONLY things that the directory cache does. It's a
cache, and the normal operation is to re-generate it completely from a
@@ -241,220 +247,216 @@
the index file can have the representation of an intermediate tree that
has not yet been instantiated. So the index can be thought of as a
write-back cache, which can contain dirty information that has not yet
-been written back to the backing store.
-
-
+been written back to the backing store.
- The Workflow
+The Workflow
+------------
Generally, all "git" operations work on the index file. Some operations
-work _purely_ on the index file (showing the current state of the
+work *purely* on the index file (showing the current state of the
index), but most operations move data to and from the index file. Either
from the database or from the working directory. Thus there are four
main combinations:
- 1) working directory -> index
+1) working directory -> index
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- You update the index with information from the working directory
- with the "update-cache" command. You generally update the index
- information by just specifying the filename you want to update,
- like so:
+You update the index with information from the working directory with
+the "update-cache" command. You generally update the index
+information by just specifying the filename you want to update, like
+so:
update-cache filename
- but to avoid common mistakes with filename globbing etc, the
- command will not normally add totally new entries or remove old
- entries, i.e. it will normally just update existing cache entries.
-
- To tell git that yes, you really do realize that certain files
- no longer exist in the archive, or that new files should be
- added, you should use the "--remove" and "--add" flags
- respectively.
-
- NOTE! A "--remove" flag does _not_ mean that subsequent
- filenames will necessarily be removed: if the files still exist
- in your directory structure, the index will be updated with
- their new status, not removed. The only thing "--remove" means
- is that update-cache will be considering a removed file to be a
- valid thing, and if the file really does not exist any more, it
- will update the index accordingly.
-
- As a special case, you can also do "update-cache --refresh",
- which will refresh the "stat" information of each index to match
- the current stat information. It will _not_ update the object
- status itself, and it will only update the fields that are used
- to quickly test whether an object still matches its old backing
- store object.
+but to avoid common mistakes with filename globbing etc, the command
+will not normally add totally new entries or remove old entries,
+i.e. it will normally just update existing cache entries.
+
+To tell git that yes, you really do realize that certain files no
+longer exist in the archive, or that new files should be added, you
+should use the "--remove" and "--add" flags respectively.
+
+NOTE! A "--remove" flag does _not_ mean that subsequent filenames will
+necessarily be removed: if the files still exist in your directory
+structure, the index will be updated with their new status, not
+removed. The only thing "--remove" means is that update-cache will be
+considering a removed file to be a valid thing, and if the file really
+does not exist any more, it will update the index accordingly.
+
+As a special case, you can also do "update-cache --refresh", which
+will refresh the "stat" information of each index to match the current
+stat information. It will _not_ update the object status itself, and
+it will only update the fields that are used to quickly test whether
+an object still matches its old backing store object.
- 2) index -> object database
+2) index -> object database
+~~~~~~~~~~~~~~~~~~~~~~~~~~~
- You write your current index file to a "tree" object with the
- program
+You write your current index file to a "tree" object with the program
write-tree
- that doesn't come with any options - it will just write out the
- current index into the set of tree objects that describe that
- state, and it will return the name of the resulting top-level
- tree. You can use that tree to re-generate the index at any time
- by going in the other direction:
-
- 3) object database -> index
-
- You read a "tree" file from the object database, and use that to
- populate (and overwrite - don't do this if your index contains
- any unsaved state that you might want to restore later!) your
- current index. Normal operation is just
+that doesn't come with any options - it will just write out the
+current index into the set of tree objects that describe that state,
+and it will return the name of the resulting top-level tree. You can
+use that tree to re-generate the index at any time by going in the
+other direction:
+
+3) object database -> index
+~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+You read a "tree" file from the object database, and use that to
+populate (and overwrite - don't do this if your index contains any
+unsaved state that you might want to restore later!) your current
+index. Normal operation is just
read-tree <sha1 of tree>
- and your index file will now be equivalent to the tree that you
- saved earlier. However, that is only your _index_ file: your
- working directory contents have not been modified.
-
- 4) index -> working directory
-
- You update your working directory from the index by "checking
- out" files. This is not a very common operation, since normally
- you'd just keep your files updated, and rather than write to
- your working directory, you'd tell the index files about the
- changes in your working directory (i.e. "update-cache").
-
- However, if you decide to jump to a new version, or check out
- somebody else's version, or just restore a previous tree, you'd
- populate your index file with read-tree, and then you need to
- check out the result with
+and your index file will now be equivalent to the tree that you saved
+earlier. However, that is only your _index_ file: your working
+directory contents have not been modified.
+
+4) index -> working directory
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+You update your working directory from the index by "checking out"
+files. This is not a very common operation, since normally you'd just
+keep your files updated, and rather than write to your working
+directory, you'd tell the index files about the changes in your
+working directory (i.e. "update-cache").
+
+However, if you decide to jump to a new version, or check out somebody
+else's version, or just restore a previous tree, you'd populate your
+index file with read-tree, and then you need to check out the result
+with
checkout-cache filename
- or, if you want to check out all of the index, use "-a".
+or, if you want to check out all of the index, use "-a".
- NOTE! checkout-cache normally refuses to overwrite old files, so
- if you have an old version of the tree already checked out, you
- will need to use the "-f" flag (_before_ the "-a" flag or the
- filename) to _force_ the checkout.
+NOTE! checkout-cache normally refuses to overwrite old files, so if
+you have an old version of the tree already checked out, you will need
+to use the "-f" flag (_before_ the "-a" flag or the filename) to
+_force_ the checkout.
-Finally, there are a few odds and ends which are not purely moving from
-one representation to the other:
+Finally, there are a few odds and ends which are not purely moving
+from one representation to the other:
- 5) Tying it all together
+5) Tying it all together
+~~~~~~~~~~~~~~~~~~~~~~~~
- To commit a tree you have instantiated with "write-tree", you'd
- create a "commit" object that refers to that tree and the
- history behind it - most notably the "parent" commits that
- preceded it in history.
+To commit a tree you have instantiated with "write-tree", you'd create
+a "commit" object that refers to that tree and the history behind it -
+most notably the "parent" commits that preceded it in history.
- Normally a "commit" has one parent: the previous state of the
- tree before a certain change was made. However, sometimes it can
- have two or more parent commits, in which case we call it a
- "merge", due to the fact that such a commit brings together
- ("merges") two or more previous states represented by other
- commits.
+Normally a "commit" has one parent: the previous state of the tree
+before a certain change was made. However, sometimes it can have two
+or more parent commits, in which case we call it a "merge", due to the
+fact that such a commit brings together ("merges") two or more
+previous states represented by other commits.
- In other words, while a "tree" represents a particular directory
- state of a working directory, a "commit" represents that state
- in "time", and explains how we got there.
+In other words, while a "tree" represents a particular directory state
+of a working directory, a "commit" represents that state in "time",
+and explains how we got there.
- You create a commit object by giving it the tree that describes
- the state at the time of the commit, and a list of parents:
+You create a commit object by giving it the tree that describes the
+state at the time of the commit, and a list of parents:
commit-tree <tree> -p <parent> [-p <parent2> ..]
- and then giving the reason for the commit on stdin (either
- through redirection from a pipe or file, or by just typing it at
- the tty).
-
- commit-tree will return the name of the object that represents
- that commit, and you should save it away for later use.
- Normally, you'd commit a new "HEAD" state, and while git doesn't
- care where you save the note about that state, in practice we
- tend to just write the result to the file ".git/HEAD", so that
- we can always see what the last committed state was.
-
- 6) Examining the data
-
- You can examine the data represented in the object database and
- the index with various helper tools. For every object, you can
- use "cat-file" to examine details about the object:
+and then giving the reason for the commit on stdin (either through
+redirection from a pipe or file, or by just typing it at the tty).
+
+commit-tree will return the name of the object that represents that
+commit, and you should save it away for later use. Normally, you'd
+commit a new "HEAD" state, and while git doesn't care where you save
+the note about that state, in practice we tend to just write the
+result to the file ".git/HEAD", so that we can always see what the
+last committed state was.
+
+6) Examining the data
+~~~~~~~~~~~~~~~~~~~~~
+
+You can examine the data represented in the object database and the
+index with various helper tools. For every object, you can use
+"cat-file" to examine details about the object:
cat-file -t <objectname>
- shows the type of the object, and once you have the type (which
- is usually implicit in where you find the object), you can use
+shows the type of the object, and once you have the type (which is
+usually implicit in where you find the object), you can use
cat-file blob|tree|commit <objectname>
- to show its contents. NOTE! Trees have binary content, and as a
- result there is a special helper for showing that content,
- called "ls-tree", which turns the binary content into a more
- easily readable form.
-
- It's especially instructive to look at "commit" objects, since
- those tend to be small and fairly self-explanatory. In
- particular, if you follow the convention of having the top
- commit name in ".git/HEAD", you can do
+to show its contents. NOTE! Trees have binary content, and as a result
+there is a special helper for showing that content, called "ls-tree",
+which turns the binary content into a more easily readable form.
+
+It's especially instructive to look at "commit" objects, since those
+tend to be small and fairly self-explanatory. In particular, if you
+follow the convention of having the top commit name in ".git/HEAD",
+you can do
cat-file commit $(cat .git/HEAD)
- to see what the top commit was.
+to see what the top commit was.
- 7) Merging multiple trees
+7) Merging multiple trees
+~~~~~~~~~~~~~~~~~~~~~~~~~
- Git helps you do a three-way merge, which you can expand to
- n-way by repeating the merge procedure arbitrary times until you
- finally "commit" the state. The normal situation is that you'd
- only do one three-way merge (two parents), and commit it, but if
- you like to, you can do multiple parents in one go.
-
- To do a three-way merge, you need the two sets of "commit"
- objects that you want to merge, use those to find the closest
- common parent (a third "commit" object), and then use those
- commit objects to find the state of the directory ("tree"
- object) at these points.
+Git helps you do a three-way merge, which you can expand to n-way by
+repeating the merge procedure arbitrary times until you finally
+"commit" the state. The normal situation is that you'd only do one
+three-way merge (two parents), and commit it, but if you like to, you
+can do multiple parents in one go.
+
+To do a three-way merge, you need the two sets of "commit" objects
+that you want to merge, use those to find the closest common parent (a
+third "commit" object), and then use those commit objects to find the
+state of the directory ("tree" object) at these points.
- To get the "base" for the merge, you first look up the common
- parent of two commits with
+To get the "base" for the merge, you first look up the common parent
+of two commits with
merge-base <commit1> <commit2>
- which will return you the commit they are both based on. You
- should now look up the "tree" objects of those commits, which
- you can easily do with (for example)
+which will return you the commit they are both based on. You should
+now look up the "tree" objects of those commits, which you can easily
+do with (for example)
cat-file commit <commitname> | head -1
- since the tree object information is always the first line in a
- commit object.
+since the tree object information is always the first line in a commit
+object.
+
+Once you know the three trees you are going to merge (the one
+"original" tree, aka the common case, and the two "result" trees, aka
+the branches you want to merge), you do a "merge" read into the
+index. This will throw away your old index contents, so you should
+make sure that you've committed those - in fact you would normally
+always do a merge against your last commit (which should thus match
+what you have in your current index anyway).
- Once you know the three trees you are going to merge (the one
- "original" tree, aka the common case, and the two "result" trees,
- aka the branches you want to merge), you do a "merge" read into
- the index. This will throw away your old index contents, so you
- should make sure that you've committed those - in fact you would
- normally always do a merge against your last commit (which
- should thus match what you have in your current index anyway).
- To do the merge, do
+To do the merge, do
read-tree -m <origtree> <target1tree> <target2tree>
- which will do all trivial merge operations for you directly in
- the index file, and you can just write the result out with
- "write-tree".
-
- NOTE! Because the merge is done in the index file, and not in
- your working directory, your working directory will no longer
- match your index. You can use "checkout-cache -f -a" to make the
- effect of the merge be seen in your working directory.
-
- NOTE2! Sadly, many merges aren't trivial. If there are files
- that have been added.moved or removed, or if both branches have
- modified the same file, you will be left with an index tree that
- contains "merge entries" in it. Such an index tree can _NOT_ be
- written out to a tree object, and you will have to resolve any
- such merge clashes using other tools before you can write out
- the result.
+which will do all trivial merge operations for you directly in the
+index file, and you can just write the result out with "write-tree".
+
+NOTE! Because the merge is done in the index file, and not in your
+working directory, your working directory will no longer match your
+index. You can use "checkout-cache -f -a" to make the effect of the
+merge be seen in your working directory.
+
+NOTE2! Sadly, many merges aren't trivial. If there are files that have
+been added.moved or removed, or if both branches have modified the
+same file, you will be left with an index tree that contains "merge
+entries" in it. Such an index tree can _NOT_ be written out to a tree
+object, and you will have to resolve any such merge clashes using
+other tools before you can write out the result.
- [ fixme: talk about resolving merges here ]
+[ fixme: talk about resolving merges here ]
^ permalink raw reply
* [PATCH 5/5] Docs - delta object
From: David Greaves @ 2005-05-22 17:44 UTC (permalink / raw)
To: Linus Torvalds; +Cc: git
Added delta documentation
Signed-off-by: David Greaves <david@dgreaves.com>
---
commit e45371bf4e895f1ff0343c2f1e3cafbdf44dd3e4
tree e07586b3428cb3c605ddfb9c09919bbf0039a473
parent 702d4ba4f44643b77f3eadbec62b0dd0c22053fd
author David Greaves <david@dgreaves.com> Sun, 22 May 2005 18:39:11 +0100
committer David Greaves <david@dgreaves.com> Sun, 22 May 2005 18:39:11 +0100
Documentation/git-fsck-cache.txt | 5 +++-
Documentation/git-mkdelta.txt | 45 ++++++++++++++++++++++++++++++++++++++
Documentation/git.txt | 3 ++
README | 46 +++++++++++++++++++++++++++++++--------
4 files changed, 89 insertions(+), 10 deletions(-)
Index: Documentation/git-fsck-cache.txt
===================================================================
--- d25a34a8599fec7c11f9ba515b8338cad5837292/Documentation/git-fsck-cache.txt (mode:100644)
+++ e07586b3428cb3c605ddfb9c09919bbf0039a473/Documentation/git-fsck-cache.txt (mode:100644)
@@ -9,7 +9,7 @@
SYNOPSIS
--------
-'git-fsck-cache' [--tags] [--root] [[--unreachable] [--cache] <object>\*]
+'git-fsck-cache' [--tags] [--root] [--delta-depth] [[--unreachable] [--cache] <object>\*]
DESCRIPTION
-----------
@@ -34,6 +34,9 @@
Consider any object recorded in the cache also as a head node for
an unreachability trace.
+--delta-depth::
+ Report back the length of the longest delta chain found.
+
It tests SHA1 and general object sanity, and it does full tracking of
the resulting reachability and everything else. It prints out any
corruption it finds (missing or bad objects), and if you use the
Index: Documentation/git-mkdelta.txt
===================================================================
--- /dev/null (tree:d25a34a8599fec7c11f9ba515b8338cad5837292)
+++ e07586b3428cb3c605ddfb9c09919bbf0039a473/Documentation/git-mkdelta.txt (mode:100644)
@@ -0,0 +1,45 @@
+git-mkdelta(1)
+==============
+May 2005
+
+NAME
+----
+git-mkdelta - Creates a delta object
+
+
+SYNOPSIS
+--------
+'git-mkdelta' [-v] [-d N | --max-depth=N ] <reference_object> <target_object> [ <next_object> ... ]
+
+DESCRIPTION
+-----------
+Creates a delta object to replace <reference_object> by using an
+ordered list of potential objects to deltafy against earlier objects
+in the list.
+
+A cap on the depth of delta references can be provided as well,
+otherwise the default is to not have any limit. A limit of 0 will
+also undeltafy a given object.
+
+
+OPTIONS
+-------
+-v::
+ Verbose
+
+-d|--max-depth::
+ limit the number of delta references in a chain
+ If 0 then all objects are undeltafied.
+
+Author
+------
+Git is written by Linus Torvalds <torvalds@osdl.org> and the git-list <git@vger.kernel.org>.
+
+Documentation
+--------------
+Documentation by David Greaves, Junio C Hamano and the git-list <git@vger.kernel.org>.
+
+GIT
+---
+Part of the link:git.html[git] suite
+
Index: Documentation/git.txt
===================================================================
--- d25a34a8599fec7c11f9ba515b8338cad5837292/Documentation/git.txt (mode:100644)
+++ e07586b3428cb3c605ddfb9c09919bbf0039a473/Documentation/git.txt (mode:100644)
@@ -51,6 +51,9 @@
link:git-merge-base.html[git-merge-base]::
Finds as good a common ancestor as possible for a merge
+link:git-mkdelta.html[git-mkdelta]::
+ Creates a delta object
+
link:git-mktag.html[git-mktag]::
Creates a tag object
Index: README
===================================================================
--- d25a34a8599fec7c11f9ba515b8338cad5837292/README (mode:100644)
+++ e07586b3428cb3c605ddfb9c09919bbf0039a473/README (mode:100644)
@@ -32,8 +32,8 @@
All objects have a statically determined "type" aka "tag", which is
determined at object creation time, and which identifies the format of
the object (i.e. how it is used, and how it can refer to other
-objects). There are currently four different object types: "blob",
-"tree", "commit" and "tag".
+objects). There are currently five different object types: "blob",
+"tree", "commit", "tag" and "delta"
A "blob" object cannot refer to any other object, and is, like the tag
implies, a pure storage object containing some user data. It is used to
@@ -62,13 +62,17 @@
objects. It contains the identifier and type of another object, a
symbolic name (of course!) and, optionally, a signature.
-Regardless of object type, all objects are share the following
-characteristics: they are all in deflated with zlib, and have a header
-that not only specifies their tag, but also size information about the
-data in the object. It's worth noting that the SHA1 hash that is used
-to name the object is the hash of the original data (historical note:
-in the dawn of the age of git this was the sha1 of the _compressed_
-object)
+A "delta" object is used internally by the object database to minimise
+disk usage. Instead of storing the entire contents of a revision, git
+can behave in a similar manner to RCS et al and simply store a delta.
+
+Regardless of object type, all objects share the following
+characteristics: they are all deflated with zlib, and have a header
+that not only specifies their tag, but also provides size information
+about the data in the object. It's worth noting that the SHA1 hash
+that is used to name the object is the hash of the original data or
+the delta. (Historical note: in the dawn of the age of git the hash
+was the sha1 of the _compressed_ object)
As a result, the general consistency of an object can always be tested
independently of the contents or the type of the object: all objects can
@@ -215,6 +219,30 @@
A tag is created with link:git-mktag.html[git-mktag] and
it's data can be accessed by link:git-cat-file.html[git-cat-file]
+Delta Object
+~~~~~~~~~~~~
+
+The "delta" object is used internally by the object database to
+minimise storage usage by using xdeltas (byte level diffs). Deltas can
+form chains of arbitrary length as RCS does (although this is
+configureable at creation time). Most operations won't see or even be
+aware of delta objects as they are automatically 'applied' and appear
+as 'real' git objects In other words, if you write your own routines
+to look at the contents of the object database then you need to know
+about this - otherwise you don't. Actually, that's not quite true -
+one important area where deltas are likely to prove very valuable is
+in reducing bandwidth loads - so the more sophisticated network tools
+for git repositories will be aware of them too.
+
+Finally, git repositories can (and must) be deltafied in the
+background - the work to calculate the differences does not take place
+automatically at commit time.
+
+A delta can be created (or undeltafied) with
+link:git-mkdelta.html[git-mkdelta] it's raw data cannot be accessed at
+present.
+
+
The "index" aka "Current Directory Cache"
-----------------------------------------
The index is a simple binary file, which contains an efficient
^ permalink raw reply
* [PATCH 4/5] Docs - tag object, git- prefix and s/changeset/commit/g
From: David Greaves @ 2005-05-22 17:44 UTC (permalink / raw)
To: Linus Torvalds; +Cc: git
Add docs for tag type
Rename commands to have git- prefix
Rename changeset to commit throughout
Signed-off-by: David Greaves <david@dgreaves.com>
---
commit 702d4ba4f44643b77f3eadbec62b0dd0c22053fd
tree d25a34a8599fec7c11f9ba515b8338cad5837292
parent e6d7c5341942fdd07d966efe36fde653167e84f0
author David Greaves <david@dgreaves.com> Sun, 22 May 2005 18:36:10 +0100
committer David Greaves <david@dgreaves.com> Sun, 22 May 2005 18:36:10 +0100
README | 163 ++++++++++++++++++++++++++++++++++++-----------------------------
1 files changed, 91 insertions(+), 72 deletions(-)
Index: README
===================================================================
--- 03ae742170ebaef9040fa8234e1d6752bad140ab/README (mode:100644)
+++ d25a34a8599fec7c11f9ba515b8338cad5837292/README (mode:100644)
@@ -31,9 +31,9 @@
All objects have a statically determined "type" aka "tag", which is
determined at object creation time, and which identifies the format of
-the object (i.e. how it is used, and how it can refer to other objects).
-There are currently three different object types: "blob", "tree" and
-"commit".
+the object (i.e. how it is used, and how it can refer to other
+objects). There are currently four different object types: "blob",
+"tree", "commit" and "tag".
A "blob" object cannot refer to any other object, and is, like the tag
implies, a pure storage object containing some user data. It is used to
@@ -44,7 +44,7 @@
directory structure. In addition, a tree object can refer to other tree
objects, thus creating a directory hierarchy.
-Finally, a "commit" object ties such directory hierarchies together into
+A "commit" object ties such directory hierarchies together into
a DAG of revisions - each "commit" is associated with exactly one tree
(the directory hierarchy at the time of the commit). In addition, a
"commit" refers to one or more "parent" commit objects that describe the
@@ -79,9 +79,9 @@
The structured objects can further have their structure and
connectivity to other objects verified. This is generally done with
-the "fsck-cache" program, which generates a full dependency graph of
-all objects, and verifies their internal consistency (in addition to
-just verifying their superficial consistency through the hash).
+the "git-fsck-cache" program, which generates a full dependency graph
+of all objects, and verifies their internal consistency (in addition
+to just verifying their superficial consistency through the hash).
The object types in some more detail:
@@ -102,6 +102,9 @@
directory tree, and renaming a file does not change the object that
file is associated with in any way.
+A blob is created with link:git-write-blob.html[git-write-blob] and
+it's data can be accessed by link:git-cat-file.html[git-cat-file]
+
Tree Object
~~~~~~~~~~~
The next hierarchical object type is the "tree" object. A tree object
@@ -138,65 +141,79 @@
noticing that the blob stayed the same. However, renames with data
changes need a smarter "diff" implementation.
+A tree is created with link:git-write-tree.html[git-write-tree] and
+it's data can be accessed by link:git-ls-tree.html[git-ls-tree]
-Changeset Object
-~~~~~~~~~~~~~~~~
-The "changeset" object is an object that introduces the notion of
+Commit Object
+~~~~~~~~~~~~~
+The "commit" object is an object that introduces the notion of
history into the picture. In contrast to the other objects, it
doesn't just describe the physical state of a tree, it describes how
we got there, and why.
-A "changeset" is defined by the tree-object that it results in, the
-parent changesets (zero, one or more) that led up to that point, and a
-comment on what happened. Again, a changeset is not trusted per se:
+A "commit" is defined by the tree-object that it results in, the
+parent commits (zero, one or more) that led up to that point, and a
+comment on what happened. Again, a commit is not trusted per se:
the contents are well-defined and "safe" due to the cryptographically
strong signatures at all levels, but there is no reason to believe
that the tree is "good" or that the merge information makes sense.
The parents do not have to actually have any relationship with the
result, for example.
-Note on changesets: unlike real SCM's, changesets do not contain
-rename information or file mode change information. All of that is
+Note on commits: unlike real SCM's, commits do not contain
+rename information or file mode chane information. All of that is
implicit in the trees involved (the result tree, and the result trees
of the parents), and describing that makes no sense in this idiotic
file manager.
-Trust Object
-~~~~~~~~~~~~
-The notion of "trust" is really outside the scope of "git", but it's
-worth noting a few things. First off, since everything is hashed with
-SHA1, you _can_ trust that an object is intact and has not been messed
-with by external sources. So the name of an object uniquely
-identifies a known state - just not a state that you may want to
-trust.
+A commit is created with link:git-commit-tree.html[git-commit-tree] and
+it's data can be accessed by link:git-cat-file.html[git-cat-file]
+
+Trust
+~~~~~
+An aside on the notion of "trust". Trust is really outside the scope
+of "git", but it's worth noting a few things. First off, since
+everything is hashed with SHA1, you _can_ trust that an object is
+intact and has not been messed with by external sources. So the name
+of an object uniquely identifies a known state - just not a state that
+you may want to trust.
-Furthermore, since the SHA1 signature of a changeset refers to the
+Furthermore, since the SHA1 signature of a commit refers to the
SHA1 signatures of the tree it is associated with and the signatures
-of the parent, a single named changeset specifies uniquely a whole set
+of the parent, a single named commit specifies uniquely a whole set
of history, with full contents. You can't later fake any step of the
-way once you have the name of a changeset.
+way once you have the name of a commit.
So to introduce some real trust in the system, the only thing you need
to do is to digitally sign just _one_ special note, which includes the
-name of a top-level changeset. Your digital signature shows others
-that you trust that changeset, and the immutability of the history of
-changesets tells others that they can trust the whole history.
+name of a top-level commit. Your digital signature shows others
+that you trust that commit, and the immutability of the history of
+commits tells others that they can trust the whole history.
In other words, you can easily validate a whole archive by just
sending out a single email that tells the people the name (SHA1 hash)
-of the top changeset, and digitally sign that email using something
+of the top commit, and digitally sign that email using something
like GPG/PGP.
-In particular, you can also have a separate archive of "trust points"
-or tags, which document your (and other peoples) trust. You may, of
-course, archive these "certificates of trust" using "git" itself, but
-it's not something "git" does for you.
-
-Another way of saying the last point: "git" itself only handles
-content integrity, the trust has to come from outside.
-
+To assist in this, git also provides the tag object...
+Tag Object
+~~~~~~~~~~
+Git provides the "tag" object to simplify creating, managing and
+exchanging symbolic and signed tokens. The "tag" object at its
+simplest simply symbolically identifies another object by containing
+the sha1, type and symbolic name.
+
+However it can optionally contain additional signature information
+(which git doesn't care about as long as there's less than 8k of
+it). This can then be verified externally to git.
+
+Note that despite the tag features, "git" itself only handles content
+integrity; the trust framework (and signature provision and
+verification) has to come from outside.
+A tag is created with link:git-mktag.html[git-mktag] and
+it's data can be accessed by link:git-cat-file.html[git-cat-file]
The "index" aka "Current Directory Cache"
-----------------------------------------
@@ -263,11 +280,11 @@
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
You update the index with information from the working directory with
-the "update-cache" command. You generally update the index
-information by just specifying the filename you want to update, like
-so:
+the link:git-update-cache.html[git-update-cache] command. You
+generally update the index information by just specifying the filename
+you want to update, like so:
- update-cache filename
+ git-update-cache filename
but to avoid common mistakes with filename globbing etc, the command
will not normally add totally new entries or remove old entries,
@@ -284,7 +301,7 @@
considering a removed file to be a valid thing, and if the file really
does not exist any more, it will update the index accordingly.
-As a special case, you can also do "update-cache --refresh", which
+As a special case, you can also do "git-update-cache --refresh", which
will refresh the "stat" information of each index to match the current
stat information. It will _not_ update the object status itself, and
it will only update the fields that are used to quickly test whether
@@ -295,7 +312,7 @@
You write your current index file to a "tree" object with the program
- write-tree
+ git-write-tree
that doesn't come with any options - it will just write out the
current index into the set of tree objects that describe that state,
@@ -311,7 +328,7 @@
unsaved state that you might want to restore later!) your current
index. Normal operation is just
- read-tree <sha1 of tree>
+ git-read-tree <sha1 of tree>
and your index file will now be equivalent to the tree that you saved
earlier. However, that is only your _index_ file: your working
@@ -324,20 +341,19 @@
files. This is not a very common operation, since normally you'd just
keep your files updated, and rather than write to your working
directory, you'd tell the index files about the changes in your
-working directory (i.e. "update-cache").
+working directory (i.e. "git-update-cache").
However, if you decide to jump to a new version, or check out somebody
else's version, or just restore a previous tree, you'd populate your
index file with read-tree, and then you need to check out the result
with
-
- checkout-cache filename
+ git-checkout-cache filename
or, if you want to check out all of the index, use "-a".
-NOTE! checkout-cache normally refuses to overwrite old files, so if
-you have an old version of the tree already checked out, you will need
-to use the "-f" flag (_before_ the "-a" flag or the filename) to
+NOTE! git-checkout-cache normally refuses to overwrite old files, so
+if you have an old version of the tree already checked out, you will
+need to use the "-f" flag (_before_ the "-a" flag or the filename) to
_force_ the checkout.
@@ -346,10 +362,10 @@
5) Tying it all together
~~~~~~~~~~~~~~~~~~~~~~~~
-
-To commit a tree you have instantiated with "write-tree", you'd create
-a "commit" object that refers to that tree and the history behind it -
-most notably the "parent" commits that preceded it in history.
+To commit a tree you have instantiated with "git-write-tree", you'd
+create a "commit" object that refers to that tree and the history
+behind it - most notably the "parent" commits that preceded it in
+history.
Normally a "commit" has one parent: the previous state of the tree
before a certain change was made. However, sometimes it can have two
@@ -364,15 +380,15 @@
You create a commit object by giving it the tree that describes the
state at the time of the commit, and a list of parents:
- commit-tree <tree> -p <parent> [-p <parent2> ..]
+ git-commit-tree <tree> -p <parent> [-p <parent2> ..]
and then giving the reason for the commit on stdin (either through
redirection from a pipe or file, or by just typing it at the tty).
-commit-tree will return the name of the object that represents that
-commit, and you should save it away for later use. Normally, you'd
-commit a new "HEAD" state, and while git doesn't care where you save
-the note about that state, in practice we tend to just write the
+git-commit-tree will return the name of the object that represents
+that commit, and you should save it away for later use. Normally,
+you'd commit a new "HEAD" state, and while git doesn't care where you
+save the note about that state, in practice we tend to just write the
result to the file ".git/HEAD", so that we can always see what the
last committed state was.
@@ -381,25 +397,27 @@
You can examine the data represented in the object database and the
index with various helper tools. For every object, you can use
-"cat-file" to examine details about the object:
+link:git-cat-file.html[git-cat-file] to examine details about the
+object:
- cat-file -t <objectname>
+ git-cat-file -t <objectname>
shows the type of the object, and once you have the type (which is
usually implicit in where you find the object), you can use
- cat-file blob|tree|commit <objectname>
+ git-cat-file blob|tree|commit <objectname>
to show its contents. NOTE! Trees have binary content, and as a result
-there is a special helper for showing that content, called "ls-tree",
-which turns the binary content into a more easily readable form.
+there is a special helper for showing that content, called
+"git-ls-tree", which turns the binary content into a more easily
+readable form.
It's especially instructive to look at "commit" objects, since those
tend to be small and fairly self-explanatory. In particular, if you
follow the convention of having the top commit name in ".git/HEAD",
you can do
- cat-file commit $(cat .git/HEAD)
+ git-cat-file commit $(cat .git/HEAD)
to see what the top commit was.
@@ -420,13 +438,13 @@
To get the "base" for the merge, you first look up the common parent
of two commits with
- merge-base <commit1> <commit2>
+ git-merge-base <commit1> <commit2>
which will return you the commit they are both based on. You should
now look up the "tree" objects of those commits, which you can easily
do with (for example)
- cat-file commit <commitname> | head -1
+ git-cat-file commit <commitname> | head -1
since the tree object information is always the first line in a commit
object.
@@ -441,15 +459,16 @@
To do the merge, do
- read-tree -m <origtree> <target1tree> <target2tree>
+ git-read-tree -m <origtree> <target1tree> <target2tree>
which will do all trivial merge operations for you directly in the
-index file, and you can just write the result out with "write-tree".
+index file, and you can just write the result out with
+"git-write-tree".
NOTE! Because the merge is done in the index file, and not in your
working directory, your working directory will no longer match your
-index. You can use "checkout-cache -f -a" to make the effect of the
-merge be seen in your working directory.
+index. You can use "git-checkout-cache -f -a" to make the effect of
+the merge be seen in your working directory.
NOTE2! Sadly, many merges aren't trivial. If there are files that have
been added.moved or removed, or if both branches have modified the
^ permalink raw reply
* Re: git-diff-files -z output
From: Junio C Hamano @ 2005-05-22 17:49 UTC (permalink / raw)
To: GIT
In-Reply-To: <20050522173243.GA18500@cip.informatik.uni-erlangen.de>
>>>>> "TG" == Thomas Glanzmann <sithglan@stud.uni-erlangen.de> writes:
I do not do Porcelain, but...
TG> this is better (it strips the colon from the first mode):
I think you are also stripping the colon at the beginning of the
filename if I am not mistaken. Also posting only this part is
not very useful because I cannot tell what parameter this sub is
being fed. I am presuming that you are either feeding a single
line from DIFF_FORMAT_HUMAN format output, or three lines
(unless dealing with 'U' entry in which case you have to do only
a single line) from DIFF_FORMAT_MACHINE format output. When in
doubt, seeing what diff-helper does would help.
^ permalink raw reply
* [PATCH] Makefile: Solaris fix: call $(MAKE) instead of make for subdirectories
From: Thomas Glanzmann @ 2005-05-22 18:10 UTC (permalink / raw)
To: GIT; +Cc: Linus Torvalds
--- a/Makefile
+++ b/Makefile
@@ -134,11 +134,11 @@
diffcore-pickaxe.o : $(LIB_H) diffcore.h
test: all
- make -C t/ all
+ $(MAKE) -C t/ all
clean:
rm -f *.o mozilla-sha1/*.o ppc/*.o $(PROG) $(LIB_FILE)
- make -C Documentation/ clean
+ $(MAKE) -C Documentation/ clean
backup: clean
cd .. ; tar czvf dircache.tar.gz dir-cache
^ permalink raw reply
* [PATCH] Makefile: Solaris fix: call $(MAKE) instead of make for subdirectories
From: Thomas Glanzmann @ 2005-05-22 18:27 UTC (permalink / raw)
To: GIT; +Cc: Linus Torvalds
[PATCH] Makefile: Solaris fix: call $(MAKE) instead of make for subdirectories
Signed-off-by: Thomas Glanzmann <sithglan@stud.uni-erlangen.de>
--- a/Makefile
+++ b/Makefile
@@ -134,11 +134,11 @@
diffcore-pickaxe.o : $(LIB_H) diffcore.h
test: all
- make -C t/ all
+ $(MAKE) -C t/ all
clean:
rm -f *.o mozilla-sha1/*.o ppc/*.o $(PROG) $(LIB_FILE)
- make -C Documentation/ clean
+ $(MAKE) -C Documentation/ clean
backup: clean
cd .. ; tar czvf dircache.tar.gz dir-cache
^ permalink raw reply
* Re: How stop tracking a file?
From: jeff millar @ 2005-05-22 18:29 UTC (permalink / raw)
To: Junio C Hamano; +Cc: git
In-Reply-To: <7vacmnfapv.fsf@assigned-by-dhcp.cox.net>
Junio C Hamano wrote:
> jm> cg-rm does two things
> jm> rm -f "$@"
> jm> git-update-cache --remove -- "$@"
>
>I do not do Porcelain, but something along the following lines
>should work:
>
> for path
> do
> git-update-cache --force-remove "$path"
> done
>
Seems a bit more difficult...
[jeff@Desk gsmc-1.1]$ git-update-cache --force-remove main.o
[jeff@Desk gsmc-1.1]$ cg-diff
Index: main.o
===================================================================
Binary files a5d1a55e0818ab11b71fee01bcd9053c4ecc65a6/main.o
(mode:100644) and /dev/null (tree:uncommitted) differ
[jeff@Desk gsmc-1.1]$ cg-commit
Refusing to make an empty commit - the tree was not modified
since the previous commit. If you really want to make the
commit, do: commit-tree `tree-id` -p `parent-id`
A picky porcelain problem?
^ permalink raw reply
* Re: [PATCH] The diff-raw format updates.
From: Linus Torvalds @ 2005-05-22 18:35 UTC (permalink / raw)
To: Junio C Hamano; +Cc: Git Mailing List
In-Reply-To: <7vvf5cc779.fsf_-_@assigned-by-dhcp.cox.net>
On Sat, 21 May 2005, Junio C Hamano wrote:
>
> Update the diff-raw format as Linus and I discussed, except that
> it does not use sequence of underscore '_' letters to express
> nonexistence. All '0' mode is used for that purpose instead.
>
> The new diff-raw format can express rename/copy
Having looked at this, I have to disagree.
It can _almost_ express rename/copy, but you can't tell the two apart. In
both cases you have two different modes, two different SHA1's, and two
different filenames.
Also, while you can trivially tell whether a file is deleted or new (look
at the 000000... SHA1), it is pretty illogical to give a "filename" for
the non-existent side, as in the line
:000000 100644 0000000000000000000000000000000000000000 25ab9eda939ad92bb746c2419d083b1e52117a56 diffcore-pathspec.c diffcore-pathspec.c
Finally, having now looked at it some more, I've come to realize that it's
actually pretty hard to tell the different cases apart visually (is it a
rename or just a change), because the full pathnames can be so long that
it's not at all immediately obvious.
Anyway, I think we can trivially tweak the filename output to handle all
these problems.
I'd suggest:
- we'd continue to have two "filename" fields, with the existing
termination, but they aren't pure filenames any more, they are just
tab-separated (or zero-separated) "source" and "destination" fields.
- if no filename exists (ie the source side of a new file, or the
destination side of a deleted file), output "/dev/null". In other
words, a nonexistent file is _always_ associated with mode 000000, SHA1
00000.. and a "name field" of "/dev/null".
- ONLY IF HUMAN-READABLE: if the destination filename is the same as the
source, drop it (and the tab) completely. This just makes things so
much more readable, and it's still parseable, because the
line-termination is different from the inter-file termination.
NOTE! In the zero-terminated format, you can't do this, since you
wouldn't know where the line ended. You might drop the name completely,
but you'd have to have two NUL bytes. I'd argue that since this format
isn't human-readable anyway, you might just want to keep the filename
the same.
- in all other cases: if the file is new, prepend a "+", if the file is
old, prepend a "*", and if the file goes away, prepend a "-". In other
words, the actual pathname (if it exists) always starts at the second
character and is always prepended by _something_ (ie there is no
ambiguoity with pathnames that start in -/+/*).
The above hass a few nice properties, notably you can parse the first
character of the name field, and you always know what's up:
- '/' is always "/dev/null" aka "no file"
- '+' is always "added file"
- '-' is always "removed file"
- '*' is always "existing file"
- '\0' (ie empty) is always "same filename as source"
So for the above "create" event, it would look like
:000000 100644 0000.. 25ab.. /dev/null +diffcore-pathspec.c
which is visually quite obviously a create. Similarly, deletes are also
visually pretty obvious:
:100644 000000 25ab.. 0000.. -diffcore-pathspec.c /dev/null
while a "copy" would be (git-pull-script stays around, so it gets a "*"):
:100755 100755 bd89.. 17f2.. *git-pull-script +git-fetch-script
and a "rename" would be:
:100644 100644 51bb.. 51bb.. -diff-tree-helper.c +diff-helper.c
(ie the difference is in the source file having a "-" in front of it
instead of a "*").
A regular modification would be
:100644 100644 bcd3.. c05b.. *Documentation/git-fsck-cache.txt
which is also very visually distinct from the other cases.
What do you think?
Linus
^ permalink raw reply
* Re: [PATCH] The diff-raw format updates.
From: Thomas Glanzmann @ 2005-05-22 18:42 UTC (permalink / raw)
To: Git Mailing List
In-Reply-To: <Pine.LNX.4.58.0505221108000.2307@ppc970.osdl.org>
Hello,
> - in all other cases: if the file is new, prepend a "+", if the file is
> old, prepend a "*", and if the file goes away, prepend a "-". In other
> words, the actual pathname (if it exists) always starts at the second
> character and is always prepended by _something_ (ie there is no
> ambiguoity with pathnames that start in -/+/*).
I guess that this is only on human readable but not on the machine
format, right?
> What do you think?
Sounds good. Especially that we keep the fixed fields for the machine
parsable stuff.
Thomas
^ permalink raw reply
* Re: [PATCH] The diff-raw format updates.
From: Niklas Hoglund @ 2005-05-22 18:36 UTC (permalink / raw)
To: git
In-Reply-To: <Pine.LNX.4.58.0505221108000.2307@ppc970.osdl.org>
On Sun, May 22, 2005 at 11:35:34AM -0700, Linus Torvalds wrote:
> :000000 100644 0000000000000000000000000000000000000000 25ab9eda939ad92bb746c2419d083b1e52117a56 diffcore-pathspec.c diffcore-pathspec.c
Don't you think it would be easier to read if the SHA1 field was, say, a
dash and 19 spaces, instead of an obviously bogus SHA1?
This feels a bit like using 0 where NULL would be more appropriate...
Best regards,
Niklas
^ permalink raw reply
* Re: [PATCH] The diff-raw format updates.
From: Linus Torvalds @ 2005-05-22 19:05 UTC (permalink / raw)
To: Thomas Glanzmann; +Cc: Git Mailing List
In-Reply-To: <20050522184237.GG18500@cip.informatik.uni-erlangen.de>
On Sun, 22 May 2005, Thomas Glanzmann wrote:
>
> > - in all other cases: if the file is new, prepend a "+", if the file is
> > old, prepend a "*", and if the file goes away, prepend a "-". In other
> > words, the actual pathname (if it exists) always starts at the second
> > character and is always prepended by _something_ (ie there is no
> > ambiguoity with pathnames that start in -/+/*).
>
> I guess that this is only on human readable but not on the machine
> format, right?
The machine readable format has the same issue: it needs to be able to
distinguish between a "copy" (where the source remains) and a "rename"
(where the source is removed). So you still need the "*/-" thing, and then
you're better off doing "+" and "/" too in the machine-readable format, to
make the differences be as small as possible _and_ to avoid confusion if a
pathname starts with '*' or '-'.
Linus
^ permalink raw reply
* Re: [PATCH] The diff-raw format updates.
From: Thomas Glanzmann @ 2005-05-22 19:05 UTC (permalink / raw)
To: Git Mailing List
In-Reply-To: <Pine.LNX.4.58.0505221203410.2307@ppc970.osdl.org>
Hello,
> The machine readable format has the same issue: it needs to be able to
> distinguish between a "copy" (where the source remains) and a "rename"
> (where the source is removed). So you still need the "*/-" thing, and then
> you're better off doing "+" and "/" too in the machine-readable format, to
> make the differences be as small as possible _and_ to avoid confusion if a
> pathname starts with '*' or '-'.
thanks, I see the point now.
Thomas
^ permalink raw reply
* Re: running git-update-cache --refresh on different machines on a NFS share always ends up in a lot of io/cpu/time waste
From: Linus Torvalds @ 2005-05-22 19:09 UTC (permalink / raw)
To: Thomas Glanzmann; +Cc: GIT
In-Reply-To: <20050522122849.GJ15178@cip.informatik.uni-erlangen.de>
On Sun, 22 May 2005, Thomas Glanzmann wrote:
>
> I wonder why 'git-update-cache --refresh' running in the same directory
> shared via NFS ends up in reindexing the whole files when running on
> different machines on a NFS share.
It does?
Can you check what
ls -li --time=atime
shows on the different clients? Also, try "ctime".
> Is there a reason for this or can it easily be fixes. I also wonder if
> the locking which is used to lock the cache is 'nfs safe'.
It _should_ be safe. It does the old lockfile thing, with a "link()" that
should guarantee atomicity. No fcntl locking or similar that can have
problems with networked filesystems and different UNIXes.
Linus
^ permalink raw reply
* Re: [PATCH] The diff-raw format updates.
From: Junio C Hamano @ 2005-05-22 19:13 UTC (permalink / raw)
To: Linus Torvalds; +Cc: Git Mailing List
In-Reply-To: <Pine.LNX.4.58.0505221108000.2307@ppc970.osdl.org>
I have to have some time to ruminate about this, but I am
leaving for the day and won't be back till late afternoon (PDT).
My feeling, knee-jerk reaction, to what you are proposing is
that you are trying to go half-way back to the earlier format
that had addremove/change distinction.
I have to disagree that having path for the non-existent side is
_illogical_. I ask "what is different between tree A and tree
B", and the diff-raw answers "there was no path0 in tree A but
path0 exists in tree B; there was path1 in tree A but now path2
is there instead in tree B". To me, the answer would be more
illogical if the diff-raw said "there was no /dev/null in tree
A, and instead path0 exists in tree B.", which is what your
suggestion makes it say if I am reading you right. Also, again
this is my knee-jerk reaction without thinking things through,
you are hiding (not losing, because having a rename/copy entry
that removes a path _is_ illogical) information by not saying
what no longer exists by replacing the right hand side with
/dev/null and having the reader to infer what is removed. I
want the reader to be able to say "I can look at only right hand
side to see what is in the right hand side tree". With
/dev/null munging, it becomes necessary to sometimes look at the
other side.
^ permalink raw reply
* Re: [PATCH] The diff-raw format updates.
From: Junio C Hamano @ 2005-05-22 19:15 UTC (permalink / raw)
To: Niklas Hoglund; +Cc: git
In-Reply-To: <20050522183645.GA1866@localhost.localdomain>
>>>>> "NH" == Niklas Hoglund <nhoglund@gmail.com> writes:
NH> On Sun, May 22, 2005 at 11:35:34AM -0700, Linus Torvalds wrote:
>> :000000 100644 0000000000000000000000000000000000000000 25ab9eda939ad92bb746c2419d083b1e52117a56 diffcore-pathspec.c diffcore-pathspec.c
NH> Don't you think it would be easier to read if the SHA1 field was, say, a
NH> dash and 19 spaces, instead of an obviously bogus SHA1?
My understanding of the purpose of the diff-raw format is
primarily about machine readablility; 0{40} was far easier to
code cleanly---please see why in diff-helper.c.
^ permalink raw reply
* Re: [PATCH] The diff-raw format updates.
From: Junio C Hamano @ 2005-05-22 19:20 UTC (permalink / raw)
To: Linus Torvalds; +Cc: Thomas Glanzmann, Git Mailing List
In-Reply-To: <Pine.LNX.4.58.0505221203410.2307@ppc970.osdl.org>
>>>>> "LT" == Linus Torvalds <torvalds@osdl.org> writes:
LT> The machine readable format has the same issue: it needs to be able to
LT> distinguish between a "copy" (where the source remains) and a "rename"
LT> (where the source is removed).
Why? If the same path appears later as the left hand side then
it is a copy otherwise it is a rename. Please see what
diffcore-rename does when assigning to dp->xfrm_msg.
What I've been trying hard so far was to keep diff_filepair not
to be too specific to rename/copy. What I do not like about
what is being proposed is that it would force me to introduce
this "is this a copy or a rename" flag to that structure.
^ permalink raw reply
* Re: running git-update-cache --refresh on different machines on a NFS share always ends up in a lot of io/cpu/time waste
From: Thomas Glanzmann @ 2005-05-22 19:27 UTC (permalink / raw)
To: Linus Torvalds; +Cc: GIT
In-Reply-To: <Pine.LNX.4.58.0505221205580.2307@ppc970.osdl.org>
Hello,
> It does?
Not for me at the moment:
faui03 -> NFS Server (Solaris 2.9)
faui04a -> NFS Client (Solaris 2.9)
faui01 -> NFS Client (Linux 2.4.30)
(faui03) [~/work/blastwave] date; time git-update-cache --refresh
Sun May 22 21:09:33 CEST 2005
real 1m6.362s
user 0m12.550s
sys 0m9.200s
(faui04a) [~/work/blastwave] date; time git-update-cache --refresh
Sun May 22 21:10:56 CEST 2005
real 1m20.097s
user 0m12.270s
sys 0m8.930s
(faui01) [~/work/blastwave] date; time git-update-cache --refresh;
Sun May 22 21:17:22 CEST 2005
real 0m30.617s
user 0m2.340s
sys 0m7.970s
> Can you check what
> ls -li --time=atime
> shows on the different clients? Also, try "ctime".
atime is different of course different.
(faui01) [~/work/blastwave] (ls -Rli --time=atime; ls -lRi --time=ctime) > ~/faui01
(faui03) [~/work/blastwave] (ls -Rli --time=atime; ls -lRi --time=ctime) > ~/faui03
(faui04a) [~/work/blastwave] (ls -Rli --time=atime; ls -lRi --time=ctime) > ~/faui04a
(faui01) [~/work/blastwave] md5sum ~/faui0{1,3,4a}
a2c2cdb38537a54fb74613d1cf6537f0 /home/cip/adm/sithglan/faui01
67aee985bfb7514900a0a1d2c629cec9 /home/cip/adm/sithglan/faui03
67aee985bfb7514900a0a1d2c629cec9 /home/cip/adm/sithglan/faui04a
(faui01) [~/work/blastwave] diff -b -u ~/faui01 ~/faui03
--- /home/cip/adm/sithglan/faui01 2005-05-22 21:24:02.000000000 +0200
+++ /home/cip/adm/sithglan/faui03 2005-05-22 21:23:54.000000000 +0200
@@ -1,11 +1,11 @@
.:
total 15
5483033 -rw-r--r-- 1 sithglan icipguru 391 May 22 21:14 Makefile
-1842682 drwxr-xr-x 2 sithglan icipguru 512 May 22 21:23 packages/
-5541351 drwxr-xr-x 2 sithglan icipguru 512 May 22 21:23 public_html/
-5541339 drwxr-xr-x 2 sithglan icipguru 512 May 22 21:23 scripts/
-5482949 drwxr-xr-x 2 sithglan icipguru 8704 May 22 21:23 sources/
-5482985 drwxr-xr-x 2 sithglan icipguru 2048 May 22 21:23 specs/
+1842682 drwxr-xr-x 2 sithglan icipguru 512 May 22 21:19 packages/
+5541351 drwxr-xr-x 2 sithglan icipguru 512 May 22 21:19 public_html/
+5541339 drwxr-xr-x 2 sithglan icipguru 512 May 22 21:19 scripts/
+5482949 drwxr-xr-x 2 sithglan icipguru 8704 May 22 21:19 sources/
+5482985 drwxr-xr-x 2 sithglan icipguru 2048 May 22 21:19 specs/
./packages:
total 0
If you need the files:
http://wwwcip.informatik.uni-erlangen.de/~sithglan/faui01 (58k)
http://wwwcip.informatik.uni-erlangen.de/~sithglan/faui03 (61k)
http://wwwcip.informatik.uni-erlangen.de/~sithglan/faui04a (61k)
> It _should_ be safe. It does the old lockfile thing, with a "link()" that
> should guarantee atomicity. No fcntl locking or similar that can have
> problems with networked filesystems and different UNIXes.
Is link() NFS safe? I thought only mkdir() for nfs?
Thomas
^ permalink raw reply
* Re: [PATCH] The diff-raw format updates.
From: Junio C Hamano @ 2005-05-22 19:35 UTC (permalink / raw)
To: Linus Torvalds; +Cc: Thomas Glanzmann, Git Mailing List
In-Reply-To: <7v64xbdq4y.fsf@assigned-by-dhcp.cox.net>
>>>>> "JCH" == Junio C Hamano <junkio@cox.net> writes:
>>>>> "LT" == Linus Torvalds <torvalds@osdl.org> writes:
LT> The machine readable format has the same issue: it needs to be able to
LT> distinguish between a "copy" (where the source remains) and a "rename"
LT> (where the source is removed).
JCH> Why? If the same path appears later as the left hand side then
JCH> it is a copy otherwise it is a rename. Please see what
JCH> diffcore-rename does when assigning to dp->xfrm_msg.
JCH> What I've been trying hard so far was to keep diff_filepair not
JCH> to be too specific to rename/copy. What I do not like about
JCH> what is being proposed is that it would force me to introduce
JCH> this "is this a copy or a rename" flag to that structure.
Linus, another way of saying the above is this.
Think about the example in test that munge COPYING file. What
was recorded in the two trees as the result of
sed $munge_1 <COPYING >COPYING.1
sed $munge_2 <COPYING COPYING.2
rm COPYING
will be expressed as copy-edit of COPYING.1 and rename-edit of
COPYING.2 (both from COPYING). But that is just _one_
interpretation diffcore-rename _arbitrarily_ makes.
It could have been copy-edit of COPYING.2 and rename-edit of
COPYING.1 (both from COPYING). If you make the change you are
proposing to diff-raw format, reordering diff-raw entries stops
making sense, while the current format allows us to.
It is similar to your argument of not _recording_ renames on
commit but _tracking_ it upon inspection. I deliberatly chose
not to record rename/copy distinction in diff-raw --- it is to
be inferred from which entry touches the src _last_. Everything
but the last one to touch the same path is copy, and the last
one is rename.
^ permalink raw reply
* Re: [PATCH] The diff-raw format updates.
From: Linus Torvalds @ 2005-05-22 20:24 UTC (permalink / raw)
To: Junio C Hamano; +Cc: Thomas Glanzmann, Git Mailing List
In-Reply-To: <7vy8a7cavf.fsf@assigned-by-dhcp.cox.net>
On Sun, 22 May 2005, Junio C Hamano wrote:
>
> I deliberatly chose not to record rename/copy distinction in diff-raw
> --- it is to be inferred from which entry touches the src _last_.
> Everything but the last one to touch the same path is copy, and the last
> one is rename.
My counter-example: there is no rename at all, just a copy.
The current raw-diff output simply _cannot_ distinguish this from the case
where there is a rename, as far as I can tell.
Basically, imagine doing something like this:
mkdir test-copy
cd test-copy
git-init-db
cp ~/v2.6/linux/kernel/sched.c .
git-update-cache --add sched.c
echo duh | git-commit-tree $(git-write-tree) > .git/HEAD
sed 's/sched\.c/other\.c/g' < sched.c > other.c
git-update-cache --add other.c
echo duh2 | git-commit-tree $(git-write-tree) -p HEAD
and dammit, if "other.c" doesn't show up as a copy (with small
differences) of sched.c, then the whole diff algorithm is broken and
clearly isn't doing copy-diffs right at all (right now it doesn't do it
since diff-tree doesn't even do the "check copies against old", but that's
a different issue).
In other words, how do you propose to _describe_ that copy?
The whole point to the "raw diff" format is that you should be able to
get the same output with
git-diff-tree -C HEAD | git-diff-helper
git-diff-tree -C -p HEAD
and right now I don't see how you can do that.. And if you can't do that,
then the raw diff format is pointless. It's not "raw diff" at all, it's a
"less capable diff" format.
THAT is why I think the raw diff output is broken right now. All the rest
was about just trying to also make it a bit more readable while at it.
Try it. I added in the "&& detect_rename < 2" thing to diff-tree.c, and I
get:
git-whatchanged -C --root | git-diff-helper | less -S
resulting in:
diff-tree eb773598aa29bb642d6016a0d5961c80628ce490 (from 8c63fcad1f27ceed6825110aa806349dad99d89f)
Author: Linus Torvalds <torvalds@ppc970.osdl.org>
Date: Sun May 22 13:17:40 2005 -0700
duh2
diff --git a/sched.c b/other.c
--- a/sched.c
+++ b/other.c
@@ -1,5 +1,5 @@
/*
- * kernel/sched.c
+ * kernel/other.c
*
* Kernel scheduler and related syscalls
*
ie it does NOT say it is a copy, because it _cannot_ say it is a copy. It
just doesn't know. A copy and a rename look exactly the same in the raw
diff output, and that's a BUG.
Linus
^ permalink raw reply
* Re: running git-update-cache --refresh on different machines on a NFS share always ends up in a lot of io/cpu/time waste
From: Linus Torvalds @ 2005-05-22 20:43 UTC (permalink / raw)
To: Thomas Glanzmann; +Cc: GIT
In-Reply-To: <20050522192734.GB23388@cip.informatik.uni-erlangen.de>
On Sun, 22 May 2005, Thomas Glanzmann wrote:
>
> Is link() NFS safe? I thought only mkdir() for nfs?
Sorry, I meant "rename", not "link", and yes, it should be NFS-safe. It's
how all the mailers do things too, afaik.
As to your update-cache problem, it seems to be just due to NFS stat
caching. You generally should _not_ work on two machines at the same time,
but it probably does the right thing in the end.
In general, I would suggest using separate GIT repositories over sharing
them over NFS. As far as I'm concerned, I think NFS should work in the
sense that you can work from different clients at _different_times_, and
I'm certainly not going to guarantee that two different clients that work
at the same time against the same repository will get sane results.
For example, if you do a "git-checkout-cache -f -a" at the same time, I
won't guarantee that things won't race on the working files. Don't do it.
Linus
^ permalink raw reply
* [PATCH] Don't include devicenumber into INODE_CHANGED test [WAS: Re: running git-update-cache --refresh on different machines on a NFS share always ends up in a lot of io/cpu/time waste]
From: Thomas Glanzmann @ 2005-05-22 21:23 UTC (permalink / raw)
To: GIT; +Cc: Linus Torvalds
In-Reply-To: <Pine.LNX.4.58.0505221332590.2307@ppc970.osdl.org>
Hello,
> Sorry, I meant "rename", not "link", and yes, it should be NFS-safe. It's
> how all the mailers do things too, afaik.
okay. I will doublecheck that and come back.
> As to your update-cache problem, it seems to be just due to NFS stat
> caching. You generally should _not_ work on two machines at the same time,
> but it probably does the right thing in the end.
I added some debugging output (see attached patch) and saw that the
reason for the invalid thing is that the inode has changed:
...
name: pull.h 0x00000010
name: read-cache.c 0x00000010
...
#define INODE_CHANGED 0x0010
Same problem tla had. It looked at the device number. And of course the
device number for NFS shares isn't the same on all machines. So I
attached a little patch which fixes the issue for me (and others).
> In general, I would suggest using separate GIT repositories over sharing
> them over NFS. As far as I'm concerned, I think NFS should work in the
> sense that you can work from different clients at _different_times_, and
> I'm certainly not going to guarantee that two different clients that work
> at the same time against the same repository will get sane results.
It is more like that I don't remember on which machine I worked last and
working accidently on my next free window in screen (and I have a lot of
windows). And getting 370 Mbyte over NFS hits my nerves. ;-)
> For example, if you do a "git-checkout-cache -f -a" at the same time, I
> won't guarantee that things won't race on the working files. Don't do it.
I will not do that. And I will add locking for such operations in my frontend
anyway.
Thomas
CRAP CRAP CRAP: This is just the patch which showed me the debugging
output:
diff --git a/update-cache.c b/update-cache.c
--- a/update-cache.c
+++ b/update-cache.c
@@ -174,6 +174,8 @@ static struct cache_entry *refresh_entry
if (!changed)
return ce;
+ fprintf(stderr, "name: %s 0x%08x\n", ce->name, changed);
+
/*
* If the mode or type has changed, there's no point in trying
* to refresh the entry - it's not going to match
Here is the real patch:
[PATCH] Don't include devicenumber into INODE_CHANGED test
This fixes the problem that git-update-cache --refresh rebuilds the
cache stat information everytime it is started on a different host while
working in the same NFS shared repository.
Signed-off-by: Thomas Glanzmann <sithglan@stud.uni-erlangen.de>
diff --git a/read-cache.c b/read-cache.c
--- a/read-cache.c
+++ b/read-cache.c
@@ -65,8 +65,7 @@ int ce_match_stat(struct cache_entry *ce
if (ce->ce_uid != htonl(st->st_uid) ||
ce->ce_gid != htonl(st->st_gid))
changed |= OWNER_CHANGED;
- if (ce->ce_dev != htonl(st->st_dev) ||
- ce->ce_ino != htonl(st->st_ino))
+ if (ce->ce_ino != htonl(st->st_ino))
changed |= INODE_CHANGED;
if (ce->ce_size != htonl(st->st_size))
changed |= DATA_CHANGED;
^ permalink raw reply
* Alternate Patch: [PATCH] Don't include device number in cache invalidation when running on NFS
From: Thomas Glanzmann @ 2005-05-22 21:41 UTC (permalink / raw)
To: GIT, Linus Torvalds
In-Reply-To: <20050522212312.GC23388@cip.informatik.uni-erlangen.de>
Hello,
* Thomas Glanzmann <sithglan@stud.uni-erlangen.de> [050522 23:24]:
> Hello,
> > Sorry, I meant "rename", not "link", and yes, it should be NFS-safe. It's
> > how all the mailers do things too, afaik.
> okay. I will doublecheck that and come back.
yes, you're right.
While reading liblockfile I saw the following:
/*
* See if the directory where is certain file is in
* is located on an NFS mounted volume.
*/
static int is_nfs(const char *file)
{
char dir[1024];
char *s;
struct stat st;
strncpy(dir, file, sizeof(dir));
if ((s = strrchr(dir, '/')) != NULL)
*s = 0;
else
strcpy(dir, ".");
if (stat(dir, &st) < 0)
return 0;
return ((st.st_dev & 0xFF00) == 0);
}
So here comes an alternate patch if you like to verify the st_dev for non
NFS stuff. Also tested.
[PATCH] Don't include device number in cache invalidation when running on NFS
This patches includes the device number only in the cache invalidation
process when not running on a NFS volume.
Signed-off-by: Thomas Glanzmann <sithglan@stud.uni-erlangen.de>
diff --git a/read-cache.c b/read-cache.c
--- a/read-cache.c
+++ b/read-cache.c
@@ -65,8 +65,11 @@ int ce_match_stat(struct cache_entry *ce
if (ce->ce_uid != htonl(st->st_uid) ||
ce->ce_gid != htonl(st->st_gid))
changed |= OWNER_CHANGED;
- if (ce->ce_dev != htonl(st->st_dev) ||
- ce->ce_ino != htonl(st->st_ino))
+ /* Only include device number if not running on NFS */
+ if (ce->ce_dev != htonl(st->st_dev) &&
+ ((st->st_dev & 0xFF00) == 0))
+ changed |= INODE_CHANGED;
+ if (ce->ce_ino != htonl(st->st_ino))
changed |= INODE_CHANGED;
if (ce->ce_size != htonl(st->st_size))
changed |= DATA_CHANGED;
^ permalink raw reply
* Re: Alternate Patch: [PATCH] Don't include device number in cache invalidation when running on NFS
From: Linus Torvalds @ 2005-05-22 21:58 UTC (permalink / raw)
To: Thomas Glanzmann; +Cc: GIT
In-Reply-To: <20050522214115.GD23388@cip.informatik.uni-erlangen.de>
On Sun, 22 May 2005, Thomas Glanzmann wrote:
>
> While reading liblockfile I saw the following:
This is _really_ Linux-specific afaik. Which is ok for git, but at the
same time it really makes me go "Ewww". It's testing that the major number
is 0, and it would be a lot more cleaner to use
if (!major(st.st_dev))
but even that is very Linux-specific.
> [PATCH] Don't include device number in cache invalidation when running on NFS
I'll have to think about it. Maybe I should just remove the st_dev check.
I guess inode/size/mtime/ctime should be plenty safe enough in practice.
Linus
^ permalink raw reply
* Re: Alternate Patch: [PATCH] Don't include device number in cache invalidation when running on NFS
From: Thomas Glanzmann @ 2005-05-22 22:07 UTC (permalink / raw)
To: GIT
In-Reply-To: <Pine.LNX.4.58.0505221451590.2307@ppc970.osdl.org>
Hello,
> This is _really_ Linux-specific afaik. Which is ok for git, but at the
> same time it really makes me go "Ewww". It's testing that the major number
> is 0, and it would be a lot more cleaner to use
> if (!major(st.st_dev))
> but even that is very Linux-specific.
I see.
> I'll have to think about it. Maybe I should just remove the st_dev check.
> I guess inode/size/mtime/ctime should be plenty safe enough in practice.
I think so. At least I kick this one out because it is just getting on
my nerves. :-)
Thomas
^ permalink raw reply
page: next (older) | prev (newer) | latest
- recent:[subjects (threaded)|topics (new)|topics (active)]
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox