Merge branch 'pb/config' into next
[gitweb.git] / builtin-log.c
index 6612f4c2a803451a6769d26345089e36b4bc221e..5a8a50b81dabea4ccd9b0ba0fcb5d925a00560d0 100644 (file)
@@ -40,6 +40,8 @@ static int cmd_log_wc(int argc, const char **argv, char **envp,
                log_tree_commit(rev, commit);
                free(commit->buffer);
                commit->buffer = NULL;
+               free_commit_list(commit->parents);
+               commit->parents = NULL;
        }
        return 0;
 }
@@ -51,6 +53,7 @@ int cmd_whatchanged(int argc, const char **argv, char **envp)
        init_revisions(&rev);
        rev.diff = 1;
        rev.diffopt.recursive = 1;
+       rev.simplify_history = 0;
        return cmd_log_wc(argc, argv, envp, &rev);
 }
 
@@ -103,7 +106,7 @@ static int git_format_config(const char *var, const char *value)
 
 
 static FILE *realstdout = NULL;
-static char *output_directory = NULL;
+static const char *output_directory = NULL;
 
 static void reopen_stdout(struct commit *commit, int nr, int keep_subject)
 {
@@ -112,7 +115,7 @@ static void reopen_stdout(struct commit *commit, int nr, int keep_subject)
        int len = 0;
 
        if (output_directory) {
-               strncpy(filename, output_directory, 1010);
+               safe_strncpy(filename, output_directory, 1010);
                len = strlen(filename);
                if (filename[len - 1] != '/')
                        filename[len++] = '/';
@@ -206,19 +209,22 @@ int cmd_format_patch(int argc, const char **argv, char **envp)
                        keep_subject = 1;
                        rev.total = -1;
                }
-               else if (!strcmp(argv[i], "-o")) {
-                       if (argc < 3)
-                               die ("Which directory?");
-                       if (mkdir(argv[i + 1], 0777) < 0 && errno != EEXIST)
-                               die("Could not create directory %s",
-                                               argv[i + 1]);
-                       output_directory = strdup(argv[i + 1]);
+               else if (!strcmp(argv[i], "--output-directory") ||
+                        !strcmp(argv[i], "-o")) {
                        i++;
+                       if (argc <= i)
+                               die("Which directory?");
+                       if (output_directory)
+                               die("Two output directories?");
+                       output_directory = argv[i];
                }
                else if (!strcmp(argv[i], "--signoff") ||
                         !strcmp(argv[i], "-s")) {
-                       const char *committer = git_committer_info(1);
-                       const char *endpos = strchr(committer, '>');
+                       const char *committer;
+                       const char *endpos;
+                       setup_ident();
+                       committer = git_committer_info(1);
+                       endpos = strchr(committer, '>');
                        if (!endpos)
                                die("bogos committer info %s\n", committer);
                        add_signoff = xmalloc(endpos - committer + 2);
@@ -243,8 +249,16 @@ int cmd_format_patch(int argc, const char **argv, char **envp)
        if (argc > 1)
                die ("unrecognized argument: %s", argv[1]);
 
-       if (rev.pending_objects && rev.pending_objects->next == NULL) {
-               rev.pending_objects->item->flags |= UNINTERESTING;
+       if (output_directory) {
+               if (use_stdout)
+                       die("standard output, or directory, which one?");
+               if (mkdir(output_directory, 0777) < 0 && errno != EEXIST)
+                       die("Could not create directory %s",
+                           output_directory);
+       }
+
+       if (rev.pending.nr == 1) {
+               rev.pending.objects[0].item->flags |= UNINTERESTING;
                add_head(&rev);
        }
 
@@ -293,8 +307,6 @@ int cmd_format_patch(int argc, const char **argv, char **envp)
                if (!use_stdout)
                        fclose(stdout);
        }
-       if (output_directory)
-               free(output_directory);
        free(list);
        return 0;
 }