Merge branch 'ab/commit-graph-write-progress'
authorJunio C Hamano <gitster@pobox.com>
Tue, 5 Feb 2019 22:26:14 +0000 (14:26 -0800)
committerJunio C Hamano <gitster@pobox.com>
Tue, 5 Feb 2019 22:26:14 +0000 (14:26 -0800)
The codepath to show progress meter while writing out commit-graph
file has been improved.

* ab/commit-graph-write-progress:
commit-graph write: emit a percentage for all progress
commit-graph write: add itermediate progress
commit-graph write: remove empty line for readability
commit-graph write: add more descriptive progress output
commit-graph write: show progress for object search
commit-graph write: more descriptive "writing out" output
commit-graph write: add "Writing out" progress output
commit-graph: don't call write_graph_chunk_extra_edges() unnecessarily
commit-graph: rename "large edges" to "extra edges"

1  2 
commit-graph.c
commit-graph.h
t/t5318-commit-graph.sh
diff --cc commit-graph.c
index 8d52727def0b5981e0ef2697e215d20d98c4dd25,017225cceaf0801ac18237327a3deb91d2804a78..47e9be0a3aad883c17221b11c972b8376a70a555
  #define GRAPH_CHUNKID_OIDFANOUT 0x4f494446 /* "OIDF" */
  #define GRAPH_CHUNKID_OIDLOOKUP 0x4f49444c /* "OIDL" */
  #define GRAPH_CHUNKID_DATA 0x43444154 /* "CDAT" */
- #define GRAPH_CHUNKID_LARGEEDGES 0x45444745 /* "EDGE" */
+ #define GRAPH_CHUNKID_EXTRAEDGES 0x45444745 /* "EDGE" */
  
 -#define GRAPH_DATA_WIDTH 36
 +#define GRAPH_DATA_WIDTH (the_hash_algo->rawsz + 16)
  
  #define GRAPH_VERSION_1 0x1
  #define GRAPH_VERSION GRAPH_VERSION_1
  
- #define GRAPH_OCTOPUS_EDGES_NEEDED 0x80000000
 -#define GRAPH_OID_VERSION_SHA1 1
 -#define GRAPH_OID_LEN_SHA1 GIT_SHA1_RAWSZ
 -#define GRAPH_OID_VERSION GRAPH_OID_VERSION_SHA1
 -#define GRAPH_OID_LEN GRAPH_OID_LEN_SHA1
 -
+ #define GRAPH_EXTRA_EDGES_NEEDED 0x80000000
 -#define GRAPH_PARENT_MISSING 0x7fffffff
  #define GRAPH_EDGE_LAST_MASK 0x7fffffff
  #define GRAPH_PARENT_NONE 0x70000000
  
@@@ -374,8 -343,8 +374,8 @@@ static int fill_commit_in_graph(struct 
        edge_value = get_be32(commit_data + g->hash_len + 4);
        if (edge_value == GRAPH_PARENT_NONE)
                return 1;
-       if (!(edge_value & GRAPH_OCTOPUS_EDGES_NEEDED)) {
+       if (!(edge_value & GRAPH_EXTRA_EDGES_NEEDED)) {
 -              pptr = insert_parent_or_die(g, edge_value, pptr);
 +              pptr = insert_parent_or_die(r, g, edge_value, pptr);
                return 1;
        }
  
@@@ -810,7 -783,9 +825,10 @@@ void write_commit_graph(const char *obj
        int num_extra_edges;
        struct commit_list *parent;
        struct progress *progress = NULL;
 +      const unsigned hashsz = the_hash_algo->rawsz;
+       uint64_t progress_cnt = 0;
+       struct strbuf progress_title = STRBUF_INIT;
+       unsigned long approx_nr_objects;
  
        if (!commit_graph_compatible(the_repository))
                return;
                if (!oideq(&oids.list[i - 1], &oids.list[i]))
                        count_distinct++;
        }
+       stop_progress(&progress);
  
 -      if (count_distinct >= GRAPH_PARENT_MISSING)
 +      if (count_distinct >= GRAPH_EDGE_LAST_MASK)
                die(_("the commit graph format cannot write %d commits"), count_distinct);
  
        commits.nr = 0;
                commits.nr++;
        }
        num_chunks = num_extra_edges ? 4 : 3;
+       stop_progress(&progress);
  
 -      if (commits.nr >= GRAPH_PARENT_MISSING)
 +      if (commits.nr >= GRAPH_EDGE_LAST_MASK)
                die(_("too many commits to write graph"));
  
        compute_generation_numbers(&commits, report_progress);
                hashwrite(f, chunk_write, 12);
        }
  
-       write_graph_chunk_fanout(f, commits.list, commits.nr);
-       write_graph_chunk_oids(f, hashsz, commits.list, commits.nr);
-       write_graph_chunk_data(f, hashsz, commits.list, commits.nr);
-       write_graph_chunk_large_edges(f, commits.list, commits.nr);
+       if (report_progress) {
+               strbuf_addf(&progress_title,
+                           Q_("Writing out commit graph in %d pass",
+                              "Writing out commit graph in %d passes",
+                              num_chunks),
+                           num_chunks);
+               progress = start_delayed_progress(
+                       progress_title.buf,
+                       num_chunks * commits.nr);
+       }
+       write_graph_chunk_fanout(f, commits.list, commits.nr, progress, &progress_cnt);
 -      write_graph_chunk_oids(f, GRAPH_OID_LEN, commits.list, commits.nr, progress, &progress_cnt);
 -      write_graph_chunk_data(f, GRAPH_OID_LEN, commits.list, commits.nr, progress, &progress_cnt);
++      write_graph_chunk_oids(f, hashsz, commits.list, commits.nr, progress, &progress_cnt);
++      write_graph_chunk_data(f, hashsz, commits.list, commits.nr, progress, &progress_cnt);
+       if (num_extra_edges)
+               write_graph_chunk_extra_edges(f, commits.list, commits.nr, progress, &progress_cnt);
+       stop_progress(&progress);
+       strbuf_release(&progress_title);
  
        close_commit_graph(the_repository);
        finalize_hashfile(f, NULL, CSUM_HASH_IN_STREAM | CSUM_FSYNC);
diff --cc commit-graph.h
Simple merge
Simple merge