Merge branch 'lt/logopt' into next
authorJunio C Hamano <junkio@cox.net>
Tue, 18 Apr 2006 06:15:41 +0000 (23:15 -0700)
committerJunio C Hamano <junkio@cox.net>
Tue, 18 Apr 2006 06:15:41 +0000 (23:15 -0700)
* lt/logopt:
combine-diff: show diffstat with the first parent.
git.c: LOGSIZE is unused after log printing cleanup.
Log message printout cleanups (#3): fix --pretty=oneline
Log message printout cleanups (#2)
Log message printout cleanups
rev-list --header: output format fix

1  2 
combine-diff.c
rev-list.c
revision.c
revision.h
diff --combined combine-diff.c
index 9445e86c2f329858d5b805d144d6668526e0c289,27f6f57f3ab8e94e853d67ba031437fe6491d52d..ca36f5d5e7342e9198675ce0faf11ba49ca67876
@@@ -5,6 -5,7 +5,7 @@@
  #include "diffcore.h"
  #include "quote.h"
  #include "xdiff-interface.h"
+ #include "log-tree.h"
  
  static int uninteresting(struct diff_filepair *p)
  {
@@@ -584,12 -585,22 +585,22 @@@ static void reuse_combine_diff(struct s
        sline->p_lno[i] = sline->p_lno[j];
  }
  
+ static void dump_quoted_path(const char *prefix, const char *path)
+ {
+       fputs(prefix, stdout);
+       if (quote_c_style(path, NULL, NULL, 0))
+               quote_c_style(path, NULL, stdout, 0);
+       else
+               printf("%s", path);
+       putchar('\n');
+ }
  static int show_patch_diff(struct combine_diff_path *elem, int num_parent,
-                          int dense, const char *header,
-                          struct diff_options *opt)
+                          int dense, struct rev_info *rev)
  {
+       struct diff_options *opt = &rev->diffopt;
        unsigned long result_size, cnt, lno;
 -      char *result, *cp, *ep;
 +      char *result, *cp;
        struct sline *sline; /* survived lines */
        int mode_differs = 0;
        int i, show_hunks, shown_header = 0;
                cnt++; /* incomplete line */
  
        sline = xcalloc(cnt+2, sizeof(*sline));
 -      ep = result;
        sline[0].bol = result;
        for (lno = 0; lno <= cnt + 1; lno++) {
                sline[lno].lost_tail = &sline[lno].lost_head;
        if (show_hunks || mode_differs || working_tree_file) {
                const char *abb;
  
-               if (header) {
-                       shown_header++;
-                       printf("%s%c", header, opt->line_termination);
-               }
-               printf("diff --%s ", dense ? "cc" : "combined");
-               if (quote_c_style(elem->path, NULL, NULL, 0))
-                       quote_c_style(elem->path, NULL, stdout, 0);
-               else
-                       printf("%s", elem->path);
-               putchar('\n');
+               if (rev->loginfo)
+                       show_log(rev, rev->loginfo, "\n");
+               dump_quoted_path(dense ? "diff --cc " : "diff --combined ", elem->path);
                printf("index ");
                for (i = 0; i < num_parent; i++) {
                        abb = find_unique_abbrev(elem->parent[i].sha1,
                        }
                        putchar('\n');
                }
+               dump_quoted_path("--- a/", elem->path);
+               dump_quoted_path("+++ b/", elem->path);
                dump_sline(sline, cnt, num_parent);
        }
        free(result);
  
  #define COLONS "::::::::::::::::::::::::::::::::"
  
- static void show_raw_diff(struct combine_diff_path *p, int num_parent, const char *header, struct diff_options *opt)
+ static void show_raw_diff(struct combine_diff_path *p, int num_parent, struct rev_info *rev)
  {
 -      int i, offset, mod_type = 'A';
+       struct diff_options *opt = &rev->diffopt;
 +      int i, offset;
        const char *prefix;
        int line_termination, inter_name_termination;
  
        if (!line_termination)
                inter_name_termination = 0;
  
-       if (header)
-               printf("%s%c", header, line_termination);
+       if (rev->loginfo)
+               show_log(rev, rev->loginfo, "\n");
  
 -      for (i = 0; i < num_parent; i++) {
 -              if (p->parent[i].mode)
 -                      mod_type = 'M';
 -      }
 -      if (!p->mode)
 -              mod_type = 'D';
 -
        if (opt->output_format == DIFF_FORMAT_RAW) {
                offset = strlen(COLONS) - num_parent;
                if (offset < 0)
        }
  }
  
int show_combined_diff(struct combine_diff_path *p,
void show_combined_diff(struct combine_diff_path *p,
                       int num_parent,
                       int dense,
-                      const char *header,
-                      struct diff_options *opt)
+                      struct rev_info *rev)
  {
+       struct diff_options *opt = &rev->diffopt;
        if (!p->len)
-               return 0;
+               return;
        switch (opt->output_format) {
        case DIFF_FORMAT_RAW:
        case DIFF_FORMAT_NAME_STATUS:
        case DIFF_FORMAT_NAME:
-               show_raw_diff(p, num_parent, header, opt);
-               return 1;
-       default:
+               show_raw_diff(p, num_parent, rev);
+               return;
        case DIFF_FORMAT_PATCH:
-               return show_patch_diff(p, num_parent, dense, header, opt);
+               show_patch_diff(p, num_parent, dense, rev);
+               return;
+       default:
+               return;
        }
  }
  
- const char *diff_tree_combined_merge(const unsigned char *sha1,
-                            const char *header, int dense,
-                            struct diff_options *opt)
+ void diff_tree_combined_merge(const unsigned char *sha1,
+                            int dense, struct rev_info *rev)
  {
+       struct diff_options *opt = &rev->diffopt;
        struct commit *commit = lookup_commit(sha1);
        struct diff_options diffopts;
        struct commit_list *parents;
        struct combine_diff_path *p, *paths = NULL;
        int num_parent, i, num_paths;
+       int do_diffstat;
  
+       do_diffstat = (opt->output_format == DIFF_FORMAT_DIFFSTAT ||
+                      opt->with_stat);
        diffopts = *opt;
-       diffopts.output_format = DIFF_FORMAT_NO_OUTPUT;
        diffopts.with_raw = 0;
+       diffopts.with_stat = 0;
        diffopts.recursive = 1;
  
        /* count parents */
             parents;
             parents = parents->next, i++) {
                struct commit *parent = parents->item;
+               /* show stat against the first parent even
+                * when doing combined diff.
+                */
+               if (i == 0 && do_diffstat)
+                       diffopts.output_format = DIFF_FORMAT_DIFFSTAT;
+               else
+                       diffopts.output_format = DIFF_FORMAT_NO_OUTPUT;
                diff_tree_sha1(parent->object.sha1, commit->object.sha1, "",
                               &diffopts);
                diffcore_std(&diffopts);
                paths = intersect_paths(paths, i, num_parent);
+               if (do_diffstat && rev->loginfo)
+                       show_log(rev, rev->loginfo,
+                                opt->with_stat ? "---\n" : "\n");
                diff_flush(&diffopts);
+               if (opt->with_stat)
+                       putchar('\n');
        }
  
        /* find out surviving paths */
                        int saved_format = opt->output_format;
                        opt->output_format = DIFF_FORMAT_RAW;
                        for (p = paths; p; p = p->next) {
-                               if (show_combined_diff(p, num_parent, dense,
-                                                      header, opt))
-                                       header = NULL;
+                               show_combined_diff(p, num_parent, dense, rev);
                        }
                        opt->output_format = saved_format;
                        putchar(opt->line_termination);
                }
                for (p = paths; p; p = p->next) {
-                       if (show_combined_diff(p, num_parent, dense,
-                                              header, opt))
-                               header = NULL;
+                       show_combined_diff(p, num_parent, dense, rev);
                }
        }
  
                paths = paths->next;
                free(tmp);
        }
-       return header;
  }
diff --combined rev-list.c
index b75da12408c58576264a72014c4791969c253308,a4d72af6e01d88aa41962736d9a52f58bf65aad7..8b0ec388fa0afe5ffb28c94f2e75544612ab7265
@@@ -8,9 -8,9 +8,9 @@@
  #include "diff.h"
  #include "revision.h"
  
 -/* bits #0-6 in revision.h */
 +/* bits #0-15 in revision.h */
  
 -#define COUNTED               (1u<<7)
 +#define COUNTED               (1u<<16)
  
  static const char rev_list_usage[] =
  "git-rev-list [OPTION] <commit-id>... [ -- paths... ]\n"
@@@ -41,13 -41,14 +41,14 @@@ struct rev_info revs
  static int bisect_list = 0;
  static int show_timestamp = 0;
  static int hdr_termination = 0;
+ static const char *header_prefix;
  
  static void show_commit(struct commit *commit)
  {
        if (show_timestamp)
                printf("%lu ", commit->date);
-       if (*revs.header_prefix)
-               fputs(revs.header_prefix, stdout);
+       if (header_prefix)
+               fputs(header_prefix, stdout);
        if (commit->object.flags & BOUNDARY)
                putchar('-');
        if (revs.abbrev_commit && revs.abbrev)
@@@ -322,10 -323,13 +323,13 @@@ int main(int argc, const char **argv
                /* The command line has a --pretty  */
                hdr_termination = '\n';
                if (revs.commit_format == CMIT_FMT_ONELINE)
-                       revs.header_prefix = "";
+                       header_prefix = "";
                else
-                       revs.header_prefix = "commit ";
+                       header_prefix = "commit ";
        }
+       else if (revs.verbose_header)
+               /* Only --header was specified */
+               revs.commit_format = CMIT_FMT_RAW;
  
        list = revs.commits;
  
  
        save_commit_buffer = revs.verbose_header;
        track_object_refs = 0;
 +      if (bisect_list)
 +              revs.limited = 1;
  
        prepare_revision_walk(&revs);
        if (revs.tree_objects)
diff --combined revision.c
index 3cd6a2ed9f978776b2a021747f3f0995ebb70b28,5abec18bc1ce161a2964dfa89f967ec7a0ec2fde..2976497ebf6843e91d954475af3a61e9ba734cb4
@@@ -498,7 -498,6 +498,6 @@@ void init_revisions(struct rev_info *re
        revs->topo_setter = topo_sort_default_setter;
        revs->topo_getter = topo_sort_default_getter;
  
-       revs->header_prefix = "";
        revs->commit_format = CMIT_FMT_DEFAULT;
  
        diff_setup(&revs->diffopt);
@@@ -675,12 -674,10 +674,10 @@@ int setup_revisions(int argc, const cha
                        }
                        if (!strcmp(arg, "-v")) {
                                revs->verbose_header = 1;
-                               revs->header_prefix = "diff-tree ";
                                continue;
                        }
                        if (!strncmp(arg, "--pretty", 8)) {
                                revs->verbose_header = 1;
-                               revs->header_prefix = "diff-tree ";
                                revs->commit_format = get_commit_format(arg+8);
                                continue;
                        }
@@@ -856,17 -853,6 +853,17 @@@ static void rewrite_parents(struct rev_
        }
  }
  
 +static void mark_boundary_to_show(struct commit *commit)
 +{
 +      struct commit_list *p = commit->parents;
 +      while (p) {
 +              commit = p->item;
 +              p = p->next;
 +              if (commit->object.flags & BOUNDARY)
 +                      commit->object.flags |= BOUNDARY_SHOW;
 +      }
 +}
 +
  struct commit *get_revision(struct rev_info *revs)
  {
        struct commit_list *list = revs->commits;
                }
                if (commit->object.flags & SHOWN)
                        continue;
 -              if (!(commit->object.flags & BOUNDARY) &&
 -                  (commit->object.flags & UNINTERESTING))
 +
 +              /* We want to show boundary commits only when their
 +               * children are shown.  When path-limiter is in effect,
 +               * rewrite_parents() drops some commits from getting shown,
 +               * and there is no point showing boundary parents that
 +               * are not shown.  After rewrite_parents() rewrites the
 +               * parents of a commit that is shown, we mark the boundary
 +               * parents with BOUNDARY_SHOW.
 +               */
 +              if (commit->object.flags & BOUNDARY_SHOW) {
 +                      commit->object.flags |= SHOWN;
 +                      return commit;
 +              }
 +              if (commit->object.flags & UNINTERESTING)
                        continue;
                if (revs->min_age != -1 && (commit->date > revs->min_age))
                        continue;
                        if (revs->parents)
                                rewrite_parents(revs, commit);
                }
 +              if (revs->boundary)
 +                      mark_boundary_to_show(commit);
                commit->object.flags |= SHOWN;
                return commit;
        } while (revs->commits);
diff --combined revision.h
index 872bcd81725d08d20ece460a5898e0c9ea2ca3a1,05f658a214a7e1ca7e009c0de9667bf66552dc47..48d7b4ca94f3fd00f7a1f6a3fb57ebed934ffc0d
@@@ -7,10 -7,10 +7,11 @@@
  #define SHOWN         (1u<<3)
  #define TMP_MARK      (1u<<4) /* for isolated cases; clean after use */
  #define BOUNDARY      (1u<<5)
 -#define ADDED         (1u<<6) /* Parents already parsed and added? */
 +#define BOUNDARY_SHOW (1u<<6)
 +#define ADDED         (1u<<7) /* Parents already parsed and added? */
  
  struct rev_info;
+ struct log_info;
  
  typedef void (prune_fn_t)(struct rev_info *revs, struct commit *commit);
  
@@@ -52,12 -52,11 +53,11 @@@ struct rev_info 
                        always_show_header:1;
  
        /* Format info */
-       unsigned int    abbrev_commit:1;
+       unsigned int    shown_one:1,
+                       abbrev_commit:1;
        unsigned int    abbrev;
        enum cmit_fmt   commit_format;
-       const char      *header_prefix;
-       const char      *header;
-       const char      *use_precomputed_header;
+       struct log_info *loginfo;
  
        /* special limits */
        int max_count;