Merge branch 'jc/make-static'
authorJunio C Hamano <gitster@pobox.com>
Tue, 18 Sep 2012 21:37:46 +0000 (14:37 -0700)
committerJunio C Hamano <gitster@pobox.com>
Tue, 18 Sep 2012 21:37:46 +0000 (14:37 -0700)
Turn many file-scope private symbols to static to reduce the
global namespace contamination.

* jc/make-static:
sequencer.c: mark a private file-scope symbol as static
ident.c: mark private file-scope symbols as static
trace.c: mark a private file-scope symbol as static
wt-status.c: mark a private file-scope symbol as static
read-cache.c: mark a private file-scope symbol as static
strbuf.c: mark a private file-scope symbol as static
sha1-array.c: mark a private file-scope symbol as static
symlinks.c: mark private file-scope symbols as static
notes.c: mark a private file-scope symbol as static
rerere.c: mark private file-scope symbols as static
graph.c: mark private file-scope symbols as static
diff.c: mark a private file-scope symbol as static
commit.c: mark a file-scope private symbol as static
builtin/notes.c: mark file-scope private symbols as static

1  2 
diff.c
sequencer.c
sequencer.h
diff --combined diff.c
index 32142dba64e0a6e926101c38b6efd95d21e0dc82,ddcdfed7879d6cca568544e3256c1e2df5973089..35d3f073859acf66dbd38c6096c0cc47bd26b6e2
--- 1/diff.c
--- 2/diff.c
+++ b/diff.c
@@@ -25,7 -25,7 +25,7 @@@
  static int diff_detect_rename_default;
  static int diff_rename_limit_default = 400;
  static int diff_suppress_blank_empty;
- int diff_use_color_default = -1;
static int diff_use_color_default = -1;
  static const char *diff_word_regex_cfg;
  static const char *external_diff_cmd_cfg;
  int diff_auto_refresh_index = 1;
@@@ -1398,11 -1398,11 +1398,11 @@@ int print_stat_summary(FILE *fp, int fi
  
        if (!files) {
                assert(insertions == 0 && deletions == 0);
 -              return fprintf(fp, "%s\n", _(" 0 files changed"));
 +              return fprintf(fp, "%s\n", " 0 files changed");
        }
  
        strbuf_addf(&sb,
 -                  Q_(" %d file changed", " %d files changed", files),
 +                  (files == 1) ? " %d file changed" : " %d files changed",
                    files);
  
        /*
                 * do not translate it.
                 */
                strbuf_addf(&sb,
 -                          Q_(", %d insertion(+)", ", %d insertions(+)",
 -                             insertions),
 +                          (insertions == 1) ? ", %d insertion(+)" : ", %d insertions(+)",
                            insertions);
        }
  
                 * do not translate it.
                 */
                strbuf_addf(&sb,
 -                          Q_(", %d deletion(-)", ", %d deletions(-)",
 -                             deletions),
 +                          (deletions == 1) ? ", %d deletion(-)" : ", %d deletions(-)",
                            deletions);
        }
        strbuf_addch(&sb, '\n');
diff --combined sequencer.c
index dbef5cea027f61a8172c4889005c090f1d0df048,ce8a59f576ac4950cd3abacd2f7a60086751de2a..e3723d20956719d2cba13ee6c6890ff1a8cfd21a
@@@ -17,9 -17,7 +17,9 @@@
  
  #define GIT_REFLOG_ACTION "GIT_REFLOG_ACTION"
  
- void remove_sequencer_state(void)
 +const char sign_off_header[] = "Signed-off-by: ";
 +
+ static void remove_sequencer_state(void)
  {
        struct strbuf seq_dir = STRBUF_INIT;
  
@@@ -235,9 -233,6 +235,9 @@@ static int do_recursive_merge(struct co
                die(_("%s: Unable to write new index file"), action_name(opts));
        rollback_lock_file(&index_lock);
  
 +      if (opts->signoff)
 +              append_signoff(msgbuf, 0);
 +
        if (!clean) {
                int i;
                strbuf_addstr(msgbuf, "\nConflicts:\n");
@@@ -1016,63 -1011,3 +1016,63 @@@ int sequencer_pick_revisions(struct rep
        save_opts(opts);
        return pick_commits(todo_list, opts);
  }
 +
 +static int ends_rfc2822_footer(struct strbuf *sb, int ignore_footer)
 +{
 +      int ch;
 +      int hit = 0;
 +      int i, j, k;
 +      int len = sb->len - ignore_footer;
 +      int first = 1;
 +      const char *buf = sb->buf;
 +
 +      for (i = len - 1; i > 0; i--) {
 +              if (hit && buf[i] == '\n')
 +                      break;
 +              hit = (buf[i] == '\n');
 +      }
 +
 +      while (i < len - 1 && buf[i] == '\n')
 +              i++;
 +
 +      for (; i < len; i = k) {
 +              for (k = i; k < len && buf[k] != '\n'; k++)
 +                      ; /* do nothing */
 +              k++;
 +
 +              if ((buf[k] == ' ' || buf[k] == '\t') && !first)
 +                      continue;
 +
 +              first = 0;
 +
 +              for (j = 0; i + j < len; j++) {
 +                      ch = buf[i + j];
 +                      if (ch == ':')
 +                              break;
 +                      if (isalnum(ch) ||
 +                          (ch == '-'))
 +                              continue;
 +                      return 0;
 +              }
 +      }
 +      return 1;
 +}
 +
 +void append_signoff(struct strbuf *msgbuf, int ignore_footer)
 +{
 +      struct strbuf sob = STRBUF_INIT;
 +      int i;
 +
 +      strbuf_addstr(&sob, sign_off_header);
 +      strbuf_addstr(&sob, fmt_name(getenv("GIT_COMMITTER_NAME"),
 +                              getenv("GIT_COMMITTER_EMAIL")));
 +      strbuf_addch(&sob, '\n');
 +      for (i = msgbuf->len - 1 - ignore_footer; i > 0 && msgbuf->buf[i - 1] != '\n'; i--)
 +              ; /* do nothing */
 +      if (prefixcmp(msgbuf->buf + i, sob.buf)) {
 +              if (!i || !ends_rfc2822_footer(msgbuf, ignore_footer))
 +                      strbuf_splice(msgbuf, msgbuf->len - ignore_footer, 0, "\n", 1);
 +              strbuf_splice(msgbuf, msgbuf->len - ignore_footer, 0, sob.buf, sob.len);
 +      }
 +      strbuf_release(&sob);
 +}
diff --combined sequencer.h
index 60287b8da2cddf635bc5ef13121e33e3cf25047c,99eb7fa09043094bdb6f1599c19716b9f578586c..9d57d57524d411c54d55346a5ecff67bc256595c
@@@ -44,13 -44,6 +44,10 @@@ struct replay_opts 
        struct rev_info *revs;
  };
  
- /* Removes SEQ_DIR. */
- extern void remove_sequencer_state(void);
  int sequencer_pick_revisions(struct replay_opts *opts);
  
 +extern const char sign_off_header[];
 +
 +void append_signoff(struct strbuf *msgbuf, int ignore_footer);
 +
  #endif