Merge branch 'vm/octopus-merge-bases-simplify'
authorJunio C Hamano <gitster@pobox.com>
Fri, 10 Jan 2014 18:33:45 +0000 (10:33 -0800)
committerJunio C Hamano <gitster@pobox.com>
Fri, 10 Jan 2014 18:33:45 +0000 (10:33 -0800)
* vm/octopus-merge-bases-simplify:
get_octopus_merge_bases(): cleanup redundant variable

1  2 
commit.c
diff --combined commit.c
index b9f9838110b4703a387fa256a138eff74b61589c,249a83b0cc6b91be5206b52e4dbed50c439d2eb6..6bf4fe00d4b0365eca75fd9988852650660b6884
+++ b/commit.c
@@@ -196,19 -196,19 +196,19 @@@ bad_graft_data
  static int read_graft_file(const char *graft_file)
  {
        FILE *fp = fopen(graft_file, "r");
 -      char buf[1024];
 +      struct strbuf buf = STRBUF_INIT;
        if (!fp)
                return -1;
 -      while (fgets(buf, sizeof(buf), fp)) {
 +      while (!strbuf_getwholeline(&buf, fp, '\n')) {
                /* The format is just "Commit Parent1 Parent2 ...\n" */
 -              int len = strlen(buf);
 -              struct commit_graft *graft = read_graft_line(buf, len);
 +              struct commit_graft *graft = read_graft_line(buf.buf, buf.len);
                if (!graft)
                        continue;
                if (register_commit_graft(graft, 1))
 -                      error("duplicate graft data: %s", buf);
 +                      error("duplicate graft data: %s", buf.buf);
        }
        fclose(fp);
 +      strbuf_release(&buf);
        return 0;
  }
  
@@@ -841,26 -841,26 +841,26 @@@ static struct commit_list *merge_bases_
  struct commit_list *get_octopus_merge_bases(struct commit_list *in)
  {
        struct commit_list *i, *j, *k, *ret = NULL;
-       struct commit_list **pptr = &ret;
  
-       for (i = in; i; i = i->next) {
-               if (!ret)
-                       pptr = &commit_list_insert(i->item, pptr)->next;
-               else {
-                       struct commit_list *new = NULL, *end = NULL;
-                       for (j = ret; j; j = j->next) {
-                               struct commit_list *bases;
-                               bases = get_merge_bases(i->item, j->item, 1);
-                               if (!new)
-                                       new = bases;
-                               else
-                                       end->next = bases;
-                               for (k = bases; k; k = k->next)
-                                       end = k;
-                       }
-                       ret = new;
+       if (!in)
+               return ret;
+       commit_list_insert(in->item, &ret);
+       for (i = in->next; i; i = i->next) {
+               struct commit_list *new = NULL, *end = NULL;
+               for (j = ret; j; j = j->next) {
+                       struct commit_list *bases;
+                       bases = get_merge_bases(i->item, j->item, 1);
+                       if (!new)
+                               new = bases;
+                       else
+                               end->next = bases;
+                       for (k = bases; k; k = k->next)
+                               end = k;
                }
+               ret = new;
        }
        return ret;
  }
@@@ -1356,7 -1356,7 +1356,7 @@@ void free_commit_extra_headers(struct c
        }
  }
  
 -int commit_tree(const struct strbuf *msg, unsigned char *tree,
 +int commit_tree(const struct strbuf *msg, const unsigned char *tree,
                struct commit_list *parents, unsigned char *ret,
                const char *author, const char *sign_commit)
  {
@@@ -1485,7 -1485,7 +1485,7 @@@ static const char commit_utf8_warn[] 
  "You may want to amend it after fixing the message, or set the config\n"
  "variable i18n.commitencoding to the encoding your project uses.\n";
  
 -int commit_tree_extended(const struct strbuf *msg, unsigned char *tree,
 +int commit_tree_extended(const struct strbuf *msg, const unsigned char *tree,
                         struct commit_list *parents, unsigned char *ret,
                         const char *author, const char *sign_commit,
                         struct commit_extra_header *extra)