Merge branch 'ds/commit-graph-incremental'
authorJunio C Hamano <gitster@pobox.com>
Fri, 9 Aug 2019 17:13:13 +0000 (10:13 -0700)
committerJunio C Hamano <gitster@pobox.com>
Fri, 9 Aug 2019 17:13:13 +0000 (10:13 -0700)
Leakfix.

* ds/commit-graph-incremental:
commit-graph: release strbufs after use

1  2 
commit-graph.c
diff --combined commit-graph.c
index 90fdee9256977ad4626737b5acbd4d4e6c0ad48d,fa0760c430cd6a007972affa9e40742e5e41f106..fe954ab5f845e65bc5cad987308aeb6598f2fd24
@@@ -297,10 -297,8 +297,10 @@@ struct commit_graph *parse_commit_graph
  
        hashcpy(graph->oid.hash, graph->data + graph->data_len - graph->hash_len);
  
 -      if (verify_commit_graph_lite(graph))
 +      if (verify_commit_graph_lite(graph)) {
 +              free(graph);
                return NULL;
 +      }
  
        return graph;
  }
@@@ -434,6 -432,7 +434,7 @@@ static struct commit_graph *load_commit
  
        free(oids);
        fclose(fp);
+       strbuf_release(&line);
  
        return graph_chain;
  }
@@@ -590,11 -589,6 +591,11 @@@ static void fill_commit_graph_info(stru
        item->generation = get_be32(commit_data + g->hash_len + 8) >> 2;
  }
  
 +static inline void set_commit_tree(struct commit *c, struct tree *t)
 +{
 +      c->maybe_tree = t;
 +}
 +
  static int fill_commit_in_graph(struct repository *r,
                                struct commit *item,
                                struct commit_graph *g, uint32_t pos)
  
        item->object.parsed = 1;
  
 -      item->maybe_tree = NULL;
 +      set_commit_tree(item, NULL);
  
        date_high = get_be32(commit_data + g->hash_len + 8) & 0x3;
        date_low = get_be32(commit_data + g->hash_len + 12);
@@@ -725,7 -719,7 +726,7 @@@ static struct tree *load_tree_for_commi
                        GRAPH_DATA_WIDTH * (c->graph_pos - g->num_commits_in_base);
  
        hashcpy(oid.hash, commit_data);
 -      c->maybe_tree = lookup_tree(r, &oid);
 +      set_commit_tree(c, lookup_tree(r, &oid));
  
        return c->maybe_tree;
  }
@@@ -1186,7 -1180,7 +1187,7 @@@ static int fill_oids_from_packs(struct 
        }
  
        stop_progress(&ctx->progress);
-       strbuf_reset(&progress_title);
+       strbuf_release(&progress_title);
        strbuf_release(&packname);
  
        return 0;
@@@ -1636,7 -1630,7 +1637,7 @@@ static void sort_and_scan_merged_commit
                                num_parents++;
  
                        if (num_parents > 2)
 -                              ctx->num_extra_edges += num_parents - 2;
 +                              ctx->num_extra_edges += num_parents - 1;
                }
        }
  
@@@ -1713,10 -1707,8 +1714,8 @@@ static void expire_commit_graphs(struc
        strbuf_addstr(&path, "/info/commit-graphs");
        dir = opendir(path.buf);
  
-       if (!dir) {
-               strbuf_release(&path);
-               return;
-       }
+       if (!dir)
+               goto out;
  
        strbuf_addch(&path, '/');
        dirnamelen = path.len;
                if (!found)
                        unlink(path.buf);
        }
+ out:
+       strbuf_release(&path);
  }
  
  int write_commit_graph(const char *obj_dir,
@@@ -1995,7 -1990,7 +1997,7 @@@ int verify_commit_graph(struct reposito
                hashcpy(cur_oid.hash, g->chunk_oid_lookup + g->hash_len * i);
  
                graph_commit = lookup_commit(r, &cur_oid);
 -              odb_commit = (struct commit *)create_object(r, cur_oid.hash, alloc_commit_node(r));
 +              odb_commit = (struct commit *)create_object(r, &cur_oid, alloc_commit_node(r));
                if (parse_commit_internal(odb_commit, 0, 0)) {
                        graph_report(_("failed to parse commit %s from object database for commit-graph"),
                                     oid_to_hex(&cur_oid));