let pack-objects do the writing of unreachable objects as loose objects
[gitweb.git] / builtin-log.c
index 836b61ec57b37499950e3a0244e2d0261024204a..256bbac93a3927adfbd12b124f9c838a4101120d 100644 (file)
@@ -20,6 +20,7 @@
 
 static int default_show_root = 1;
 static const char *fmt_patch_subject_prefix = "PATCH";
+static const char *fmt_pretty;
 
 static void add_name_decoration(const char *prefix, const char *name, struct object *obj)
 {
@@ -54,6 +55,8 @@ static void cmd_log_init(int argc, const char **argv, const char *prefix,
 
        rev->abbrev = DEFAULT_ABBREV;
        rev->commit_format = CMIT_FMT_DEFAULT;
+       if (fmt_pretty)
+               get_commit_format(fmt_pretty, rev);
        rev->verbose_header = 1;
        DIFF_OPT_SET(&rev->diffopt, RECURSIVE);
        rev->show_root_diff = default_show_root;
@@ -221,6 +224,8 @@ static int cmd_log_walk(struct rev_info *rev)
 
 static int git_log_config(const char *var, const char *value)
 {
+       if (!strcmp(var, "format.pretty"))
+               return git_config_string(&fmt_pretty, var, value);
        if (!strcmp(var, "format.subjectprefix")) {
                if (!value)
                        config_error_nonbool(var);
@@ -395,6 +400,7 @@ int cmd_log_reflog(int argc, const char **argv, const char *prefix)
         * allow us to set a different default.
         */
        rev.commit_format = CMIT_FMT_ONELINE;
+       rev.use_terminator = 1;
        rev.always_show_header = 1;
 
        /*
@@ -647,8 +653,7 @@ static void make_cover_letter(struct rev_info *rev, int use_stdout,
                              int nr, struct commit **list, struct commit *head)
 {
        const char *committer;
-       const char *origin_sha1, *head_sha1;
-       const char *argv[7];
+       char *head_sha1;
        const char *subject_start = NULL;
        const char *body = "*** SUBJECT HERE ***\n\n*** BLURB HERE ***\n";
        const char *msg;
@@ -657,6 +662,8 @@ static void make_cover_letter(struct rev_info *rev, int use_stdout,
        struct strbuf sb;
        int i;
        const char *encoding = "utf-8";
+       struct diff_options opts;
+       int need_8bit_cte = 0;
 
        if (rev->commit_format != CMIT_FMT_EMAIL)
                die("Cover letter needs email format");
@@ -667,7 +674,8 @@ static void make_cover_letter(struct rev_info *rev, int use_stdout,
 
        head_sha1 = sha1_to_hex(head->object.sha1);
 
-       log_write_email_headers(rev, head_sha1, &subject_start, &extra_headers);
+       log_write_email_headers(rev, head_sha1, &subject_start, &extra_headers,
+                               &need_8bit_cte);
 
        committer = git_committer_info(0);
 
@@ -676,13 +684,17 @@ static void make_cover_letter(struct rev_info *rev, int use_stdout,
        pp_user_info(NULL, CMIT_FMT_EMAIL, &sb, committer, DATE_RFC2822,
                     encoding);
        pp_title_line(CMIT_FMT_EMAIL, &msg, &sb, subject_start, extra_headers,
-                     encoding, 0);
+                     encoding, need_8bit_cte);
        pp_remainder(CMIT_FMT_EMAIL, &msg, &sb, 0);
        printf("%s\n", sb.buf);
 
        strbuf_release(&sb);
 
        shortlog_init(&log);
+       log.wrap_lines = 1;
+       log.wrap = 72;
+       log.in1 = 2;
+       log.in2 = 4;
        for (i = 0; i < nr; i++)
                shortlog_add_commit(&log, list[i]);
 
@@ -694,20 +706,17 @@ static void make_cover_letter(struct rev_info *rev, int use_stdout,
        if (!origin)
                return;
 
-       origin_sha1 = sha1_to_hex(origin->object.sha1);
+       memcpy(&opts, &rev->diffopt, sizeof(opts));
+       opts.output_format = DIFF_FORMAT_SUMMARY | DIFF_FORMAT_DIFFSTAT;
 
-       argv[0] = "diff";
-       argv[1] = "--stat";
-       argv[2] = "--summary";
-       argv[3] = head_sha1;
-       argv[4] = "--not";
-       argv[5] = origin_sha1;
-       argv[6] = "--";
-       argv[7] = NULL;
-       fflush(stdout);
-       run_command_v_opt(argv, RUN_GIT_CMD);
+       diff_setup_done(&opts);
+
+       diff_tree_sha1(origin->tree->object.sha1,
+                      head->tree->object.sha1,
+                      "", &opts);
+       diffcore_std(&opts);
+       diff_flush(&opts);
 
-       fflush(stdout);
        printf("\n");
 }
 
@@ -761,7 +770,6 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
        rev.diff = 1;
        rev.combine_merges = 0;
        rev.ignore_merges = 1;
-       rev.diffopt.msg_sep = "";
        DIFF_OPT_SET(&rev.diffopt, RECURSIVE);
 
        rev.subject_prefix = fmt_patch_subject_prefix;