Merge branch 'mk/maint-graph-infinity-loop' into maint
authorJunio C Hamano <gitster@pobox.com>
Mon, 14 Jan 2013 15:32:18 +0000 (07:32 -0800)
committerJunio C Hamano <gitster@pobox.com>
Mon, 14 Jan 2013 15:32:18 +0000 (07:32 -0800)
* mk/maint-graph-infinity-loop:
graph.c: infinite loop in git whatchanged --graph -m

1  2 
graph.c
t/t4202-log.sh
diff --combined graph.c
index e864fe2c6a21379398e454e60627e78a63a09462,d92868ba128efa3b6592ed7921979a61e525d257..391a712e5eafbc05b8d4b739d96aaca0dd481460
+++ b/graph.c
@@@ -7,34 -7,6 +7,34 @@@
  
  /* Internal API */
  
 +/*
 + * Output the next line for a graph.
 + * This formats the next graph line into the specified strbuf.  It is not
 + * terminated with a newline.
 + *
 + * Returns 1 if the line includes the current commit, and 0 otherwise.
 + * graph_next_line() will return 1 exactly once for each time
 + * graph_update() is called.
 + */
 +static int graph_next_line(struct git_graph *graph, struct strbuf *sb);
 +
 +/*
 + * Set up a custom scheme for column colors.
 + *
 + * The default column color scheme inserts ANSI color escapes to colorize
 + * the graph. The various color escapes are stored in an array of strings
 + * where each entry corresponds to a color, except for the last entry,
 + * which denotes the escape for resetting the color back to the default.
 + * When generating the graph, strings from this array are inserted before
 + * and after the various column characters.
 + *
 + * This function allows you to enable a custom array of color escapes.
 + * The 'colors_max' argument is the index of the last "reset" entry.
 + *
 + * This functions must be called BEFORE graph_init() is called.
 + */
 +static void graph_set_column_colors(const char **colors, unsigned short colors_max);
 +
  /*
   * Output a padding line in the graph.
   * This is similar to graph_next_line().  However, it is guaranteed to
@@@ -90,7 -62,7 +90,7 @@@ enum graph_state 
  static const char **column_colors;
  static unsigned short column_colors_max;
  
 -void graph_set_column_colors(const char **colors, unsigned short colors_max)
 +static void graph_set_column_colors(const char **colors, unsigned short colors_max)
  {
        column_colors = colors;
        column_colors_max = colors_max;
@@@ -1144,7 -1116,7 +1144,7 @@@ static void graph_output_collapsing_lin
                graph_update_state(graph, GRAPH_PADDING);
  }
  
 -int graph_next_line(struct git_graph *graph, struct strbuf *sb)
 +static int graph_next_line(struct git_graph *graph, struct strbuf *sb)
  {
        switch (graph->state) {
        case GRAPH_PADDING:
@@@ -1227,7 -1199,7 +1227,7 @@@ void graph_show_commit(struct git_grap
        if (!graph)
                return;
  
-       while (!shown_commit_line) {
+       while (!shown_commit_line && !graph_is_commit_finished(graph)) {
                shown_commit_line = graph_next_line(graph, &msgbuf);
                fwrite(msgbuf.buf, sizeof(char), msgbuf.len, stdout);
                if (!shown_commit_line)
diff --combined t/t4202-log.sh
index a343bf6c629f8e6acaf7559d3168a97fcce9d286,14f73e3bac9a7416dbf26255c76053d8dbb5cb4b..fa686b887d6b49ab8e6d30893501744645f72a91
@@@ -72,9 -72,9 +72,9 @@@ cat > expect << EO
    commit.
  EOF
  
 -test_expect_success 'format %w(12,1,2)' '
 +test_expect_success 'format %w(11,1,2)' '
  
 -      git log -2 --format="%w(12,1,2)This is the %s commit." > actual &&
 +      git log -2 --format="%w(11,1,2)This is the %s commit." > actual &&
        test_cmp expect actual
  '
  
@@@ -178,21 -178,11 +178,21 @@@ test_expect_success 'git log --no-walk 
        test_cmp expect actual
  '
  
 +test_expect_success 'git log --no-walk=sorted <commits> sorts by commit time' '
 +      git log --no-walk=sorted --oneline 5d31159 804a787 394ef78 > actual &&
 +      test_cmp expect actual
 +'
 +
  cat > expect << EOF
  5d31159 fourth
  804a787 sixth
  394ef78 fifth
  EOF
 +test_expect_success 'git log --no-walk=unsorted <commits> leaves list of commits as given' '
 +      git log --no-walk=unsorted --oneline 5d31159 804a787 394ef78 > actual &&
 +      test_cmp expect actual
 +'
 +
  test_expect_success 'git show <commits> leaves list of commits as given' '
        git show --oneline -s 5d31159 804a787 394ef78 > actual &&
        test_cmp expect actual
@@@ -230,12 -220,6 +230,12 @@@ test_expect_success 'log --grep -i' 
        test_cmp expect actual
  '
  
 +test_expect_success 'log -F -E --grep=<ere> uses ere' '
 +      echo second >expect &&
 +      git log -1 --pretty="tformat:%s" -F -E --grep=s.c.nd >actual &&
 +      test_cmp expect actual
 +'
 +
  cat > expect <<EOF
  * Second
  * sixth
@@@ -280,6 -264,16 +280,16 @@@ test_expect_success 'log --graph with m
        test_cmp expect actual
  '
  
+ test_expect_success 'log --raw --graph -m with merge' '
+       git log --raw --graph --oneline -m master | head -n 500 >actual &&
+       grep "initial" actual
+ '
+ test_expect_success 'diff-tree --graph' '
+       git diff-tree --graph master^ | head -n 500 >actual &&
+       grep "one" actual
+ '
  cat > expect <<\EOF
  *   commit master
  |\  Merge: A B
@@@ -819,14 -813,7 +829,14 @@@ sanitize_output () 
  test_expect_success 'log --graph with diff and stats' '
        git log --graph --pretty=short --stat -p >actual &&
        sanitize_output >actual.sanitized <actual &&
 -      test_cmp expect actual.sanitized
 +      test_i18ncmp expect actual.sanitized
 +'
 +
 +test_expect_success 'dotdot is a parent directory' '
 +      mkdir -p a/b &&
 +      ( echo sixth && echo fifth ) >expect &&
 +      ( cd a/b && git log --format=%s .. ) >actual &&
 +      test_cmp expect actual
  '
  
  test_done