From: David Greaves <david@dgreaves.com>
To: Petr Baudis <pasky@ucw.cz>
Cc: GIT Mailing Lists <git@vger.kernel.org>
Subject: [PATCH] Docs update
Date: Thu, 21 Apr 2005 21:40:44 +0100 [thread overview]
Message-ID: <42680FCC.6030901@dgreaves.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 108 bytes --]
Added commit-tree, diff-cache and environment info
Signed-off-by: David Greaves <david@dgreaves.com>
---
[-- Attachment #2: README.reference.patch2 --]
[-- Type: text/plain, Size: 7471 bytes --]
Index: README.reference
===================================================================
--- c0260bfb82da04aeff4e598ced5295d6ae2e262d/README.reference (mode:100644 sha1:8186a561108d3c62625614272bd5e2f7d5826b4b)
+++ 5f204110aef2538fdc512e09e4a075b3afac8eff/README.reference (mode:100644 sha1:b5fc4fb969ec3f52877408c8df4ba131a8c4a7b2)
@@ -109,12 +109,173 @@
################################################################
commit-tree
- commit-tree <sha1> [-p <sha1>]* < changelog
+ commit-tree <sha1> [-p <parent sha1>...] < changelog
+Creates a new commit object based on the provided tree object and
+emits the new commit object id on stdout. If no parent is given then
+it is considered to be an initial tree.
+
+A commit object usually has 1 parent (a commit after a change) or 2
+parents (a merge) although there is no reason it cannot have more than
+2 parents.
+
+While a tree represents a particular directory state of a working
+directory, a commit represents that state in "time", and explains how
+to get there.
+
+Normally a commit would identify 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.
+
+Options
+
+<sha1>
+ An existing tree object
+
+-p <parent sha1>
+ Each -p indicates a the id of a parent commit object.
+
+
+Commit Information
+
+A commit encapsulates:
+ all parent object ids
+ author name, email and date
+ committer name and email and the commit time.
+
+If not provided, commit-tree uses your name, hostname and domain to
+provide author and committer info. This can be overridden using the
+following environment variables.
+ AUTHOR_NAME
+ AUTHOR_EMAIL
+ AUTHOR_DATE
+ COMMIT_AUTHOR_NAME
+ COMMIT_AUTHOR_EMAIL
+(nb <,> and CRs are stripped)
+
+A commit comment is read from stdin (max 999 chars)
+
+see also: write-tree
+
+
+################################################################
+diff-cache
+ diff-cache [-r] [-z] <tree/commit sha1>
+
+Compares the content and mode of the blobs found via a tree object
+with the content of the current cache and, optionally, the stat state
+of the file on disk.
+
+(This is basically a special case of diff-tree that works with the
+current cache as the first tree.)
+
+<tree sha1>
+ The id of a tree or commit object to diff against.
+
+-r
+ recurse
+
+-z
+ /0 line termintation on output
+
+--cached
+ do not consider the on-disk file at all
+
+Output format:
+
+For files in the tree but not in the cache
+-<mode> <type> <sha1> <filename>
+
+For files in the cache but not in the tree
++<mode> <type> <sha1> <filename>
+
+For files that differ:
+*<tree-mode>-><cache-mode> <type> <tree sha1>-><cache sha1> path/<filename>
+
+In the special case of the file being changed on disk and out of sync with the cache, the sha1
+
+Operating Modes
+You can choose whether you want to trust the index file entirely
+(using the "--cached" flag) or ask the diff logic to show any files
+that don't match the stat state as being "tentatively changed". Both
+of these operations are very useful indeed.
+
+Cached Mode
+If --cached is specified, it allows you to ask:
+ show me the differences between HEAD and the current index
+ contents (the ones I'd write with a "write-tree")
+
+For example, let's say that you have worked on your index file, and are
+ready to commit. You want to see eactly _what_ you are going to commit is
+without having to write a new tree object and compare it that way, and to
+do that, you just do
+
+ diff-cache --cached $(cat .git/HEAD)
+
+Example: let's say I had renamed "commit.c" to "git-commit.c", and I had
+done an "upate-cache" to make that effective in the index file.
+"show-diff" wouldn't show anything at all, since the index file matches
+my working directory. But doing a diff-cache does:
+ torvalds@ppc970:~/git> diff-cache --cached $(cat .git/HEAD)
+ -100644 blob 4161aecc6700a2eb579e842af0b7f22b98443f74 commit.c
+ +100644 blob 4161aecc6700a2eb579e842af0b7f22b98443f74 git-commit.c
+
+And as you can see, the output matches "diff-tree -r" output (we
+always do "-r", since the index is always fully populated
+??CHECK??).
+You can trivially see that the above is a rename.
+
+In fact, "diff-tree --cached" _should_ always be entirely equivalent to
+actually doing a "write-tree" and comparing that. Except this one is much
+nicer for the case where you just want to check where you are.
+
+So doing a "diff-cache --cached" is basically very useful when you are
+asking yourself "what have I already marked for being committed, and
+what's the difference to a previous tree".
+
+Non-cached Mode
+
+The "non-cached" mode takes a different approach, and is potentially
+the even more useful of the two in that what it does can't be emulated
+with a "write-tree + diff-tree". Thus that's the default mode. The
+non-cached version asks the question
+
+ "show me the differences between HEAD and the currently checked out
+ tree - index contents _and_ files that aren't up-to-date"
+
+which is obviously a very useful question too, since that tells you what
+you _could_ commit. Again, the output matches the "diff-tree -r" output to
+a tee, but with a twist.
+
+The twist is that if some file doesn't match the cache, we don't have a
+backing store thing for it, and we use the magic "all-zero" sha1 to show
+that. So let's say that you have edited "kernel/sched.c", but have not
+actually done an update-cache on it yet - there is no "object" associated
+with the new state, and you get:
+
+ torvalds@ppc970:~/v2.6/linux> diff-cache $(cat .git/HEAD )
+ *100644->100664 blob 7476bbcfe5ef5a1dd87d745f298b831143e4d77e->0000000000000000000000000000000000000000 kernel/sched.c
+
+ie it shows that the tree has changed, and that "kernel/sched.c" has is
+not up-to-date and may contain new stuff. The all-zero sha1 means that to
+get the real diff, you need to look at the object in the working directory
+directly rather than do an object-to-object diff.
+
+NOTE! As with other commands of this type, "diff-cache" does not actually
+look at the contents of the file at all. So maybe "kernel/sched.c" hasn't
+actually changed, and it's just that you touched it. In either case, it's
+a note that you need to upate-cache it to make the cache be in sync.
+
+NOTE 2! You can have a mixture of files show up as "has been updated" and
+"is still dirty in the working directory" together. You can always tell
+which file is in which state, since the "has been updated" ones show a
+valid sha1, and the "not in sync with the index" ones will always have the
+special all-zero sha1.
################################################################
diff-tree
- diff-tree [-r] [-z] <tree sha1> <tree sha1>
+ diff-tree [-r] [-z] <tree sha1> <tree sha1>
################################################################
@@ -156,3 +317,23 @@
unpack-file
unpack-file.c <sha1>
+
+
+git Environment Variables
+GIT_CACHE_DIRECTORY
+AUTHOR_NAME
+AUTHOR_EMAIL
+AUTHOR_DATE
+RSYNC_FLAGS
+GIT_INDEX_FILE
+
+
+.git Repository Files
+
+.git/HEAD
+This file always contains the last (head) commit object created for this branch of the repository.
+(Usually symlinked to a file in .git/heads/)
+
+.git/heads/
+This directory contains a file for each branch of the .git repository.
+The name of the file is the friendly name of the branch (eg pasky)
next reply other threads:[~2005-04-21 20:36 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-04-21 20:40 David Greaves [this message]
2005-04-21 20:43 ` [PATCH] Docs update Petr Baudis
2005-04-21 21:16 ` David Greaves
2005-04-21 21:26 ` Petr Baudis
2005-04-21 22:53 ` Junio C Hamano
2005-04-21 23:10 ` David Greaves
-- strict thread matches above, loose matches on Subject: below --
2009-02-19 5:21 Warren Togami
[not found] ` <499CEC4E.6060003-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2009-02-19 11:41 ` Thiago Galesi
2009-02-19 12:09 ` Seewer Philippe
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=42680FCC.6030901@dgreaves.com \
--to=david@dgreaves.com \
--cc=git@vger.kernel.org \
--cc=pasky@ucw.cz \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.