Merge branch 'master' into js/fmt-patch
authorJunio C Hamano <junkio@cox.net>
Sat, 6 May 2006 21:42:08 +0000 (14:42 -0700)
committerJunio C Hamano <junkio@cox.net>
Sat, 6 May 2006 21:42:59 +0000 (14:42 -0700)
* master: (109 commits)
t1300-repo-config: two new config parsing tests.
Another config file parsing fix.
update-index: plug memory leak from prefix_path()
checkout-index: plug memory leak from prefix_path()
update-index --unresolve: work from a subdirectory.
pack-object: squelch eye-candy on non-tty
core.prefersymlinkrefs: use symlinks for .git/HEAD
repo-config: trim white-space before comment
Fix for config file section parsing.
Clarify git-cherry documentation.
Update git-unpack-objects documentation.
Fix up docs where "--" isn't displayed correctly.
Several trivial documentation touch ups.
git-svn 1.0.0
git-svn: documentation updates
delta: stricter constness
Makefile: do not link rev-list any specially.
builtin-push: --all and --tags _are_ explicit refspecs
builtin-log/whatchanged/show: make them official.
show-branch: omit uninteresting merges.
...

1  2 
builtin.h
cache.h
git.c
log-tree.c
show-branch.c
diff --combined builtin.h
index 94dc0732f9f42069f375673ce1b26aa0b43c26e6,bb63f0729a4a05e60ef3e609b971bdf57b60b06d..635a00bf7a20ef347944f364c5f89e978ce50af9
+++ b/builtin.h
@@@ -19,6 -19,9 +19,10 @@@ extern int cmd_version(int argc, const 
  extern int cmd_whatchanged(int argc, const char **argv, char **envp);
  extern int cmd_show(int argc, const char **argv, char **envp);
  extern int cmd_log(int argc, const char **argv, char **envp);
+ extern int cmd_diff(int argc, const char **argv, char **envp);
 +extern int cmd_format_patch(int argc, const char **argv, char **envp);
+ extern int cmd_count_objects(int argc, const char **argv, char **envp);
+ extern int cmd_push(int argc, const char **argv, char **envp);
  
  #endif
diff --combined cache.h
index f6c590959853f88a2184cbfe433ad9b88a621546,9d0ddcff016be608e91f105ef7cbb975fb49198a..605b80e268684ebdd1f0d707b307ade48ac24d03
+++ b/cache.h
@@@ -134,6 -134,8 +134,8 @@@ extern const char *setup_git_directory_
  extern const char *setup_git_directory(void);
  extern const char *prefix_path(const char *prefix, int len, const char *path);
  extern const char *prefix_filename(const char *prefix, int len, const char *path);
+ extern void verify_filename(const char *prefix, const char *name);
+ extern void verify_non_filename(const char *prefix, const char *name);
  
  #define alloc_nr(x) (((x)+16)*3/2)
  
@@@ -167,7 -169,7 +169,7 @@@ extern void rollback_index_file(struct 
  /* Environment bits from configuration mechanism */
  extern int trust_executable_bit;
  extern int assume_unchanged;
- extern int only_use_symrefs;
+ extern int prefer_symlink_refs;
  extern int warn_ambiguous_refs;
  extern int diff_rename_limit_default;
  extern int shared_repository;
@@@ -249,7 -251,6 +251,7 @@@ extern void *read_object_with_reference
                                        unsigned char *sha1_ret);
  
  const char *show_date(unsigned long time, int timezone);
 +const char *show_rfc2822_date(unsigned long time, int timezone);
  int parse_date(const char *date, char *buf, int bufsize);
  void datestamp(char *buf, int bufsize);
  unsigned long approxidate(const char *);
diff --combined git.c
index 619c6654e45d0208adefc6aecf723c5c25fd4a7b,49ba5189d923493aaed40a6a0fccc2ead040b06a..a8f7926b4875512b1d93768c1bc6d934111954f6
--- 1/git.c
--- 2/git.c
+++ b/git.c
@@@ -8,7 -8,6 +8,6 @@@
  #include <errno.h>
  #include <limits.h>
  #include <stdarg.h>
- #include <sys/ioctl.h>
  #include "git-compat-util.h"
  #include "exec_cmd.h"
  
@@@ -47,7 -46,9 +46,10 @@@ static void handle_internal_command(in
                { "log", cmd_log },
                { "whatchanged", cmd_whatchanged },
                { "show", cmd_show },
+               { "push", cmd_push },
 +              { "fmt-patch", cmd_format_patch },
+               { "count-objects", cmd_count_objects },
+               { "diff", cmd_diff },
        };
        int i;
  
diff --combined log-tree.c
index 4a3cd6791b43c9dd98c0237e9b0577deca9d1b37,b90ba6762ad0aa469a19c42cf8d53f7a79db02d5..526d578e98eef5a099be43bf39a300b33ac1991c
@@@ -3,6 -3,15 +3,15 @@@
  #include "commit.h"
  #include "log-tree.h"
  
+ static void show_parents(struct commit *commit, int abbrev)
+ {
+       struct commit_list *p;
+       for (p = commit->parents; p ; p = p->next) {
+               struct commit *parent = p->item;
+               printf(" %s", diff_unique_abbrev(parent->object.sha1, abbrev));
+       }
+ }
  void show_log(struct rev_info *opt, struct log_info *log, const char *sep)
  {
        static char this_header[16384];
        int abbrev_commit = opt->abbrev_commit ? opt->abbrev : 40;
        const char *extra;
        int len;
 +      char* subject = NULL;
  
        opt->loginfo = NULL;
        if (!opt->verbose_header) {
-               puts(sha1_to_hex(commit->object.sha1));
+               fputs(diff_unique_abbrev(commit->object.sha1, abbrev_commit), stdout);
+               if (opt->parents)
+                       show_parents(commit, abbrev_commit);
+               putchar('\n');
                return;
        }
  
        /*
         * Print header line of header..
         */
 -      printf("%s%s",
 -              opt->commit_format == CMIT_FMT_ONELINE ? "" : "commit ",
 -              diff_unique_abbrev(commit->object.sha1, abbrev_commit));
 -      if (opt->parents)
 -              show_parents(commit, abbrev_commit);
 -      if (parent)
 -              printf(" (from %s)", diff_unique_abbrev(parent->object.sha1, abbrev_commit));
 -      putchar(opt->commit_format == CMIT_FMT_ONELINE ? ' ' : '\n');
 +
 +      if (opt->commit_format == CMIT_FMT_EMAIL) {
 +              if (opt->total > 0) {
 +                      static char buffer[64];
 +                      snprintf(buffer, sizeof(buffer),
 +                                      "Subject: [PATCH %d/%d] ",
 +                                      opt->nr, opt->total);
 +                      subject = buffer;
 +              } else if (opt->total == 0)
 +                      subject = "Subject: [PATCH] ";
 +              else
 +                      subject = "Subject: ";
 +
 +              printf("From %s  Thu Apr 7 15:13:13 2005\n",
 +                     sha1_to_hex(commit->object.sha1));
 +      } else {
 +              printf("%s%s",
 +                     opt->commit_format == CMIT_FMT_ONELINE ? "" : "commit ",
 +                     diff_unique_abbrev(commit->object.sha1, abbrev_commit));
++              if (opt->parents)
++                      show_parents(commit, abbrev_commit);
 +              if (parent) 
 +                      printf(" (from %s)",
 +                             diff_unique_abbrev(parent->object.sha1,
 +                                                abbrev_commit));
 +              putchar(opt->commit_format == CMIT_FMT_ONELINE ? ' ' : '\n');
 +      }
  
        /*
         * And then the pretty-printed message itself
         */
 -      len = pretty_print_commit(opt->commit_format, commit, ~0u, this_header, sizeof(this_header), abbrev);
 +      len = pretty_print_commit(opt->commit_format, commit, ~0u, this_header, sizeof(this_header), abbrev, subject);
        printf("%s%s%s", this_header, extra, sep);
  }
  
@@@ -172,18 -166,15 +186,18 @@@ static int log_tree_diff(struct rev_inf
  int log_tree_commit(struct rev_info *opt, struct commit *commit)
  {
        struct log_info log;
 +      int shown;
  
        log.commit = commit;
        log.parent = NULL;
        opt->loginfo = &log;
  
 -      if (!log_tree_diff(opt, commit, &log) && opt->loginfo && opt->always_show_header) {
 +      shown = log_tree_diff(opt, commit, &log);
 +      if (!shown && opt->loginfo && opt->always_show_header) {
                log.parent = NULL;
                show_log(opt, opt->loginfo, "");
 +              shown = 1;
        }
        opt->loginfo = NULL;
 -      return 0;
 +      return shown;
  }
diff --combined show-branch.c
index 5da3a1a90b23646eee18046ba33efe8953f8ba67,268c57b180627f7d8ba3a3a754210a37d420fb0d..bbe26c2e7af7515d07af990a4db67c62ee14eb36
@@@ -5,7 -5,7 +5,7 @@@
  #include "refs.h"
  
  static const char show_branch_usage[] =
- "git-show-branch [--current] [--all] [--heads] [--tags] [--topo-order] [--more=count | --list | --independent | --merge-base ] [--topics] [<refs>...]";
+ "git-show-branch [--dense] [--current] [--all] [--heads] [--tags] [--topo-order] [--more=count | --list | --independent | --merge-base ] [--topics] [<refs>...]";
  
  static int default_num = 0;
  static int default_alloc = 0;
@@@ -259,7 -259,7 +259,7 @@@ static void show_one_commit(struct comm
        struct commit_name *name = commit->object.util;
        if (commit->object.parsed)
                pretty_print_commit(CMIT_FMT_ONELINE, commit, ~0,
 -                                  pretty, sizeof(pretty), 0);
 +                                  pretty, sizeof(pretty), 0, NULL);
        else
                strcpy(pretty, "(unavailable)");
        if (!strncmp(pretty, "[PATCH] ", 8))
@@@ -527,6 -527,27 +527,27 @@@ static int git_show_branch_config(cons
        return git_default_config(var, value);
  }
  
+ static int omit_in_dense(struct commit *commit, struct commit **rev, int n)
+ {
+       /* If the commit is tip of the named branches, do not
+        * omit it.
+        * Otherwise, if it is a merge that is reachable from only one
+        * tip, it is not that interesting.
+        */
+       int i, flag, count;
+       for (i = 0; i < n; i++)
+               if (rev[i] == commit)
+                       return 0;
+       flag = commit->object.flags;
+       for (i = count = 0; i < n; i++) {
+               if (flag & (1u << (i + REV_SHIFT)))
+                       count++;
+       }
+       if (count == 1)
+               return 1;
+       return 0;
+ }
  int main(int ac, char **av)
  {
        struct commit *rev[MAX_REVS], *commit;
        int with_current_branch = 0;
        int head_at = -1;
        int topics = 0;
+       int dense = 1;
  
        setup_git_directory();
        git_config(git_show_branch_config);
                        lifo = 1;
                else if (!strcmp(arg, "--topics"))
                        topics = 1;
+               else if (!strcmp(arg, "--sparse"))
+                       dense = 0;
                else if (!strcmp(arg, "--date-order"))
                        lifo = 0;
                else
                shown_merge_point |= is_merge_point;
  
                if (1 < num_rev) {
-                       int is_merge = !!(commit->parents && commit->parents->next);
+                       int is_merge = !!(commit->parents &&
+                                         commit->parents->next);
                        if (topics &&
                            !is_merge_point &&
                            (this_flag & (1u << REV_SHIFT)))
                                continue;
+                       if (dense && is_merge &&
+                           omit_in_dense(commit, rev, num_rev))
+                               continue;
                        for (i = 0; i < num_rev; i++) {
                                int mark;
                                if (!(this_flag & (1u << (i + REV_SHIFT))))