Merge branch 'maint'
authorJunio C Hamano <gitster@pobox.com>
Wed, 8 Apr 2009 06:05:43 +0000 (23:05 -0700)
committerJunio C Hamano <gitster@pobox.com>
Wed, 8 Apr 2009 06:05:43 +0000 (23:05 -0700)
* maint:
Change double quotes to single quotes in message
Documentation: clarify .gitattributes search
git-checkout.txt: clarify that <branch> applies when no path is given.
git-checkout.txt: fix incorrect statement about HEAD and index

Conflicts:
Documentation/git-checkout.txt

1  2 
Documentation/git-checkout.txt
builtin-checkout.c
index 1a6c19e5c39ad038e3fa073926683a21d7c21935,132fc4faa5efab2a07b592e3567340b5eeb3f910..223ea9caef4d0ca875768db47e03f5c6cb71354f
@@@ -8,7 -8,7 +8,7 @@@ git-checkout - Checkout a branch or pat
  SYNOPSIS
  --------
  [verse]
 -'git checkout' [-q] [-f] [--track | --no-track] [-b <new_branch> [-l]] [-m] [<branch>]
 +'git checkout' [-q] [-f] [-t | --track | --no-track] [-b <new_branch> [-l]] [-m] [<branch>]
  'git checkout' [-f|--ours|--theirs|-m|--conflict=<style>] [<tree-ish>] [--] <paths>...
  
  DESCRIPTION
@@@ -21,15 -21,15 +21,15 @@@ specified, <new_branch>.  Using -b wil
  be created; in this case you can use the --track or --no-track
  options, which will be passed to `git branch`.
  
 -As a convenience, --track will default to create a branch whose
 +As a convenience, --track will default to creating a branch whose
  name is constructed from the specified branch name by stripping
  the first namespace level.
  
  When <paths> are given, this command does *not* switch
  branches.  It updates the named paths in the working tree from
  the index file, or from a named <tree-ish> (most often a commit).  In
 -this case, the `-b` options is meaningless and giving
 -either of them results in an error.  <tree-ish> argument can be
 +this case, the `-b` and `--track` options are meaningless and giving
 +either of them results in an error. The <tree-ish> argument can be
  used to specify a specific tree-ish (i.e. commit, tag or tree)
  to update the index for the given paths before updating the
  working tree.
@@@ -75,13 -75,14 +75,13 @@@ entries; instead, unmerged entries are 
        <repository> <refspec>" explicitly. This behavior is the default
        when the start point is a remote branch. Set the
        branch.autosetupmerge configuration variable to `false` if you want
 -      'git-checkout' and 'git-branch' to always behave as if '--no-track' were
 +      'git checkout' and 'git branch' to always behave as if '--no-track' were
        given. Set it to `always` if you want this behavior when the
 -      start-point is either a local or remote branch.
 +      start point is either a local or remote branch.
  +
 -If no '-b' option was given, the name of the new branch will be
 -derived from the remote branch, by attempting to guess the name
 -of the branch on remote system.  If "remotes/" or "refs/remotes/"
 -are prefixed, it is stripped away, and then the part up to the
 +If no '-b' option is given, the name of the new branch will be
 +derived from the remote branch.  If "remotes/" or "refs/remotes/"
 +is prefixed it is stripped away, and then the part up to the
  next slash (which would be the nickname of the remote) is removed.
  This would tell us to use "hack" as the local branch when branching
  off of "origin/hack" (or "remotes/origin/hack", or even
@@@ -126,16 -127,20 +126,20 @@@ the conflicted merge in the specified p
  <new_branch>::
        Name for the new branch.
  
+ <tree-ish>::
+       Tree to checkout from (when paths are given). If not specified,
+       the index will be used.
  <branch>::
-       Branch to checkout; may be any object ID that resolves to a
-       commit.  Defaults to HEAD.
+       Branch to checkout (when no paths are given); may be any object
+       ID that resolves to a commit.  Defaults to HEAD.
  +
  When this parameter names a non-branch (but still a valid commit object),
  your HEAD becomes 'detached'.
  +
 -As a special case, the "`@\{-N\}`" syntax for the N-th last branch
 +As a special case, the `"@\{-N\}"` syntax for the N-th last branch
  checks out the branch (instead of detaching).  You may also specify
 -"`-`" which is synonymous with "`@\{-1\}`".
 +`-` which is synonymous with `"@\{-1\}"`.
  
  
  Detached HEAD
@@@ -151,12 -156,12 +155,12 @@@ $ git checkout v2.6.1
  ------------
  
  Earlier versions of git did not allow this and asked you to
 -create a temporary branch using `-b` option, but starting from
 +create a temporary branch using the `-b` option, but starting from
  version 1.5.0, the above command 'detaches' your HEAD from the
 -current branch and directly point at the commit named by the tag
 -(`v2.6.18` in the above example).
 +current branch and directly points at the commit named by the tag
 +(`v2.6.18` in the example above).
  
 -You can use usual git commands while in this state.  You can use
 +You can use all git commands while in this state.  You can use
  `git reset --hard $othercommit` to further move around, for
  example.  You can make changes and create a new commit on top of
  a detached HEAD.  You can even create a merge by using `git
@@@ -191,7 -196,7 +195,7 @@@ $ git checkout hello.c            <3
  +
  <1> switch branch
  <2> take a file out of another commit
- <3> restore hello.c from HEAD of current branch
+ <3> restore hello.c from the index
  +
  If you have an unfortunate branch that is named `hello.c`, this
  step would be confused as an instruction to switch to that branch.
@@@ -201,7 -206,7 +205,7 @@@ You should instead write
  $ git checkout -- hello.c
  ------------
  
 -. After working in a wrong branch, switching to the correct
 +. After working in the wrong branch, switching to the correct
  branch would be done using:
  +
  ------------
@@@ -209,7 -214,7 +213,7 @@@ $ git checkout mytopi
  ------------
  +
  However, your "wrong" branch and correct "mytopic" branch may
 -differ in files that you have locally modified, in which case,
 +differ in files that you have modified locally, in which case
  the above checkout would fail like this:
  +
  ------------
diff --combined builtin-checkout.c
index 2e4fe1a4533b852fa6bfda81dd594c6cf6fb5b8f,ed0f318c0ce8a1c70ff3e45605c760c8bbb173f2..ee1edd406ffde4b31bf2685a634a6d318407724f
@@@ -53,6 -53,9 +53,6 @@@ static int update_some(const unsigned c
        int len;
        struct cache_entry *ce;
  
 -      if (S_ISGITLINK(mode))
 -              return 0;
 -
        if (S_ISDIR(mode))
                return READ_TREE_RECURSIVE;
  
@@@ -292,8 -295,6 +292,8 @@@ static void show_local_changes(struct o
        init_revisions(&rev, NULL);
        rev.abbrev = 0;
        rev.diffopt.output_format |= DIFF_FORMAT_NAME_STATUS;
 +      if (diff_setup_done(&rev.diffopt) < 0)
 +              die("diff_setup_done failed");
        add_pending_object(&rev, head, NULL);
        run_diff_index(&rev, 0);
  }
@@@ -350,11 -351,16 +350,11 @@@ struct branch_info 
  static void setup_branch_path(struct branch_info *branch)
  {
        struct strbuf buf = STRBUF_INIT;
 -      int ret;
  
 -      if ((ret = interpret_nth_last_branch(branch->name, &buf))
 -          && ret == strlen(branch->name)) {
 +      strbuf_branchname(&buf, branch->name);
 +      if (strcmp(buf.buf, branch->name))
                branch->name = xstrdup(buf.buf);
 -              strbuf_splice(&buf, 0, 0, "refs/heads/", 11);
 -      } else {
 -              strbuf_addstr(&buf, "refs/heads/");
 -              strbuf_addstr(&buf, branch->name);
 -      }
 +      strbuf_splice(&buf, 0, 0, "refs/heads/", 11);
        branch->path = strbuf_detach(&buf, NULL);
  }
  
@@@ -399,7 -405,7 +399,7 @@@ static int merge_working_tree(struct ch
                topts.verbose_update = !opts->quiet;
                topts.fn = twoway_merge;
                topts.dir = xcalloc(1, sizeof(*topts.dir));
 -              topts.dir->show_ignored = 1;
 +              topts.dir->flags |= DIR_SHOW_IGNORED;
                topts.dir->exclude_per_dir = ".gitignore";
                tree = parse_tree_indirect(old->commit->object.sha1);
                init_tree_desc(&trees[0], tree->buffer, tree->size);
@@@ -495,10 -501,10 +495,10 @@@ static void update_refs_for_switch(stru
                create_symref("HEAD", new->path, msg.buf);
                if (!opts->quiet) {
                        if (old->path && !strcmp(new->path, old->path))
-                               fprintf(stderr, "Already on \"%s\"\n",
+                               fprintf(stderr, "Already on '%s'\n",
                                        new->name);
                        else
-                               fprintf(stderr, "Switched to%s branch \"%s\"\n",
+                               fprintf(stderr, "Switched to%s branch '%s'\n",
                                        opts->new_branch ? " a new" : "",
                                        new->name);
                }
                           REF_NODEREF, DIE_ON_ERR);
                if (!opts->quiet) {
                        if (old->path)
-                               fprintf(stderr, "Note: moving to \"%s\" which isn't a local branch\nIf you want to create a new branch from this checkout, you may do so\n(now or later) by using -b with the checkout command again. Example:\n  git checkout -b <new_branch_name>\n", new->name);
+                               fprintf(stderr, "Note: moving to '%s' which isn't a local branch\nIf you want to create a new branch from this checkout, you may do so\n(now or later) by using -b with the checkout command again. Example:\n  git checkout -b <new_branch_name>\n", new->name);
                        describe_detached_head("HEAD is now at", new->commit);
                }
        }
@@@ -550,8 -556,8 +550,8 @@@ static int switch_branches(struct check
  
        if (!old.commit && !opts->force) {
                if (!opts->quiet) {
 -                      fprintf(stderr, "warning: You appear to be on a branch yet to be born.\n");
 -                      fprintf(stderr, "warning: Forcing checkout of %s.\n", new->name);
 +                      warning("You appear to be on a branch yet to be born.");
 +                      warning("Forcing checkout of %s.", new->name);
                }
                opts->force = 1;
        }
@@@ -730,11 -736,12 +730,11 @@@ no_reference
  
        if (opts.new_branch) {
                struct strbuf buf = STRBUF_INIT;
 -              strbuf_addstr(&buf, "refs/heads/");
 -              strbuf_addstr(&buf, opts.new_branch);
 +              if (strbuf_check_branch_ref(&buf, opts.new_branch))
 +                      die("git checkout: we do not like '%s' as a branch name.",
 +                          opts.new_branch);
                if (!get_sha1(buf.buf, rev))
                        die("git checkout: branch %s already exists", opts.new_branch);
 -              if (check_ref_format(buf.buf))
 -                      die("git checkout: we do not like '%s' as a branch name.", opts.new_branch);
                strbuf_release(&buf);
        }