From: Junio C Hamano Date: Tue, 18 Sep 2012 21:37:46 +0000 (-0700) Subject: Merge branch 'jc/make-static' X-Git-Tag: v1.8.0-rc0~35 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/06e211acc61c52a2e1709ea8b62a0b0f6dcb492b?ds=inline;hp=-c Merge branch 'jc/make-static' 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 --- 06e211acc61c52a2e1709ea8b62a0b0f6dcb492b diff --combined diff.c index 32142dba64,ddcdfed787..35d3f07385 --- a/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); /* @@@ -1419,7 -1419,8 +1419,7 @@@ * do not translate it. */ strbuf_addf(&sb, - Q_(", %d insertion(+)", ", %d insertions(+)", - insertions), + (insertions == 1) ? ", %d insertion(+)" : ", %d insertions(+)", insertions); } @@@ -1429,7 -1430,8 +1429,7 @@@ * 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 dbef5cea02,ce8a59f576..e3723d2095 --- a/sequencer.c +++ b/sequencer.c @@@ -17,9 -17,7 +17,9 @@@ #define GIT_REFLOG_ACTION "GIT_REFLOG_ACTION" +const char sign_off_header[] = "Signed-off-by: "; + - void remove_sequencer_state(void) + 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 60287b8da2,99eb7fa090..9d57d57524 --- a/sequencer.h +++ b/sequencer.h @@@ -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