Merge branch 'maint'
authorJunio C Hamano <junkio@cox.net>
Wed, 28 Feb 2007 06:15:42 +0000 (22:15 -0800)
committerJunio C Hamano <junkio@cox.net>
Wed, 28 Feb 2007 06:15:42 +0000 (22:15 -0800)
* maint:
builtin-fmt-merge-msg: fix bugs in --file option
index-pack: Loop over pread until data loading is complete.
blameview: Fix the browse behavior in blameview
Fix minor typos/grammar in user-manual.txt
Correct ordering in git-cvsimport's option documentation
git-show: Reject native ref
Fix git-show man page formatting in the EXAMPLES section

1  2 
Documentation/user-manual.txt
builtin-fmt-merge-msg.c
index-pack.c
revision.c
index 03736bbcd3ebfd5e1cbe6a006acb2b31411af527,7b6dc22e7bad8bfc3d6f018e47e2025f2a1508ee..34e965104b892ff0353064f254414cb744da85d4
@@@ -2,7 -2,7 +2,7 @@@ Git User's Manua
  _________________
  
  This manual is designed to be readable by someone with basic unix
- commandline skills, but no previous knowledge of git.
+ command-line skills, but no previous knowledge of git.
  
  Chapter 1 gives a brief overview of git commands, without any
  explanation; you may prefer to skip to chapter 2 on a first reading.
@@@ -1196,7 -1196,7 +1196,7 @@@ will be HEAD, the tip of the current br
  tip of the other branch, which is stored temporarily in MERGE_HEAD.
  
  The diff above shows the differences between the working-tree version
- of file.txt and two previous version: one version from HEAD, and one
+ of file.txt and two previous versions: one version from HEAD, and one
  from MERGE_HEAD.  So instead of preceding each line by a single "+"
  or "-", it now uses two columns: the first column is used for
  differences between the first parent and the working directory copy,
@@@ -1479,7 -1479,7 +1479,7 @@@ Examining dangling object
  
  In some situations the reflog may not be able to save you.  For
  example, suppose you delete a branch, then realize you need the history
- it pointed you.  The reflog is also deleted; however, if you have not
+ it contained.  The reflog is also deleted; however, if you have not
  yet pruned the repository, then you may still be able to find
  the lost commits; run git-fsck and watch for output that mentions
  "dangling commits":
@@@ -1505,7 -1505,7 +1505,7 @@@ history that is described by all your e
  you get exactly the history reachable from that commit that is lost.
  (And notice that it might not be just one commit: we only report the
  "tip of the line" as being dangling, but there might be a whole deep
- and complex commit history that was gotten dropped.)
+ and complex commit history that was dropped.)
  
  If you decide you want the history back, you can always create a new
  reference pointing to it, for example, a new branch:
@@@ -1561,7 -1561,7 +1561,7 @@@ repository that you pulled from
  
  (But note that no such commit will be created in the case of a
  <<fast-forwards,fast forward>>; instead, your branch will just be
- updated to point to the latest commit from the upstream branch).
+ updated to point to the latest commit from the upstream branch.)
  
  The git-pull command can also be given "." as the "remote" repository,
  in which case it just merges in a branch from the current repository; so
@@@ -1638,8 -1638,8 +1638,8 @@@ updates with git pull>>"
  
  If you and maintainer both have accounts on the same machine, then
  then you can just pull changes from each other's repositories
- directly; note that all of the command (gitlink:git-clone[1],
- git-fetch[1], git-pull[1], etc.) which accept a URL as an argument
+ directly; note that all of the commands (gitlink:git-clone[1],
+ git-fetch[1], git-pull[1], etc.) that accept a URL as an argument
  will also accept a local file patch; so, for example, you can
  use
  
@@@ -1832,7 -1832,7 +1832,7 @@@ that makes it easy for them to read you
  correct, and understand why you made each change.
  
  If you present all of your changes as a single patch (or commit), they
- may find it is too much to digest all at once.
+ may find that it is too much to digest all at once.
  
  If you present them with the entire history of your work, complete with
  mistakes, corrections, and dead ends, they may be overwhelmed.
@@@ -1858,11 -1858,8 +1858,8 @@@ you are rewriting history
  Keeping a patch series up to date using git-rebase
  --------------------------------------------------
  
- Suppose you have a series of commits in a branch "mywork", which
- originally branched off from "origin".
- Suppose you create a branch "mywork" on a remote-tracking branch
- "origin", and created some commits on top of it:
+ Suppose that you create a branch "mywork" on a remote-tracking branch
+ "origin", and create some commits on top of it:
  
  -------------------------------------------------
  $ git checkout -b mywork origin
@@@ -1966,7 -1963,7 +1963,7 @@@ Other tool
  -----------
  
  There are numerous other tools, such as stgit, which exist for the
- purpose of maintaining a patch series.  These are out of the scope of
+ purpose of maintaining a patch series.  These are outside of the scope of
  this manual.
  
  Problems with rewriting history
@@@ -2088,7 -2085,7 +2085,7 @@@ descendant of the old head, you may for
  $ git fetch git://example.com/proj.git +master:refs/remotes/example/master
  -------------------------------------------------
  
- Note the addition of the "+" sign.  Be aware that commits which the
+ Note the addition of the "+" sign.  Be aware that commits that the
  old version of example/master pointed at may be lost, as we saw in
  the previous section.
  
@@@ -2096,7 -2093,7 +2093,7 @@@ Configuring remote branche
  ---------------------------
  
  We saw above that "origin" is just a shortcut to refer to the
- repository which you originally cloned from.  This information is
+ repository that you originally cloned from.  This information is
  stored in git configuration variables, which you can see using
  gitlink:git-config[1]:
  
@@@ -2407,7 -2404,7 +2404,7 @@@ conflicts between different tree object
  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
+ Those are the ONLY three things that the directory cache does.  It's a
  cache, and the normal operation is to re-generate it completely from a
  known tree object, or update/compare it with a live tree that is being
  developed.  If you blow the directory cache away entirely, you generally
@@@ -2755,7 -2752,7 +2752,7 @@@ stages to temporary files and calls a "
  $ git-merge-index git-merge-one-file hello.c
  -------------------------------------------------
  
 -and that is what higher level `git resolve` is implemented with.
 +and that is what higher level `git merge -s resolve` is implemented with.
  
  How git stores objects efficiently: pack files
  ----------------------------------------------
diff --combined builtin-fmt-merge-msg.c
index 14898835649f4156c86f53ecde658009c735ca3f,5be6fb4388e6d1df53de4c06db1acb32d24426c1..5c145d2165027adc5e5d44c6dda969e1ed86be57
@@@ -81,7 -81,7 +81,7 @@@ static int handle_line(char *line
        if (len < 43 || line[40] != '\t')
                return 1;
  
 -      if (!strncmp(line + 41, "not-for-merge", 13))
 +      if (!prefixcmp(line + 41, "not-for-merge"))
                return 0;
  
        if (line[41] != '\t')
        if (pulling_head) {
                origin = xstrdup(src);
                src_data->head_status |= 1;
 -      } else if (!strncmp(line, "branch ", 7)) {
 +      } else if (!prefixcmp(line, "branch ")) {
                origin = xstrdup(line + 7);
                append_to_list(&src_data->branch, origin, NULL);
                src_data->head_status |= 2;
 -      } else if (!strncmp(line, "tag ", 4)) {
 +      } else if (!prefixcmp(line, "tag ")) {
                origin = line;
                append_to_list(&src_data->tag, xstrdup(origin + 4), NULL);
                src_data->head_status |= 2;
 -      } else if (!strncmp(line, "remote branch ", 14)) {
 +      } else if (!prefixcmp(line, "remote branch ")) {
                origin = xstrdup(line + 14);
                append_to_list(&src_data->r_branch, origin, NULL);
                src_data->head_status |= 2;
@@@ -259,13 -259,15 +259,15 @@@ int cmd_fmt_merge_msg(int argc, const c
                else if (!strcmp(argv[1], "--no-summary"))
                        merge_summary = 0;
                else if (!strcmp(argv[1], "-F") || !strcmp(argv[1], "--file")) {
-                       if (argc < 2)
+                       if (argc < 3)
                                die ("Which file?");
                        if (!strcmp(argv[2], "-"))
                                in = stdin;
                        else {
                                fclose(in);
                                in = fopen(argv[2], "r");
+                               if (!in)
+                                       die("cannot open %s", argv[2]);
                        }
                        argc--; argv++;
                } else
        current_branch = resolve_ref("HEAD", head_sha1, 1, NULL);
        if (!current_branch)
                die("No current branch");
 -      if (!strncmp(current_branch, "refs/heads/", 11))
 +      if (!prefixcmp(current_branch, "refs/heads/"))
                current_branch += 11;
  
        while (fgets(line, sizeof(line), in)) {
diff --combined index-pack.c
index fa9a0e74892ce35d8d9a3b9e0d4e2c1c0c9e8dab,f9177442afb6daef9feef43696165be5b6eb224c..48874a052a8be22c50fdbb8b4b707af2d49c4859
@@@ -277,13 -277,19 +277,19 @@@ static void *get_data_from_pack(struct 
  {
        unsigned long from = obj[0].offset + obj[0].hdr_size;
        unsigned long len = obj[1].offset - from;
+       unsigned long rdy = 0;
        unsigned char *src, *data;
        z_stream stream;
        int st;
  
        src = xmalloc(len);
-       if (pread(pack_fd, src, len, from) != len)
-               die("cannot pread pack file: %s", strerror(errno));
+       data = src;
+       do {
+               ssize_t n = pread(pack_fd, data + rdy, len - rdy, from + rdy);
+               if (n <= 0)
+                       die("cannot pread pack file: %s", strerror(errno));
+               rdy += n;
+       } while (rdy < len);
        data = xmalloc(obj->size);
        memset(&stream, 0, sizeof(stream));
        stream.next_out = data;
@@@ -849,9 -855,9 +855,9 @@@ int main(int argc, char **argv
                                fix_thin_pack = 1;
                        } else if (!strcmp(arg, "--keep")) {
                                keep_msg = "";
 -                      } else if (!strncmp(arg, "--keep=", 7)) {
 +                      } else if (!prefixcmp(arg, "--keep=")) {
                                keep_msg = arg + 7;
 -                      } else if (!strncmp(arg, "--pack_header=", 14)) {
 +                      } else if (!prefixcmp(arg, "--pack_header=")) {
                                struct pack_header *hdr;
                                char *c;
  
diff --combined revision.c
index 4cf697e2c1fccdf9a6cded983c9d3bbf45fc5af8,76499dcf38bb9c92bd52d251549725bceb6a9ba1..b84c066cbac33bb8b4103e8be0de5959a02a643c
@@@ -116,6 -116,8 +116,8 @@@ void mark_parents_uninteresting(struct 
  
  void add_pending_object(struct rev_info *revs, struct object *obj, const char *name)
  {
+       if (revs->no_walk && (obj->flags & UNINTERESTING))
+               die("object ranges do not make sense when not walking revisions");
        add_object_array(obj, name, &revs->pending);
        if (revs->reflog_info && obj->type == OBJ_COMMIT)
                add_reflog_for_walk(revs->reflog_info,
@@@ -813,11 -815,11 +815,11 @@@ int setup_revisions(int argc, const cha
                const char *arg = argv[i];
                if (*arg == '-') {
                        int opts;
 -                      if (!strncmp(arg, "--max-count=", 12)) {
 +                      if (!prefixcmp(arg, "--max-count=")) {
                                revs->max_count = atoi(arg + 12);
                                continue;
                        }
 -                      if (!strncmp(arg, "--skip=", 7)) {
 +                      if (!prefixcmp(arg, "--skip=")) {
                                revs->skip_count = atoi(arg + 7);
                                continue;
                        }
                                revs->max_count = atoi(argv[++i]);
                                continue;
                        }
 -                      if (!strncmp(arg,"-n",2)) {
 +                      if (!prefixcmp(arg, "-n")) {
                                revs->max_count = atoi(arg + 2);
                                continue;
                        }
 -                      if (!strncmp(arg, "--max-age=", 10)) {
 +                      if (!prefixcmp(arg, "--max-age=")) {
                                revs->max_age = atoi(arg + 10);
                                continue;
                        }
 -                      if (!strncmp(arg, "--since=", 8)) {
 +                      if (!prefixcmp(arg, "--since=")) {
                                revs->max_age = approxidate(arg + 8);
                                continue;
                        }
 -                      if (!strncmp(arg, "--after=", 8)) {
 +                      if (!prefixcmp(arg, "--after=")) {
                                revs->max_age = approxidate(arg + 8);
                                continue;
                        }
 -                      if (!strncmp(arg, "--min-age=", 10)) {
 +                      if (!prefixcmp(arg, "--min-age=")) {
                                revs->min_age = atoi(arg + 10);
                                continue;
                        }
 -                      if (!strncmp(arg, "--before=", 9)) {
 +                      if (!prefixcmp(arg, "--before=")) {
                                revs->min_age = approxidate(arg + 9);
                                continue;
                        }
 -                      if (!strncmp(arg, "--until=", 8)) {
 +                      if (!prefixcmp(arg, "--until=")) {
                                revs->min_age = approxidate(arg + 8);
                                continue;
                        }
                                revs->num_ignore_packed = 0;
                                continue;
                        }
 -                      if (!strncmp(arg, "--unpacked=", 11)) {
 +                      if (!prefixcmp(arg, "--unpacked=")) {
                                revs->unpacked = 1;
                                add_ignore_packed(revs, arg+11);
                                continue;
                                revs->verbose_header = 1;
                                continue;
                        }
 -                      if (!strncmp(arg, "--pretty", 8)) {
 +                      if (!prefixcmp(arg, "--pretty")) {
                                revs->verbose_header = 1;
                                revs->commit_format = get_commit_format(arg+8);
                                continue;
                                revs->abbrev = DEFAULT_ABBREV;
                                continue;
                        }
 -                      if (!strncmp(arg, "--abbrev=", 9)) {
 +                      if (!prefixcmp(arg, "--abbrev=")) {
                                revs->abbrev = strtoul(arg + 9, NULL, 10);
                                if (revs->abbrev < MINIMUM_ABBREV)
                                        revs->abbrev = MINIMUM_ABBREV;
                        /*
                         * Grepping the commit log
                         */
 -                      if (!strncmp(arg, "--author=", 9)) {
 +                      if (!prefixcmp(arg, "--author=")) {
                                add_header_grep(revs, "author", arg+9);
                                continue;
                        }
 -                      if (!strncmp(arg, "--committer=", 12)) {
 +                      if (!prefixcmp(arg, "--committer=")) {
                                add_header_grep(revs, "committer", arg+12);
                                continue;
                        }
 -                      if (!strncmp(arg, "--grep=", 7)) {
 +                      if (!prefixcmp(arg, "--grep=")) {
                                add_message_grep(revs, arg+7);
                                continue;
                        }
                                all_match = 1;
                                continue;
                        }
 -                      if (!strncmp(arg, "--encoding=", 11)) {
 +                      if (!prefixcmp(arg, "--encoding=")) {
                                arg += 11;
                                if (strcmp(arg, "none"))
                                        git_log_output_encoding = strdup(arg);
                                        git_log_output_encoding = "";
                                continue;
                        }
 +                      if (!strcmp(arg, "--reverse")) {
 +                              revs->reverse ^= 1;
 +                              continue;
 +                      }
  
                        opts = diff_opt_parse(&revs->diffopt, argv+i, argc-i);
                        if (opts > 0) {
@@@ -1233,15 -1231,9 +1235,15 @@@ static struct commit *get_revision_1(st
                 */
                if (!revs->limited) {
                        if (revs->max_age != -1 &&
 -                          (commit->date < revs->max_age))
 -                              continue;
 -                      add_parents_to_list(revs, commit, &revs->commits);
 +                          (commit->date < revs->max_age)) {
 +                              if (revs->boundary)
 +                                      commit->object.flags |=
 +                                              BOUNDARY_SHOW | BOUNDARY;
 +                              else
 +                                      continue;
 +                      } else
 +                              add_parents_to_list(revs, commit,
 +                                              &revs->commits);
                }
                if (commit->object.flags & SHOWN)
                        continue;
@@@ -1296,40 -1288,6 +1298,40 @@@ struct commit *get_revision(struct rev_
  {
        struct commit *c = NULL;
  
 +      if (revs->reverse) {
 +              struct commit_list *list;
 +
 +              /*
 +               * rev_info.reverse is used to note the fact that we
 +               * want to output the list of revisions in reverse
 +               * order.  To accomplish this goal, reverse can have
 +               * different values:
 +               *
 +               *  0  do nothing
 +               *  1  reverse the list
 +               *  2  internal use:  we have already obtained and
 +               *     reversed the list, now we only need to yield
 +               *     its items.
 +               */
 +
 +              if (revs->reverse == 1) {
 +                      revs->reverse = 0;
 +                      list = NULL;
 +                      while ((c = get_revision(revs)))
 +                              commit_list_insert(c, &list);
 +                      revs->commits = list;
 +                      revs->reverse = 2;
 +              }
 +
 +              if (!revs->commits)
 +                      return NULL;
 +              c = revs->commits->item;
 +              list = revs->commits->next;
 +              free(revs->commits);
 +              revs->commits = list;
 +              return c;
 +      }
 +
        if (0 < revs->skip_count) {
                while ((c = get_revision_1(revs)) != NULL) {
                        if (revs->skip_count-- <= 0)
        case -1:
                break;
        case 0:
 -              return NULL;
 +              if (revs->boundary) {
 +                      struct commit_list *list = revs->commits;
 +                      while (list) {
 +                              list->item->object.flags |=
 +                                      BOUNDARY_SHOW | BOUNDARY;
 +                              list = list->next;
 +                      }
 +                      /* all remaining commits are boundary commits */
 +                      revs->max_count = -1;
 +                      revs->limited = 1;
 +              } else
 +                      return NULL;
        default:
                revs->max_count--;
        }