Merge branch 'fixes'
authorJunio C Hamano <junkio@cox.net>
Sat, 15 Oct 2005 18:19:09 +0000 (11:19 -0700)
committerJunio C Hamano <junkio@cox.net>
Sat, 15 Oct 2005 18:19:09 +0000 (11:19 -0700)
1  2 
Documentation/tutorial.txt
rsh.c
index 19da3e243e0418c94a014a19d06fe0c7dad634d6,6ecb089c5cc4cf8dcaa8005c0ee6e4208bced346..b9f737e9640a4a4a5c9554c8d6bdd1b7847ec5b2
@@@ -1,5 -1,6 +1,5 @@@
  A short git tutorial
  ====================
 -v0.99.5, Aug 2005
  
  Introduction
  ------------
@@@ -51,7 -52,9 +51,9 @@@ your new project. You will now have a `
  inspect that with `ls`. For your new empty project, it should show you
  three entries, among other things:
  
-  - a symlink called `HEAD`, pointing to `refs/heads/master`
+  - a symlink called `HEAD`, pointing to `refs/heads/master` (if your
+    platform does not have native symlinks, it is a file containing the
+    line "ref: refs/heads/master")
  +
  Don't worry about the fact that the file that the `HEAD` link points to
  doesn't even exist yet -- you haven't created the commit that will
@@@ -160,7 -163,7 +162,7 @@@ you'll have to use the object name, no
        git-cat-file -t 557db03de997c86a4a028e1ebd3a1ceb225be238
  
  where the `-t` tells `git-cat-file` to tell you what the "type" of the
 -object is. Git will tell you that you have a "blob" object (ie just a
 +object is. git will tell you that you have a "blob" object (ie just a
  regular file), and you can see the contents with
  
        git-cat-file "blob" 557db03
@@@ -227,6 -230,7 +229,7 @@@ which will spit ou
  
  ------------
  diff --git a/hello b/hello
+ index 557db03..263414f 100644
  --- a/hello
  +++ b/hello
  @@ -1 +1,2 @@
@@@ -289,13 -293,16 +292,16 @@@ also wants to get a commit messag
  on its standard input, and it will write out the resulting object name for the
  commit to its standard output.
  
- And this is where we start using the `.git/HEAD` file. The `HEAD` file is
- supposed to contain the reference to the top-of-tree, and since that's
- exactly what `git-commit-tree` spits out, we can do this all with a simple
- shell pipeline:
+ And this is where we create the `.git/refs/heads/master` file
+ which is pointed at by `HEAD`. This file is supposed to contain
+ the reference to the top-of-tree of the master branch, and since
+ that's exactly what `git-commit-tree` spits out, we can do this
+ all with a sequence of simple shell commands:
  
  ------------------------------------------------
- echo "Initial commit" | git-commit-tree $(git-write-tree) > .git/HEAD
+ tree=$(git-write-tree)
+ commit=$(echo 'Initial commit' | git-commit-tree $tree)
+ git-update-ref HEAD $(commit)
  ------------------------------------------------
  
  which will say:
@@@ -377,7 -384,7 +383,7 @@@ come from the working tree or not
  
  This is not hard to understand, as soon as you realize that git simply
  never knows (or cares) about files that it is not told about
 -explicitly. Git will never go *looking* for files to compare, it
 +explicitly. git will never go *looking* for files to compare, it
  expects you to tell it what the files are, and that's what the index
  is there for.
  ================
@@@ -543,7 -550,7 +549,7 @@@ name for the state at that point
  Copying repositories
  --------------------
  
 -Git repositories are normally totally self-sufficient, and it's worth noting
 +git repositories are normally totally self-sufficient, and it's worth noting
  that unlike CVS, for example, there is no separate notion of
  "repository" and "working tree". A git repository normally *is* the
  working tree, with the local git information hidden in the `.git`
@@@ -691,7 -698,9 +697,9 @@@ other point in the history than the cur
  just telling `git checkout` what the base of the checkout would be.
  In other words, if you have an earlier tag or branch, you'd just do
  
-       git checkout -b mybranch earlier-commit
+ ------------
+ git checkout -b mybranch earlier-commit
+ ------------
  
  and it would create the new branch `mybranch` at the earlier commit,
  and check out the state at that time.
  
  You can always just jump back to your original `master` branch by doing
  
-       git checkout master
+ ------------
+ git checkout master
+ ------------
  
  (or any other branch-name, for that matter) and if you forget which
  branch you happen to be on, a simple
  
-       ls -l .git/HEAD
+ ------------
+ ls -l .git/HEAD
+ ------------
  
- will tell you where it's pointing. To get the list of branches
- you have, you can say
+ will tell you where it's pointing (Note that on platforms with bad or no
+ symlink support, you have to execute
  
-       git branch
+ ------------
+ cat .git/HEAD
+ ------------
+ instead). To get the list of branches you have, you can say
+ ------------
+ git branch
+ ------------
  
  which is nothing more than a simple script around `ls .git/refs/heads`.
  There will be asterisk in front of the branch you are currently on.
  Sometimes you may wish to create a new branch _without_ actually
  checking it out and switching to it. If so, just use the command
  
-       git branch <branchname> [startingpoint]
+ ------------
+ git branch <branchname> [startingpoint]
+ ------------
  
  which will simply _create_ the branch, but will not do anything further. 
  You can then later -- once you decide that you want to actually develop
@@@ -843,7 -866,6 +865,6 @@@ $ git show-branch master mybranc
   ! [mybranch] Some work.
  --
  +  [master] Merged "mybranch" changes.
- +  [master~1] Some fun.
  ++ [mybranch] Some work.
  ------------------------------------------------
  
@@@ -870,8 -892,10 +891,10 @@@ Now, let's pretend you are the one who 
  to the `master` branch. Let's go back to `mybranch`, and run
  resolve to get the "upstream changes" back to your branch.
  
-       git checkout mybranch
-       git resolve HEAD master "Merge upstream changes."
+ ------------
+ git checkout mybranch
+ git resolve HEAD master "Merge upstream changes."
+ ------------
  
  This outputs something like this (the actual commit object names
  would be different)
@@@ -950,7 -974,7 +973,7 @@@ This transport is the same as SSH trans
  both ends on the local machine instead of running other end on
  the remote machine via `ssh`.
  
 -GIT Native::
 +git Native::
        `git://remote.machine/path/to/repo.git/`
  +
  This transport was designed for anonymous downloading.  Like SSH
@@@ -971,13 -995,13 +994,13 @@@ necessary objects.  Because of this beh
  sometimes also called 'commit walkers'.
  +
  The 'commit walkers' are sometimes also called 'dumb
 -transports', because they do not require any GIT aware smart
 -server like GIT Native transport does.  Any stock HTTP server
 +transports', because they do not require any git aware smart
 +server like git Native transport does.  Any stock HTTP server
  would suffice.
  +
  There are (confusingly enough) `git-ssh-fetch` and `git-ssh-upload`
  programs, which are 'commit walkers'; they outlived their
 -usefulness when GIT Native and SSH transports were introduced,
 +usefulness when git Native and SSH transports were introduced,
  and not used by `git pull` or `git push` scripts.
  
  Once you fetch from the remote repository, you `resolve` that
@@@ -1081,19 -1105,23 +1104,23 @@@ done only once
  on the remote machine. The communication between the two over
  the network internally uses an SSH connection.
  
 -Your private repository's GIT directory is usually `.git`, but
 +Your private repository's git directory is usually `.git`, but
  your public repository is often named after the project name,
  i.e. `<project>.git`. Let's create such a public repository for
  project `my-git`. After logging into the remote machine, create
  an empty directory:
  
-       mkdir my-git.git
+ ------------
+ mkdir my-git.git
+ ------------
  
 -Then, make that directory into a GIT repository by running
 +Then, make that directory into a git repository by running
  `git init-db`, but this time, since its name is not the usual
  `.git`, we do things slightly differently:
  
-       GIT_DIR=my-git.git git-init-db
+ ------------
+ GIT_DIR=my-git.git git-init-db
+ ------------
  
  Make sure this directory is available for others you want your
  changes to be pulled by via the transport of your choice. Also
@@@ -1117,7 -1145,9 +1144,9 @@@ Your "public repository" is now ready t
  Come back to the machine you have your private repository. From
  there, run this command:
  
-       git push <public-host>:/path/to/my-git.git master
+ ------------
+ git push <public-host>:/path/to/my-git.git master
+ ------------
  
  This synchronizes your public repository to match the named
  branch head (i.e. `master` in this case) and objects reachable
@@@ -1127,7 -1157,9 +1156,9 @@@ As a real example, this is how I updat
  repository. Kernel.org mirror network takes care of the
  propagation to other publicly visible machines:
  
-       git push master.kernel.org:/pub/scm/git/git.git/ 
+ ------------
+ git push master.kernel.org:/pub/scm/git/git.git/ 
+ ------------
  
  
  Packing your repository
@@@ -1140,7 -1172,9 +1171,9 @@@ not so convenient to transport over th
  immutable once they are created, there is a way to optimize the
  storage by "packing them together". The command
  
-       git repack
+ ------------
+ git repack
+ ------------
  
  will do it for you. If you followed the tutorial examples, you
  would have accumulated about 17 objects in `.git/objects/??/`
@@@ -1164,7 -1198,9 +1197,9 @@@ Our programs are always perfect ;-)
  Once you have packed objects, you do not need to leave the
  unpacked objects that are contained in the pack file anymore.
  
-       git prune-packed
+ ------------
+ git prune-packed
+ ------------
  
  would remove them for you.
  
diff --combined rsh.c
index 64c48091cb32af1d8c5b2ec145ad660ab9f0a75f,1fef6da513b8157331b1a71c1d4c8df4c438498e..d66526941fbe45f99e51babc2c55a63b4baa027c
--- 1/rsh.c
--- 2/rsh.c
+++ b/rsh.c
@@@ -1,16 -1,52 +1,16 @@@
 -#include "rsh.h"
 -
  #include <string.h>
  #include <sys/types.h>
  #include <sys/socket.h>
  
 +#include "rsh.h"
 +#include "quote.h"
  #include "cache.h"
  
  #define COMMAND_SIZE 4096
  
  /*
 - * Write a shell-quoted version of a string into a buffer, and
 - * return bytes that ought to be output excluding final null.
 - */
 -static int shell_quote(char *buf, int nmax, const char *str)
 -{
 -      char ch;
 -      int nq;
 -      int oc = 0;
 -
 -      while ( (ch = *str++) ) {
 -              nq = 0;
 -              if ( strchr(" !\"#$%&\'()*;<=>?[\\]^`{|}", ch) )
 -                      nq = 1;
 -
 -              if ( nq ) {
 -                      if ( nmax > 1 ) {
 -                              *buf++ = '\\';
 -                              nmax--;
 -                      }
 -                      oc++;
 -              }
 -
 -              if ( nmax > 1 ) {
 -                      *buf++ = ch;
 -                      nmax--;
 -              }
 -              oc++;
 -      }
 -
 -      if ( nmax )
 -              *buf = '\0';
 -
 -      return oc;
 -}
 -                      
 -/*
 - * Append a string to a string buffer, with or without quoting.  Return true
 - * if the buffer overflowed.
 + * Append a string to a string buffer, with or without shell quoting.
 + * Return true if the buffer overflowed.
   */
  static int add_to_string(char **ptrp, int *sizep, const char *str, int quote)
  {
@@@ -20,7 -56,7 +20,7 @@@
        int err = 0;
  
        if ( quote ) {
 -              oc = shell_quote(p, size, str);
 +              oc = sq_quote_buf(p, size, str);
        } else {
                oc = strlen(str);
                memcpy(p, str, (oc >= size) ? size-1 : oc);
@@@ -68,12 -104,13 +68,12 @@@ int setup_connection(int *fd_in, int *f
        if (!path) {
                return error("Bad URL: %s", url);
        }
-       /* $GIT_RSH <host> "env GIR_DIR=<path> <remote_prog> <args...>" */
+       /* $GIT_RSH <host> "env GIT_DIR=<path> <remote_prog> <args...>" */
        sizen = COMMAND_SIZE;
        posn = command;
        of = 0;
        of |= add_to_string(&posn, &sizen, "env ", 0);
 -      of |= add_to_string(&posn, &sizen, GIT_DIR_ENVIRONMENT, 0);
 -      of |= add_to_string(&posn, &sizen, "=", 0);
 +      of |= add_to_string(&posn, &sizen, GIT_DIR_ENVIRONMENT "=", 0);
        of |= add_to_string(&posn, &sizen, path, 1);
        of |= add_to_string(&posn, &sizen, " ", 0);
        of |= add_to_string(&posn, &sizen, remote_prog, 1);