From ca135e7acc06f7d24ead732d2a1a531428da7135 Mon Sep 17 00:00:00 2001 From: Linus Torvalds Date: Mon, 16 Apr 2007 16:05:10 -0700 Subject: Add support for "commit name decorations" to log family of commands This adds "--decorate" as a log option, which prints out the ref names of any commits that are shown. Signed-off-by: Linus Torvalds Signed-off-by: Junio C Hamano --- commit.h | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'commit.h') diff --git a/commit.h b/commit.h index 83507a07e4..59de17eff8 100644 --- a/commit.h +++ b/commit.h @@ -3,6 +3,7 @@ #include "object.h" #include "tree.h" +#include "decorate.h" struct commit_list { struct commit *item; @@ -21,6 +22,13 @@ struct commit { extern int save_commit_buffer; extern const char *commit_type; +/* While we can decorate any object with a name, it's only used for commits.. */ +extern struct decoration name_decoration; +struct name_decoration { + struct name_decoration *next; + char name[1]; +}; + struct commit *lookup_commit(const unsigned char *sha1); struct commit *lookup_commit_reference(const unsigned char *sha1); struct commit *lookup_commit_reference_gently(const unsigned char *sha1, -- cgit v1.2.3 From a7b02ccf9a682fa0c2b28df6ca20f9199cdca4de Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Tue, 24 Apr 2007 23:36:22 -0700 Subject: Add --date={local,relative,default} This adds --date={local,relative,default} option to log family of commands, to allow displaying timestamps in user's local timezone, relative time, or the default format. Existing --relative-date option is a synonym of --date=relative; we could probably deprecate it in the long run. Signed-off-by: Junio C Hamano --- Documentation/git-rev-list.txt | 14 +++++++++++++- builtin-rev-list.c | 2 +- cache.h | 2 +- commit.c | 12 ++++++------ commit.h | 2 +- date.c | 35 +++++++++++++++++++++++++++++++++-- log-tree.c | 4 ++-- revision.c | 13 ++++++++++++- revision.h | 4 ++-- 9 files changed, 71 insertions(+), 17 deletions(-) (limited to 'commit.h') diff --git a/Documentation/git-rev-list.txt b/Documentation/git-rev-list.txt index 77e068b15f..1b12b4f2a4 100644 --- a/Documentation/git-rev-list.txt +++ b/Documentation/git-rev-list.txt @@ -25,6 +25,7 @@ SYNOPSIS [ \--cherry-pick ] [ \--encoding[=] ] [ \--(author|committer|grep)= ] + [ \--date={local|relative|default} ] [ [\--objects | \--objects-edge] [ \--unpacked ] ] [ \--pretty | \--header ] [ \--bisect ] @@ -90,9 +91,20 @@ include::pretty-formats.txt[] --relative-date:: - Show dates relative to the current time, e.g. "2 hours ago". + Synonym for `--date=relative`. + +--date={relative,local,default}:: + Only takes effect for dates shown in human-readable format, such as when using "--pretty". ++ +`--date=relative` shows dates relative to the current time, +e.g. "2 hours ago". ++ +`--date=local` shows timestamps in user's local timezone. ++ +`--date=default` shows timestamps in the original timezone +(either committer's or author's). --header:: diff --git a/builtin-rev-list.c b/builtin-rev-list.c index c0329dcecd..ebf53f5944 100644 --- a/builtin-rev-list.c +++ b/builtin-rev-list.c @@ -95,7 +95,7 @@ static void show_commit(struct commit *commit) static char pretty_header[16384]; pretty_print_commit(revs.commit_format, commit, ~0, pretty_header, sizeof(pretty_header), - revs.abbrev, NULL, NULL, revs.relative_date); + revs.abbrev, NULL, NULL, revs.date_mode); printf("%s%c", pretty_header, hdr_termination); } fflush(stdout); diff --git a/cache.h b/cache.h index 38a0cbd580..8e76152645 100644 --- a/cache.h +++ b/cache.h @@ -389,7 +389,7 @@ extern void *read_object_with_reference(const unsigned char *sha1, unsigned long *size, unsigned char *sha1_ret); -enum date_mode { DATE_NORMAL = 0, DATE_RELATIVE, DATE_SHORT }; +enum date_mode { DATE_NORMAL = 0, DATE_RELATIVE, DATE_SHORT, DATE_LOCAL }; const char *show_date(unsigned long time, int timezone, enum date_mode mode); const char *show_rfc2822_date(unsigned long time, int timezone); int parse_date(const char *date, char *buf, int bufsize); diff --git a/commit.c b/commit.c index 10466c4ae0..f1ba972d9a 100644 --- a/commit.c +++ b/commit.c @@ -526,7 +526,7 @@ static int add_rfc2047(char *buf, const char *line, int len, } static int add_user_info(const char *what, enum cmit_fmt fmt, char *buf, - const char *line, int relative_date, + const char *line, enum date_mode dmode, const char *encoding) { char *date; @@ -569,7 +569,7 @@ static int add_user_info(const char *what, enum cmit_fmt fmt, char *buf, switch (fmt) { case CMIT_FMT_MEDIUM: ret += sprintf(buf + ret, "Date: %s\n", - show_date(time, tz, relative_date)); + show_date(time, tz, dmode)); break; case CMIT_FMT_EMAIL: ret += sprintf(buf + ret, "Date: %s\n", @@ -577,7 +577,7 @@ static int add_user_info(const char *what, enum cmit_fmt fmt, char *buf, break; case CMIT_FMT_FULLER: ret += sprintf(buf + ret, "%sDate: %s\n", what, - show_date(time, tz, relative_date)); + show_date(time, tz, dmode)); break; default: /* notin' */ @@ -919,7 +919,7 @@ unsigned long pretty_print_commit(enum cmit_fmt fmt, char *buf, unsigned long space, int abbrev, const char *subject, const char *after_subject, - int relative_date) + enum date_mode dmode) { int hdr = 1, body = 0, seen_title = 0; unsigned long offset = 0; @@ -1023,14 +1023,14 @@ unsigned long pretty_print_commit(enum cmit_fmt fmt, offset += add_user_info("Author", fmt, buf + offset, line + 7, - relative_date, + dmode, encoding); if (!memcmp(line, "committer ", 10) && (fmt == CMIT_FMT_FULL || fmt == CMIT_FMT_FULLER)) offset += add_user_info("Commit", fmt, buf + offset, line + 10, - relative_date, + dmode, encoding); continue; } diff --git a/commit.h b/commit.h index 59de17eff8..86e8dca0c9 100644 --- a/commit.h +++ b/commit.h @@ -61,7 +61,7 @@ enum cmit_fmt { }; extern enum cmit_fmt get_commit_format(const char *arg); -extern unsigned long pretty_print_commit(enum cmit_fmt fmt, const struct commit *, unsigned long len, char *buf, unsigned long space, int abbrev, const char *subject, const char *after_subject, int relative_date); +extern unsigned long pretty_print_commit(enum cmit_fmt fmt, const struct commit *, unsigned long len, char *buf, unsigned long space, int abbrev, const char *subject, const char *after_subject, enum date_mode dmode); /** Removes the first commit from a list sorted by date, and adds all * of its parents. diff --git a/date.c b/date.c index 0ceccbe034..a9b59a289e 100644 --- a/date.c +++ b/date.c @@ -55,6 +55,32 @@ static struct tm *time_to_tm(unsigned long time, int tz) return gmtime(&t); } +/* + * What value of "tz" was in effect back then at "time" in the + * local timezone? + */ +static int local_tzoffset(unsigned long time) +{ + time_t t, t_local; + struct tm tm; + int offset, eastwest; + + t = time; + localtime_r(&t, &tm); + t_local = my_mktime(&tm); + + if (t_local < t) { + eastwest = -1; + offset = t - t_local; + } else { + eastwest = 1; + offset = t_local - t; + } + offset /= 60; /* in minutes */ + offset = (offset % 60) + ((offset / 60) * 100); + return offset * eastwest; +} + const char *show_date(unsigned long time, int tz, enum date_mode mode) { struct tm *tm; @@ -102,6 +128,9 @@ const char *show_date(unsigned long time, int tz, enum date_mode mode) /* Else fall back on absolute format.. */ } + if (mode == DATE_LOCAL) + tz = local_tzoffset(time); + tm = time_to_tm(time, tz); if (!tm) return NULL; @@ -109,12 +138,14 @@ const char *show_date(unsigned long time, int tz, enum date_mode mode) sprintf(timebuf, "%04d-%02d-%02d", tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday); else - sprintf(timebuf, "%.3s %.3s %d %02d:%02d:%02d %d %+05d", + sprintf(timebuf, "%.3s %.3s %d %02d:%02d:%02d %d%c%+05d", weekday_names[tm->tm_wday], month_names[tm->tm_mon], tm->tm_mday, tm->tm_hour, tm->tm_min, tm->tm_sec, - tm->tm_year + 1900, tz); + tm->tm_year + 1900, + (mode == DATE_LOCAL) ? 0 : ' ', + tz); return timebuf; } diff --git a/log-tree.c b/log-tree.c index 300b733560..c679324c07 100644 --- a/log-tree.c +++ b/log-tree.c @@ -267,7 +267,7 @@ void show_log(struct rev_info *opt, const char *sep) if (opt->reflog_info) { show_reflog_message(opt->reflog_info, opt->commit_format == CMIT_FMT_ONELINE, - opt->relative_date); + opt->date_mode); if (opt->commit_format == CMIT_FMT_ONELINE) { printf("%s", sep); return; @@ -280,7 +280,7 @@ void show_log(struct rev_info *opt, const char *sep) */ len = pretty_print_commit(opt->commit_format, commit, ~0u, this_header, sizeof(this_header), abbrev, subject, - extra_headers, opt->relative_date); + extra_headers, opt->date_mode); if (opt->add_signoff) len = append_signoff(this_header, sizeof(this_header), len, diff --git a/revision.c b/revision.c index 49bd29225b..e60a26c6bb 100644 --- a/revision.c +++ b/revision.c @@ -1111,7 +1111,18 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, const ch continue; } if (!strcmp(arg, "--relative-date")) { - revs->relative_date = 1; + revs->date_mode = DATE_RELATIVE; + continue; + } + if (!strncmp(arg, "--date=", 7)) { + if (!strcmp(arg + 7, "relative")) + revs->date_mode = DATE_RELATIVE; + else if (!strcmp(arg + 7, "local")) + revs->date_mode = DATE_LOCAL; + else if (!strcmp(arg + 7, "default")) + revs->date_mode = DATE_NORMAL; + else + die("unknown date format %s", arg); continue; } diff --git a/revision.h b/revision.h index 5b41e2da20..cdf94ad695 100644 --- a/revision.h +++ b/revision.h @@ -63,8 +63,8 @@ struct rev_info { /* Format info */ unsigned int shown_one:1, - abbrev_commit:1, - relative_date:1; + abbrev_commit:1; + enum date_mode date_mode; const char **ignore_packed; /* pretend objects in these are unpacked */ int num_ignore_packed; -- cgit v1.2.3 From a6080a0a44d5ead84db3dabbbc80e82df838533d Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Thu, 7 Jun 2007 00:04:01 -0700 Subject: War on whitespace This uses "git-apply --whitespace=strip" to fix whitespace errors that have crept in to our source files over time. There are a few files that need to have trailing whitespaces (most notably, test vectors). The results still passes the test, and build result in Documentation/ area is unchanged. Signed-off-by: Junio C Hamano --- Documentation/RelNotes-1.5.0.4.txt | 2 - Documentation/RelNotes-1.5.0.5.txt | 2 - Documentation/RelNotes-1.5.0.6.txt | 1 - Documentation/RelNotes-1.5.1.3.txt | 1 - Documentation/SubmittingPatches | 14 +- Documentation/asciidoc.conf | 2 - Documentation/config.txt | 2 - Documentation/core-tutorial.txt | 46 +- Documentation/diff-format.txt | 21 +- Documentation/diff-options.txt | 4 +- Documentation/diffcore.txt | 3 +- Documentation/docbook-xsl.css | 572 ++++++++++----------- Documentation/fetch-options.txt | 1 - Documentation/git-add.txt | 1 - Documentation/git-am.txt | 1 - Documentation/git-apply.txt | 1 - Documentation/git-archimport.txt | 45 +- Documentation/git-bisect.txt | 3 +- Documentation/git-branch.txt | 1 - Documentation/git-cat-file.txt | 1 - Documentation/git-check-attr.txt | 1 - Documentation/git-checkout-index.txt | 1 - Documentation/git-checkout.txt | 1 - Documentation/git-cherry-pick.txt | 1 - Documentation/git-cherry.txt | 1 - Documentation/git-clone.txt | 1 - Documentation/git-commit-tree.txt | 3 +- Documentation/git-config.txt | 1 - Documentation/git-convert-objects.txt | 1 - Documentation/git-count-objects.txt | 1 - Documentation/git-cvsexportcommit.txt | 15 +- Documentation/git-cvsimport.txt | 13 +- Documentation/git-daemon.txt | 1 - Documentation/git-describe.txt | 1 - Documentation/git-diff-files.txt | 3 +- Documentation/git-diff-index.txt | 3 +- Documentation/git-diff-tree.txt | 1 - Documentation/git-diff.txt | 1 - Documentation/git-fast-import.txt | 1 - Documentation/git-fmt-merge-msg.txt | 1 - Documentation/git-format-patch.txt | 1 - Documentation/git-fsck.txt | 1 - Documentation/git-get-tar-commit-id.txt | 1 - Documentation/git-grep.txt | 1 - Documentation/git-hash-object.txt | 3 +- Documentation/git-http-fetch.txt | 1 - Documentation/git-http-push.txt | 2 +- Documentation/git-index-pack.txt | 1 - Documentation/git-init-db.txt | 1 - Documentation/git-init.txt | 1 - Documentation/git-instaweb.txt | 1 - Documentation/git-local-fetch.txt | 1 - Documentation/git-log.txt | 1 - Documentation/git-ls-files.txt | 1 - Documentation/git-ls-remote.txt | 1 - Documentation/git-ls-tree.txt | 1 - Documentation/git-mailinfo.txt | 1 - Documentation/git-mailsplit.txt | 1 - Documentation/git-merge-base.txt | 1 - Documentation/git-merge-index.txt | 3 +- Documentation/git-merge-one-file.txt | 1 - Documentation/git-merge-tree.txt | 1 - Documentation/git-merge.txt | 2 +- Documentation/git-mergetool.txt | 1 - Documentation/git-mktag.txt | 1 - Documentation/git-mktree.txt | 1 - Documentation/git-mv.txt | 1 - Documentation/git-name-rev.txt | 1 - Documentation/git-p4import.txt | 1 - Documentation/git-pack-objects.txt | 1 - Documentation/git-pack-redundant.txt | 3 +- Documentation/git-patch-id.txt | 1 - Documentation/git-peek-remote.txt | 1 - Documentation/git-prune-packed.txt | 1 - Documentation/git-prune.txt | 1 - Documentation/git-pull.txt | 1 - Documentation/git-push.txt | 1 - Documentation/git-quiltimport.txt | 1 - Documentation/git-read-tree.txt | 1 - Documentation/git-rebase.txt | 1 - Documentation/git-reflog.txt | 1 - Documentation/git-relink.txt | 1 - Documentation/git-remote.txt | 1 - Documentation/git-repack.txt | 1 - Documentation/git-request-pull.txt | 1 - Documentation/git-rev-parse.txt | 1 - Documentation/git-revert.txt | 1 - Documentation/git-rm.txt | 1 - Documentation/git-runstatus.txt | 1 - Documentation/git-send-email.txt | 3 +- Documentation/git-sh-setup.txt | 1 - Documentation/git-shell.txt | 1 - Documentation/git-shortlog.txt | 1 - Documentation/git-show-index.txt | 1 - Documentation/git-show.txt | 1 - Documentation/git-ssh-fetch.txt | 1 - Documentation/git-ssh-upload.txt | 1 - Documentation/git-status.txt | 1 - Documentation/git-stripspace.txt | 1 - Documentation/git-svnimport.txt | 1 - Documentation/git-tar-tree.txt | 1 - Documentation/git-unpack-file.txt | 1 - Documentation/git-unpack-objects.txt | 1 - Documentation/git-update-index.txt | 9 +- Documentation/git-update-server-info.txt | 1 - Documentation/git-var.txt | 1 - Documentation/git-verify-pack.txt | 1 - Documentation/git-verify-tag.txt | 1 - Documentation/git-whatchanged.txt | 1 - Documentation/git-write-tree.txt | 1 - Documentation/git.txt | 1 - Documentation/gitk.txt | 1 - Documentation/howto/rebase-and-edit.txt | 20 +- .../howto/rebase-from-internal-branch.txt | 12 +- Documentation/howto/rebuild-from-update-hook.txt | 1 - Documentation/howto/revert-branch-rebase.txt | 2 +- Documentation/howto/separating-topic-branches.txt | 13 +- Documentation/howto/use-git-daemon.txt | 1 - Documentation/merge-options.txt | 1 - Documentation/pretty-formats.txt | 1 - Documentation/pretty-options.txt | 1 - Documentation/pull-fetch-param.txt | 2 +- Documentation/repository-layout.txt | 1 - Documentation/technical/pack-format.txt | 8 +- Documentation/user-manual.txt | 38 +- GIT-VERSION-GEN | 2 - INSTALL | 3 +- arm/sha1.c | 4 +- arm/sha1_arm.S | 1 - builtin-annotate.c | 1 - builtin-diff-index.c | 2 +- builtin-fmt-merge-msg.c | 1 - builtin-fsck.c | 4 +- builtin-ls-files.c | 2 +- builtin-name-rev.c | 1 - builtin-pack-objects.c | 2 +- builtin-rerere.c | 1 - builtin-shortlog.c | 1 - cache.h | 2 +- commit.c | 14 +- commit.h | 2 +- compat/mmap.c | 1 - config.c | 3 +- config.mak.in | 1 - connect.c | 2 +- contrib/README | 1 - contrib/blameview/README | 1 - contrib/gitview/gitview | 2 - contrib/hooks/post-receive-email | 2 +- contrib/remotes2config.sh | 2 - convert-objects.c | 2 +- copy.c | 1 - ctype.c | 1 - daemon.c | 4 +- date.c | 10 +- diff-lib.c | 2 +- diff.c | 4 +- diffcore-pickaxe.c | 2 +- entry.c | 2 +- environment.c | 2 - fetch-pack.c | 2 +- fetch.c | 4 +- git-archimport.perl | 175 ++++--- git-checkout.sh | 4 +- git-clone.sh | 5 +- git-commit.sh | 2 +- git-cvsexportcommit.perl | 2 +- git-cvsimport.perl | 12 +- git-gui/GIT-VERSION-GEN | 2 - git-gui/lib/class.tcl | 1 - git-merge-one-file.sh | 2 +- git-p4import.py | 1 - git-svnimport.perl | 4 +- git-tag.sh | 5 +- git-verify-tag.sh | 1 - git.spec.in | 2 +- gitk | 2 +- gitweb/README | 1 - help.c | 2 - http-fetch.c | 2 +- http-push.c | 2 +- http.c | 2 +- imap-send.c | 2 +- local-fetch.c | 8 +- lockfile.c | 1 - mailmap.c | 1 - match-trees.c | 1 - merge-index.c | 2 +- mktag.c | 2 +- mozilla-sha1/sha1.c | 19 +- mozilla-sha1/sha1.h | 18 +- object-refs.c | 2 - object.h | 2 +- pack-redundant.c | 4 +- patch-id.c | 2 +- path-list.c | 1 - perl/Makefile | 1 - pkt-line.c | 2 +- ppc/sha1.c | 2 +- read-cache.c | 10 +- rsh.h | 2 +- setup.c | 4 +- sha1_file.c | 8 +- shallow.c | 1 - ssh-upload.c | 10 +- strbuf.c | 1 - t/Makefile | 1 - t/lib-read-tree-m-3way.sh | 2 +- t/t0000-basic.sh | 2 +- t/t1200-tutorial.sh | 1 - t/t1300-repo-config.sh | 1 - t/t2000-checkout-cache-clash.sh | 2 - t/t2001-checkout-cache-clash.sh | 1 - t/t3030-merge-recursive.sh | 1 - t/t3403-rebase-skip.sh | 1 - t/t4006-diff-mode.sh | 1 - t/t4100-apply-stat.sh | 1 - t/t4110-apply-scan.sh | 1 - t/t4112-apply-renames.sh | 16 +- t/t4118-apply-empty-context.sh | 1 - t/t4119-apply-config.sh | 2 +- t/t4121-apply-diffs.sh | 1 - t/t4122-apply-symlink-inside.sh | 1 - t/t4200-rerere.sh | 2 - t/t5400-send-pack.sh | 2 +- t/t5520-pull.sh | 1 - t/t5710-info-alternate.sh | 1 - t/t6000lib.sh | 16 +- t/t6002-rev-list-bisect.sh | 8 +- t/t6021-merge-criss-cross.sh | 2 +- t/t6023-merge-file.sh | 1 - t/t6030-bisect-porcelain.sh | 1 - t/t6101-rev-parse-parents.sh | 1 - t/t9107-git-svn-migrate.sh | 1 - t/t9111/svnsync.dump | 2 - t/test-lib.sh | 2 +- templates/hooks--commit-msg | 1 - templates/hooks--post-receive | 1 - templates/hooks--pre-applypatch | 1 - templates/hooks--pre-commit | 1 - tree-walk.c | 1 - upload-pack.c | 2 +- var.c | 4 +- xdiff-interface.c | 2 - xdiff/xdiff.h | 1 - xdiff/xdiffi.c | 1 - xdiff/xdiffi.h | 1 - xdiff/xemit.c | 1 - xdiff/xemit.h | 1 - xdiff/xinclude.h | 1 - xdiff/xmacros.h | 1 - xdiff/xprepare.c | 1 - xdiff/xprepare.h | 1 - xdiff/xtypes.h | 1 - xdiff/xutils.c | 1 - xdiff/xutils.h | 1 - 256 files changed, 645 insertions(+), 852 deletions(-) (limited to 'commit.h') diff --git a/Documentation/RelNotes-1.5.0.4.txt b/Documentation/RelNotes-1.5.0.4.txt index b727a8d1e5..feefa5dfd4 100644 --- a/Documentation/RelNotes-1.5.0.4.txt +++ b/Documentation/RelNotes-1.5.0.4.txt @@ -20,5 +20,3 @@ Fixes since v1.5.0.3 * Documentation updates * User manual updates - - diff --git a/Documentation/RelNotes-1.5.0.5.txt b/Documentation/RelNotes-1.5.0.5.txt index aa86149d4f..eeec3d73d0 100644 --- a/Documentation/RelNotes-1.5.0.5.txt +++ b/Documentation/RelNotes-1.5.0.5.txt @@ -24,5 +24,3 @@ Fixes since v1.5.0.3 * Documentation updates * User manual updates - - diff --git a/Documentation/RelNotes-1.5.0.6.txt b/Documentation/RelNotes-1.5.0.6.txt index e15447ffdb..c02015ad5f 100644 --- a/Documentation/RelNotes-1.5.0.6.txt +++ b/Documentation/RelNotes-1.5.0.6.txt @@ -19,4 +19,3 @@ Fixes since v1.5.0.5 - user-manual has better cross references. - gitweb installation/deployment procedure is now documented. - diff --git a/Documentation/RelNotes-1.5.1.3.txt b/Documentation/RelNotes-1.5.1.3.txt index 2ddeabd029..876408b65a 100644 --- a/Documentation/RelNotes-1.5.1.3.txt +++ b/Documentation/RelNotes-1.5.1.3.txt @@ -43,4 +43,3 @@ Fixes since v1.5.1.2 description was given by the caller. Also contains various documentation updates. - diff --git a/Documentation/SubmittingPatches b/Documentation/SubmittingPatches index b9baa1d3b4..01354c2bb5 100644 --- a/Documentation/SubmittingPatches +++ b/Documentation/SubmittingPatches @@ -296,15 +296,15 @@ diff --git a/pico/pico.c b/pico/pico.c --- a/pico/pico.c +++ b/pico/pico.c @@ -219,7 +219,9 @@ PICO *pm; - switch(pico_all_done){ /* prepare for/handle final events */ - case COMP_EXIT : /* already confirmed */ - packheader(); + switch(pico_all_done){ /* prepare for/handle final events */ + case COMP_EXIT : /* already confirmed */ + packheader(); +#if 0 - stripwhitespace(); + stripwhitespace(); +#endif - c |= COMP_EXIT; - break; - + c |= COMP_EXIT; + break; + (Daniel Barkalow) diff --git a/Documentation/asciidoc.conf b/Documentation/asciidoc.conf index 60e15ba349..99302c5beb 100644 --- a/Documentation/asciidoc.conf +++ b/Documentation/asciidoc.conf @@ -54,5 +54,3 @@ ifdef::backend-xhtml11[] [gitlink-inlinemacro] {target}{0?({0})} endif::backend-xhtml11[] - - diff --git a/Documentation/config.txt b/Documentation/config.txt index 5868d587a9..de408b6571 100644 --- a/Documentation/config.txt +++ b/Documentation/config.txt @@ -682,5 +682,3 @@ receive.denyNonFastForwards:: transfer.unpackLimit:: When `fetch.unpackLimit` or `receive.unpackLimit` are not set, the value of this variable is used instead. - - diff --git a/Documentation/core-tutorial.txt b/Documentation/core-tutorial.txt index 6b9b9ad7d1..4fb6f4143c 100644 --- a/Documentation/core-tutorial.txt +++ b/Documentation/core-tutorial.txt @@ -9,11 +9,11 @@ repository, mainly because being hands-on and using explicit examples is often the best way of explaining what is going on. In normal life, most people wouldn't use the "core" git programs -directly, but rather script around them to make them more palatable. +directly, but rather script around them to make them more palatable. Understanding the core git stuff may help some people get those scripts done, though, and it may also be instructive in helping people understand what it is that the higher-level helper scripts are actually -doing. +doing. The core git is often called "plumbing", with the prettier user interfaces on top of it called "porcelain". You may not want to use the @@ -41,7 +41,7 @@ Creating a new git repository couldn't be easier: all git repositories start out empty, and the only thing you need to do is find yourself a subdirectory that you want to use as a working tree - either an empty one for a totally new project, or an existing working tree that you want -to import into git. +to import into git. For our first example, we're going to start a totally new repository from scratch, with no pre-existing files, and we'll call it `git-tutorial`. @@ -169,7 +169,7 @@ $ ls .git/objects/??/* and see two files: ---------------- -.git/objects/55/7db03de997c86a4a028e1ebd3a1ceb225be238 +.git/objects/55/7db03de997c86a4a028e1ebd3a1ceb225be238 .git/objects/f2/4c74a2e500f5ee1332c86b94199f52b1d1d962 ---------------- @@ -220,7 +220,7 @@ you have not actually really "checked in" your files into git so far, you've only *told* git about them. However, since git knows about them, you can now start using some of the -most basic git commands to manipulate the files or look at their status. +most basic git commands to manipulate the files or look at their status. In particular, let's not even check in the two files into git yet, we'll start off by adding another line to `hello` first: @@ -350,7 +350,7 @@ Making a change Remember how we did the `git-update-index` on file `hello` and then we changed `hello` afterward, and could compare the new state of `hello` with the -state we saved in the index file? +state we saved in the index file? Further, remember how I said that `git-write-tree` writes the contents of the *index* file to the tree, and thus what we just committed was in @@ -370,7 +370,7 @@ file and the working tree, `git-diff-index` shows the differences between a committed *tree* and either the index file or the working tree. In other words, `git-diff-index` wants a tree to be diffed against, and before we did the commit, we couldn't do that, because we -didn't have anything to diff against. +didn't have anything to diff against. But now we can do @@ -379,7 +379,7 @@ $ git-diff-index -p HEAD ---------------- (where `-p` has the same meaning as it did in `git-diff-files`), and it -will show us the same difference, but for a totally different reason. +will show us the same difference, but for a totally different reason. Now we're comparing the working tree not against the index file, but against the tree we just wrote. It just so happens that those two are obviously the same, so we get the same result. @@ -398,7 +398,7 @@ working tree, but when given the `\--cached` flag, it is told to instead compare against just the index cache contents, and ignore the current working tree state entirely. Since we just wrote the index file to HEAD, doing `git-diff-index \--cached -p HEAD` should thus return -an empty set of differences, and that's exactly what it does. +an empty set of differences, and that's exactly what it does. [NOTE] ================ @@ -549,7 +549,7 @@ $ git-whatchanged -p --root ---------------- and you will see exactly what has changed in the repository over its -short history. +short history. [NOTE] The `\--root` flag is a flag to `git-diff-tree` to tell it to @@ -637,7 +637,7 @@ So the mental model of "the git information is always tied directly to the working tree that it describes" may not be technically 100% accurate, but it's a good model for all normal use. -This has two implications: +This has two implications: - if you grow bored with the tutorial repository you created (or you've made a mistake and want to start all over), you can just do simple @@ -705,7 +705,7 @@ Many (most?) public remote repositories will not contain any of the checked out files or even an index file, and will *only* contain the actual core git files. Such a repository usually doesn't even have the `.git` subdirectory, but has all the git files directly in the -repository. +repository. To create your own local live copy of such a "raw" git repository, you'd first create your own subdirectory for the project, and then copy the @@ -718,7 +718,7 @@ $ cd my-git $ rsync -rL rsync://rsync.kernel.org/pub/scm/git/git.git/ .git ---------------- -followed by +followed by ---------------- $ git-read-tree HEAD @@ -738,7 +738,7 @@ up-to-date (so that you don't have to refresh it afterward), and the `-a` flag means "check out all files" (if you have a stale copy or an older version of a checked out tree you may also need to add the `-f` flag first, to tell git-checkout-index to *force* overwriting of any old -files). +files). Again, this can all be simplified with @@ -751,7 +751,7 @@ $ git checkout which will end up doing all of the above for you. You have now successfully copied somebody else's (mine) remote -repository, and checked it out. +repository, and checked it out. Creating a new branch @@ -760,14 +760,14 @@ Creating a new branch Branches in git are really nothing more than pointers into the git object database from within the `.git/refs/` subdirectory, and as we already discussed, the `HEAD` branch is nothing but a symlink to one of -these object pointers. +these object pointers. You can at any time create a new branch by just picking an arbitrary point in the project history, and just writing the SHA1 name of that object into a file under `.git/refs/heads/`. You can use any filename you want (and indeed, subdirectories), but the convention is that the "normal" branch is called `master`. That's just a convention, though, -and nothing enforces it. +and nothing enforces it. To show that as an example, let's go back to the git-tutorial repository we used earlier, and create a branch in it. You do that by simply just @@ -778,7 +778,7 @@ $ git checkout -b mybranch ------------ will create a new branch based at the current `HEAD` position, and switch -to it. +to it. [NOTE] ================================================ @@ -825,7 +825,7 @@ checking it out and switching to it. If so, just use the command $ git branch [startingpoint] ------------ -which will simply _create_ the branch, but will not do anything further. +which will simply _create_ the branch, but will not do anything further. You can then later -- once you decide that you want to actually develop on that branch -- switch to that branch with a regular `git checkout` with the branchname as the argument. @@ -884,7 +884,7 @@ $ gitk --all will show you graphically both of your branches (that's what the `\--all` means: normally it will just show you your current `HEAD`) and their histories. You can also see exactly how they came to be from a common -source. +source. Anyway, let's exit `gitk` (`^Q` or the File menu), and decide that we want to merge the work we did on the `mybranch` branch into the `master` @@ -905,8 +905,8 @@ of it as it can automatically (which in this case is just merge the `example` file, which had no differences in the `mybranch` branch), and say: ---------------- - Auto-merging hello - CONFLICT (content): Merge conflict in hello + Auto-merging hello + CONFLICT (content): Merge conflict in hello Automatic merge failed; fix up by hand ---------------- @@ -1387,7 +1387,7 @@ repository. Kernel.org mirror network takes care of the propagation to other publicly visible machines: ------------ -$ git push master.kernel.org:/pub/scm/git/git.git/ +$ git push master.kernel.org:/pub/scm/git/git.git/ ------------ diff --git a/Documentation/diff-format.txt b/Documentation/diff-format.txt index e38a1f1405..18d49d2c3b 100644 --- a/Documentation/diff-format.txt +++ b/Documentation/diff-format.txt @@ -1,7 +1,7 @@ The output format from "git-diff-index", "git-diff-tree" and "git-diff-files" are very similar. -These commands all compare two sets of things; what is +These commands all compare two sets of things; what is compared differs: git-diff-index :: @@ -139,28 +139,28 @@ index fabadb8,cc95eb0..4866510 --- a/describe.c +++ b/describe.c @@@ -98,20 -98,12 +98,20 @@@ - return (a_date > b_date) ? -1 : (a_date == b_date) ? 0 : 1; + return (a_date > b_date) ? -1 : (a_date == b_date) ? 0 : 1; } - + - static void describe(char *arg) -static void describe(struct commit *cmit, int last_one) ++static void describe(char *arg, int last_one) { + unsigned char sha1[20]; + struct commit *cmit; - struct commit_list *list; - static int initialized = 0; - struct commit_name *n; - + struct commit_list *list; + static int initialized = 0; + struct commit_name *n; + + if (get_sha1(arg, sha1) < 0) + usage(describe_usage); + cmit = lookup_commit_reference(sha1); + if (!cmit) + usage(describe_usage); + - if (!initialized) { - initialized = 1; - for_each_ref(get_name); + if (!initialized) { + initialized = 1; + for_each_ref(get_name); ------------ 1. It is preceded with a "git diff" header, that looks like @@ -233,4 +233,3 @@ parents). When shown by `git diff-files -c`, it compares the two unresolved merge parents with the working tree file (i.e. file1 is stage 2 aka "our version", file2 is stage 3 aka "their version"). - diff --git a/Documentation/diff-options.txt b/Documentation/diff-options.txt index 1689c74817..b2a05937f9 100644 --- a/Documentation/diff-options.txt +++ b/Documentation/diff-options.txt @@ -100,8 +100,8 @@ that matches other criteria, nothing is selected. --find-copies-harder:: - For performance reasons, by default, -C option finds copies only - if the original file of the copy was modified in the same + For performance reasons, by default, -C option finds copies only + if the original file of the copy was modified in the same changeset. This flag makes the command inspect unmodified files as candidates for the source of copy. This is a very expensive operation for large diff --git a/Documentation/diffcore.txt b/Documentation/diffcore.txt index 34cd306bb1..c6a983a5d5 100644 --- a/Documentation/diffcore.txt +++ b/Documentation/diffcore.txt @@ -71,7 +71,7 @@ The first transformation in the chain is diffcore-pathspec, and is controlled by giving the pathname parameters to the git-diff-* commands on the command line. The pathspec is used to limit the world diff operates in. It removes the filepairs -outside the specified set of pathnames. E.g. If the input set +outside the specified set of pathnames. E.g. If the input set of filepairs included: ------------------------------------------------ @@ -269,4 +269,3 @@ Documentation *.c t ------------------------------------------------ - diff --git a/Documentation/docbook-xsl.css b/Documentation/docbook-xsl.css index 8821e305dd..b878b385c6 100644 --- a/Documentation/docbook-xsl.css +++ b/Documentation/docbook-xsl.css @@ -1,286 +1,286 @@ -/* - CSS stylesheet for XHTML produced by DocBook XSL stylesheets. - Tested with XSL stylesheets 1.61.2, 1.67.2 -*/ - -span.strong { - font-weight: bold; -} - -body blockquote { - margin-top: .75em; - line-height: 1.5; - margin-bottom: .75em; -} - -html body { - margin: 1em 5% 1em 5%; - line-height: 1.2; -} - -body div { - margin: 0; -} - -h1, h2, h3, h4, h5, h6, -div.toc p b, -div.list-of-figures p b, -div.list-of-tables p b, -div.abstract p.title -{ - color: #527bbd; - font-family: tahoma, verdana, sans-serif; -} - -div.toc p:first-child, -div.list-of-figures p:first-child, -div.list-of-tables p:first-child, -div.example p.title -{ - margin-bottom: 0.2em; -} - -body h1 { - margin: .0em 0 0 -4%; - line-height: 1.3; - border-bottom: 2px solid silver; -} - -body h2 { - margin: 0.5em 0 0 -4%; - line-height: 1.3; - border-bottom: 2px solid silver; -} - -body h3 { - margin: .8em 0 0 -3%; - line-height: 1.3; -} - -body h4 { - margin: .8em 0 0 -3%; - line-height: 1.3; -} - -body h5 { - margin: .8em 0 0 -2%; - line-height: 1.3; -} - -body h6 { - margin: .8em 0 0 -1%; - line-height: 1.3; -} - -body hr { - border: none; /* Broken on IE6 */ -} -div.footnotes hr { - border: 1px solid silver; -} - -div.navheader th, div.navheader td, div.navfooter td { - font-family: sans-serif; - font-size: 0.9em; - font-weight: bold; - color: #527bbd; -} -div.navheader img, div.navfooter img { - border-style: none; -} -div.navheader a, div.navfooter a { - font-weight: normal; -} -div.navfooter hr { - border: 1px solid silver; -} - -body td { - line-height: 1.2 -} - -body th { - line-height: 1.2; -} - -ol { - line-height: 1.2; -} - -ul, body dir, body menu { - line-height: 1.2; -} - -html { - margin: 0; - padding: 0; -} - -body h1, body h2, body h3, body h4, body h5, body h6 { - margin-left: 0 -} - -body pre { - margin: 0.5em 10% 0.5em 1em; - line-height: 1.0; - color: navy; -} - -tt.literal, code.literal { - color: navy; -} - -div.literallayout p { - padding: 0em; - margin: 0em; -} - -div.literallayout { - font-family: monospace; -# margin: 0.5em 10% 0.5em 1em; - margin: 0em; - color: navy; - border: 1px solid silver; - background: #f4f4f4; - padding: 0.5em; -} - -.programlisting, .screen { - border: 1px solid silver; - background: #f4f4f4; - margin: 0.5em 10% 0.5em 0; - padding: 0.5em 1em; -} - -div.sidebar { - background: #ffffee; - margin: 1.0em 10% 0.5em 0; - padding: 0.5em 1em; - border: 1px solid silver; -} -div.sidebar * { padding: 0; } -div.sidebar div { margin: 0; } -div.sidebar p.title { - font-family: sans-serif; - margin-top: 0.5em; - margin-bottom: 0.2em; -} - -div.bibliomixed { - margin: 0.5em 5% 0.5em 1em; -} - -div.glossary dt { - font-weight: bold; -} -div.glossary dd p { - margin-top: 0.2em; -} - -dl { - margin: .8em 0; - line-height: 1.2; -} - -dt { - margin-top: 0.5em; -} - -dt span.term { - font-style: italic; -} - -div.variablelist dd p { - margin-top: 0; -} - -div.itemizedlist li, div.orderedlist li { - margin-left: -0.8em; - margin-top: 0.5em; -} - -ul, ol { - list-style-position: outside; -} - -div.sidebar ul, div.sidebar ol { - margin-left: 2.8em; -} - -div.itemizedlist p.title, -div.orderedlist p.title, -div.variablelist p.title -{ - margin-bottom: -0.8em; -} - -div.revhistory table { - border-collapse: collapse; - border: none; -} -div.revhistory th { - border: none; - color: #527bbd; - font-family: tahoma, verdana, sans-serif; -} -div.revhistory td { - border: 1px solid silver; -} - -/* Keep TOC and index lines close together. */ -div.toc dl, div.toc dt, -div.list-of-figures dl, div.list-of-figures dt, -div.list-of-tables dl, div.list-of-tables dt, -div.indexdiv dl, div.indexdiv dt -{ - line-height: normal; - margin-top: 0; - margin-bottom: 0; -} - -/* - Table styling does not work because of overriding attributes in - generated HTML. -*/ -div.table table, -div.informaltable table -{ - margin-left: 0; - margin-right: 5%; - margin-bottom: 0.8em; -} -div.informaltable table -{ - margin-top: 0.4em -} -div.table thead, -div.table tfoot, -div.table tbody, -div.informaltable thead, -div.informaltable tfoot, -div.informaltable tbody -{ - /* No effect in IE6. */ - border-top: 2px solid #527bbd; - border-bottom: 2px solid #527bbd; -} -div.table thead, div.table tfoot, -div.informaltable thead, div.informaltable tfoot -{ - font-weight: bold; -} - -div.mediaobject img { - border: 1px solid silver; - margin-bottom: 0.8em; -} -div.figure p.title, -div.table p.title -{ - margin-top: 1em; - margin-bottom: 0.4em; -} - -@media print { - div.navheader, div.navfooter { display: none; } -} +/* + CSS stylesheet for XHTML produced by DocBook XSL stylesheets. + Tested with XSL stylesheets 1.61.2, 1.67.2 +*/ + +span.strong { + font-weight: bold; +} + +body blockquote { + margin-top: .75em; + line-height: 1.5; + margin-bottom: .75em; +} + +html body { + margin: 1em 5% 1em 5%; + line-height: 1.2; +} + +body div { + margin: 0; +} + +h1, h2, h3, h4, h5, h6, +div.toc p b, +div.list-of-figures p b, +div.list-of-tables p b, +div.abstract p.title +{ + color: #527bbd; + font-family: tahoma, verdana, sans-serif; +} + +div.toc p:first-child, +div.list-of-figures p:first-child, +div.list-of-tables p:first-child, +div.example p.title +{ + margin-bottom: 0.2em; +} + +body h1 { + margin: .0em 0 0 -4%; + line-height: 1.3; + border-bottom: 2px solid silver; +} + +body h2 { + margin: 0.5em 0 0 -4%; + line-height: 1.3; + border-bottom: 2px solid silver; +} + +body h3 { + margin: .8em 0 0 -3%; + line-height: 1.3; +} + +body h4 { + margin: .8em 0 0 -3%; + line-height: 1.3; +} + +body h5 { + margin: .8em 0 0 -2%; + line-height: 1.3; +} + +body h6 { + margin: .8em 0 0 -1%; + line-height: 1.3; +} + +body hr { + border: none; /* Broken on IE6 */ +} +div.footnotes hr { + border: 1px solid silver; +} + +div.navheader th, div.navheader td, div.navfooter td { + font-family: sans-serif; + font-size: 0.9em; + font-weight: bold; + color: #527bbd; +} +div.navheader img, div.navfooter img { + border-style: none; +} +div.navheader a, div.navfooter a { + font-weight: normal; +} +div.navfooter hr { + border: 1px solid silver; +} + +body td { + line-height: 1.2 +} + +body th { + line-height: 1.2; +} + +ol { + line-height: 1.2; +} + +ul, body dir, body menu { + line-height: 1.2; +} + +html { + margin: 0; + padding: 0; +} + +body h1, body h2, body h3, body h4, body h5, body h6 { + margin-left: 0 +} + +body pre { + margin: 0.5em 10% 0.5em 1em; + line-height: 1.0; + color: navy; +} + +tt.literal, code.literal { + color: navy; +} + +div.literallayout p { + padding: 0em; + margin: 0em; +} + +div.literallayout { + font-family: monospace; +# margin: 0.5em 10% 0.5em 1em; + margin: 0em; + color: navy; + border: 1px solid silver; + background: #f4f4f4; + padding: 0.5em; +} + +.programlisting, .screen { + border: 1px solid silver; + background: #f4f4f4; + margin: 0.5em 10% 0.5em 0; + padding: 0.5em 1em; +} + +div.sidebar { + background: #ffffee; + margin: 1.0em 10% 0.5em 0; + padding: 0.5em 1em; + border: 1px solid silver; +} +div.sidebar * { padding: 0; } +div.sidebar div { margin: 0; } +div.sidebar p.title { + font-family: sans-serif; + margin-top: 0.5em; + margin-bottom: 0.2em; +} + +div.bibliomixed { + margin: 0.5em 5% 0.5em 1em; +} + +div.glossary dt { + font-weight: bold; +} +div.glossary dd p { + margin-top: 0.2em; +} + +dl { + margin: .8em 0; + line-height: 1.2; +} + +dt { + margin-top: 0.5em; +} + +dt span.term { + font-style: italic; +} + +div.variablelist dd p { + margin-top: 0; +} + +div.itemizedlist li, div.orderedlist li { + margin-left: -0.8em; + margin-top: 0.5em; +} + +ul, ol { + list-style-position: outside; +} + +div.sidebar ul, div.sidebar ol { + margin-left: 2.8em; +} + +div.itemizedlist p.title, +div.orderedlist p.title, +div.variablelist p.title +{ + margin-bottom: -0.8em; +} + +div.revhistory table { + border-collapse: collapse; + border: none; +} +div.revhistory th { + border: none; + color: #527bbd; + font-family: tahoma, verdana, sans-serif; +} +div.revhistory td { + border: 1px solid silver; +} + +/* Keep TOC and index lines close together. */ +div.toc dl, div.toc dt, +div.list-of-figures dl, div.list-of-figures dt, +div.list-of-tables dl, div.list-of-tables dt, +div.indexdiv dl, div.indexdiv dt +{ + line-height: normal; + margin-top: 0; + margin-bottom: 0; +} + +/* + Table styling does not work because of overriding attributes in + generated HTML. +*/ +div.table table, +div.informaltable table +{ + margin-left: 0; + margin-right: 5%; + margin-bottom: 0.8em; +} +div.informaltable table +{ + margin-top: 0.4em +} +div.table thead, +div.table tfoot, +div.table tbody, +div.informaltable thead, +div.informaltable tfoot, +div.informaltable tbody +{ + /* No effect in IE6. */ + border-top: 2px solid #527bbd; + border-bottom: 2px solid #527bbd; +} +div.table thead, div.table tfoot, +div.informaltable thead, div.informaltable tfoot +{ + font-weight: bold; +} + +div.mediaobject img { + border: 1px solid silver; + margin-bottom: 0.8em; +} +div.figure p.title, +div.table p.title +{ + margin-top: 1em; + margin-bottom: 0.4em; +} + +@media print { + div.navheader, div.navfooter { display: none; } +} diff --git a/Documentation/fetch-options.txt b/Documentation/fetch-options.txt index bdc7332c7b..da034223f3 100644 --- a/Documentation/fetch-options.txt +++ b/Documentation/fetch-options.txt @@ -52,4 +52,3 @@ Deepen the history of a 'shallow' repository created by `git clone` with `--depth=` option (see gitlink:git-clone[1]) by the specified number of commits. - diff --git a/Documentation/git-add.txt b/Documentation/git-add.txt index a0c9f68580..76d2b05854 100644 --- a/Documentation/git-add.txt +++ b/Documentation/git-add.txt @@ -228,4 +228,3 @@ Documentation by Junio C Hamano and the git-list . GIT --- Part of the gitlink:git[7] suite - diff --git a/Documentation/git-am.txt b/Documentation/git-am.txt index f3387f5d09..e4a6b3a6f0 100644 --- a/Documentation/git-am.txt +++ b/Documentation/git-am.txt @@ -158,4 +158,3 @@ Documentation by Petr Baudis, Junio C Hamano and the git-list parameters supplied. If it cannot find the remote branch a merge comes from -it will just import it as a regular commit. If it can find it, it will mark it -as a merge whenever possible (see discussion below). +it will just import it as a regular commit. If it can find it, it will mark it +as a merge whenever possible (see discussion below). -The script expects you to provide the key roots where it can start the import -from an 'initial import' or 'tag' type of Arch commit. It will follow and -import new branches within the provided roots. +The script expects you to provide the key roots where it can start the import +from an 'initial import' or 'tag' type of Arch commit. It will follow and +import new branches within the provided roots. -It expects to be dealing with one project only. If it sees -branches that have different roots, it will refuse to run. In that case, -edit your parameters to define clearly the scope of the -import. +It expects to be dealing with one project only. If it sees +branches that have different roots, it will refuse to run. In that case, +edit your parameters to define clearly the scope of the +import. -`git-archimport` uses `tla` extensively in the background to access the +`git-archimport` uses `tla` extensively in the background to access the Arch repository. Make sure you have a recent version of `tla` available in the path. `tla` must -know about the repositories you pass to `git-archimport`. +know about the repositories you pass to `git-archimport`. -For the initial import `git-archimport` expects to find itself in an empty -directory. To follow the development of a project that uses Arch, rerun -`git-archimport` with the same parameters as the initial import to perform +For the initial import `git-archimport` expects to find itself in an empty +directory. To follow the development of a project that uses Arch, rerun +`git-archimport` with the same parameters as the initial import to perform incremental imports. While git-archimport will try to create sensible branch names for the @@ -54,15 +54,15 @@ convert Arch repositories that had been rotated periodically. MERGES ------ -Patch merge data from Arch is used to mark merges in git as well. git +Patch merge data from Arch is used to mark merges in git as well. git does not care much about tracking patches, and only considers a merge when a branch incorporates all the commits since the point they forked. The end result -is that git will have a good idea of how far branches have diverged. So the +is that git will have a good idea of how far branches have diverged. So the import process does lose some patch-trading metadata. -Fortunately, when you try and merge branches imported from Arch, -git will find a good merge base, and it has a good chance of identifying -patches that have been traded out-of-sequence between the branches. +Fortunately, when you try and merge branches imported from Arch, +git will find a good merge base, and it has a good chance of identifying +patches that have been traded out-of-sequence between the branches. OPTIONS ------- @@ -71,10 +71,10 @@ OPTIONS Display usage. -v:: - Verbose output. + Verbose output. -T:: - Many tags. Will create a tag for every commit, reflecting the commit + Many tags. Will create a tag for every commit, reflecting the commit name in the Arch repository. -f:: @@ -104,7 +104,7 @@ OPTIONS :: - Archive/branch identifier in a format that `tla log` understands. + Archive/branch identifier in a format that `tla log` understands. Author @@ -118,4 +118,3 @@ Documentation by Junio C Hamano, Martin Langhoff and the git-list +'git bisect' DESCRIPTION ----------- @@ -200,4 +200,3 @@ Documentation by Junio C Hamano and the git-list . GIT --- Part of the gitlink:git[7] suite - diff --git a/Documentation/git-branch.txt b/Documentation/git-branch.txt index 8dc5171f5e..8d72bb9368 100644 --- a/Documentation/git-branch.txt +++ b/Documentation/git-branch.txt @@ -158,4 +158,3 @@ Documentation by Junio C Hamano and the git-list . GIT --- Part of the gitlink:git[7] suite - diff --git a/Documentation/git-cat-file.txt b/Documentation/git-cat-file.txt index 075c0d05ef..afa095c795 100644 --- a/Documentation/git-cat-file.txt +++ b/Documentation/git-cat-file.txt @@ -71,4 +71,3 @@ Documentation by David Greaves, Junio C Hamano and the git-list . GIT --- Part of the gitlink:git[7] suite - diff --git a/Documentation/git-checkout.txt b/Documentation/git-checkout.txt index 918d8ee720..ea26da8e21 100644 --- a/Documentation/git-checkout.txt +++ b/Documentation/git-checkout.txt @@ -215,4 +215,3 @@ Documentation by Junio C Hamano and the git-list . GIT --- Part of the gitlink:git[7] suite - diff --git a/Documentation/git-cherry-pick.txt b/Documentation/git-cherry-pick.txt index 68bba98260..47b1e8c2fc 100644 --- a/Documentation/git-cherry-pick.txt +++ b/Documentation/git-cherry-pick.txt @@ -68,4 +68,3 @@ Documentation by Junio C Hamano and the git-list . GIT --- Part of the gitlink:git[7] suite - diff --git a/Documentation/git-cherry.txt b/Documentation/git-cherry.txt index 27b67b81a5..b62c97097f 100644 --- a/Documentation/git-cherry.txt +++ b/Documentation/git-cherry.txt @@ -64,4 +64,3 @@ Documentation by Junio C Hamano and the git-list . GIT --- Part of the gitlink:git[7] suite - diff --git a/Documentation/git-clone.txt b/Documentation/git-clone.txt index 644bf126fb..2461c0ec2d 100644 --- a/Documentation/git-clone.txt +++ b/Documentation/git-clone.txt @@ -175,4 +175,3 @@ Documentation by Junio C Hamano and the git-list . GIT --- Part of the gitlink:git[7] suite - diff --git a/Documentation/git-commit-tree.txt b/Documentation/git-commit-tree.txt index 504a3aa1b4..9586b97291 100644 --- a/Documentation/git-commit-tree.txt +++ b/Documentation/git-commit-tree.txt @@ -40,7 +40,7 @@ OPTIONS -p :: Each '-p' indicates the id of a parent commit object. - + Commit Information ------------------ @@ -107,4 +107,3 @@ Documentation by David Greaves, Junio C Hamano and the git-list . GIT --- Part of the gitlink:git[7] suite - diff --git a/Documentation/git-cvsexportcommit.txt b/Documentation/git-cvsexportcommit.txt index da5c242241..827711c3c9 100644 --- a/Documentation/git-cvsexportcommit.txt +++ b/Documentation/git-cvsexportcommit.txt @@ -14,19 +14,19 @@ SYNOPSIS DESCRIPTION ----------- Exports a commit from GIT to a CVS checkout, making it easier -to merge patches from a git repository into a CVS repository. +to merge patches from a git repository into a CVS repository. -Execute it from the root of the CVS working copy. GIT_DIR must be defined. +Execute it from the root of the CVS working copy. GIT_DIR must be defined. See examples below. -It does its best to do the safe thing, it will check that the files are -unchanged and up to date in the CVS checkout, and it will not autocommit +It does its best to do the safe thing, it will check that the files are +unchanged and up to date in the CVS checkout, and it will not autocommit by default. Supports file additions, removals, and commits that affect binary files. If the commit is a merge commit, you must tell git-cvsexportcommit what parent -should the changeset be done against. +should the changeset be done against. OPTIONS ------- @@ -55,7 +55,7 @@ OPTIONS Force the parent commit, even if it is not a direct parent. -m:: - Prepend the commit message with the provided prefix. + Prepend the commit message with the provided prefix. Useful for patch series and the like. -u:: @@ -73,7 +73,7 @@ Merge one patch into CVS:: $ export GIT_DIR=~/project/.git $ cd ~/project_cvs_checkout $ git-cvsexportcommit -v -$ cvs commit -F .mgs +$ cvs commit -F .mgs ------------ Merge pending patches into CVS automatically -- only if you really know what you are doing :: @@ -95,4 +95,3 @@ Documentation by Martin Langhoff GIT --- Part of the gitlink:git[7] suite - diff --git a/Documentation/git-cvsimport.txt b/Documentation/git-cvsimport.txt index e0be856546..3985e0164b 100644 --- a/Documentation/git-cvsimport.txt +++ b/Documentation/git-cvsimport.txt @@ -37,7 +37,7 @@ OPTIONS -d :: The root of the CVS archive. May be local (a simple path) or remote; - currently, only the :local:, :ext: and :pserver: access methods + currently, only the :local:, :ext: and :pserver: access methods are supported. If not given, git-cvsimport will try to read it from `CVS/Root`. If no such file exists, it checks for the `CVSROOT` environment variable. @@ -67,7 +67,7 @@ the old cvs2git tool. -k:: Kill keywords: will extract files with '-kk' from the CVS archive to avoid noisy changesets. Highly recommended, but off by default - to preserve compatibility with early imported trees. + to preserve compatibility with early imported trees. -u:: Convert underscores in tag and branch names to dots. @@ -89,15 +89,15 @@ If you need to pass multiple options, separate them with a comma. Instead of calling cvsps, read the provided cvsps output file. Useful for debugging or when cvsps is being handled outside cvsimport. --m:: +-m:: Attempt to detect merges based on the commit message. This option - will enable default regexes that try to capture the name source - branch name from the commit message. + will enable default regexes that try to capture the name source + branch name from the commit message. -M :: Attempt to detect merges based on the commit message with a custom regex. It can be used with '-m' to also see the default regexes. - You must escape forward slashes. + You must escape forward slashes. -S :: Skip paths matching the regex. @@ -156,4 +156,3 @@ Documentation by Matthias Urlichs . GIT --- Part of the gitlink:git[7] suite - diff --git a/Documentation/git-daemon.txt b/Documentation/git-daemon.txt index 9ddab71203..4b30b18b42 100644 --- a/Documentation/git-daemon.txt +++ b/Documentation/git-daemon.txt @@ -235,4 +235,3 @@ Documentation by Junio C Hamano and the git-list . GIT --- Part of the gitlink:git[7] suite - diff --git a/Documentation/git-describe.txt b/Documentation/git-describe.txt index dc47b65ced..ac23e28f27 100644 --- a/Documentation/git-describe.txt +++ b/Documentation/git-describe.txt @@ -124,4 +124,3 @@ Documentation by David Greaves, Junio C Hamano and the git-list . GIT --- Part of the gitlink:git[7] suite - diff --git a/Documentation/git-fast-import.txt b/Documentation/git-fast-import.txt index 8d06775a6b..5eacab08dc 100644 --- a/Documentation/git-fast-import.txt +++ b/Documentation/git-fast-import.txt @@ -908,4 +908,3 @@ Documentation by Shawn O. Pearce . GIT --- Part of the gitlink:git[7] suite - diff --git a/Documentation/git-fmt-merge-msg.txt b/Documentation/git-fmt-merge-msg.txt index 4913c2552f..6affc5bb4d 100644 --- a/Documentation/git-fmt-merge-msg.txt +++ b/Documentation/git-fmt-merge-msg.txt @@ -60,4 +60,3 @@ Documentation by Petr Baudis, Junio C Hamano and the git-list . GIT --- Part of the gitlink:git[7] suite - diff --git a/Documentation/git-fsck.txt b/Documentation/git-fsck.txt index ed6413a3c7..234c22f57f 100644 --- a/Documentation/git-fsck.txt +++ b/Documentation/git-fsck.txt @@ -145,4 +145,3 @@ Documentation by David Greaves, Junio C Hamano and the git-list . GIT --- Part of the gitlink:git[7] suite - diff --git a/Documentation/git-grep.txt b/Documentation/git-grep.txt index c5a5dad1ce..97faaa1d3a 100644 --- a/Documentation/git-grep.txt +++ b/Documentation/git-grep.txt @@ -144,4 +144,3 @@ Documentation by Junio C Hamano and the git-list . GIT --- Part of the gitlink:git[7] suite - diff --git a/Documentation/git-hash-object.txt b/Documentation/git-hash-object.txt index 5edc36f060..616f196d81 100644 --- a/Documentation/git-hash-object.txt +++ b/Documentation/git-hash-object.txt @@ -18,7 +18,7 @@ work tree), and optionally writes the resulting object into the object database. Reports its object ID to its standard output. This is used by "git-cvsimport" to update the index without modifying files in the work tree. When is not -specified, it defaults to "blob". +specified, it defaults to "blob". OPTIONS ------- @@ -43,4 +43,3 @@ Documentation by David Greaves, Junio C Hamano and the git-list ' specification can be either a single pattern, or a pair of such patterns separated by a colon ":" (this means that a ref name -cannot have a colon in it). A single pattern '' is just a +cannot have a colon in it). A single pattern '' is just a shorthand for ':'. Each pattern pair consists of the source side (before the colon) diff --git a/Documentation/git-index-pack.txt b/Documentation/git-index-pack.txt index 226926964e..a8a7f6f04b 100644 --- a/Documentation/git-index-pack.txt +++ b/Documentation/git-index-pack.txt @@ -98,4 +98,3 @@ Documentation by Sergey Vlasov GIT --- Part of the gitlink:git[7] suite - diff --git a/Documentation/git-init-db.txt b/Documentation/git-init-db.txt index 5412135d76..ab0201aec2 100644 --- a/Documentation/git-init-db.txt +++ b/Documentation/git-init-db.txt @@ -16,4 +16,3 @@ DESCRIPTION This is a synonym for gitlink:git-init[1]. Please refer to the documentation of that command. - diff --git a/Documentation/git-init.txt b/Documentation/git-init.txt index 1b64d3ab03..413ed65143 100644 --- a/Documentation/git-init.txt +++ b/Documentation/git-init.txt @@ -108,4 +108,3 @@ Documentation by David Greaves, Junio C Hamano and the git-list . GIT --- Part of the gitlink:git[7] suite - diff --git a/Documentation/git-local-fetch.txt b/Documentation/git-local-fetch.txt index 51389ef37d..19b5f8895c 100644 --- a/Documentation/git-local-fetch.txt +++ b/Documentation/git-local-fetch.txt @@ -62,4 +62,3 @@ Documentation by David Greaves, Junio C Hamano and the git-list GIT --- Part of the gitlink:git[7] suite - diff --git a/Documentation/git-ls-tree.txt b/Documentation/git-ls-tree.txt index ad7f1b9202..7b78599673 100644 --- a/Documentation/git-ls-tree.txt +++ b/Documentation/git-ls-tree.txt @@ -92,4 +92,3 @@ Documentation by David Greaves, Junio C Hamano and the git-list GIT --- Part of the gitlink:git[7] suite - diff --git a/Documentation/git-mailinfo.txt b/Documentation/git-mailinfo.txt index 16956951dd..64aa6a1ea6 100644 --- a/Documentation/git-mailinfo.txt +++ b/Documentation/git-mailinfo.txt @@ -67,4 +67,3 @@ Documentation by Junio C Hamano and the git-list . GIT --- Part of the gitlink:git[7] suite - diff --git a/Documentation/git-mailsplit.txt b/Documentation/git-mailsplit.txt index abb0903696..c4f4cabbdc 100644 --- a/Documentation/git-mailsplit.txt +++ b/Documentation/git-mailsplit.txt @@ -56,4 +56,3 @@ Documentation by Junio C Hamano and the git-list . GIT --- Part of the gitlink:git[7] suite - diff --git a/Documentation/git-merge-base.txt b/Documentation/git-merge-base.txt index 3190aed108..6b71880ec4 100644 --- a/Documentation/git-merge-base.txt +++ b/Documentation/git-merge-base.txt @@ -40,4 +40,3 @@ Documentation by David Greaves, Junio C Hamano and the git-list git-merge-index cat AA MM cat: : No such file or directory @@ -85,4 +85,3 @@ Documentation by David Greaves, Junio C Hamano and the git-list . GIT --- Part of the gitlink:git[7] suite - diff --git a/Documentation/git-merge.txt b/Documentation/git-merge.txt index 912ef29efc..d285cba033 100644 --- a/Documentation/git-merge.txt +++ b/Documentation/git-merge.txt @@ -95,7 +95,7 @@ When things cleanly merge, these things happen: 1. the results are updated both in the index file and in your working tree, 2. index file is written out as a tree, -3. the tree gets committed, and +3. the tree gets committed, and 4. the `HEAD` pointer gets advanced. Because of 2., we require that the original state of the index diff --git a/Documentation/git-mergetool.txt b/Documentation/git-mergetool.txt index add01e855a..b89c51c65b 100644 --- a/Documentation/git-mergetool.txt +++ b/Documentation/git-mergetool.txt @@ -43,4 +43,3 @@ Documentation by Theodore Y Ts'o. GIT --- Part of the gitlink:git[7] suite - diff --git a/Documentation/git-mktag.txt b/Documentation/git-mktag.txt index 2860a3d1ba..0ac3be10c7 100644 --- a/Documentation/git-mktag.txt +++ b/Documentation/git-mktag.txt @@ -44,4 +44,3 @@ Documentation by David Greaves, Junio C Hamano and the git-list . GIT --- Part of the gitlink:git[7] suite - diff --git a/Documentation/git-mv.txt b/Documentation/git-mv.txt index 6756b76bb1..2c9cf743c7 100644 --- a/Documentation/git-mv.txt +++ b/Documentation/git-mv.txt @@ -51,4 +51,3 @@ Documentation by David Greaves, Junio C Hamano and the git-list GIT --- Part of the gitlink:git[7] suite - diff --git a/Documentation/git-pack-objects.txt b/Documentation/git-pack-objects.txt index cfe127ad9e..e3549b5044 100644 --- a/Documentation/git-pack-objects.txt +++ b/Documentation/git-pack-objects.txt @@ -185,4 +185,3 @@ gitlink:git-prune-packed[1] GIT --- Part of the gitlink:git[7] suite - diff --git a/Documentation/git-pack-redundant.txt b/Documentation/git-pack-redundant.txt index 94bbea0db2..f2ceebac4b 100644 --- a/Documentation/git-pack-redundant.txt +++ b/Documentation/git-pack-redundant.txt @@ -17,7 +17,7 @@ are redundant. The output is suitable for piping to 'xargs rm' if you are in the root of the repository. git-pack-redundant accepts a list of objects on standard input. Any objects -given will be ignored when checking which packs are required. This makes the +given will be ignored when checking which packs are required. This makes the following command useful when wanting to remove packs which contain unreachable objects. @@ -55,4 +55,3 @@ gitlink:git-prune-packed[1] GIT --- Part of the gitlink:git[7] suite - diff --git a/Documentation/git-patch-id.txt b/Documentation/git-patch-id.txt index a7e9fd021a..ad528a9224 100644 --- a/Documentation/git-patch-id.txt +++ b/Documentation/git-patch-id.txt @@ -40,4 +40,3 @@ Documentation by Junio C Hamano and the git-list . GIT --- Part of the gitlink:git[7] suite - diff --git a/Documentation/git-peek-remote.txt b/Documentation/git-peek-remote.txt index 74f37bd904..abc171266a 100644 --- a/Documentation/git-peek-remote.txt +++ b/Documentation/git-peek-remote.txt @@ -52,4 +52,3 @@ Documentation by Junio C Hamano. GIT --- Part of the gitlink:git[7] suite - diff --git a/Documentation/git-prune-packed.txt b/Documentation/git-prune-packed.txt index 310033e460..3800edb7bb 100644 --- a/Documentation/git-prune-packed.txt +++ b/Documentation/git-prune-packed.txt @@ -50,4 +50,3 @@ gitlink:git-repack[1] GIT --- Part of the gitlink:git[7] suite - diff --git a/Documentation/git-prune.txt b/Documentation/git-prune.txt index 0b44f3015d..50ee5bddd0 100644 --- a/Documentation/git-prune.txt +++ b/Documentation/git-prune.txt @@ -58,4 +58,3 @@ Documentation by David Greaves, Junio C Hamano and the git-list . GIT --- Part of the gitlink:git[7] suite - diff --git a/Documentation/git-push.txt b/Documentation/git-push.txt index e9ad10672a..366c5dbdce 100644 --- a/Documentation/git-push.txt +++ b/Documentation/git-push.txt @@ -110,4 +110,3 @@ Documentation by Junio C Hamano and the git-list . GIT --- Part of the gitlink:git[7] suite - diff --git a/Documentation/git-quiltimport.txt b/Documentation/git-quiltimport.txt index 296937a416..1c3ef4c593 100644 --- a/Documentation/git-quiltimport.txt +++ b/Documentation/git-quiltimport.txt @@ -58,4 +58,3 @@ Documentation by Eric Biederman GIT --- Part of the gitlink:git[7] suite - diff --git a/Documentation/git-read-tree.txt b/Documentation/git-read-tree.txt index acb57447a8..84184d6294 100644 --- a/Documentation/git-read-tree.txt +++ b/Documentation/git-read-tree.txt @@ -356,4 +356,3 @@ Documentation by David Greaves, Junio C Hamano and the git-list . GIT --- Part of the gitlink:git[7] suite - diff --git a/Documentation/git-reflog.txt b/Documentation/git-reflog.txt index 1e343bcdcd..f717e1e30c 100644 --- a/Documentation/git-reflog.txt +++ b/Documentation/git-reflog.txt @@ -65,4 +65,3 @@ Documentation by Junio C Hamano and the git-list . GIT --- Part of the gitlink:git[7] suite - diff --git a/Documentation/git-relink.txt b/Documentation/git-relink.txt index aca60120c8..fe631bb3dd 100644 --- a/Documentation/git-relink.txt +++ b/Documentation/git-relink.txt @@ -34,4 +34,3 @@ Documentation by Junio C Hamano and the git-list . GIT --- Part of the gitlink:git[7] suite - diff --git a/Documentation/git-remote.txt b/Documentation/git-remote.txt index 3dde7134a5..ab232c2f68 100644 --- a/Documentation/git-remote.txt +++ b/Documentation/git-remote.txt @@ -128,4 +128,3 @@ Documentation by J. Bruce Fields and the git-list . GIT --- Part of the gitlink:git[7] suite - diff --git a/Documentation/git-repack.txt b/Documentation/git-repack.txt index 2847c9b8d7..c33a512ffb 100644 --- a/Documentation/git-repack.txt +++ b/Documentation/git-repack.txt @@ -101,4 +101,3 @@ gitlink:git-prune-packed[1] GIT --- Part of the gitlink:git[7] suite - diff --git a/Documentation/git-request-pull.txt b/Documentation/git-request-pull.txt index 478a5fd6b7..087eeb7cc2 100644 --- a/Documentation/git-request-pull.txt +++ b/Documentation/git-request-pull.txt @@ -37,4 +37,3 @@ Documentation by Junio C Hamano and the git-list . GIT --- Part of the gitlink:git[7] suite - diff --git a/Documentation/git-rev-parse.txt b/Documentation/git-rev-parse.txt index 7757abe621..e1cb4ef856 100644 --- a/Documentation/git-rev-parse.txt +++ b/Documentation/git-rev-parse.txt @@ -286,4 +286,3 @@ Documentation by Junio C Hamano and the git-list . GIT --- Part of the gitlink:git[7] suite - diff --git a/Documentation/git-revert.txt b/Documentation/git-revert.txt index 8081bbaffa..69db498447 100644 --- a/Documentation/git-revert.txt +++ b/Documentation/git-revert.txt @@ -56,4 +56,3 @@ Documentation by Junio C Hamano and the git-list . GIT --- Part of the gitlink:git[7] suite - diff --git a/Documentation/git-rm.txt b/Documentation/git-rm.txt index a65f24a0f6..78f45dca2e 100644 --- a/Documentation/git-rm.txt +++ b/Documentation/git-rm.txt @@ -95,4 +95,3 @@ Documentation by Junio C Hamano and the git-list . GIT --- Part of the gitlink:git[7] suite - diff --git a/Documentation/git-runstatus.txt b/Documentation/git-runstatus.txt index 8bb52f4687..dee5d0da9d 100644 --- a/Documentation/git-runstatus.txt +++ b/Documentation/git-runstatus.txt @@ -66,4 +66,3 @@ Documentation by David Greaves, Junio C Hamano and the git-list . GIT --- Part of the gitlink:git[7] suite - diff --git a/Documentation/git-shell.txt b/Documentation/git-shell.txt index 228b9f14f3..48f2d57b7b 100644 --- a/Documentation/git-shell.txt +++ b/Documentation/git-shell.txt @@ -32,4 +32,3 @@ Documentation by Petr Baudis and the git-list . GIT --- Part of the gitlink:git[7] suite - diff --git a/Documentation/git-shortlog.txt b/Documentation/git-shortlog.txt index 15cc6f77c1..2220ef6ea8 100644 --- a/Documentation/git-shortlog.txt +++ b/Documentation/git-shortlog.txt @@ -56,4 +56,3 @@ Documentation by Junio C Hamano. GIT --- Part of the gitlink:git[7] suite - diff --git a/Documentation/git-show-index.txt b/Documentation/git-show-index.txt index be09b62beb..764d99356b 100644 --- a/Documentation/git-show-index.txt +++ b/Documentation/git-show-index.txt @@ -32,4 +32,3 @@ Documentation by Junio C Hamano GIT --- Part of the gitlink:git[7] suite - diff --git a/Documentation/git-show.txt b/Documentation/git-show.txt index 34c5caf2d0..a42e121150 100644 --- a/Documentation/git-show.txt +++ b/Documentation/git-show.txt @@ -84,4 +84,3 @@ This manual page is a stub. You can help the git documentation by expanding it. GIT --- Part of the gitlink:git[7] suite - diff --git a/Documentation/git-ssh-fetch.txt b/Documentation/git-ssh-fetch.txt index 192b1f15a9..aaf3db06da 100644 --- a/Documentation/git-ssh-fetch.txt +++ b/Documentation/git-ssh-fetch.txt @@ -48,4 +48,3 @@ Documentation by David Greaves, Junio C Hamano and the git-list . GIT --- Part of the gitlink:git[7] suite - diff --git a/Documentation/git-svnimport.txt b/Documentation/git-svnimport.txt index bdae7d87dc..e97d15e8f2 100644 --- a/Documentation/git-svnimport.txt +++ b/Documentation/git-svnimport.txt @@ -174,4 +174,3 @@ Documentation by Matthias Urlichs . GIT --- Part of the gitlink:git[7] suite - diff --git a/Documentation/git-tar-tree.txt b/Documentation/git-tar-tree.txt index 7bde73b1b8..2d01d9666f 100644 --- a/Documentation/git-tar-tree.txt +++ b/Documentation/git-tar-tree.txt @@ -90,4 +90,3 @@ Documentation by David Greaves, Junio C Hamano and the git-list :: Directly insert the specified info into the index. - + --index-info:: Read index information from stdin. --chmod=(+|-)x:: - Set the execute permissions on the updated files. + Set the execute permissions on the updated files. --assume-unchanged, --no-assume-unchanged:: When these flags are specified, the object name recorded @@ -126,7 +126,7 @@ OPTIONS :: Files to act on. Note that files beginning with '.' are discarded. This includes - `./file` and `dir/./file`. If you don't want this, then use + `./file` and `dir/./file`. If you don't want this, then use cleaner names. The same applies to directories ending '/' and paths with '//' @@ -324,4 +324,3 @@ Documentation by David Greaves, Junio C Hamano and the git-list . GIT --- Part of the gitlink:git[7] suite - diff --git a/Documentation/git-verify-pack.txt b/Documentation/git-verify-pack.txt index 7a6132b016..f4c540f39b 100644 --- a/Documentation/git-verify-pack.txt +++ b/Documentation/git-verify-pack.txt @@ -51,4 +51,3 @@ Documentation by Junio C Hamano GIT --- Part of the gitlink:git[7] suite - diff --git a/Documentation/git-verify-tag.txt b/Documentation/git-verify-tag.txt index 0f9bdb58dc..48d17fd9c4 100644 --- a/Documentation/git-verify-tag.txt +++ b/Documentation/git-verify-tag.txt @@ -29,4 +29,3 @@ Documentation by Junio C Hamano and the git-list . GIT --- Part of the gitlink:git[7] suite - diff --git a/Documentation/git-whatchanged.txt b/Documentation/git-whatchanged.txt index 399bff3bbc..607df48f09 100644 --- a/Documentation/git-whatchanged.txt +++ b/Documentation/git-whatchanged.txt @@ -78,4 +78,3 @@ Documentation by David Greaves, Junio C Hamano and the git-list . GIT --- Part of the gitlink:git[7] suite - diff --git a/Documentation/gitk.txt b/Documentation/gitk.txt index 48c5894736..e9f82b97b9 100644 --- a/Documentation/gitk.txt +++ b/Documentation/gitk.txt @@ -99,4 +99,3 @@ Documentation by Junio C Hamano, Jonas Fonseca, and the git-list GIT --- Part of the gitlink:git[7] suite - diff --git a/Documentation/howto/rebase-and-edit.txt b/Documentation/howto/rebase-and-edit.txt index 646c55cc69..554909fe08 100644 --- a/Documentation/howto/rebase-and-edit.txt +++ b/Documentation/howto/rebase-and-edit.txt @@ -9,16 +9,16 @@ Abstract: In this article, Linus demonstrates how a broken commit On Sat, 13 Aug 2005, Linus Torvalds wrote: -> That's correct. Same things apply: you can move a patch over, and create a -> new one with a modified comment, but basically the _old_ commit will be +> That's correct. Same things apply: you can move a patch over, and create a +> new one with a modified comment, but basically the _old_ commit will be > immutable. Let me clarify. You can entirely _drop_ old branches, so commits may be immutable, but -nothing forces you to keep them. Of course, when you drop a commit, you'll -always end up dropping all the commits that depended on it, and if you -actually got somebody else to pull that commit you can't drop it from +nothing forces you to keep them. Of course, when you drop a commit, you'll +always end up dropping all the commits that depended on it, and if you +actually got somebody else to pull that commit you can't drop it from _their_ repository, but undoing things is not impossible. For example, let's say that you've made a mess of things: you've committed @@ -29,7 +29,7 @@ want to save "b" and "c". What you can do is # for reference git branch broken - # Reset the main branch to three parents back: this + # Reset the main branch to three parents back: this # effectively undoes the three top commits git reset HEAD^^^ git checkout -f @@ -59,7 +59,7 @@ Finally, check out the end result again: to see that everything looks sensible. -And then, you can just remove the broken branch if you decide you really +And then, you can just remove the broken branch if you decide you really don't want it: # remove 'broken' branch @@ -68,8 +68,8 @@ don't want it: # Prune old objects if you're really really sure git prune -And yeah, I'm sure there are other ways of doing this. And as usual, the -above is totally untested, and I just wrote it down in this email, so if +And yeah, I'm sure there are other ways of doing this. And as usual, the +above is totally untested, and I just wrote it down in this email, so if I've done something wrong, you'll have to figure it out on your own ;) Linus @@ -77,5 +77,3 @@ I've done something wrong, you'll have to figure it out on your own ;) To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html - - diff --git a/Documentation/howto/rebase-from-internal-branch.txt b/Documentation/howto/rebase-from-internal-branch.txt index 3b3a5c2e69..7a76045eb7 100644 --- a/Documentation/howto/rebase-from-internal-branch.txt +++ b/Documentation/howto/rebase-from-internal-branch.txt @@ -14,10 +14,10 @@ Petr Baudis writes: > Dear diary, on Sun, Aug 14, 2005 at 09:57:13AM CEST, I got a letter > where Junio C Hamano told me that... >> Linus Torvalds writes: ->> ->> > Junio, maybe you want to talk about how you move patches from your "pu" +>> +>> > Junio, maybe you want to talk about how you move patches from your "pu" >> > branch to the real branches. ->> +>> > Actually, wouldn't this be also precisely for what StGIT is intended to? Exactly my feeling. I was sort of waiting for Catalin to speak @@ -118,7 +118,7 @@ up your changes, along with other changes. where *your "master" head upstream --> #1 --> #2 --> #3 - used \ + used \ to be \--> #A --> #2' --> #3' --> #B --> #C *upstream head @@ -133,7 +133,7 @@ You fetch from upstream, but not merge. $ git fetch upstream This leaves the updated upstream head in .git/FETCH_HEAD but -does not touch your .git/HEAD nor .git/refs/heads/master. +does not touch your .git/HEAD nor .git/refs/heads/master. You run "git rebase" now. $ git rebase FETCH_HEAD master @@ -161,5 +161,3 @@ the #1' commit. To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html - - diff --git a/Documentation/howto/rebuild-from-update-hook.txt b/Documentation/howto/rebuild-from-update-hook.txt index 02621b54a0..8d55dfbfae 100644 --- a/Documentation/howto/rebuild-from-update-hook.txt +++ b/Documentation/howto/rebuild-from-update-hook.txt @@ -84,4 +84,3 @@ There are four things worth mentioning: - This is still crude and does not protect against simultaneous make invocations stomping on each other. I would need to add some locking mechanism for this. - diff --git a/Documentation/howto/revert-branch-rebase.txt b/Documentation/howto/revert-branch-rebase.txt index d88ec23a97..865a666324 100644 --- a/Documentation/howto/revert-branch-rebase.txt +++ b/Documentation/howto/revert-branch-rebase.txt @@ -146,7 +146,7 @@ Everything is in the good order. I do not need the temporary branch nor tag anymore, so remove them: ------------------------------------------------ -$ rm -f .git/refs/tags/pu-anchor +$ rm -f .git/refs/tags/pu-anchor $ git branch -d revert-c99 ------------------------------------------------ diff --git a/Documentation/howto/separating-topic-branches.txt b/Documentation/howto/separating-topic-branches.txt index 090e2c9b01..0d73b31224 100644 --- a/Documentation/howto/separating-topic-branches.txt +++ b/Documentation/howto/separating-topic-branches.txt @@ -12,7 +12,7 @@ up with a history like this: "master" o---o - \ "topic" + \ "topic" o---o---o---o---o---o At this point, "topic" contains something I know I want, but it @@ -29,11 +29,11 @@ start building on top of "master": $ git checkout -b topicA master ... pick and apply pieces from P.diff to build ... commits on topicA branch. - + o---o---o / "topicA" o---o"master" - \ "topic" + \ "topic" o---o---o---o---o---o Before doing each commit on "topicA" HEAD, I run "diff HEAD" @@ -59,7 +59,7 @@ other topic: /o---o---o |/ "topicA" o---o"master" - \ "topic" + \ "topic" o---o---o---o---o---o After I am done, I'd try a pretend-merge between "topicA" and @@ -73,7 +73,7 @@ After I am done, I'd try a pretend-merge between "topicA" and /o---o---o----------' |/ "topicA" o---o"master" - \ "topic" + \ "topic" o---o---o---o---o---o The last diff better not to show anything other than cleanups @@ -84,8 +84,7 @@ for crufts. Then I can finally clean things up: "topicB" o---o---o---o---o - / + / /o---o---o |/ "topicA" o---o"master" - diff --git a/Documentation/howto/use-git-daemon.txt b/Documentation/howto/use-git-daemon.txt index 1a1eb246bf..4e2f75cb61 100644 --- a/Documentation/howto/use-git-daemon.txt +++ b/Documentation/howto/use-git-daemon.txt @@ -49,4 +49,3 @@ Now, test your daemon with $ git ls-remote git://127.0.0.1/rule-the-world.git If this does not work, find out why, and submit a patch to this document. - diff --git a/Documentation/merge-options.txt b/Documentation/merge-options.txt index 56f1d8d69d..d64c259bb3 100644 --- a/Documentation/merge-options.txt +++ b/Documentation/merge-options.txt @@ -25,4 +25,3 @@ If there is no `-s` option, a built-in list of strategies is used instead (`git-merge-recursive` when merging a single head, `git-merge-octopus` otherwise). - diff --git a/Documentation/pretty-formats.txt b/Documentation/pretty-formats.txt index d922e8e86c..c551ea61d2 100644 --- a/Documentation/pretty-formats.txt +++ b/Documentation/pretty-formats.txt @@ -121,4 +121,3 @@ The placeholders are: - '%Creset': reset color - '%m': left, right or boundary mark - '%n': newline - diff --git a/Documentation/pretty-options.txt b/Documentation/pretty-options.txt index 7d515be0fd..6338def5a7 100644 --- a/Documentation/pretty-options.txt +++ b/Documentation/pretty-options.txt @@ -11,4 +11,3 @@ command to re-code the commit log message in the encoding preferred by the user. For non plumbing commands this defaults to UTF-8. - diff --git a/Documentation/pull-fetch-param.txt b/Documentation/pull-fetch-param.txt index 8d4e950abc..b6eb7fc618 100644 --- a/Documentation/pull-fetch-param.txt +++ b/Documentation/pull-fetch-param.txt @@ -58,7 +58,7 @@ is often useful. + Some short-cut notations are also supported. + -* `tag ` means the same as `refs/tags/:refs/tags/`; +* `tag ` means the same as `refs/tags/:refs/tags/`; it requests fetching everything up to the given tag. * A parameter without a colon is equivalent to : when pulling/fetching, so it merges into the current diff --git a/Documentation/repository-layout.txt b/Documentation/repository-layout.txt index 15221b5320..4c92e375fe 100644 --- a/Documentation/repository-layout.txt +++ b/Documentation/repository-layout.txt @@ -177,4 +177,3 @@ shallow:: This is similar to `info/grafts` but is internally used and maintained by shallow clone mechanism. See `--depth` option to gitlink:git-clone[1] and gitlink:git-fetch[1]. - diff --git a/Documentation/technical/pack-format.txt b/Documentation/technical/pack-format.txt index 9ce3c473ae..e5b31c81fa 100644 --- a/Documentation/technical/pack-format.txt +++ b/Documentation/technical/pack-format.txt @@ -80,7 +80,7 @@ Pack Idx file: +--------------------------------+ | main | offset | | index | object name 00XXXXXXXXXXXXXXXX | | -table +--------------------------------+ | +table +--------------------------------+ | | offset | | | object name 00XXXXXXXXXXXXXXXX | | +--------------------------------+ | @@ -97,14 +97,14 @@ trailer | | packfile checksum | | +--------------------------------+ | | idxfile checksum | | +--------------------------------+ - .-------. + .-------. | Pack file entry: <+ packed object header: 1-byte size extension bit (MSB) type (next 3 bit) - size0 (lower 4-bit) + size0 (lower 4-bit) n-byte sizeN (as long as MSB is set, each 7-bit) size0..sizeN form 4+7+7+..+7 bit integer, size0 is the least significant part, and sizeN is the @@ -114,5 +114,5 @@ Pack file entry: <+ is the size before compression). If it is DELTA, then 20-byte base object name SHA1 (the size above is the - size of the delta data that follows). + size of the delta data that follows). delta data, deflated. diff --git a/Documentation/user-manual.txt b/Documentation/user-manual.txt index 7eaafa80e9..957cd00761 100644 --- a/Documentation/user-manual.txt +++ b/Documentation/user-manual.txt @@ -154,11 +154,11 @@ Author: Jamal Hadi Salim Date: Sat Dec 2 22:22:25 2006 -0800 [XFRM]: Fix aevent structuring to be more complete. - + aevents can not uniquely identify an SA. We break the ABI with this patch, but consensus is that since it is not yet utilized by any (known) application then it is fine (better do it now than later). - + Signed-off-by: Jamal Hadi Salim Signed-off-by: David S. Miller @@ -167,7 +167,7 @@ index 8be626f..d7aac9d 100644 --- a/Documentation/networking/xfrm_sync.txt +++ b/Documentation/networking/xfrm_sync.txt @@ -47,10 +47,13 @@ aevent_id structure looks like: - + struct xfrm_aevent_id { struct xfrm_usersa_id sa_id; + xfrm_address_t saddr; @@ -1056,7 +1056,7 @@ $ git show ------------------------------------------------- As a special shortcut, - + ------------------------------------------------- $ git commit -a ------------------------------------------------- @@ -1554,7 +1554,7 @@ history. Fortunately, git also keeps a log, called a "reflog", of all the previous values of each branch. So in this case you can still find the -old history using, for example, +old history using, for example, ------------------------------------------------- $ git log master@{1} @@ -1630,7 +1630,7 @@ If you decide you want the history back, you can always create a new reference pointing to it, for example, a new branch: ------------------------------------------------ -$ git branch recovered-branch 7281251ddd +$ git branch recovered-branch 7281251ddd ------------------------------------------------ Other types of dangling objects (blobs and trees) are also possible, and @@ -1793,7 +1793,7 @@ like this: you push your personal repo ------------------> your public repo - ^ | + ^ | | | | you pull | they pull | | @@ -2359,7 +2359,7 @@ the result would create a new merge commit, like this: \ \ a--b--c--m <-- mywork ................................................ - + However, if you prefer to keep the history in mywork a simple series of commits without any merges, you may instead choose to use gitlink:git-rebase[1]: @@ -2735,7 +2735,7 @@ must have at least one root, and while you can tie several different root objects together into one project by creating a commit object which has two or more separate roots as its ultimate parents, that's probably just going to confuse people. So aim for the notion of "one root object -per project", even if git itself does not enforce that. +per project", even if git itself does not enforce that. A <> symbolically identifies and can be used to sign other objects. It contains the identifier and type of @@ -2757,7 +2757,7 @@ independently of the contents or the type of the object: all objects can be validated by verifying that (a) their hashes match the content of the file and (b) the object successfully inflates to a stream of bytes that forms a sequence of + + + + . +size> + + . The structured objects can further have their structure and connectivity to other objects verified. This is generally done with @@ -2954,7 +2954,7 @@ cache, and the normal operation is to re-generate it completely from a known tree object, or update/compare it with a live tree that is being developed. If you blow the directory cache away entirely, you generally haven't lost any information as long as you have the name of the tree -that it described. +that it described. At the same time, the index is at the same time also the staging area for creating new trees, and creating a new tree always @@ -2974,7 +2974,7 @@ Generally, all "git" operations work on the index file. Some operations work *purely* on the index file (showing the current state of the index), but most operations move data to and from the index file. Either from the database or from the working directory. Thus there are four -main combinations: +main combinations: [[working-directory-to-index]] working directory -> index @@ -3437,7 +3437,7 @@ because you interrupted a "git fetch" with ^C or something like that, leaving _some_ of the new objects in the object database, but just dangling and useless. -Anyway, once you are sure that you're not interested in any dangling +Anyway, once you are sure that you're not interested in any dangling state, you can just prune all unreachable objects: ------------------------------------------------ @@ -3448,12 +3448,12 @@ and they'll be gone. But you should only run "git prune" on a quiescent repository - it's kind of like doing a filesystem fsck recovery: you don't want to do that while the filesystem is mounted. -(The same is true of "git-fsck" itself, btw - but since -git-fsck never actually *changes* the repository, it just reports -on what it found, git-fsck itself is never "dangerous" to run. -Running it while somebody is actually changing the repository can cause -confusing and scary messages, but it won't actually do anything bad. In -contrast, running "git prune" while somebody is actively changing the +(The same is true of "git-fsck" itself, btw - but since +git-fsck never actually *changes* the repository, it just reports +on what it found, git-fsck itself is never "dangerous" to run. +Running it while somebody is actually changing the repository can cause +confusing and scary messages, but it won't actually do anything bad. In +contrast, running "git prune" while somebody is actively changing the repository is a *BAD* idea). [[birdview-on-the-source-code]] diff --git a/GIT-VERSION-GEN b/GIT-VERSION-GEN index 06c360b267..289c8067b5 100755 --- a/GIT-VERSION-GEN +++ b/GIT-VERSION-GEN @@ -43,5 +43,3 @@ test "$VN" = "$VC" || { echo >&2 "GIT_VERSION = $VN" echo "GIT_VERSION = $VN" >$GVF } - - diff --git a/INSTALL b/INSTALL index 361c65bacc..95269cc513 100644 --- a/INSTALL +++ b/INSTALL @@ -31,7 +31,7 @@ Issues of note: interactive tools. None of the core git stuff needs the wrapper, it's just a convenient shorthand and while it is documented in some places, you can always replace "git commit" with "git-commit" - instead. + instead. But let's face it, most of us don't have GNU interactive tools, and even if we had it, we wouldn't know what it does. I don't think it @@ -111,4 +111,3 @@ Issues of note: would instead give you a copy of what you see at: http://www.kernel.org/pub/software/scm/git/docs/ - diff --git a/arm/sha1.c b/arm/sha1.c index 11b1a048b4..9e3ae038e8 100644 --- a/arm/sha1.c +++ b/arm/sha1.c @@ -49,7 +49,7 @@ void SHA1_Update(SHA_CTX *c, const void *p, unsigned long n) void SHA1_Final(unsigned char *hash, SHA_CTX *c) { uint64_t bitlen; - uint32_t bitlen_hi, bitlen_lo; + uint32_t bitlen_hi, bitlen_lo; unsigned int i, offset, padlen; unsigned char bits[8]; static const unsigned char padding[64] = { 0x80, }; @@ -69,7 +69,7 @@ void SHA1_Final(unsigned char *hash, SHA_CTX *c) bits[5] = bitlen_lo >> 16; bits[6] = bitlen_lo >> 8; bits[7] = bitlen_lo; - SHA1_Update(c, bits, 8); + SHA1_Update(c, bits, 8); for (i = 0; i < 5; i++) { uint32_t v = c->hash[i]; diff --git a/arm/sha1_arm.S b/arm/sha1_arm.S index a328b73375..8c1cb99fb4 100644 --- a/arm/sha1_arm.S +++ b/arm/sha1_arm.S @@ -181,4 +181,3 @@ sha_transform: .L_sha_K: .word 0x5a827999, 0x6ed9eba1, 0x8f1bbcdc, 0xca62c1d6 - diff --git a/builtin-annotate.c b/builtin-annotate.c index 9db7cfe74c..fc43eed36b 100644 --- a/builtin-annotate.c +++ b/builtin-annotate.c @@ -22,4 +22,3 @@ int cmd_annotate(int argc, const char **argv, const char *prefix) return cmd_blame(argc + 1, nargv, prefix); } - diff --git a/builtin-diff-index.c b/builtin-diff-index.c index d90eba95a6..81e7167438 100644 --- a/builtin-diff-index.c +++ b/builtin-diff-index.c @@ -23,7 +23,7 @@ int cmd_diff_index(int argc, const char **argv, const char *prefix) argc = setup_revisions(argc, argv, &rev, NULL); for (i = 1; i < argc; i++) { const char *arg = argv[i]; - + if (!strcmp(arg, "--cached")) cached = 1; else diff --git a/builtin-fmt-merge-msg.c b/builtin-fmt-merge-msg.c index 5c145d2165..ae60fccea7 100644 --- a/builtin-fmt-merge-msg.c +++ b/builtin-fmt-merge-msg.c @@ -357,4 +357,3 @@ int cmd_fmt_merge_msg(int argc, const char **argv, const char *prefix) return 0; } - diff --git a/builtin-fsck.c b/builtin-fsck.c index bacae5dfa6..944a496650 100644 --- a/builtin-fsck.c +++ b/builtin-fsck.c @@ -351,7 +351,7 @@ static int fsck_commit(struct commit *commit) if (!commit->parents && show_root) printf("root %s\n", sha1_to_hex(commit->object.sha1)); if (!commit->date) - printf("bad commit date in %s\n", + printf("bad commit date in %s\n", sha1_to_hex(commit->object.sha1)); return 0; } @@ -719,7 +719,7 @@ int cmd_fsck(int argc, char **argv, const char *prefix) heads = 0; for (i = 1; i < argc; i++) { - const char *arg = argv[i]; + const char *arg = argv[i]; if (*arg == '-') continue; diff --git a/builtin-ls-files.c b/builtin-ls-files.c index f7c066b24b..5398a41415 100644 --- a/builtin-ls-files.c +++ b/builtin-ls-files.c @@ -117,7 +117,7 @@ static void show_other_files(struct dir_struct *dir) if (0 <= pos) continue; /* exact match */ pos = -pos - 1; - if (pos < active_nr) { + if (pos < active_nr) { ce = active_cache[pos]; if (ce_namelen(ce) == len && !memcmp(ce->name, ent->name, len)) diff --git a/builtin-name-rev.c b/builtin-name-rev.c index d3c42ed67e..61eba343ab 100644 --- a/builtin-name-rev.c +++ b/builtin-name-rev.c @@ -290,4 +290,3 @@ int cmd_name_rev(int argc, const char **argv, const char *prefix) return 0; } - diff --git a/builtin-pack-objects.c b/builtin-pack-objects.c index 8b9740c277..3d396ca37a 100644 --- a/builtin-pack-objects.c +++ b/builtin-pack-objects.c @@ -252,7 +252,7 @@ static void *delta_against(void *buf, unsigned long size, struct object_entry *e delta_buf = diff_delta(otherbuf, othersize, buf, size, &delta_size, 0); if (!delta_buf || delta_size != entry->delta_size) - die("delta size changed"); + die("delta size changed"); free(buf); free(otherbuf); return delta_buf; diff --git a/builtin-rerere.c b/builtin-rerere.c index 8c2c8bdc18..f6409b93c1 100644 --- a/builtin-rerere.c +++ b/builtin-rerere.c @@ -434,4 +434,3 @@ int cmd_rerere(int argc, const char **argv, const char *prefix) path_list_clear(&merge_rr, 1); return 0; } - diff --git a/builtin-shortlog.c b/builtin-shortlog.c index 8d3f742d43..16af6199ab 100644 --- a/builtin-shortlog.c +++ b/builtin-shortlog.c @@ -331,4 +331,3 @@ int cmd_shortlog(int argc, const char **argv, const char *prefix) return 0; } - diff --git a/cache.h b/cache.h index 8a9d1f3883..5e7381eb1e 100644 --- a/cache.h +++ b/cache.h @@ -479,7 +479,7 @@ extern void prepare_packed_git(void); extern void reprepare_packed_git(void); extern void install_packed_git(struct packed_git *pack); -extern struct packed_git *find_sha1_pack(const unsigned char *sha1, +extern struct packed_git *find_sha1_pack(const unsigned char *sha1, struct packed_git *packs); extern void pack_report(void); diff --git a/commit.c b/commit.c index 5632e32685..57b69ca7fa 100644 --- a/commit.c +++ b/commit.c @@ -148,7 +148,7 @@ static int commit_graft_pos(const unsigned char *sha1) int register_commit_graft(struct commit_graft *graft, int ignore_dups) { int pos = commit_graft_pos(graft->sha1); - + if (0 <= pos) { if (ignore_dups) free(graft); @@ -406,7 +406,7 @@ struct commit_list * insert_by_date(struct commit *item, struct commit_list **li return commit_list_insert(item, pp); } - + void sort_by_date(struct commit_list **list) { struct commit_list *ret = NULL; @@ -1160,7 +1160,7 @@ void sort_in_topological_order_fn(struct commit_list ** list, int lifo, next = next->next; count++; } - + if (!count) return; /* allocate an array to help sort the list */ @@ -1188,11 +1188,11 @@ void sort_in_topological_order_fn(struct commit_list ** list, int lifo, } next=next->next; } - /* + /* * find the tips * - * tips are nodes not reachable from any other node in the list - * + * tips are nodes not reachable from any other node in the list + * * the tips serve as a starting set for the work queue. */ next=*list; @@ -1220,7 +1220,7 @@ void sort_in_topological_order_fn(struct commit_list ** list, int lifo, if (pn) { /* - * parents are only enqueued for emission + * parents are only enqueued for emission * when all their children have been emitted thereby * guaranteeing topological order. */ diff --git a/commit.h b/commit.h index 86e8dca0c9..75b43a53ed 100644 --- a/commit.h +++ b/commit.h @@ -66,7 +66,7 @@ extern unsigned long pretty_print_commit(enum cmit_fmt fmt, const struct commit /** Removes the first commit from a list sorted by date, and adds all * of its parents. **/ -struct commit *pop_most_recent_commit(struct commit_list **list, +struct commit *pop_most_recent_commit(struct commit_list **list, unsigned int mark); struct commit *pop_commit(struct commit_list **stack); diff --git a/compat/mmap.c b/compat/mmap.c index 4cfaee3136..c9d46d1742 100644 --- a/compat/mmap.c +++ b/compat/mmap.c @@ -40,4 +40,3 @@ int git_munmap(void *start, size_t length) free(start); return 0; } - diff --git a/config.c b/config.c index 0614c2b29f..58d3ed5d37 100644 --- a/config.c +++ b/config.c @@ -621,7 +621,7 @@ static ssize_t find_beginning_of_line(const char* contents, size_t size, size_t equal_offset = size, bracket_offset = size; ssize_t offset; - for (offset = offset_-2; offset > 0 + for (offset = offset_-2; offset > 0 && contents[offset] != '\n'; offset--) switch (contents[offset]) { case '=': equal_offset = offset; break; @@ -989,4 +989,3 @@ int git_config_rename_section(const char *old_name, const char *new_name) free(config_filename); return ret; } - diff --git a/config.mak.in b/config.mak.in index eb9d7a5549..a3032e389f 100644 --- a/config.mak.in +++ b/config.mak.in @@ -38,4 +38,3 @@ NO_STRCASESTR=@NO_STRCASESTR@ NO_STRLCPY=@NO_STRLCPY@ NO_SETENV=@NO_SETENV@ NO_ICONV=@NO_ICONV@ - diff --git a/connect.c b/connect.c index 8cbda88dda..7fab9c0fd9 100644 --- a/connect.c +++ b/connect.c @@ -390,7 +390,7 @@ static int git_proxy_command_options(const char *var, const char *value) } if (0 <= matchlen) { /* core.gitproxy = none for kernel.org */ - if (matchlen == 4 && + if (matchlen == 4 && !memcmp(value, "none", 4)) matchlen = 0; git_proxy_command = xmalloc(matchlen + 1); diff --git a/contrib/README b/contrib/README index e1c0a01ff3..05f291c1f1 100644 --- a/contrib/README +++ b/contrib/README @@ -41,4 +41,3 @@ submit a patch to create a subdirectory of contrib/ and put your stuff there. -jc - diff --git a/contrib/blameview/README b/contrib/blameview/README index 50a6f67fd6..fada5ce909 100644 --- a/contrib/blameview/README +++ b/contrib/blameview/README @@ -7,4 +7,3 @@ To: Linus Torvalds Cc: git@vger.kernel.org Date: Sat, 27 Jan 2007 18:52:38 -0500 Message-ID: <20070127235238.GA28706@coredump.intra.peff.net> - diff --git a/contrib/gitview/gitview b/contrib/gitview/gitview index 2d80e2bad2..3dc1ef50c7 100755 --- a/contrib/gitview/gitview +++ b/contrib/gitview/gitview @@ -1277,5 +1277,3 @@ if __name__ == "__main__": view = GitView( without_diff != 1) view.run(sys.argv[without_diff:]) - - diff --git a/contrib/hooks/post-receive-email b/contrib/hooks/post-receive-email index d1bef9125b..c589a39a0c 100644 --- a/contrib/hooks/post-receive-email +++ b/contrib/hooks/post-receive-email @@ -199,7 +199,7 @@ generate_email_footer() hooks/post-receive - -- + -- $projectdesc EOF } diff --git a/contrib/remotes2config.sh b/contrib/remotes2config.sh index dc09eae972..0c8b954490 100644 --- a/contrib/remotes2config.sh +++ b/contrib/remotes2config.sh @@ -31,5 +31,3 @@ if [ -d "$GIT_DIR"/remotes ]; then esac done fi - - diff --git a/convert-objects.c b/convert-objects.c index cefbcebdca..90e7900e6d 100644 --- a/convert-objects.c +++ b/convert-objects.c @@ -194,7 +194,7 @@ static unsigned long parse_oldstyle_date(const char *buf) fmt++; } while (*buf && *fmt); printf("left: %s\n", buf); - return mktime(&tm); + return mktime(&tm); } static int convert_date_line(char *dst, void **buf, unsigned long *sp) diff --git a/copy.c b/copy.c index d340bb253e..c225d1b0ff 100644 --- a/copy.c +++ b/copy.c @@ -34,4 +34,3 @@ int copy_fd(int ifd, int ofd) close(ifd); return 0; } - diff --git a/ctype.c b/ctype.c index 56bdffa636..ee06eb7f48 100644 --- a/ctype.c +++ b/ctype.c @@ -20,4 +20,3 @@ unsigned char sane_ctype[256] = { AA, AA, AA, AA, AA, AA, AA, AA, AA, AA, AA, 0, 0, 0, 0, 0, /* 112-15 */ /* Nothing in the 128.. range */ }; - diff --git a/daemon.c b/daemon.c index 674e30dca3..77792509e3 100644 --- a/daemon.c +++ b/daemon.c @@ -133,7 +133,7 @@ static int avoid_alias(char *p) { int sl, ndot; - /* + /* * This resurrects the belts and suspenders paranoia check by HPA * done in <435560F7.4080006@zytor.com> thread, now enter_repo() * does not do getcwd() based path canonicalizations. @@ -247,7 +247,7 @@ static char *path_ok(struct interp *itable) int pathlen = strlen(path); /* The validation is done on the paths after enter_repo - * appends optional {.git,.git/.git} and friends, but + * appends optional {.git,.git/.git} and friends, but * it does not use getcwd(). So if your /pub is * a symlink to /mnt/pub, you can whitelist /pub and * do not have to say /mnt/pub. diff --git a/date.c b/date.c index 4690371e55..316841e8ad 100644 --- a/date.c +++ b/date.c @@ -403,7 +403,7 @@ static int match_multi_number(unsigned long num, char c, const char *date, char } /* - * We've seen a digit. Time? Year? Date? + * We've seen a digit. Time? Year? Date? */ static int match_digit(const char *date, struct tm *tm, int *offset, int *tm_gmt) { @@ -495,7 +495,7 @@ static int match_digit(const char *date, struct tm *tm, int *offset, int *tm_gmt } else if (num > 0 && num < 13) { tm->tm_mon = num-1; } - + return n; } @@ -569,13 +569,13 @@ int parse_date(const char *date, char *result, int maxlen) if (!match) { /* BAD CRAP */ match = 1; - } + } date += match; } /* mktime uses local timezone */ - then = my_mktime(&tm); + then = my_mktime(&tm); if (offset == -1) offset = (then - mktime(&tm)) / 60; @@ -691,7 +691,7 @@ static const struct typelen { { "days", 24*60*60 }, { "weeks", 7*24*60*60 }, { NULL } -}; +}; static const char *approxidate_alpha(const char *date, struct tm *tm, int *num) { diff --git a/diff-lib.c b/diff-lib.c index 07f4e8106a..7fb19c7b87 100644 --- a/diff-lib.c +++ b/diff-lib.c @@ -664,7 +664,7 @@ int run_diff_index(struct rev_info *revs, int cached) const char *tree_name; int match_missing = 0; - /* + /* * Backward compatibility wart - "diff-index -m" does * not mean "do not ignore merges", but totally different. */ diff --git a/diff.c b/diff.c index c57ac33414..cafa7debeb 100644 --- a/diff.c +++ b/diff.c @@ -3031,7 +3031,7 @@ void diff_addremove(struct diff_options *options, * entries to the diff-core. They will be prefixed * with something like '=' or '*' (I haven't decided * which but should not make any difference). - * Feeding the same new and old to diff_change() + * Feeding the same new and old to diff_change() * also has the same effect. * Before the final output happens, they are pruned after * merged into rename/copy pairs as appropriate. @@ -3058,7 +3058,7 @@ void diff_change(struct diff_options *options, unsigned old_mode, unsigned new_mode, const unsigned char *old_sha1, const unsigned char *new_sha1, - const char *base, const char *path) + const char *base, const char *path) { char concatpath[PATH_MAX]; struct diff_filespec *one, *two; diff --git a/diffcore-pickaxe.c b/diffcore-pickaxe.c index c4a77d71da..af9fffe6e8 100644 --- a/diffcore-pickaxe.c +++ b/diffcore-pickaxe.c @@ -102,7 +102,7 @@ void diffcore_pickaxe(const char *needle, int opts) for (i = 0; i < q->nr; i++) diff_free_filepair(q->queue[i]); } - else + else /* Showing only the filepairs that has the needle */ for (i = 0; i < q->nr; i++) { struct diff_filepair *p = q->queue[i]; diff --git a/entry.c b/entry.c index ae6476496a..c540ae13e8 100644 --- a/entry.c +++ b/entry.c @@ -31,7 +31,7 @@ static void remove_subtree(const char *path) struct dirent *de; char pathbuf[PATH_MAX]; char *name; - + if (!dir) die("cannot opendir %s (%s)", path, strerror(errno)); strcpy(pathbuf, path); diff --git a/environment.c b/environment.c index 9d3e5eb72f..8b9b89d0a0 100644 --- a/environment.c +++ b/environment.c @@ -105,5 +105,3 @@ char *get_graft_file(void) setup_git_env(); return git_graft_file; } - - diff --git a/fetch-pack.c b/fetch-pack.c index aa59043c03..9c81305be5 100644 --- a/fetch-pack.c +++ b/fetch-pack.c @@ -114,7 +114,7 @@ static const unsigned char* get_rev(void) commit->object.flags |= POPPED; if (!(commit->object.flags & COMMON)) non_common_revs--; - + parents = commit->parents; if (commit->object.flags & COMMON) { diff --git a/fetch.c b/fetch.c index 8e29d313f8..dda33e548b 100644 --- a/fetch.c +++ b/fetch.c @@ -15,7 +15,7 @@ int get_verbosely = 0; int get_recover = 0; static unsigned char current_commit_sha1[20]; -void pull_say(const char *fmt, const char *hex) +void pull_say(const char *fmt, const char *hex) { if (get_verbosely) fprintf(stderr, fmt, hex); @@ -153,7 +153,7 @@ static int process(struct object *obj) return 0; prefetch(obj->sha1); } - + object_list_insert(obj, process_queue_end); process_queue_end = &(*process_queue_end)->next; return 0; diff --git a/git-archimport.perl b/git-archimport.perl index c1e7c1ddcb..b21077206a 100755 --- a/git-archimport.perl +++ b/git-archimport.perl @@ -3,19 +3,19 @@ # This tool is copyright (c) 2005, Martin Langhoff. # It is released under the Gnu Public License, version 2. # -# The basic idea is to walk the output of tla abrowse, -# fetch the changesets and apply them. +# The basic idea is to walk the output of tla abrowse, +# fetch the changesets and apply them. # =head1 Invocation - git-archimport [ -h ] [ -v ] [ -o ] [ -a ] [ -f ] [ -T ] - [ -D depth] [ -t tempdir ] / [ / ] + git-archimport [ -h ] [ -v ] [ -o ] [ -a ] [ -f ] [ -T ] + [ -D depth] [ -t tempdir ] / [ / ] Imports a project from one or more Arch repositories. It will follow branches and repositories within the namespaces defined by the parameters supplied. If it cannot find the remote branch a merge comes from -it will just import it as a regular commit. If it can find it, it will mark it +it will just import it as a regular commit. If it can find it, it will mark it as a merge whenever possible. See man (1) git-archimport for more details. @@ -25,14 +25,14 @@ See man (1) git-archimport for more details. - create tag objects instead of ref tags - audit shell-escaping of filenames - hide our private tags somewhere smarter - - find a way to make "cat *patches | patch" safe even when patchfiles are missing newlines + - find a way to make "cat *patches | patch" safe even when patchfiles are missing newlines - sort and apply patches by graphing ancestry relations instead of just relying in dates supplied in the changeset itself. tla ancestry-graph -m could be helpful here... =head1 Devel tricks -Add print in front of the shell commands invoked via backticks. +Add print in front of the shell commands invoked via backticks. =head1 Devel Notes @@ -126,16 +126,16 @@ sub do_abrowse { my $stage = shift; while (my ($limit, $level) = each %arch_branches) { next unless $level == $stage; - - open ABROWSE, "$TLA abrowse -fkD --merges $limit |" + + open ABROWSE, "$TLA abrowse -fkD --merges $limit |" or die "Problems with tla abrowse: $!"; - + my %ps = (); # the current one my $lastseen = ''; - + while () { chomp; - + # first record padded w 8 spaces if (s/^\s{8}\b//) { my ($id, $type) = split(m/\s+/, $_, 2); @@ -147,13 +147,13 @@ sub do_abrowse { push (@psets, \%last_ps); $psets{ $last_ps{id} } = \%last_ps; } - + my $branch = extract_versionname($id); %ps = ( id => $id, branch => $branch ); if (%last_ps && ($last_ps{branch} eq $branch)) { $ps{parent_id} = $last_ps{id}; } - + $arch_branches{$branch} = 1; $lastseen = 'id'; @@ -166,16 +166,16 @@ sub do_abrowse { $ps{type} = 't'; # read which revision we've tagged when we parse the log $ps{tag} = $1; - } else { + } else { warn "Unknown type $type"; } $arch_branches{$branch} = 1; $lastseen = 'id'; - } elsif (s/^\s{10}//) { - # 10 leading spaces or more + } elsif (s/^\s{10}//) { + # 10 leading spaces or more # indicate commit metadata - + # date if ($lastseen eq 'id' && m/^(\d{4}-\d\d-\d\d \d\d:\d\d:\d\d)/){ $ps{date} = $1; @@ -186,12 +186,12 @@ sub do_abrowse { } elsif ($lastseen eq 'merges' && s/^\s{2}//) { my $id = $_; push (@{$ps{merges}}, $id); - + # aggressive branch finding: if ($opt_D) { my $branch = extract_versionname($id); my $repo = extract_reponame($branch); - + if (archive_reachable($repo) && !defined $arch_branches{$branch}) { $arch_branches{$branch} = $stage + 1; @@ -208,10 +208,10 @@ sub do_abrowse { if (@psets && $psets[$#psets]{branch} eq $ps{branch}) { $temp{parent_id} = $psets[$#psets]{id}; } - push (@psets, \%temp); + push (@psets, \%temp); $psets{ $temp{id} } = \%temp; - } - + } + close ABROWSE or die "$TLA abrowse failed on $limit\n"; } } # end foreach $root @@ -253,7 +253,7 @@ unless (-d $git_dir) { # initial import while (my $file = readdir(DIR)) { # skip non-interesting-files next unless -f "$ptag_dir/$file"; - + # convert first '--' to '/' from old git-archimport to use # as an archivename/c--b--v private tag if ($file !~ m!,!) { @@ -275,7 +275,7 @@ sub extract_reponame { my $fq_cvbr = shift; # archivename/[[[[category]branch]version]revision] return (split(/\//, $fq_cvbr))[0]; } - + sub extract_versionname { my $name = shift; $name =~ s/--(?:patch|version(?:fix)?|base)-\d+$//; @@ -283,7 +283,7 @@ sub extract_versionname { } # convert a fully-qualified revision or version to a unique dirname: -# normalperson@yhbt.net-05/mpd--uclinux--1--patch-2 +# normalperson@yhbt.net-05/mpd--uclinux--1--patch-2 # becomes: normalperson@yhbt.net-05,mpd--uclinux--1 # # the git notion of a branch is closer to @@ -339,7 +339,7 @@ sub git_branchname { sub process_patchset_accurate { my $ps = shift; - + # switch to that branch if we're not already in that branch: if (-e "$git_dir/refs/heads/$ps->{branch}") { system('git-checkout','-f',$ps->{branch}) == 0 or die "$! $?\n"; @@ -348,7 +348,7 @@ sub process_patchset_accurate { my $rm = safe_pipe_capture('git-ls-files','--others','-z'); rmtree(split(/\0/,$rm)) if $rm; } - + # Apply the import/changeset/merge into the working tree my $dir = sync_to_ps($ps); # read the new log entry: @@ -361,9 +361,9 @@ sub process_patchset_accurate { parselog($ps, \@commitlog); if ($ps->{id} =~ /--base-0$/ && $ps->{id} ne $psets[0]{id}) { - # this should work when importing continuations + # this should work when importing continuations if ($ps->{tag} && (my $branchpoint = eval { ptag($ps->{tag}) })) { - + # find where we are supposed to branch from if (! -e "$git_dir/refs/heads/$ps->{branch}") { system('git-branch',$ps->{branch},$branchpoint) == 0 or die "$! $?\n"; @@ -388,8 +388,8 @@ sub process_patchset_accurate { } # allow multiple bases/imports here since Arch supports cherry-picks # from unrelated trees - } - + } + # update the index with all the changes we got system('git-diff-files --name-only -z | '. 'git-update-index --remove -z --stdin') == 0 or die "$! $?\n"; @@ -402,7 +402,7 @@ sub process_patchset_accurate { # does not handle permissions or any renames involving directories sub process_patchset_fast { my $ps = shift; - # + # # create the branch if needed # if ($ps->{type} eq 'i' && !$import) { @@ -417,9 +417,9 @@ sub process_patchset_fast { # new branch! we need to verify a few things die "Branch on a non-tag!" unless $ps->{type} eq 't'; my $branchpoint = ptag($ps->{tag}); - die "Tagging from unknown id unsupported: $ps->{tag}" + die "Tagging from unknown id unsupported: $ps->{tag}" unless $branchpoint; - + # find where we are supposed to branch from if (! -e "$git_dir/refs/heads/$ps->{branch}") { system('git-branch',$ps->{branch},$branchpoint) == 0 or die "$! $?\n"; @@ -435,13 +435,13 @@ sub process_patchset_fast { } system('git-checkout',$ps->{branch}) == 0 or die "$! $?\n"; return 0; - } + } die $! if $?; - } + } # # Apply the import/changeset/merge into the working tree - # + # if ($ps->{type} eq 'i' || $ps->{type} eq 't') { apply_import($ps) or die $!; $stats{import_or_tag}++; @@ -455,10 +455,10 @@ sub process_patchset_fast { # prepare update git's index, based on what arch knows # about the pset, resolve parents, etc # - - my @commitlog = safe_pipe_capture($TLA,'cat-archive-log',$ps->{id}); + + my @commitlog = safe_pipe_capture($TLA,'cat-archive-log',$ps->{id}); die "Error in cat-archive-log: $!" if $?; - + parselog($ps,\@commitlog); # imports don't give us good info @@ -485,10 +485,10 @@ sub process_patchset_fast { if (@$ren % 2) { die "Odd number of entries in rename!?"; } - + while (@$ren) { my $from = shift @$ren; - my $to = shift @$ren; + my $to = shift @$ren; unless (-d dirname($to)) { mkpath(dirname($to)); # will die on err @@ -529,20 +529,20 @@ if ($opt_f) { "Things may be a bit slow\n"; *process_patchset = *process_patchset_accurate; } - + foreach my $ps (@psets) { # process patchsets $ps->{branch} = git_branchname($ps->{id}); # - # ensure we have a clean state - # + # ensure we have a clean state + # if (my $dirty = `git-diff-files`) { die "Unclean tree when about to process $ps->{id} " . " - did we fail to commit cleanly before?\n$dirty"; } die $! if $?; - + # # skip commits already in repo # @@ -559,7 +559,7 @@ foreach my $ps (@psets) { my $tree = `git-write-tree`; die "cannot write tree $!" if $?; chomp $tree; - + # # Who's your daddy? # @@ -570,18 +570,18 @@ foreach my $ps (@psets) { close HEAD; chomp $p; push @par, '-p', $p; - } else { + } else { if ($ps->{type} eq 's') { warn "Could not find the right head for the branch $ps->{branch}"; } } } - + if ($ps->{merges}) { push @par, find_parents($ps); } - # + # # Commit, tag and clean state # $ENV{TZ} = 'GMT'; @@ -592,14 +592,14 @@ foreach my $ps (@psets) { $ENV{GIT_COMMITTER_EMAIL} = $ps->{email}; $ENV{GIT_COMMITTER_DATE} = $ps->{date}; - my $pid = open2(*READER, *WRITER,'git-commit-tree',$tree,@par) + my $pid = open2(*READER, *WRITER,'git-commit-tree',$tree,@par) or die $!; print WRITER $ps->{summary},"\n\n"; print WRITER $ps->{message},"\n"; - + # make it easy to backtrack and figure out which Arch revision this was: print WRITER 'git-archimport-id: ',$ps->{id},"\n"; - + close WRITER; my $commitid = ; # read chomp $commitid; @@ -611,7 +611,7 @@ foreach my $ps (@psets) { } # # Update the branch - # + # open HEAD, ">","$git_dir/refs/heads/$ps->{branch}"; print HEAD $commitid; close HEAD; @@ -640,7 +640,7 @@ exit 0; sub sync_to_ps { my $ps = shift; my $tree_dir = $tmp.'/'.tree_dirname($ps->{id}); - + $opt_v && print "sync_to_ps($ps->{id}) method: "; if (-d $tree_dir) { @@ -674,7 +674,7 @@ sub sync_to_ps { safe_pipe_capture($TLA,'get','--no-pristine',$ps->{id},$tree_dir); $stats{get_new}++; } - + # added -I flag to rsync since we're going to fast! AIEEEEE!!!! system('rsync','-aI','--delete','--exclude',$git_dir, # '--exclude','.arch-inventory', @@ -691,15 +691,15 @@ sub apply_import { mkpath($tmp); safe_pipe_capture($TLA,'get','-s','--no-pristine',$ps->{id},"$tmp/import"); - die "Cannot get import: $!" if $?; + die "Cannot get import: $!" if $?; system('rsync','-aI','--delete', '--exclude',$git_dir, '--exclude','.arch-ids','--exclude','{arch}', "$tmp/import/", './'); die "Cannot rsync import:$!" if $?; - + rmtree("$tmp/import"); die "Cannot remove tempdir: $!" if $?; - + return 1; } @@ -712,13 +712,13 @@ sub apply_cset { # get the changeset safe_pipe_capture($TLA,'get-changeset',$ps->{id},"$tmp/changeset"); die "Cannot get changeset: $!" if $?; - + # apply patches if (`find $tmp/changeset/patches -type f -name '*.patch'`) { # this can be sped up considerably by doing # (find | xargs cat) | patch # but that can get mucked up by patches - # with missing trailing newlines or the standard + # with missing trailing newlines or the standard # 'missing newline' flag in the patch - possibly # produced with an old/buggy diff. # slow and safe, we invoke patch once per patchfile @@ -741,7 +741,7 @@ sub apply_cset { # bring in new files system('rsync','-aI','--exclude',$git_dir, - '--exclude','.arch-ids', + '--exclude','.arch-ids', '--exclude', '{arch}', "$tmp/changeset/new-files-archive/",'./'); @@ -789,7 +789,7 @@ sub parselog { removed_files => 1, removed_directories => 1, ); - + chomp (@$log); while ($_ = shift @$log) { if (/^Continuation-of:\s*(.*)/) { @@ -828,7 +828,7 @@ sub parselog { } } } - + # drop leading empty lines from the log message while (@$log && $log->[0] eq '') { shift @$log; @@ -842,7 +842,7 @@ sub parselog { $ps->{summary} = $log->[0] . '...'; } $ps->{message} = join("\n",@$log); - + # skip Arch control files, unescape pika-escaped files foreach my $k (keys %want_headers) { next unless (defined $ps->{$k}); @@ -867,7 +867,7 @@ sub parselog { # write/read a tag sub tag { my ($tag, $commit) = @_; - + if ($opt_o) { $tag =~ s|/|--|g; } else { @@ -875,7 +875,7 @@ sub tag { $patchname =~ s/.*--//; $tag = git_branchname ($tag) . '--' . $patchname; } - + if ($commit) { open(C,">","$git_dir/refs/tags/$tag") or die "Cannot create tag $tag: $!\n"; @@ -902,8 +902,8 @@ sub ptag { my ($tag, $commit) = @_; # don't use subdirs for tags yet, it could screw up other porcelains - $tag =~ s|/|,|g; - + $tag =~ s|/|,|g; + my $tag_file = "$ptag_dir/$tag"; my $tag_branch_dir = dirname($tag_file); mkpath($tag_branch_dir) unless (-d $tag_branch_dir); @@ -915,7 +915,7 @@ sub ptag { or die "Cannot write tag $tag: $!\n"; close(C) or die "Cannot write tag $tag: $!\n"; - $rptags{$commit} = $tag + $rptags{$commit} = $tag unless $tag =~ m/--base-0$/; } else { # read # if the tag isn't there, return 0 @@ -941,7 +941,7 @@ sub find_parents { # Identify what branches are merging into me # and whether we are fully merged # git-merge-base should tell - # me what the base of the merge should be + # me what the base of the merge should be # my $ps = shift; @@ -963,14 +963,14 @@ sub find_parents { } # - # foreach branch find a merge base and walk it to the + # foreach branch find a merge base and walk it to the # head where we are, collecting the merged patchsets that # Arch has recorded. Keep that in @have # Compare that with the commits on the other branch # between merge-base and the tip of the branch (@need) # and see if we have a series of consecutive patches # starting from the merge base. The tip of the series - # of consecutive patches merged is our new parent for + # of consecutive patches merged is our new parent for # that branch. # foreach my $branch (keys %branches) { @@ -979,13 +979,13 @@ sub find_parents { next unless -e "$git_dir/refs/heads/$branch"; my $mergebase = `git-merge-base $branch $ps->{branch}`; - if ($?) { - # Don't die here, Arch supports one-way cherry-picking - # between branches with no common base (or any relationship - # at all beforehand) - warn "Cannot find merge base for $branch and $ps->{branch}"; - next; - } + if ($?) { + # Don't die here, Arch supports one-way cherry-picking + # between branches with no common base (or any relationship + # at all beforehand) + warn "Cannot find merge base for $branch and $ps->{branch}"; + next; + } chomp $mergebase; # now walk up to the mergepoint collecting what patches we have @@ -1010,7 +1010,7 @@ sub find_parents { # merge what we have with what ancestors have %have = (%have, %ancestorshave); - # see what the remote branch has - these are the merges we + # see what the remote branch has - these are the merges we # will want to have in a consecutive series from the mergebase my $otherbranchtip = git_rev_parse($branch); my @needraw = `git-rev-list --topo-order $otherbranchtip ^$mergebase`; @@ -1018,7 +1018,7 @@ sub find_parents { foreach my $needps (@needraw) { # get the psets $needps = commitid2pset($needps); # git-rev-list will also - # list commits merged in via earlier + # list commits merged in via earlier # merges. we are only interested in commits # from the branch we're looking at if ($branch eq $needps->{branch}) { @@ -1054,7 +1054,7 @@ sub find_parents { next unless ref $psets{$p}{merges}; my @merges = @{$psets{$p}{merges}}; foreach my $merge (@merges) { - if ($parents{$merge}) { + if ($parents{$merge}) { delete $parents{$merge}; } } @@ -1079,10 +1079,10 @@ sub git_rev_parse { sub commitid2pset { my $commitid = shift; chomp $commitid; - my $name = $rptags{$commitid} + my $name = $rptags{$commitid} || die "Cannot find reverse tag mapping for $commitid"; $name =~ s|,|/|; - my $ps = $psets{$name} + my $ps = $psets{$name} || (print Dumper(sort keys %psets)) && die "Cannot find patchset for $name"; return $ps; } @@ -1112,7 +1112,7 @@ sub archive_reachable { my $archive = shift; return 1 if $reachable{$archive}; return 0 if $unreachable{$archive}; - + if (system "$TLA whereis-archive $archive >/dev/null") { if ($opt_a && (system($TLA,'register-archive', "http://mirrors.sourcecontrol.net/$archive") == 0)) { @@ -1127,4 +1127,3 @@ sub archive_reachable { return 1; } } - diff --git a/git-checkout.sh b/git-checkout.sh index 6b6facfd5a..d561c88dcb 100755 --- a/git-checkout.sh +++ b/git-checkout.sh @@ -210,7 +210,7 @@ else esac # Match the index to the working tree, and do a three-way. - git diff-files --name-only | git update-index --remove --stdin && + git diff-files --name-only | git update-index --remove --stdin && work=`git write-tree` && git read-tree $v --reset -u $new || exit @@ -245,7 +245,7 @@ else (exit $saved_err) fi -# +# # Switch the HEAD pointer to the new branch if we # checked out a branch head, and remove any potential # old MERGE_HEAD's (subsequent commits will clearly not diff --git a/git-clone.sh b/git-clone.sh index fdd354f2da..5bfd8d1556 100755 --- a/git-clone.sh +++ b/git-clone.sh @@ -2,7 +2,7 @@ # # Copyright (c) 2005, Linus Torvalds # Copyright (c) 2005, Junio C Hamano -# +# # Clone a repository into a different directory that does not yet exist. # See git-sh-setup why. @@ -98,7 +98,7 @@ while *,--na|*,--nak|*,--nake|*,--naked|\ *,-b|*,--b|*,--ba|*,--bar|*,--bare) bare=yes ;; *,-l|*,--l|*,--lo|*,--loc|*,--loca|*,--local) use_local=yes ;; - *,-s|*,--s|*,--sh|*,--sha|*,--shar|*,--share|*,--shared) + *,-s|*,--s|*,--sh|*,--sha|*,--shar|*,--share|*,--shared) local_shared=yes; use_local=yes ;; 1,--template) usage ;; *,--template) @@ -410,4 +410,3 @@ fi rm -f "$GIT_DIR/CLONE_HEAD" "$GIT_DIR/REMOTE_HEAD" trap - 0 - diff --git a/git-commit.sh b/git-commit.sh index e8b60f7049..5547a02954 100755 --- a/git-commit.sh +++ b/git-commit.sh @@ -557,7 +557,7 @@ then } >>"$GIT_DIR"/COMMIT_EDITMSG else # we need to check if there is anything to commit - run_status >/dev/null + run_status >/dev/null fi if [ "$?" != "0" -a ! -f "$GIT_DIR/MERGE_HEAD" -a -z "$amend" ] then diff --git a/git-cvsexportcommit.perl b/git-cvsexportcommit.perl index 42060ef6e1..e9832d2bb9 100755 --- a/git-cvsexportcommit.perl +++ b/git-cvsexportcommit.perl @@ -197,7 +197,7 @@ if (@canstatusfiles) { # ... validate new files, foreach my $f (@afiles) { if (defined ($cvsstat{$f}) and $cvsstat{$f} ne "Unknown") { - $dirty = 1; + $dirty = 1; warn "File $f is already known in your CVS checkout -- perhaps it has been added by another user. Or this may indicate that it exists on a different branch. If this is the case, use -f to force the merge.\n"; warn "Status was: $cvsstat{$f}\n"; } diff --git a/git-cvsimport.perl b/git-cvsimport.perl index 4e6c9c6cc7..3225a2a25d 100755 --- a/git-cvsimport.perl +++ b/git-cvsimport.perl @@ -145,7 +145,7 @@ my $cvs_tree; if ($#ARGV == 0) { $cvs_tree = $ARGV[0]; } elsif (-f 'CVS/Repository') { - open my $f, '<', 'CVS/Repository' or + open my $f, '<', 'CVS/Repository' or die 'Failed to open CVS/Repository'; $cvs_tree = <$f>; chomp $cvs_tree; @@ -434,7 +434,7 @@ sub file { my ($self,$fn,$rev) = @_; my $res; - my ($fh, $name) = tempfile('gitcvs.XXXXXX', + my ($fh, $name) = tempfile('gitcvs.XXXXXX', DIR => File::Spec->tmpdir(), UNLINK => 1); $self->_file($fn,$rev) and $res = $self->_line($fh); @@ -520,8 +520,8 @@ sub is_sha1 { sub get_headref ($$) { my $name = shift; - my $git_dir = shift; - + my $git_dir = shift; + my $f = "$git_dir/refs/heads/$name"; if (open(my $fh, $f)) { chomp(my $r = <$fh>); @@ -771,7 +771,7 @@ sub commit { $xtag =~ s/\s+\*\*.*$//; # Remove stuff like ** INVALID ** and ** FUNKY ** $xtag =~ tr/_/\./ if ( $opt_u ); $xtag =~ s/[\/]/$opt_s/g; - + my $pid = open2($in, $out, 'git-mktag'); print $out "object $cid\n". "type commit\n". @@ -788,7 +788,7 @@ sub commit { $? != 0 or $tagobj !~ /^[0123456789abcdef]{40}$/ ) { die "Cannot create tag object $xtag: $!\n"; } - + open(C,">$git_dir/refs/tags/$xtag") or die "Cannot create tag $xtag: $!\n"; diff --git a/git-gui/GIT-VERSION-GEN b/git-gui/GIT-VERSION-GEN index 25647c8060..eee495a986 100755 --- a/git-gui/GIT-VERSION-GEN +++ b/git-gui/GIT-VERSION-GEN @@ -78,5 +78,3 @@ test "$VN" = "$VC" || { echo >&2 "GITGUI_VERSION = $VN" echo "GITGUI_VERSION = $VN" >$GVF } - - diff --git a/git-gui/lib/class.tcl b/git-gui/lib/class.tcl index 88b056522a..72494c1a1e 100644 --- a/git-gui/lib/class.tcl +++ b/git-gui/lib/class.tcl @@ -151,4 +151,3 @@ auto_mkindex_parser::command constructor {name args} { [format { [list source [file join $dir %s]]} \ [file split $scriptFile]] "\n" } - diff --git a/git-merge-one-file.sh b/git-merge-one-file.sh index 7d62d7902c..254d210bdc 100755 --- a/git-merge-one-file.sh +++ b/git-merge-one-file.sh @@ -88,7 +88,7 @@ case "${1:-.}${2:-.}${3:-.}" in # remove lines that are unique to ours. orig=`git-unpack-file $2` sz0=`wc -c <"$orig"` - diff -u -La/$orig -Lb/$orig $orig $src2 | git-apply --no-add + diff -u -La/$orig -Lb/$orig $orig $src2 | git-apply --no-add sz1=`wc -c <"$orig"` # If we do not have enough common material, it is not diff --git a/git-p4import.py b/git-p4import.py index 60a758bfe3..0f3d97b67e 100644 --- a/git-p4import.py +++ b/git-p4import.py @@ -358,4 +358,3 @@ for id in changes: if stitch == 1: git.clean_directories() stitch = 0 - diff --git a/git-svnimport.perl b/git-svnimport.perl index 3af8c7e110..f4597626b9 100755 --- a/git-svnimport.perl +++ b/git-svnimport.perl @@ -542,7 +542,7 @@ sub copy_path($$$$$$$$) { if ($node_kind eq $SVN::Node::dir) { $srcpath =~ s#/*$#/#; } - + my $pid = open my $f,'-|'; die $! unless defined $pid; if (!$pid) { @@ -560,7 +560,7 @@ sub copy_path($$$$$$$$) { } else { $p = $path; } - push(@$new,[$mode,$sha1,$p]); + push(@$new,[$mode,$sha1,$p]); } close($f) or print STDERR "$newrev:$newbranch: could not list files in $oldpath \@ $rev\n"; diff --git a/git-tag.sh b/git-tag.sh index 37cee978d2..c84043902f 100755 --- a/git-tag.sh +++ b/git-tag.sh @@ -64,7 +64,7 @@ do done ;; -m) - annotate=1 + annotate=1 shift message="$1" if test "$#" = "0"; then @@ -90,7 +90,7 @@ do username="$1" ;; -d) - shift + shift had_error=0 for tag do @@ -180,4 +180,3 @@ if [ "$annotate" ]; then fi git update-ref "refs/tags/$name" "$object" "$prev" - diff --git a/git-verify-tag.sh b/git-verify-tag.sh index 8db7dd0b7d..f2d5597dba 100755 --- a/git-verify-tag.sh +++ b/git-verify-tag.sh @@ -42,4 +42,3 @@ cat "$GIT_DIR/.tmp-vtag" | sed '/-----BEGIN PGP/Q' | gpg --verify "$GIT_DIR/.tmp-vtag" - || exit 1 rm -f "$GIT_DIR/.tmp-vtag" - diff --git a/git.spec.in b/git.spec.in index 3a45eb8761..b9dc1d59eb 100644 --- a/git.spec.in +++ b/git.spec.in @@ -63,7 +63,7 @@ Git tools for importing Perforce repositories. %package email Summary: Git tools for sending email Group: Development/Tools -Requires: git-core = %{version}-%{release} +Requires: git-core = %{version}-%{release} %description email Git tools for sending email. diff --git a/gitk b/gitk index a57e84cef7..87c3690ff3 100755 --- a/gitk +++ b/gitk @@ -337,7 +337,7 @@ proc readrefs {} { set tagids($name) $commit lappend idtags($commit) $name } - } + } catch { set tagcontents($name) [exec git cat-file tag $id] } diff --git a/gitweb/README b/gitweb/README index e02e90f042..7186cede2f 100644 --- a/gitweb/README +++ b/gitweb/README @@ -79,4 +79,3 @@ Originally written by: Any comment/question/concern to: Git mailing list - diff --git a/help.c b/help.c index 6a9af4d175..1cd33ece6b 100644 --- a/help.c +++ b/help.c @@ -219,5 +219,3 @@ int cmd_help(int argc, const char **argv, const char *prefix) return 0; } - - diff --git a/http-fetch.c b/http-fetch.c index 09baedc18a..202fae0ba8 100644 --- a/http-fetch.c +++ b/http-fetch.c @@ -828,7 +828,7 @@ static void abort_object_request(struct object_request *obj_req) } unlink(obj_req->tmpfile); if (obj_req->slot) { - release_active_slot(obj_req->slot); + release_active_slot(obj_req->slot); obj_req->slot = NULL; } release_object_request(obj_req); diff --git a/http-push.c b/http-push.c index 79d2c38608..7c3720f602 100644 --- a/http-push.c +++ b/http-push.c @@ -518,7 +518,7 @@ static void start_put(struct transfer_request *request) request->buffer.size = stream.total_out; request->buffer.posn = 0; - request->url = xmalloc(strlen(remote->url) + + request->url = xmalloc(strlen(remote->url) + strlen(request->lock->token) + 51); strcpy(request->url, remote->url); posn = request->url + strlen(remote->url); diff --git a/http.c b/http.c index ae27e0c940..c6fb8ace9f 100644 --- a/http.c +++ b/http.c @@ -137,7 +137,7 @@ static int http_options(const char *var, const char *value) return 0; } -#ifdef USE_CURL_MULTI +#ifdef USE_CURL_MULTI if (!strcmp("http.maxrequests", var)) { if (max_requests == -1) max_requests = git_config_int(var, value); diff --git a/imap-send.c b/imap-send.c index 4283a4acda..a5a0696084 100644 --- a/imap-send.c +++ b/imap-send.c @@ -1239,7 +1239,7 @@ split_msg( msg_data_t *all_msgs, msg_data_t *msg, int *ofs ) msg->data[ msg->len ] = 0; *ofs += msg->len; - return 1; + return 1; } static imap_server_conf_t server = diff --git a/local-fetch.c b/local-fetch.c index 4b650efa8b..bf7ec6c2a3 100644 --- a/local-fetch.c +++ b/local-fetch.c @@ -114,7 +114,7 @@ static int fetch_pack(const unsigned char *sha1) return -1; target = find_sha1_pack(sha1, packs); if (!target) - return error("Couldn't find %s: not separate or in any pack", + return error("Couldn't find %s: not separate or in any pack", sha1_to_hex(sha1)); if (get_verbosely) { fprintf(stderr, "Getting pack %s\n", @@ -122,11 +122,11 @@ static int fetch_pack(const unsigned char *sha1) fprintf(stderr, " which contains %s\n", sha1_to_hex(sha1)); } - sprintf(filename, "%s/objects/pack/pack-%s.pack", + sprintf(filename, "%s/objects/pack/pack-%s.pack", path, sha1_to_hex(target->sha1)); copy_file(filename, sha1_pack_name(target->sha1), sha1_to_hex(target->sha1), 1); - sprintf(filename, "%s/objects/pack/pack-%s.idx", + sprintf(filename, "%s/objects/pack/pack-%s.idx", path, sha1_to_hex(target->sha1)); copy_file(filename, sha1_pack_index_name(target->sha1), sha1_to_hex(target->sha1), 1); @@ -141,7 +141,7 @@ static int fetch_file(const unsigned char *sha1) char *hex = sha1_to_hex(sha1); char *dest_filename = sha1_file_name(sha1); - if (object_name_start < 0) { + if (object_name_start < 0) { strcpy(filename, path); /* e.g. git.git */ strcat(filename, "/objects/"); object_name_start = strlen(filename); diff --git a/lockfile.c b/lockfile.c index 23db35aff2..5ad2858b48 100644 --- a/lockfile.c +++ b/lockfile.c @@ -97,4 +97,3 @@ void rollback_lock_file(struct lock_file *lk) unlink(lk->filename); lk->filename[0] = 0; } - diff --git a/mailmap.c b/mailmap.c index cb567a2832..8714167059 100644 --- a/mailmap.c +++ b/mailmap.c @@ -89,4 +89,3 @@ int map_email(struct path_list *map, const char *email, char *name, int maxlen) } return 0; } - diff --git a/match-trees.c b/match-trees.c index 23cafe47b4..d7e29c4d1d 100644 --- a/match-trees.c +++ b/match-trees.c @@ -301,4 +301,3 @@ void shift_tree(const unsigned char *hash1, splice_tree(hash1, add_prefix, hash2, shifted); } - diff --git a/merge-index.c b/merge-index.c index 5599fd321b..fa719cb0b1 100644 --- a/merge-index.c +++ b/merge-index.c @@ -25,7 +25,7 @@ static void run_program(void) static int merge_entry(int pos, const char *path) { int found; - + if (pos >= active_nr) die("git-merge-index: %s not in the cache", path); arguments[0] = pgm; diff --git a/mktag.c b/mktag.c index 931011121e..070bc96c0d 100644 --- a/mktag.c +++ b/mktag.c @@ -11,7 +11,7 @@ * The first three lines are guaranteed to be at least 63 bytes: * "object \n" is 48 bytes, "type tag\n" at 9 bytes is the * shortest possible type-line, and "tag .\n" at 6 bytes is the - * shortest single-character-tag line. + * shortest single-character-tag line. * * We also artificially limit the size of the full object to 8kB. * Just because I'm a lazy bastard, and if you can't fit a signature diff --git a/mozilla-sha1/sha1.c b/mozilla-sha1/sha1.c index 847531d19f..3f06b83567 100644 --- a/mozilla-sha1/sha1.c +++ b/mozilla-sha1/sha1.c @@ -1,29 +1,29 @@ -/* +/* * The contents of this file are subject to the Mozilla Public * License Version 1.1 (the "License"); you may not use this file * except in compliance with the License. You may obtain a copy of * the License at http://www.mozilla.org/MPL/ - * + * * Software distributed under the License is distributed on an "AS * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or * implied. See the License for the specific language governing * rights and limitations under the License. - * + * * The Original Code is SHA 180-1 Reference Implementation (Compact version) - * + * * The Initial Developer of the Original Code is Paul Kocher of - * Cryptography Research. Portions created by Paul Kocher are + * Cryptography Research. Portions created by Paul Kocher are * Copyright (C) 1995-9 by Cryptography Research, Inc. All * Rights Reserved. - * + * * Contributor(s): * * Paul Kocher - * + * * Alternatively, the contents of this file may be used under the * terms of the GNU General Public License Version 2 or later (the - * "GPL"), in which case the provisions of the GPL are applicable - * instead of those above. If you wish to allow use of your + * "GPL"), in which case the provisions of the GPL are applicable + * instead of those above. If you wish to allow use of your * version of this file only under the terms of the GPL and not to * allow others to use your version of this file under the MPL, * indicate your decision by deleting the provisions above and @@ -149,4 +149,3 @@ static void shaHashBlock(SHA_CTX *ctx) { ctx->H[3] += D; ctx->H[4] += E; } - diff --git a/mozilla-sha1/sha1.h b/mozilla-sha1/sha1.h index 5d82afa3bd..16f2d3d43c 100644 --- a/mozilla-sha1/sha1.h +++ b/mozilla-sha1/sha1.h @@ -1,29 +1,29 @@ -/* +/* * The contents of this file are subject to the Mozilla Public * License Version 1.1 (the "License"); you may not use this file * except in compliance with the License. You may obtain a copy of * the License at http://www.mozilla.org/MPL/ - * + * * Software distributed under the License is distributed on an "AS * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or * implied. See the License for the specific language governing * rights and limitations under the License. - * + * * The Original Code is SHA 180-1 Header File - * + * * The Initial Developer of the Original Code is Paul Kocher of - * Cryptography Research. Portions created by Paul Kocher are + * Cryptography Research. Portions created by Paul Kocher are * Copyright (C) 1995-9 by Cryptography Research, Inc. All * Rights Reserved. - * + * * Contributor(s): * * Paul Kocher - * + * * Alternatively, the contents of this file may be used under the * terms of the GNU General Public License Version 2 or later (the - * "GPL"), in which case the provisions of the GPL are applicable - * instead of those above. If you wish to allow use of your + * "GPL"), in which case the provisions of the GPL are applicable + * instead of those above. If you wish to allow use of your * version of this file only under the terms of the GPL and not to * allow others to use your version of this file under the MPL, * indicate your decision by deleting the provisions above and diff --git a/object-refs.c b/object-refs.c index 022e8d841c..5345671569 100644 --- a/object-refs.c +++ b/object-refs.c @@ -85,5 +85,3 @@ void mark_reachable(struct object *obj, unsigned int mask) mark_reachable(refs->ref[i], mask); } } - - diff --git a/object.h b/object.h index 94f19eed86..397bbfa090 100644 --- a/object.h +++ b/object.h @@ -66,7 +66,7 @@ void set_object_refs(struct object *obj, struct object_refs *refs); void mark_reachable(struct object *obj, unsigned int mask); -struct object_list *object_list_insert(struct object *item, +struct object_list *object_list_insert(struct object *item, struct object_list **list_p); void object_list_append(struct object *item, diff --git a/pack-redundant.c b/pack-redundant.c index 6bc3bdf3f4..f5cd0ac59e 100644 --- a/pack-redundant.c +++ b/pack-redundant.c @@ -81,7 +81,7 @@ static struct llist * llist_copy(struct llist *list) { struct llist *ret; struct llist_item *new, *old, *prev; - + llist_init(&ret); if ((ret->size = list->size) == 0) @@ -100,7 +100,7 @@ static struct llist * llist_copy(struct llist *list) } new->next = NULL; ret->back = new; - + return ret; } diff --git a/patch-id.c b/patch-id.c index 086d2d9c68..9349bc5580 100644 --- a/patch-id.c +++ b/patch-id.c @@ -81,4 +81,4 @@ int main(int argc, char **argv) generate_id_list(); return 0; -} +} diff --git a/path-list.c b/path-list.c index caaa5cc57b..dcb4b3ac13 100644 --- a/path-list.c +++ b/path-list.c @@ -100,4 +100,3 @@ void print_path_list(const char *text, const struct path_list *p) for (i = 0; i < p->nr; i++) printf("%s:%p\n", p->items[i].path, p->items[i].util); } - diff --git a/perl/Makefile b/perl/Makefile index 0d695fd2f3..5e079ad011 100644 --- a/perl/Makefile +++ b/perl/Makefile @@ -40,4 +40,3 @@ endif # (even though GIT-CFLAGS aren't used yet. If ever) ../GIT-CFLAGS: $(MAKE) -C .. GIT-CFLAGS - diff --git a/pkt-line.c b/pkt-line.c index b60526869a..355546a1ad 100644 --- a/pkt-line.c +++ b/pkt-line.c @@ -5,7 +5,7 @@ * Write a packetized stream, where each line is preceded by * its length (including the header) as a 4-byte hex number. * A length of 'zero' means end of stream (and a length of 1-3 - * would be an error). + * would be an error). * * This is all pretty stupid, but we use this packetized line * format to make a streaming format possible without ever diff --git a/ppc/sha1.c b/ppc/sha1.c index 0820398b00..738e36c1e8 100644 --- a/ppc/sha1.c +++ b/ppc/sha1.c @@ -50,7 +50,7 @@ int SHA1_Update(SHA_CTX *c, const void *ptr, unsigned long n) p += nb; } return 0; -} +} int SHA1_Final(unsigned char *hash, SHA_CTX *c) { diff --git a/read-cache.c b/read-cache.c index ad4e187537..4362b11f47 100644 --- a/read-cache.c +++ b/read-cache.c @@ -166,7 +166,7 @@ static int ce_match_stat_basic(struct cache_entry *ce, struct stat *st) changed |= MTIME_CHANGED; if (ce->ce_ctime.nsec != htonl(st->st_ctim.tv_nsec)) changed |= CTIME_CHANGED; -#endif +#endif if (ce->ce_uid != htonl(st->st_uid) || ce->ce_gid != htonl(st->st_gid)) @@ -597,7 +597,7 @@ static int has_dir_name(struct index_state *istate, * is being added, or we already have path and path/file is being * added. Either one would result in a nonsense tree that has path * twice when git-write-tree tries to write it out. Prevent it. - * + * * If ok-to-replace is specified, we remove the conflicting entries * from the cache so the caller should recompute the insert position. * When this happens, we return non-zero. @@ -970,8 +970,8 @@ static int ce_write(SHA_CTX *context, int fd, void *data, unsigned int len) write_buffer_len = buffered; len -= partial; data = (char *) data + partial; - } - return 0; + } + return 0; } static int write_index_ext_header(SHA_CTX *context, int fd, @@ -1037,7 +1037,7 @@ static void ce_smudge_racily_clean_entry(struct cache_entry *ce) * size to zero here, then the object name recorded * in index is the 6-byte file but the cached stat information * becomes zero --- which would then match what we would - * obtain from the filesystem next time we stat("frotz"). + * obtain from the filesystem next time we stat("frotz"). * * However, the second update-index, before calling * this function, notices that the cached size is 6 diff --git a/rsh.h b/rsh.h index 3b4194239d..ee2f499291 100644 --- a/rsh.h +++ b/rsh.h @@ -1,7 +1,7 @@ #ifndef RSH_H #define RSH_H -int setup_connection(int *fd_in, int *fd_out, const char *remote_prog, +int setup_connection(int *fd_in, int *fd_out, const char *remote_prog, char *url, int rmt_argc, char **rmt_argv); #endif diff --git a/setup.c b/setup.c index a45ea8309a..14f62c42e3 100644 --- a/setup.c +++ b/setup.c @@ -39,7 +39,7 @@ const char *prefix_path(const char *prefix, int len, const char *path) if (len) { int speclen = strlen(path); char *n = xmalloc(speclen + len + 1); - + memcpy(n, prefix, len); memcpy(n + len, path, speclen+1); path = n; @@ -47,7 +47,7 @@ const char *prefix_path(const char *prefix, int len, const char *path) return path; } -/* +/* * Unlike prefix_path, this should be used if the named file does * not have to interact with index entry; i.e. name of a random file * on the filesystem. diff --git a/sha1_file.c b/sha1_file.c index 30bcd46ceb..2b860868f5 100644 --- a/sha1_file.c +++ b/sha1_file.c @@ -193,7 +193,7 @@ char *sha1_pack_name(const unsigned char *sha1) *buf++ = hex[val >> 4]; *buf++ = hex[val & 0xf]; } - + return base; } @@ -218,7 +218,7 @@ char *sha1_pack_index_name(const unsigned char *sha1) *buf++ = hex[val >> 4]; *buf++ = hex[val & 0xf]; } - + return base; } @@ -1139,7 +1139,7 @@ static int parse_sha1_header(const char *hdr, unsigned long *sizep) unsigned long size; /* - * The type can be at most ten bytes (including the + * The type can be at most ten bytes (including the * terminating '\0' that we add), and is followed by * a space. */ @@ -1738,7 +1738,7 @@ static int find_pack_entry(const unsigned char *sha1, struct pack_entry *e, cons return 0; } -struct packed_git *find_sha1_pack(const unsigned char *sha1, +struct packed_git *find_sha1_pack(const unsigned char *sha1, struct packed_git *packs) { struct packed_git *p; diff --git a/shallow.c b/shallow.c index d17868929c..dbd9f5ad0a 100644 --- a/shallow.c +++ b/shallow.c @@ -101,4 +101,3 @@ struct commit_list *get_shallow_commits(struct object_array *heads, int depth, return result; } - diff --git a/ssh-upload.c b/ssh-upload.c index 498d41e19b..20c35f03dd 100644 --- a/ssh-upload.c +++ b/ssh-upload.c @@ -29,24 +29,24 @@ static int serve_object(int fd_in, int fd_out) { } if (!size) return -1; - + if (verbose) fprintf(stderr, "Serving %s\n", sha1_to_hex(sha1)); remote = 0; - + if (!has_sha1_file(sha1)) { fprintf(stderr, "git-ssh-upload: could not find %s\n", sha1_to_hex(sha1)); remote = -1; } - + if (write_in_full(fd_out, &remote, 1) != 1) return 0; - + if (remote < 0) return 0; - + return write_sha1_to_fd(fd_out, sha1); } diff --git a/strbuf.c b/strbuf.c index 7f14b0fb59..e33d06b87c 100644 --- a/strbuf.c +++ b/strbuf.c @@ -39,4 +39,3 @@ void read_line(struct strbuf *sb, FILE *fp, int term) { sb->eof = 1; strbuf_end(sb); } - diff --git a/t/Makefile b/t/Makefile index 19e38508a7..b25caca887 100644 --- a/t/Makefile +++ b/t/Makefile @@ -28,4 +28,3 @@ full-svn-test: .PHONY: $(T) clean .NOTPARALLEL: - diff --git a/t/lib-read-tree-m-3way.sh b/t/lib-read-tree-m-3way.sh index d195603dfa..586df2113f 100644 --- a/t/lib-read-tree-m-3way.sh +++ b/t/lib-read-tree-m-3way.sh @@ -87,7 +87,7 @@ test_expect_success \ test_expect_success \ 'recording branch A tree' \ 'tree_A=$(git-write-tree)' - + ################################################################ # Branch B # Start from O diff --git a/t/t0000-basic.sh b/t/t0000-basic.sh index 186de70243..8bfe8320ea 100755 --- a/t/t0000-basic.sh +++ b/t/t0000-basic.sh @@ -37,7 +37,7 @@ fi find .git/objects -type f -print >should-be-empty test_expect_success \ '.git/objects should be empty after git-init in an empty repo.' \ - 'cmp -s /dev/null should-be-empty' + 'cmp -s /dev/null should-be-empty' # also it should have 2 subdirectories; no fan-out anymore, pack, and info. # 3 is counting "objects" itself diff --git a/t/t1200-tutorial.sh b/t/t1200-tutorial.sh index ca2c30f7af..d3f8358485 100755 --- a/t/t1200-tutorial.sh +++ b/t/t1200-tutorial.sh @@ -159,4 +159,3 @@ test_expect_success 'git prune-packed' 'git prune-packed' test_expect_failure '-> only packed objects' 'find -type f .git/objects/[0-9a-f][0-9a-f]' test_done - diff --git a/t/t1300-repo-config.sh b/t/t1300-repo-config.sh index 3f3fd2d7f7..7731fa72ce 100755 --- a/t/t1300-repo-config.sh +++ b/t/t1300-repo-config.sh @@ -514,4 +514,3 @@ git config --list > result test_expect_success 'value continued on next line' 'cmp result expect' test_done - diff --git a/t/t2000-checkout-cache-clash.sh b/t/t2000-checkout-cache-clash.sh index 03ea4dece4..d556b41f13 100755 --- a/t/t2000-checkout-cache-clash.sh +++ b/t/t2000-checkout-cache-clash.sh @@ -49,5 +49,3 @@ test_expect_success \ 'test -f path0 && test -d path1 && test -f path1/file1' test_done - - diff --git a/t/t2001-checkout-cache-clash.sh b/t/t2001-checkout-cache-clash.sh index 0dcab8f1de..b895a0fe36 100755 --- a/t/t2001-checkout-cache-clash.sh +++ b/t/t2001-checkout-cache-clash.sh @@ -84,4 +84,3 @@ test_expect_success \ test ! -h path1/file1 && test -f path1/file1' test_done - diff --git a/t/t3030-merge-recursive.sh b/t/t3030-merge-recursive.sh index 86ee2b0bd3..607f57ff94 100755 --- a/t/t3030-merge-recursive.sh +++ b/t/t3030-merge-recursive.sh @@ -525,4 +525,3 @@ test_expect_success 'reset and bind merge' ' ' test_done - diff --git a/t/t3403-rebase-skip.sh b/t/t3403-rebase-skip.sh index 977c498f00..9e11ed295d 100755 --- a/t/t3403-rebase-skip.sh +++ b/t/t3403-rebase-skip.sh @@ -54,4 +54,3 @@ test_expect_success 'merge and reference trees equal' \ test_debug 'gitk --all & sleep 1' test_done - diff --git a/t/t4006-diff-mode.sh b/t/t4006-diff-mode.sh index e72c6fd1b4..b8acca1813 100755 --- a/t/t4006-diff-mode.sh +++ b/t/t4006-diff-mode.sh @@ -41,4 +41,3 @@ test_expect_success \ 'git diff expected check' test_done - diff --git a/t/t4100-apply-stat.sh b/t/t4100-apply-stat.sh index 7b81c32e57..c23341feb5 100755 --- a/t/t4100-apply-stat.sh +++ b/t/t4100-apply-stat.sh @@ -44,4 +44,3 @@ test_expect_success \ git diff ../t4100/t-apply-7.expect current' test_done - diff --git a/t/t4110-apply-scan.sh b/t/t4110-apply-scan.sh index 005f744816..9faef0d66e 100755 --- a/t/t4110-apply-scan.sh +++ b/t/t4110-apply-scan.sh @@ -98,4 +98,3 @@ test_expect_success "S = cmp" \ 'cmp apply.txt patch.txt' test_done - diff --git a/t/t4112-apply-renames.sh b/t/t4112-apply-renames.sh index 69e9603c78..9baf810bee 100755 --- a/t/t4112-apply-renames.sh +++ b/t/t4112-apply-renames.sh @@ -49,10 +49,10 @@ copy to include/arch/cris/klibc/archsetjmp.h - * arch/x86_64/include/klibc/archsetjmp.h + * arch/cris/include/klibc/archsetjmp.h */ - + #ifndef _KLIBC_ARCHSETJMP_H #define _KLIBC_ARCHSETJMP_H - + struct __jmp_buf { - unsigned long __rbx; - unsigned long __rsp; @@ -74,9 +74,9 @@ copy to include/arch/cris/klibc/archsetjmp.h + unsigned long __sp; + unsigned long __srp; }; - + typedef struct __jmp_buf jmp_buf[1]; - + -#endif /* _SETJMP_H */ +#endif /* _KLIBC_ARCHSETJMP_H */ diff --git a/klibc/arch/x86_64/include/klibc/archsetjmp.h b/include/arch/m32r/klibc/archsetjmp.h @@ -90,10 +90,10 @@ rename to include/arch/m32r/klibc/archsetjmp.h - * arch/x86_64/include/klibc/archsetjmp.h + * arch/m32r/include/klibc/archsetjmp.h */ - + #ifndef _KLIBC_ARCHSETJMP_H #define _KLIBC_ARCHSETJMP_H - + struct __jmp_buf { - unsigned long __rbx; - unsigned long __rsp; @@ -108,9 +108,9 @@ rename to include/arch/m32r/klibc/archsetjmp.h unsigned long __r15; - unsigned long __rip; }; - + typedef struct __jmp_buf jmp_buf[1]; - + -#endif /* _SETJMP_H */ +#endif /* _KLIBC_ARCHSETJMP_H */ EOF diff --git a/t/t4118-apply-empty-context.sh b/t/t4118-apply-empty-context.sh index 27cc6f2b88..dd88e81e04 100755 --- a/t/t4118-apply-empty-context.sh +++ b/t/t4118-apply-empty-context.sh @@ -53,4 +53,3 @@ test_expect_success 'apply --apply' ' ' test_done - diff --git a/t/t4119-apply-config.sh b/t/t4119-apply-config.sh index 620a9207bf..edae7056e4 100755 --- a/t/t4119-apply-config.sh +++ b/t/t4119-apply-config.sh @@ -24,7 +24,7 @@ cat >gpatch.file <<\EOF && +++ file1+ 2007-02-21 01:07:44.000000000 -0800 @@ -1 +1 @@ -A -+B ++B EOF sed -e 's|file1|sub/&|' gpatch.file >gpatch-sub.file && diff --git a/t/t4121-apply-diffs.sh b/t/t4121-apply-diffs.sh index 2b2f1eda21..b95b89c341 100755 --- a/t/t4121-apply-diffs.sh +++ b/t/t4121-apply-diffs.sh @@ -30,4 +30,3 @@ test_expect_success \ '( git diff test~2 test~1; git diff test~1 test~0 )| git apply' test_done - diff --git a/t/t4122-apply-symlink-inside.sh b/t/t4122-apply-symlink-inside.sh index 3ddfe64b02..841773f75f 100755 --- a/t/t4122-apply-symlink-inside.sh +++ b/t/t4122-apply-symlink-inside.sh @@ -53,4 +53,3 @@ test_expect_success 'check result' ' ' test_done - diff --git a/t/t4200-rerere.sh b/t/t4200-rerere.sh index c64ebbb2e9..a46d7f74be 100755 --- a/t/t4200-rerere.sh +++ b/t/t4200-rerere.sh @@ -148,5 +148,3 @@ test_expect_success 'old records rest in peace' \ "test ! -f $rr/preimage && test ! -f $rr2/preimage" test_done - - diff --git a/t/t5400-send-pack.sh b/t/t5400-send-pack.sh index 477b267599..4eaea8f336 100755 --- a/t/t5400-send-pack.sh +++ b/t/t5400-send-pack.sh @@ -66,7 +66,7 @@ test_expect_success 'pack the destination repository' ' ' test_expect_success \ - 'pushing rewound head should not barf but require --force' ' + 'pushing rewound head should not barf but require --force' ' # should not fail but refuse to update. if git-send-pack ./victim/.git/ master then diff --git a/t/t5520-pull.sh b/t/t5520-pull.sh index 243212d3da..93eaf2c154 100755 --- a/t/t5520-pull.sh +++ b/t/t5520-pull.sh @@ -54,4 +54,3 @@ test_expect_success 'the default remote . should not break explicit pull' ' ' test_done - diff --git a/t/t5710-info-alternate.sh b/t/t5710-info-alternate.sh index 2f8e97cb7e..699df6ebd8 100755 --- a/t/t5710-info-alternate.sh +++ b/t/t5710-info-alternate.sh @@ -104,4 +104,3 @@ test_valid_repo' cd "$base_dir" test_done - diff --git a/t/t6000lib.sh b/t/t6000lib.sh index d40262159b..d548bf8026 100755 --- a/t/t6000lib.sh +++ b/t/t6000lib.sh @@ -17,17 +17,17 @@ unique_commit() _text=$1 _tree=$2 shift 2 - echo $_text | git-commit-tree $(tag $_tree) "$@" + echo $_text | git-commit-tree $(tag $_tree) "$@" } # Save the output of a command into the tag specified. Prepend # a substitution script for the tag onto the front of sed.script save_tag() { - _tag=$1 + _tag=$1 [ -n "$_tag" ] || error "usage: save_tag tag commit-args ..." shift 1 - "$@" >.git/refs/tags/$_tag + "$@" >.git/refs/tags/$_tag echo "s/$(tag $_tag)/$_tag/g" > sed.script.tmp cat sed.script >> sed.script.tmp @@ -35,7 +35,7 @@ save_tag() mv sed.script.tmp sed.script } -# Replace unhelpful sha1 hashses with their symbolic equivalents +# Replace unhelpful sha1 hashses with their symbolic equivalents entag() { sed -f sed.script @@ -62,7 +62,7 @@ as_author() commit_date() { _commit=$1 - git-cat-file commit $_commit | sed -n "s/^committer .*> \([0-9]*\) .*/\1/p" + git-cat-file commit $_commit | sed -n "s/^committer .*> \([0-9]*\) .*/\1/p" } on_committer_date() @@ -103,14 +103,14 @@ name_from_description() # Execute the test described by the first argument, by eval'ing # command line specified in the 2nd argument. Check the status code -# is zero and that the output matches the stream read from +# is zero and that the output matches the stream read from # stdin. test_output_expect_success() -{ +{ _description=$1 _test=$2 [ $# -eq 2 ] || error "usage: test_output_expect_success description test < $_name.expected - test_expect_success "$_description" "check_output $_name \"$_test\"" + test_expect_success "$_description" "check_output $_name \"$_test\"" } diff --git a/t/t6002-rev-list-bisect.sh b/t/t6002-rev-list-bisect.sh index fcb3302764..71cbb72e1b 100755 --- a/t/t6002-rev-list-bisect.sh +++ b/t/t6002-rev-list-bisect.sh @@ -26,7 +26,7 @@ test_bisection_diff() # Test if bisection size is close to half of list size within # tolerance. - # + # _bisect_err=`expr $_list_size - $_bisection_size \* 2` test "$_bisect_err" -lt 0 && _bisect_err=`expr 0 - $_bisect_err` _bisect_err=`expr $_bisect_err / 2` ; # floor @@ -116,8 +116,8 @@ on_committer_date "1971-08-16 00:00:06" save_tag V unique_commit V tree -p u1 -p test_sequence() { - _bisect_option=$1 - + _bisect_option=$1 + test_bisection_diff 0 $_bisect_option l0 ^root test_bisection_diff 0 $_bisect_option l1 ^root test_bisection_diff 0 $_bisect_option l2 ^root @@ -152,7 +152,7 @@ test_sequence() test_bisection_diff 0 $_bisect_option u3 ^U test_bisection_diff 0 $_bisect_option u4 ^U test_bisection_diff 0 $_bisect_option u5 ^U - + # # the following illustrates Linus' binary bug blatt idea. # diff --git a/t/t6021-merge-criss-cross.sh b/t/t6021-merge-criss-cross.sh index 499cafb882..0ab14a6e81 100755 --- a/t/t6021-merge-criss-cross.sh +++ b/t/t6021-merge-criss-cross.sh @@ -20,7 +20,7 @@ test_expect_success 'prepare repository' \ 7 8 9" > file && -git add file && +git add file && git commit -m "Initial commit" file && git branch A && git branch B && diff --git a/t/t6023-merge-file.sh b/t/t6023-merge-file.sh index c76fccfb5a..43aa5d033d 100755 --- a/t/t6023-merge-file.sh +++ b/t/t6023-merge-file.sh @@ -135,4 +135,3 @@ EOF test_expect_success "expected conflict markers" "git diff expect out" test_done - diff --git a/t/t6030-bisect-porcelain.sh b/t/t6030-bisect-porcelain.sh index 30f6ade13f..03cdba5808 100755 --- a/t/t6030-bisect-porcelain.sh +++ b/t/t6030-bisect-porcelain.sh @@ -102,4 +102,3 @@ test_expect_success \ # # test_done - diff --git a/t/t6101-rev-parse-parents.sh b/t/t6101-rev-parse-parents.sh index b0252b9413..dd6cc3a55c 100755 --- a/t/t6101-rev-parse-parents.sh +++ b/t/t6101-rev-parse-parents.sh @@ -40,4 +40,3 @@ test_expect_success 'short SHA-1 works' ' test $start = $abbrv' test_done - diff --git a/t/t9107-git-svn-migrate.sh b/t/t9107-git-svn-migrate.sh index dc2afdaa45..d549665400 100755 --- a/t/t9107-git-svn-migrate.sh +++ b/t/t9107-git-svn-migrate.sh @@ -109,4 +109,3 @@ test_expect_success ".rev_db auto-converted to .rev_db.UUID" " " test_done - diff --git a/t/t9111/svnsync.dump b/t/t9111/svnsync.dump index a9a46eeb29..499fa9594f 100644 --- a/t/t9111/svnsync.dump +++ b/t/t9111/svnsync.dump @@ -558,5 +558,3 @@ Text-content-md5: 7abb78de7f2756ca8b511cbc879fd5e7 Content-length: 4 cba - - diff --git a/t/test-lib.sh b/t/test-lib.sh index dee3ad7621..8bf4cf49a2 100644 --- a/t/test-lib.sh +++ b/t/test-lib.sh @@ -232,7 +232,7 @@ test_create_repo () { mv .git/hooks .git/hooks-disabled cd "$owd" } - + test_done () { trap - exit case "$test_failure" in diff --git a/templates/hooks--commit-msg b/templates/hooks--commit-msg index 9b04f2d69c..c5cdb9d7ee 100644 --- a/templates/hooks--commit-msg +++ b/templates/hooks--commit-msg @@ -19,4 +19,3 @@ test "" = "$(grep '^Signed-off-by: ' "$1" | echo >&2 Duplicate Signed-off-by lines. exit 1 } - diff --git a/templates/hooks--post-receive b/templates/hooks--post-receive index 190de2688c..b70c8fd364 100644 --- a/templates/hooks--post-receive +++ b/templates/hooks--post-receive @@ -14,4 +14,3 @@ #. /usr/share/doc/git-core/contrib/hooks/post-receive-email - diff --git a/templates/hooks--pre-applypatch b/templates/hooks--pre-applypatch index 5f56ce8053..eeccc934ca 100644 --- a/templates/hooks--pre-applypatch +++ b/templates/hooks--pre-applypatch @@ -12,4 +12,3 @@ test -x "$GIT_DIR/hooks/pre-commit" && exec "$GIT_DIR/hooks/pre-commit" ${1+"$@"} : - diff --git a/templates/hooks--pre-commit b/templates/hooks--pre-commit index 723a9ef210..18b87309f6 100644 --- a/templates/hooks--pre-commit +++ b/templates/hooks--pre-commit @@ -68,4 +68,3 @@ perl -e ' } exit($found_bad); ' - diff --git a/tree-walk.c b/tree-walk.c index cbb24eb3f6..8d4b67317f 100644 --- a/tree-walk.c +++ b/tree-walk.c @@ -206,4 +206,3 @@ int get_tree_entry(const unsigned char *tree_sha1, const char *name, unsigned ch free(tree); return retval; } - diff --git a/upload-pack.c b/upload-pack.c index d3a09e78d5..0e881c85b5 100644 --- a/upload-pack.c +++ b/upload-pack.c @@ -678,7 +678,7 @@ int main(int argc, char **argv) break; } } - + if (i != argc-1) usage(upload_pack_usage); dir = argv[i]; diff --git a/var.c b/var.c index e585e59d31..4127031910 100644 --- a/var.c +++ b/var.c @@ -67,8 +67,8 @@ int main(int argc, char **argv) val = read_var(argv[1]); if (!val) usage(var_usage); - + printf("%s\n", val); - + return 0; } diff --git a/xdiff-interface.c b/xdiff-interface.c index 963bb89b08..e407cf11b1 100644 --- a/xdiff-interface.c +++ b/xdiff-interface.c @@ -129,5 +129,3 @@ int buffer_is_binary(const char *ptr, unsigned long size) size = FIRST_FEW_BYTES; return !!memchr(ptr, 0, size); } - - diff --git a/xdiff/xdiff.h b/xdiff/xdiff.h index e874a7c46a..9402bb0799 100644 --- a/xdiff/xdiff.h +++ b/xdiff/xdiff.h @@ -103,4 +103,3 @@ int xdl_merge(mmfile_t *orig, mmfile_t *mf1, const char *name1, #endif /* #ifdef __cplusplus */ #endif /* #if !defined(XDIFF_H) */ - diff --git a/xdiff/xdiffi.c b/xdiff/xdiffi.c index 9aeebc473b..5cb7171a8f 100644 --- a/xdiff/xdiffi.c +++ b/xdiff/xdiffi.c @@ -565,4 +565,3 @@ int xdl_diff(mmfile_t *mf1, mmfile_t *mf2, xpparam_t const *xpp, return 0; } - diff --git a/xdiff/xdiffi.h b/xdiff/xdiffi.h index 472aeaecfa..3e099dc445 100644 --- a/xdiff/xdiffi.h +++ b/xdiff/xdiffi.h @@ -57,4 +57,3 @@ int xdl_emit_diff(xdfenv_t *xe, xdchange_t *xscr, xdemitcb_t *ecb, xdemitconf_t const *xecfg); #endif /* #if !defined(XDIFFI_H) */ - diff --git a/xdiff/xemit.c b/xdiff/xemit.c index e291dc7608..78b1d4b8bb 100644 --- a/xdiff/xemit.c +++ b/xdiff/xemit.c @@ -194,4 +194,3 @@ int xdl_emit_diff(xdfenv_t *xe, xdchange_t *xscr, xdemitcb_t *ecb, return 0; } - diff --git a/xdiff/xemit.h b/xdiff/xemit.h index e629417dd2..440a7390fa 100644 --- a/xdiff/xemit.h +++ b/xdiff/xemit.h @@ -31,4 +31,3 @@ int xdl_emit_diff(xdfenv_t *xe, xdchange_t *xscr, xdemitcb_t *ecb, #endif /* #if !defined(XEMIT_H) */ - diff --git a/xdiff/xinclude.h b/xdiff/xinclude.h index 04a9da82c9..526ccb344d 100644 --- a/xdiff/xinclude.h +++ b/xdiff/xinclude.h @@ -40,4 +40,3 @@ #endif /* #if !defined(XINCLUDE_H) */ - diff --git a/xdiff/xmacros.h b/xdiff/xmacros.h index e2cd2023b3..8ef232cfad 100644 --- a/xdiff/xmacros.h +++ b/xdiff/xmacros.h @@ -51,4 +51,3 @@ do { \ #endif /* #if !defined(XMACROS_H) */ - diff --git a/xdiff/xprepare.c b/xdiff/xprepare.c index 1be7b31950..e87ab57c65 100644 --- a/xdiff/xprepare.c +++ b/xdiff/xprepare.c @@ -466,4 +466,3 @@ static int xdl_optimize_ctxs(xdfile_t *xdf1, xdfile_t *xdf2) { return 0; } - diff --git a/xdiff/xprepare.h b/xdiff/xprepare.h index 344c569e8b..8fb06a5374 100644 --- a/xdiff/xprepare.h +++ b/xdiff/xprepare.h @@ -32,4 +32,3 @@ void xdl_free_env(xdfenv_t *xe); #endif /* #if !defined(XPREPARE_H) */ - diff --git a/xdiff/xtypes.h b/xdiff/xtypes.h index 3593a664fc..2511aef8d8 100644 --- a/xdiff/xtypes.h +++ b/xdiff/xtypes.h @@ -65,4 +65,3 @@ typedef struct s_xdfenv { #endif /* #if !defined(XTYPES_H) */ - diff --git a/xdiff/xutils.c b/xdiff/xutils.c index bf91c0f73c..2ade97b257 100644 --- a/xdiff/xutils.c +++ b/xdiff/xutils.c @@ -380,4 +380,3 @@ int xdl_emit_hunk_hdr(long s1, long c1, long s2, long c2, return 0; } - diff --git a/xdiff/xutils.h b/xdiff/xutils.h index 70d8b9838a..d5de8292e0 100644 --- a/xdiff/xutils.h +++ b/xdiff/xutils.h @@ -45,4 +45,3 @@ int xdl_emit_hunk_hdr(long s1, long c1, long s2, long c2, #endif /* #if !defined(XUTILS_H) */ - -- cgit v1.2.3 From 16befb8b7fbfcc9b2d38931f4081669558300adf Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Fri, 8 Jun 2007 02:54:57 -0700 Subject: Even more missing static Signed-off-by: Junio C Hamano --- builtin-stripspace.c | 2 +- builtin.h | 1 - commit.c | 9 --------- commit.h | 2 -- diff.c | 4 +++- diff.h | 2 -- quote.c | 14 +------------- quote.h | 2 -- upload-pack.c | 2 +- 9 files changed, 6 insertions(+), 32 deletions(-) (limited to 'commit.h') diff --git a/builtin-stripspace.c b/builtin-stripspace.c index f0d4d9e2d1..62bd4b547b 100644 --- a/builtin-stripspace.c +++ b/builtin-stripspace.c @@ -26,7 +26,7 @@ static int cleanup(char *line) return 1; } -void stripspace(FILE *in, FILE *out) +static void stripspace(FILE *in, FILE *out) { int empties = -1; int incomplete = 0; diff --git a/builtin.h b/builtin.h index fe8ba9e65f..da4834c312 100644 --- a/builtin.h +++ b/builtin.h @@ -7,7 +7,6 @@ extern const char git_version_string[]; extern const char git_usage_string[]; extern void help_unknown_cmd(const char *cmd); -extern void stripspace(FILE *in, FILE *out); extern int write_tree(unsigned char *sha1, int missing_ok, const char *prefix); extern void prune_packed_objects(int); diff --git a/commit.c b/commit.c index 57b69ca7fa..4ca4d44ba0 100644 --- a/commit.c +++ b/commit.c @@ -1116,15 +1116,6 @@ struct commit *pop_commit(struct commit_list **stack) return item; } -int count_parents(struct commit * commit) -{ - int count; - struct commit_list * parents = commit->parents; - for (count = 0; parents; parents = parents->next,count++) - ; - return count; -} - void topo_sort_default_setter(struct commit *c, void *data) { c->util = data; diff --git a/commit.h b/commit.h index 75b43a53ed..a313b53c31 100644 --- a/commit.h +++ b/commit.h @@ -73,8 +73,6 @@ struct commit *pop_commit(struct commit_list **stack); void clear_commit_marks(struct commit *commit, unsigned int mark); -int count_parents(struct commit * commit); - /* * Performs an in-place topological sort of list supplied. * diff --git a/diff.c b/diff.c index cafa7debeb..1d234d361d 100644 --- a/diff.c +++ b/diff.c @@ -2103,6 +2103,8 @@ static int opt_arg(const char *arg, int arg_short, const char *arg_long, int *va return 1; } +static int diff_scoreopt_parse(const char *opt); + int diff_opt_parse(struct diff_options *options, const char **av, int ac) { const char *arg = av[0]; @@ -2274,7 +2276,7 @@ static int parse_num(const char **cp_p) return (int)((num >= scale) ? MAX_SCORE : (MAX_SCORE * num / scale)); } -int diff_scoreopt_parse(const char *opt) +static int diff_scoreopt_parse(const char *opt) { int opt1, opt2, cmd; diff --git a/diff.h b/diff.h index 63738c1dd4..a7ee6d8c87 100644 --- a/diff.h +++ b/diff.h @@ -155,8 +155,6 @@ extern void diff_unmerge(struct diff_options *, unsigned mode, const unsigned char *sha1); -extern int diff_scoreopt_parse(const char *opt); - #define DIFF_SETUP_REVERSE 1 #define DIFF_SETUP_USE_CACHE 2 #define DIFF_SETUP_USE_SIZE_CACHE 4 diff --git a/quote.c b/quote.c index fb9e4ca253..aa440098e1 100644 --- a/quote.c +++ b/quote.c @@ -20,7 +20,7 @@ static inline int need_bs_quote(char c) return (c == '\'' || c == '!'); } -size_t sq_quote_buf(char *dst, size_t n, const char *src) +static size_t sq_quote_buf(char *dst, size_t n, const char *src) { char c; char *bp = dst; @@ -62,18 +62,6 @@ void sq_quote_print(FILE *stream, const char *src) fputc('\'', stream); } -char *sq_quote(const char *src) -{ - char *buf; - size_t cnt; - - cnt = sq_quote_buf(NULL, 0, src) + 1; - buf = xmalloc(cnt); - sq_quote_buf(buf, cnt, src); - - return buf; -} - char *sq_quote_argv(const char** argv, int count) { char *buf, *to; diff --git a/quote.h b/quote.h index bdc3610df5..8a59cc55d1 100644 --- a/quote.h +++ b/quote.h @@ -28,9 +28,7 @@ * excluding the final null regardless of the buffer size. */ -extern char *sq_quote(const char *src); extern void sq_quote_print(FILE *stream, const char *src); -extern size_t sq_quote_buf(char *dst, size_t n, const char *src); extern char *sq_quote_argv(const char** argv, int count); /* diff --git a/upload-pack.c b/upload-pack.c index 0e881c85b5..fe96ef15c4 100644 --- a/upload-pack.c +++ b/upload-pack.c @@ -62,7 +62,7 @@ static ssize_t send_client_data(int fd, const char *data, ssize_t sz) return safe_write(fd, data, sz); } -FILE *pack_pipe = NULL; +static FILE *pack_pipe = NULL; static void show_commit(struct commit *commit) { if (commit->object.flags & BOUNDARY) -- cgit v1.2.3 From 80583c0ef61cc966c7eee79cf3623a83197e19b8 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Mon, 11 Jun 2007 00:34:54 -0700 Subject: Lift 16kB limit of log message output Traditionally we had 16kB limit when formatting log messages for output, because it was easier to arrange for the caller to have a reasonably big buffer and pass it down without ever worrying about reallocating. This changes the calling convention of pretty_print_commit() to lift this limit. Instead of the buffer and remaining length, it now takes a pointer to the pointer that points at the allocated buffer, and another pointer to the location that stores the allocated length, and reallocates the buffer as necessary. To support the user format, the error return of interpolate() needed to be changed. It used to return a bool telling "Ok the result fits", or "Sorry, I had to truncate it". Now it returns 0 on success, and returns the size of the buffer it wants in order to fit the whole result. Signed-off-by: Junio C Hamano --- builtin-branch.c | 17 ++++++++++------ builtin-log.c | 6 ++++-- builtin-rev-list.c | 8 +++++--- builtin-show-branch.c | 23 +++++++++++---------- commit.c | 55 ++++++++++++++++++++++++++++++++++++++++----------- commit.h | 2 +- interpolate.c | 46 ++++++++++++++++++++---------------------- interpolate.h | 6 +++--- log-tree.c | 35 +++++++++++++++++++++----------- 9 files changed, 124 insertions(+), 74 deletions(-) (limited to 'commit.h') diff --git a/builtin-branch.c b/builtin-branch.c index da480519d7..d7c321af4f 100644 --- a/builtin-branch.c +++ b/builtin-branch.c @@ -242,7 +242,6 @@ static void print_ref_item(struct ref_item *item, int maxwidth, int verbose, char c; int color; struct commit *commit; - char subject[256]; switch (item->kind) { case REF_LOCAL_BRANCH: @@ -263,17 +262,23 @@ static void print_ref_item(struct ref_item *item, int maxwidth, int verbose, } if (verbose) { + char *subject = NULL; + unsigned long subject_len = 0; + const char *sub = " **** invalid ref ****"; + commit = lookup_commit(item->sha1); - if (commit && !parse_commit(commit)) + if (commit && !parse_commit(commit)) { pretty_print_commit(CMIT_FMT_ONELINE, commit, ~0, - subject, sizeof(subject), 0, + &subject, &subject_len, 0, NULL, NULL, 0); - else - strcpy(subject, " **** invalid ref ****"); + sub = subject; + } printf("%c %s%-*s%s %s %s\n", c, branch_get_color(color), maxwidth, item->name, branch_get_color(COLOR_BRANCH_RESET), - find_unique_abbrev(item->sha1, abbrev), subject); + find_unique_abbrev(item->sha1, abbrev), sub); + if (subject) + free(subject); } else { printf("%c %s%s%s\n", c, branch_get_color(color), item->name, branch_get_color(COLOR_BRANCH_RESET)); diff --git a/builtin-log.c b/builtin-log.c index 0aede76839..b9035ab799 100644 --- a/builtin-log.c +++ b/builtin-log.c @@ -742,11 +742,13 @@ int cmd_cherry(int argc, const char **argv, const char *prefix) sign = '-'; if (verbose) { - static char buf[16384]; + char *buf = NULL; + unsigned long buflen = 0; pretty_print_commit(CMIT_FMT_ONELINE, commit, ~0, - buf, sizeof(buf), 0, NULL, NULL, 0); + &buf, &buflen, 0, NULL, NULL, 0); printf("%c %s %s\n", sign, sha1_to_hex(commit->object.sha1), buf); + free(buf); } else { printf("%c %s\n", sign, diff --git a/builtin-rev-list.c b/builtin-rev-list.c index ebf53f5944..813aadf596 100644 --- a/builtin-rev-list.c +++ b/builtin-rev-list.c @@ -92,11 +92,13 @@ static void show_commit(struct commit *commit) putchar('\n'); if (revs.verbose_header) { - static char pretty_header[16384]; + char *buf = NULL; + unsigned long buflen = 0; pretty_print_commit(revs.commit_format, commit, ~0, - pretty_header, sizeof(pretty_header), + &buf, &buflen, revs.abbrev, NULL, NULL, revs.date_mode); - printf("%s%c", pretty_header, hdr_termination); + printf("%s%c", buf, hdr_termination); + free(buf); } fflush(stdout); if (commit->parents) { diff --git a/builtin-show-branch.c b/builtin-show-branch.c index c892f1f7a6..4fa87f6081 100644 --- a/builtin-show-branch.c +++ b/builtin-show-branch.c @@ -259,17 +259,19 @@ static void join_revs(struct commit_list **list_p, static void show_one_commit(struct commit *commit, int no_name) { - char pretty[256], *cp; + char *pretty = NULL; + const char *pretty_str = "(unavailable)"; + unsigned long pretty_len = 0; struct commit_name *name = commit->util; - if (commit->object.parsed) + + if (commit->object.parsed) { pretty_print_commit(CMIT_FMT_ONELINE, commit, ~0, - pretty, sizeof(pretty), 0, NULL, NULL, 0); - else - strcpy(pretty, "(unavailable)"); - if (!prefixcmp(pretty, "[PATCH] ")) - cp = pretty + 8; - else - cp = pretty; + &pretty, &pretty_len, + 0, NULL, NULL, 0); + pretty_str = pretty; + } + if (!prefixcmp(pretty_str, "[PATCH] ")) + pretty_str += 8; if (!no_name) { if (name && name->head_name) { @@ -286,7 +288,8 @@ static void show_one_commit(struct commit *commit, int no_name) printf("[%s] ", find_unique_abbrev(commit->object.sha1, 7)); } - puts(cp); + puts(pretty_str); + free(pretty); } static char *ref_name[MAX_REVS + 1]; diff --git a/commit.c b/commit.c index 4ca4d44ba0..d43a68ecb1 100644 --- a/commit.c +++ b/commit.c @@ -776,7 +776,7 @@ static void fill_person(struct interp *table, const char *msg, int len) } static long format_commit_message(const struct commit *commit, - const char *msg, char *buf, unsigned long space) + const char *msg, char **buf_p, unsigned long *space_p) { struct interp table[] = { { "%H" }, /* commit hash */ @@ -905,16 +905,27 @@ static long format_commit_message(const struct commit *commit, if (!table[i].value) interp_set_entry(table, i, ""); - interpolate(buf, space, user_format, table, ARRAY_SIZE(table)); + do { + char *buf = *buf_p; + unsigned long space = *space_p; + + space = interpolate(buf, space, user_format, + table, ARRAY_SIZE(table)); + if (!space) + break; + buf = xrealloc(buf, space); + *buf_p = buf; + *space_p = space; + } while (1); interp_clear_table(table, ARRAY_SIZE(table)); - return strlen(buf); + return strlen(*buf_p); } unsigned long pretty_print_commit(enum cmit_fmt fmt, const struct commit *commit, unsigned long len, - char *buf, unsigned long space, + char **buf_p, unsigned long *space_p, int abbrev, const char *subject, const char *after_subject, enum date_mode dmode) @@ -927,9 +938,11 @@ unsigned long pretty_print_commit(enum cmit_fmt fmt, int plain_non_ascii = 0; char *reencoded; const char *encoding; + char *buf; + unsigned long space, slop; if (fmt == CMIT_FMT_USERFORMAT) - return format_commit_message(commit, msg, buf, space); + return format_commit_message(commit, msg, buf_p, space_p); encoding = (git_log_output_encoding ? git_log_output_encoding @@ -969,6 +982,26 @@ unsigned long pretty_print_commit(enum cmit_fmt fmt, } } + space = *space_p; + buf = *buf_p; + + /* + * We do not want to repeatedly realloc below, so + * preallocate with enough slop to hold MIME headers, + * "Subject: " prefix, etc. + */ + slop = 1000; + if (subject) + slop += strlen(subject); + if (after_subject) + slop += strlen(after_subject); + if (space < strlen(msg) + slop) { + space = strlen(msg) + slop; + buf = xrealloc(buf, space); + *space_p = space; + *buf_p = buf; + } + for (;;) { const char *line = msg; int linelen = get_one_line(msg, len); @@ -976,14 +1009,12 @@ unsigned long pretty_print_commit(enum cmit_fmt fmt, if (!linelen) break; - /* - * We want some slop for indentation and a possible - * final "...". Thus the "+ 20". - */ + /* 20 would cover indent and leave us some slop */ if (offset + linelen + 20 > space) { - memcpy(buf + offset, " ...\n", 8); - offset += 8; - break; + space = offset + linelen + 20; + buf = xrealloc(buf, space); + *buf_p = buf; + *space_p = space; } msg += linelen; diff --git a/commit.h b/commit.h index a313b53c31..467872eeca 100644 --- a/commit.h +++ b/commit.h @@ -61,7 +61,7 @@ enum cmit_fmt { }; extern enum cmit_fmt get_commit_format(const char *arg); -extern unsigned long pretty_print_commit(enum cmit_fmt fmt, const struct commit *, unsigned long len, char *buf, unsigned long space, int abbrev, const char *subject, const char *after_subject, enum date_mode dmode); +extern unsigned long pretty_print_commit(enum cmit_fmt fmt, const struct commit *, unsigned long len, char **buf_p, unsigned long *space_p, int abbrev, const char *subject, const char *after_subject, enum date_mode dmode); /** Removes the first commit from a list sorted by date, and adds all * of its parents. diff --git a/interpolate.c b/interpolate.c index fb30694f47..00826778fc 100644 --- a/interpolate.c +++ b/interpolate.c @@ -44,33 +44,33 @@ void interp_clear_table(struct interp *table, int ninterps) * { "%%", "%"}, * } * - * Returns 1 on a successful substitution pass that fits in result, - * Returns 0 on a failed or overflowing substitution pass. + * Returns 0 on a successful substitution pass that fits in result, + * Returns a number of bytes needed to hold the full substituted + * string otherwise. */ -int interpolate(char *result, int reslen, +unsigned long interpolate(char *result, unsigned long reslen, const char *orig, const struct interp *interps, int ninterps) { const char *src = orig; char *dest = result; - int newlen = 0; + unsigned long newlen = 0; const char *name, *value; - int namelen, valuelen; + unsigned long namelen, valuelen; int i; char c; memset(result, 0, reslen); - while ((c = *src) && newlen < reslen - 1) { + while ((c = *src)) { if (c == '%') { /* Try to match an interpolation string. */ for (i = 0; i < ninterps; i++) { name = interps[i].name; namelen = strlen(name); - if (strncmp(src, name, namelen) == 0) { + if (strncmp(src, name, namelen) == 0) break; - } } /* Check for valid interpolation. */ @@ -78,29 +78,25 @@ int interpolate(char *result, int reslen, value = interps[i].value; valuelen = strlen(value); - if (newlen + valuelen < reslen - 1) { + if (newlen + valuelen + 1 < reslen) { /* Substitute. */ strncpy(dest, value, valuelen); - newlen += valuelen; dest += valuelen; - src += namelen; - } else { - /* Something's not fitting. */ - return 0; } - - } else { - /* Skip bogus interpolation. */ - *dest++ = *src++; - newlen++; + newlen += valuelen; + src += namelen; + continue; } - - } else { - /* Straight copy one non-interpolation character. */ - *dest++ = *src++; - newlen++; } + /* Straight copy one non-interpolation character. */ + if (newlen + 1 < reslen) + *dest++ = *src; + src++; + newlen++; } - return newlen < reslen - 1; + if (newlen + 1 < reslen) + return 0; + else + return newlen + 2; } diff --git a/interpolate.h b/interpolate.h index 16a26b9986..77407e67dc 100644 --- a/interpolate.h +++ b/interpolate.h @@ -19,8 +19,8 @@ struct interp { extern void interp_set_entry(struct interp *table, int slot, const char *value); extern void interp_clear_table(struct interp *table, int ninterps); -extern int interpolate(char *result, int reslen, - const char *orig, - const struct interp *interps, int ninterps); +extern unsigned long interpolate(char *result, unsigned long reslen, + const char *orig, + const struct interp *interps, int ninterps); #endif /* INTERPOLATE_H */ diff --git a/log-tree.c b/log-tree.c index 4bef909144..0cf21bc051 100644 --- a/log-tree.c +++ b/log-tree.c @@ -79,16 +79,25 @@ static int detect_any_signoff(char *letter, int size) return seen_head && seen_name; } -static int append_signoff(char *buf, int buf_sz, int at, const char *signoff) +static unsigned long append_signoff(char **buf_p, unsigned long *buf_sz_p, + unsigned long at, const char *signoff) { static const char signed_off_by[] = "Signed-off-by: "; - int signoff_len = strlen(signoff); + size_t signoff_len = strlen(signoff); int has_signoff = 0; - char *cp = buf; - - /* Do we have enough space to add it? */ - if (buf_sz - at <= strlen(signed_off_by) + signoff_len + 3) - return at; + char *cp; + char *buf; + unsigned long buf_sz; + + buf = *buf_p; + buf_sz = *buf_sz_p; + if (buf_sz <= at + strlen(signed_off_by) + signoff_len + 3) { + buf_sz += strlen(signed_off_by) + signoff_len + 3; + buf = xrealloc(buf, buf_sz); + *buf_p = buf; + *buf_sz_p = buf_sz; + } + cp = buf; /* First see if we already have the sign-off by the signer */ while ((cp = strstr(cp, signed_off_by))) { @@ -133,7 +142,8 @@ static unsigned int digits_in_number(unsigned int number) void show_log(struct rev_info *opt, const char *sep) { - static char this_header[16384]; + char *msgbuf = NULL; + unsigned long msgbuf_len = 0; struct log_info *log = opt->loginfo; struct commit *commit = log->commit, *parent = log->parent; int abbrev = opt->diffopt.abbrev; @@ -278,14 +288,15 @@ void show_log(struct rev_info *opt, const char *sep) /* * And then the pretty-printed message itself */ - len = pretty_print_commit(opt->commit_format, commit, ~0u, this_header, - sizeof(this_header), abbrev, subject, + len = pretty_print_commit(opt->commit_format, commit, ~0u, + &msgbuf, &msgbuf_len, abbrev, subject, extra_headers, opt->date_mode); if (opt->add_signoff) - len = append_signoff(this_header, sizeof(this_header), len, + len = append_signoff(&msgbuf, &msgbuf_len, len, opt->add_signoff); - printf("%s%s%s", this_header, extra, sep); + printf("%s%s%s", msgbuf, extra, sep); + free(msgbuf); } int log_tree_diff_flush(struct rev_info *opt) -- cgit v1.2.3 From 7b95089c0f59a25bb1c506b6962eb64412c585eb Mon Sep 17 00:00:00 2001 From: "Ren,bi(B Scharfe" Date: Mon, 3 Sep 2007 20:06:36 +0200 Subject: Export format_commit_message() Drop the parameter "msg" of format_commit_message() (as it can be inferred from the parameter "commit"), add a parameter "template" in order to avoid accessing the static variable user_format directly and export the result. Signed-off-by: Rene Scharfe Signed-off-by: Junio C Hamano --- commit.c | 9 +++++---- commit.h | 1 + 2 files changed, 6 insertions(+), 4 deletions(-) (limited to 'commit.h') diff --git a/commit.c b/commit.c index dc5a0643f3..99f65cee0e 100644 --- a/commit.c +++ b/commit.c @@ -787,8 +787,8 @@ static void fill_person(struct interp *table, const char *msg, int len) interp_set_entry(table, 6, show_date(date, tz, DATE_ISO8601)); } -static long format_commit_message(const struct commit *commit, - const char *msg, char **buf_p, unsigned long *space_p) +long format_commit_message(const struct commit *commit, const void *format, + char **buf_p, unsigned long *space_p) { struct interp table[] = { { "%H" }, /* commit hash */ @@ -843,6 +843,7 @@ static long format_commit_message(const struct commit *commit, char parents[1024]; int i; enum { HEADER, SUBJECT, BODY } state; + const char *msg = commit->buffer; if (ILEFT_RIGHT + 1 != ARRAY_SIZE(table)) die("invalid interp table!"); @@ -924,7 +925,7 @@ static long format_commit_message(const struct commit *commit, char *buf = *buf_p; unsigned long space = *space_p; - space = interpolate(buf, space, user_format, + space = interpolate(buf, space, format, table, ARRAY_SIZE(table)); if (!space) break; @@ -1165,7 +1166,7 @@ unsigned long pretty_print_commit(enum cmit_fmt fmt, char *buf; if (fmt == CMIT_FMT_USERFORMAT) - return format_commit_message(commit, msg, buf_p, space_p); + return format_commit_message(commit, user_format, buf_p, space_p); encoding = (git_log_output_encoding ? git_log_output_encoding diff --git a/commit.h b/commit.h index 467872eeca..a8d76616d2 100644 --- a/commit.h +++ b/commit.h @@ -61,6 +61,7 @@ enum cmit_fmt { }; extern enum cmit_fmt get_commit_format(const char *arg); +extern long format_commit_message(const struct commit *commit, const void *template, char **buf_p, unsigned long *space_p); extern unsigned long pretty_print_commit(enum cmit_fmt fmt, const struct commit *, unsigned long len, char **buf_p, unsigned long *space_p, int abbrev, const char *subject, const char *after_subject, enum date_mode dmode); /** Removes the first commit from a list sorted by date, and adds all -- cgit v1.2.3 From 674d1727305211f7ade4ade70440220f74f55162 Mon Sep 17 00:00:00 2001 From: Pierre Habouzit Date: Mon, 10 Sep 2007 12:35:06 +0200 Subject: Rework pretty_print_commit to use strbufs instead of custom buffers. Also remove the "len" parameter, as: (1) it was used as a max boundary, and every caller used ~0u (2) we check for final NUL no matter what, so it doesn't help for speed. As a result most of the pp_* function takes 3 arguments less, and we need a lot less local variables, this makes the code way more readable, and easier to extend if needed. This patch also fixes some spacing and cosmetic issues. This patch also fixes (as a side effect) a memory leak intoruced in builtin-archive.c at commit df4a394f (fmt was xmalloc'ed and not free'd) Signed-off-by: Pierre Habouzit Signed-off-by: Junio C Hamano --- builtin-archive.c | 39 +++--- builtin-branch.c | 15 ++- builtin-log.c | 12 +- builtin-rev-list.c | 13 +- builtin-show-branch.c | 13 +- commit.c | 333 +++++++++++++++++++------------------------------- commit.h | 9 +- log-tree.c | 56 +++------ 8 files changed, 191 insertions(+), 299 deletions(-) (limited to 'commit.h') diff --git a/builtin-archive.c b/builtin-archive.c index a90c65ce54..b50d5ad196 100644 --- a/builtin-archive.c +++ b/builtin-archive.c @@ -84,14 +84,16 @@ static int run_remote_archiver(const char *remote, int argc, static void *format_subst(const struct commit *commit, const char *format, unsigned long *sizep) { - unsigned long len = *sizep, result_len = 0; + unsigned long len = *sizep; const char *a = format; - char *result = NULL; + struct strbuf result; + struct strbuf fmt; + + strbuf_init(&result, 0); + strbuf_init(&fmt, 0); for (;;) { const char *b, *c; - char *fmt, *formatted = NULL; - unsigned long a_len, fmt_len, formatted_len, allocated = 0; b = memmem(a, len, "$Format:", 8); if (!b || a + len < b + 9) @@ -100,32 +102,23 @@ static void *format_subst(const struct commit *commit, const char *format, if (!c) break; - a_len = b - a; - fmt_len = c - b - 8; - fmt = xmalloc(fmt_len + 1); - memcpy(fmt, b + 8, fmt_len); - fmt[fmt_len] = '\0'; - - formatted_len = format_commit_message(commit, fmt, &formatted, - &allocated); - free(fmt); - result = xrealloc(result, result_len + a_len + formatted_len); - memcpy(result + result_len, a, a_len); - memcpy(result + result_len + a_len, formatted, formatted_len); - result_len += a_len + formatted_len; + strbuf_reset(&fmt); + strbuf_add(&fmt, b + 8, c - b - 8); + + strbuf_add(&result, a, b - a); + format_commit_message(commit, fmt.buf, &result); len -= c + 1 - a; a = c + 1; } - if (result && len) { - result = xrealloc(result, result_len + len); - memcpy(result + result_len, a, len); - result_len += len; + if (result.len && len) { + strbuf_add(&result, a, len); } - *sizep = result_len; + *sizep = result.len; - return result; + strbuf_release(&fmt); + return strbuf_detach(&result); } static void *convert_to_archive(const char *path, diff --git a/builtin-branch.c b/builtin-branch.c index 5f5c1823cb..3da8b55b8f 100644 --- a/builtin-branch.c +++ b/builtin-branch.c @@ -268,23 +268,22 @@ static void print_ref_item(struct ref_item *item, int maxwidth, int verbose, } if (verbose) { - char *subject = NULL; - unsigned long subject_len = 0; + struct strbuf subject; const char *sub = " **** invalid ref ****"; + strbuf_init(&subject, 0); + commit = lookup_commit(item->sha1); if (commit && !parse_commit(commit)) { - pretty_print_commit(CMIT_FMT_ONELINE, commit, ~0, - &subject, &subject_len, 0, - NULL, NULL, 0); - sub = subject; + pretty_print_commit(CMIT_FMT_ONELINE, commit, + &subject, 0, NULL, NULL, 0); + sub = subject.buf; } printf("%c %s%-*s%s %s %s\n", c, branch_get_color(color), maxwidth, item->name, branch_get_color(COLOR_BRANCH_RESET), find_unique_abbrev(item->sha1, abbrev), sub); - if (subject) - free(subject); + strbuf_release(&subject); } else { printf("%c %s%s%s\n", c, branch_get_color(color), item->name, branch_get_color(COLOR_BRANCH_RESET)); diff --git a/builtin-log.c b/builtin-log.c index fa81c25920..e1d3e7d74b 100644 --- a/builtin-log.c +++ b/builtin-log.c @@ -763,13 +763,13 @@ int cmd_cherry(int argc, const char **argv, const char *prefix) sign = '-'; if (verbose) { - char *buf = NULL; - unsigned long buflen = 0; - pretty_print_commit(CMIT_FMT_ONELINE, commit, ~0, - &buf, &buflen, 0, NULL, NULL, 0); + struct strbuf buf; + strbuf_init(&buf, 0); + pretty_print_commit(CMIT_FMT_ONELINE, commit, + &buf, 0, NULL, NULL, 0); printf("%c %s %s\n", sign, - sha1_to_hex(commit->object.sha1), buf); - free(buf); + sha1_to_hex(commit->object.sha1), buf.buf); + strbuf_release(&buf); } else { printf("%c %s\n", sign, diff --git a/builtin-rev-list.c b/builtin-rev-list.c index ac551d59f3..4fd4b6bec1 100644 --- a/builtin-rev-list.c +++ b/builtin-rev-list.c @@ -80,13 +80,12 @@ static void show_commit(struct commit *commit) putchar('\n'); if (revs.verbose_header) { - char *buf = NULL; - unsigned long buflen = 0; - pretty_print_commit(revs.commit_format, commit, ~0, - &buf, &buflen, - revs.abbrev, NULL, NULL, revs.date_mode); - printf("%s%c", buf, hdr_termination); - free(buf); + struct strbuf buf; + strbuf_init(&buf, 0); + pretty_print_commit(revs.commit_format, commit, + &buf, revs.abbrev, NULL, NULL, revs.date_mode); + printf("%s%c", buf.buf, hdr_termination); + strbuf_release(&buf); } maybe_flush_or_die(stdout, "stdout"); if (commit->parents) { diff --git a/builtin-show-branch.c b/builtin-show-branch.c index 4fa87f6081..07a0c2316b 100644 --- a/builtin-show-branch.c +++ b/builtin-show-branch.c @@ -259,16 +259,15 @@ static void join_revs(struct commit_list **list_p, static void show_one_commit(struct commit *commit, int no_name) { - char *pretty = NULL; + struct strbuf pretty; const char *pretty_str = "(unavailable)"; - unsigned long pretty_len = 0; struct commit_name *name = commit->util; + strbuf_init(&pretty, 0); if (commit->object.parsed) { - pretty_print_commit(CMIT_FMT_ONELINE, commit, ~0, - &pretty, &pretty_len, - 0, NULL, NULL, 0); - pretty_str = pretty; + pretty_print_commit(CMIT_FMT_ONELINE, commit, + &pretty, 0, NULL, NULL, 0); + pretty_str = pretty.buf; } if (!prefixcmp(pretty_str, "[PATCH] ")) pretty_str += 8; @@ -289,7 +288,7 @@ static void show_one_commit(struct commit *commit, int no_name) find_unique_abbrev(commit->object.sha1, 7)); } puts(pretty_str); - free(pretty); + strbuf_release(&pretty); } static char *ref_name[MAX_REVS + 1]; diff --git a/commit.c b/commit.c index 25781cc833..6602e2c72f 100644 --- a/commit.c +++ b/commit.c @@ -458,11 +458,11 @@ void clear_commit_marks(struct commit *commit, unsigned int mark) /* * Generic support for pretty-printing the header */ -static int get_one_line(const char *msg, unsigned long len) +static int get_one_line(const char *msg) { int ret = 0; - while (len--) { + for (;;) { char c = *msg++; if (!c) break; @@ -485,31 +485,24 @@ static int is_rfc2047_special(char ch) return (non_ascii(ch) || (ch == '=') || (ch == '?') || (ch == '_')); } -static int add_rfc2047(char *buf, const char *line, int len, +static void add_rfc2047(struct strbuf *sb, const char *line, int len, const char *encoding) { - char *bp = buf; - int i, needquote; - char q_encoding[128]; - const char *q_encoding_fmt = "=?%s?q?"; + int i, last; - for (i = needquote = 0; !needquote && i < len; i++) { + for (i = 0; i < len; i++) { int ch = line[i]; if (non_ascii(ch)) - needquote++; - if ((i + 1 < len) && - (ch == '=' && line[i+1] == '?')) - needquote++; + goto needquote; + if ((i + 1 < len) && (ch == '=' && line[i+1] == '?')) + goto needquote; } - if (!needquote) - return sprintf(buf, "%.*s", len, line); - - i = snprintf(q_encoding, sizeof(q_encoding), q_encoding_fmt, encoding); - if (sizeof(q_encoding) < i) - die("Insanely long encoding name %s", encoding); - memcpy(bp, q_encoding, i); - bp += i; - for (i = 0; i < len; i++) { + strbuf_add(sb, line, len); + return; + +needquote: + strbuf_addf(sb, "=?%s?q?", encoding); + for (i = last = 0; i < len; i++) { unsigned ch = line[i] & 0xFF; /* * We encode ' ' using '=20' even though rfc2047 @@ -518,15 +511,13 @@ static int add_rfc2047(char *buf, const char *line, int len, * leave the underscore in place. */ if (is_rfc2047_special(ch) || ch == ' ') { - sprintf(bp, "=%02X", ch); - bp += 3; + strbuf_add(sb, line + last, i - last); + strbuf_addf(sb, "=%02X", ch); + last = i + 1; } - else - *bp++ = ch; } - memcpy(bp, "?=", 2); - bp += 2; - return bp - buf; + strbuf_add(sb, line + last, len - last); + strbuf_addstr(sb, "?="); } static unsigned long bound_rfc2047(unsigned long len, const char *encoding) @@ -537,21 +528,21 @@ static unsigned long bound_rfc2047(unsigned long len, const char *encoding) return len * 3 + elen + 100; } -static int add_user_info(const char *what, enum cmit_fmt fmt, char *buf, +static void add_user_info(const char *what, enum cmit_fmt fmt, struct strbuf *sb, const char *line, enum date_mode dmode, const char *encoding) { char *date; int namelen; unsigned long time; - int tz, ret; + int tz; const char *filler = " "; if (fmt == CMIT_FMT_ONELINE) - return 0; + return; date = strchr(line, '>'); if (!date) - return 0; + return; namelen = ++date - line; time = strtoul(date, &date, 10); tz = strtol(date, NULL, 10); @@ -560,42 +551,35 @@ static int add_user_info(const char *what, enum cmit_fmt fmt, char *buf, char *name_tail = strchr(line, '<'); int display_name_length; if (!name_tail) - return 0; + return; while (line < name_tail && isspace(name_tail[-1])) name_tail--; display_name_length = name_tail - line; filler = ""; - strcpy(buf, "From: "); - ret = strlen(buf); - ret += add_rfc2047(buf + ret, line, display_name_length, - encoding); - memcpy(buf + ret, name_tail, namelen - display_name_length); - ret += namelen - display_name_length; - buf[ret++] = '\n'; + strbuf_addstr(sb, "From: "); + add_rfc2047(sb, line, display_name_length, encoding); + strbuf_add(sb, name_tail, namelen - display_name_length); + strbuf_addch(sb, '\n'); } else { - ret = sprintf(buf, "%s: %.*s%.*s\n", what, + strbuf_addf(sb, "%s: %.*s%.*s\n", what, (fmt == CMIT_FMT_FULLER) ? 4 : 0, filler, namelen, line); } switch (fmt) { case CMIT_FMT_MEDIUM: - ret += sprintf(buf + ret, "Date: %s\n", - show_date(time, tz, dmode)); + strbuf_addf(sb, "Date: %s\n", show_date(time, tz, dmode)); break; case CMIT_FMT_EMAIL: - ret += sprintf(buf + ret, "Date: %s\n", - show_date(time, tz, DATE_RFC2822)); + strbuf_addf(sb, "Date: %s\n", show_date(time, tz, DATE_RFC2822)); break; case CMIT_FMT_FULLER: - ret += sprintf(buf + ret, "%sDate: %s\n", what, - show_date(time, tz, dmode)); + strbuf_addf(sb, "%sDate: %s\n", what, show_date(time, tz, dmode)); break; default: /* notin' */ break; } - return ret; } static int is_empty_line(const char *line, int *len_p) @@ -607,16 +591,16 @@ static int is_empty_line(const char *line, int *len_p) return !len; } -static int add_merge_info(enum cmit_fmt fmt, char *buf, const struct commit *commit, int abbrev) +static void add_merge_info(enum cmit_fmt fmt, struct strbuf *sb, + const struct commit *commit, int abbrev) { struct commit_list *parent = commit->parents; - int offset; if ((fmt == CMIT_FMT_ONELINE) || (fmt == CMIT_FMT_EMAIL) || !parent || !parent->next) - return 0; + return; - offset = sprintf(buf, "Merge:"); + strbuf_addstr(sb, "Merge:"); while (parent) { struct commit *p = parent->item; @@ -629,10 +613,9 @@ static int add_merge_info(enum cmit_fmt fmt, char *buf, const struct commit *com dots = (abbrev && strlen(hex) != 40) ? "..." : ""; parent = parent->next; - offset += sprintf(buf + offset, " %s%s", hex, dots); + strbuf_addf(sb, " %s%s", hex, dots); } - buf[offset++] = '\n'; - return offset; + strbuf_addch(sb, '\n'); } static char *get_header(const struct commit *commit, const char *key) @@ -787,8 +770,8 @@ static void fill_person(struct interp *table, const char *msg, int len) interp_set_entry(table, 6, show_date(date, tz, DATE_ISO8601)); } -long format_commit_message(const struct commit *commit, const void *format, - char **buf_p, unsigned long *space_p) +void format_commit_message(const struct commit *commit, + const void *format, struct strbuf *sb) { struct interp table[] = { { "%H" }, /* commit hash */ @@ -841,6 +824,7 @@ long format_commit_message(const struct commit *commit, const void *format, }; struct commit_list *p; char parents[1024]; + unsigned long len; int i; enum { HEADER, SUBJECT, BODY } state; const char *msg = commit->buffer; @@ -921,20 +905,15 @@ long format_commit_message(const struct commit *commit, const void *format, if (!table[i].value) interp_set_entry(table, i, ""); - do { - char *buf = *buf_p; - unsigned long len; - - len = interpolate(buf, *space_p, format, - table, ARRAY_SIZE(table)); - if (len < *space_p) - break; - ALLOC_GROW(buf, len + 1, *space_p); - *buf_p = buf; - } while (1); + len = interpolate(sb->buf + sb->len, strbuf_avail(sb), + format, table, ARRAY_SIZE(table)); + if (len > strbuf_avail(sb)) { + strbuf_grow(sb, len); + interpolate(sb->buf + sb->len, strbuf_avail(sb) + 1, + format, table, ARRAY_SIZE(table)); + } + strbuf_setlen(sb, sb->len + len); interp_clear_table(table, ARRAY_SIZE(table)); - - return strlen(*buf_p); } static void pp_header(enum cmit_fmt fmt, @@ -943,34 +922,24 @@ static void pp_header(enum cmit_fmt fmt, const char *encoding, const struct commit *commit, const char **msg_p, - unsigned long *len_p, - unsigned long *ofs_p, - char **buf_p, - unsigned long *space_p) + struct strbuf *sb) { int parents_shown = 0; for (;;) { const char *line = *msg_p; - char *dst; - int linelen = get_one_line(*msg_p, *len_p); - unsigned long len; + int linelen = get_one_line(*msg_p); if (!linelen) return; *msg_p += linelen; - *len_p -= linelen; if (linelen == 1) /* End of header */ return; - ALLOC_GROW(*buf_p, linelen + *ofs_p + 20, *space_p); - dst = *buf_p + *ofs_p; - if (fmt == CMIT_FMT_RAW) { - memcpy(dst, line, linelen); - *ofs_p += linelen; + strbuf_add(sb, line, linelen); continue; } @@ -988,10 +957,8 @@ static void pp_header(enum cmit_fmt fmt, parent = parent->next, num++) ; /* with enough slop */ - num = *ofs_p + num * 50 + 20; - ALLOC_GROW(*buf_p, num, *space_p); - dst = *buf_p + *ofs_p; - *ofs_p += add_merge_info(fmt, dst, commit, abbrev); + strbuf_grow(sb, num * 50 + 20); + add_merge_info(fmt, sb, commit, abbrev); parents_shown = 1; } @@ -1001,129 +968,99 @@ static void pp_header(enum cmit_fmt fmt, * FULLER shows both authors and dates. */ if (!memcmp(line, "author ", 7)) { - len = linelen; + unsigned long len = linelen; if (fmt == CMIT_FMT_EMAIL) len = bound_rfc2047(linelen, encoding); - ALLOC_GROW(*buf_p, *ofs_p + len + 80, *space_p); - dst = *buf_p + *ofs_p; - *ofs_p += add_user_info("Author", fmt, dst, - line + 7, dmode, encoding); + strbuf_grow(sb, len + 80); + add_user_info("Author", fmt, sb, line + 7, dmode, encoding); } if (!memcmp(line, "committer ", 10) && (fmt == CMIT_FMT_FULL || fmt == CMIT_FMT_FULLER)) { - len = linelen; + unsigned long len = linelen; if (fmt == CMIT_FMT_EMAIL) len = bound_rfc2047(linelen, encoding); - ALLOC_GROW(*buf_p, *ofs_p + len + 80, *space_p); - dst = *buf_p + *ofs_p; - *ofs_p += add_user_info("Commit", fmt, dst, - line + 10, dmode, encoding); + strbuf_grow(sb, len + 80); + add_user_info("Commit", fmt, sb, line + 10, dmode, encoding); } } } static void pp_title_line(enum cmit_fmt fmt, const char **msg_p, - unsigned long *len_p, - unsigned long *ofs_p, - char **buf_p, - unsigned long *space_p, - int indent, + struct strbuf *sb, const char *subject, const char *after_subject, const char *encoding, int plain_non_ascii) { - char *title; - unsigned long title_alloc, title_len; + struct strbuf title; unsigned long len; - title_len = 0; - title_alloc = 80; - title = xmalloc(title_alloc); + strbuf_init(&title, 80); + for (;;) { const char *line = *msg_p; - int linelen = get_one_line(line, *len_p); - *msg_p += linelen; - *len_p -= linelen; + int linelen = get_one_line(line); + *msg_p += linelen; if (!linelen || is_empty_line(line, &linelen)) break; - if (title_alloc <= title_len + linelen + 2) { - title_alloc = title_len + linelen + 80; - title = xrealloc(title, title_alloc); - } - len = 0; - if (title_len) { + strbuf_grow(&title, linelen + 2); + if (title.len) { if (fmt == CMIT_FMT_EMAIL) { - len++; - title[title_len++] = '\n'; + strbuf_addch(&title, '\n'); } - len++; - title[title_len++] = ' '; + strbuf_addch(&title, ' '); } - memcpy(title + title_len, line, linelen); - title_len += linelen; + strbuf_add(&title, line, linelen); } /* Enough slop for the MIME header and rfc2047 */ - len = bound_rfc2047(title_len, encoding)+ 1000; + len = bound_rfc2047(title.len, encoding) + 1000; if (subject) len += strlen(subject); if (after_subject) len += strlen(after_subject); if (encoding) len += strlen(encoding); - ALLOC_GROW(*buf_p, title_len + *ofs_p + len, *space_p); + strbuf_grow(sb, title.len + len); if (subject) { - len = strlen(subject); - memcpy(*buf_p + *ofs_p, subject, len); - *ofs_p += len; - *ofs_p += add_rfc2047(*buf_p + *ofs_p, - title, title_len, encoding); + strbuf_addstr(sb, subject); + add_rfc2047(sb, title.buf, title.len, encoding); } else { - memcpy(*buf_p + *ofs_p, title, title_len); - *ofs_p += title_len; + strbuf_addbuf(sb, &title); } - (*buf_p)[(*ofs_p)++] = '\n'; + strbuf_addch(sb, '\n'); + if (plain_non_ascii) { const char *header_fmt = "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=%s\n" "Content-Transfer-Encoding: 8bit\n"; - *ofs_p += snprintf(*buf_p + *ofs_p, - *space_p - *ofs_p, - header_fmt, encoding); + strbuf_addf(sb, header_fmt, encoding); } if (after_subject) { - len = strlen(after_subject); - memcpy(*buf_p + *ofs_p, after_subject, len); - *ofs_p += len; + strbuf_addstr(sb, after_subject); } - free(title); if (fmt == CMIT_FMT_EMAIL) { - ALLOC_GROW(*buf_p, *ofs_p + 20, *space_p); - (*buf_p)[(*ofs_p)++] = '\n'; + strbuf_addch(sb, '\n'); } + strbuf_release(&title); } static void pp_remainder(enum cmit_fmt fmt, const char **msg_p, - unsigned long *len_p, - unsigned long *ofs_p, - char **buf_p, - unsigned long *space_p, + struct strbuf *sb, int indent) { int first = 1; for (;;) { const char *line = *msg_p; - int linelen = get_one_line(line, *len_p); + int linelen = get_one_line(line); *msg_p += linelen; - *len_p -= linelen; if (!linelen) break; @@ -1136,36 +1073,32 @@ static void pp_remainder(enum cmit_fmt fmt, } first = 0; - ALLOC_GROW(*buf_p, *ofs_p + linelen + indent + 20, *space_p); + strbuf_grow(sb, linelen + indent + 20); if (indent) { - memset(*buf_p + *ofs_p, ' ', indent); - *ofs_p += indent; + memset(sb->buf + sb->len, ' ', indent); + strbuf_setlen(sb, sb->len + indent); } - memcpy(*buf_p + *ofs_p, line, linelen); - *ofs_p += linelen; - (*buf_p)[(*ofs_p)++] = '\n'; + strbuf_add(sb, line, linelen); + strbuf_addch(sb, '\n'); } } -unsigned long pretty_print_commit(enum cmit_fmt fmt, - const struct commit *commit, - unsigned long len, - char **buf_p, unsigned long *space_p, - int abbrev, const char *subject, - const char *after_subject, +void pretty_print_commit(enum cmit_fmt fmt, const struct commit *commit, + struct strbuf *sb, int abbrev, + const char *subject, const char *after_subject, enum date_mode dmode) { - unsigned long offset = 0; unsigned long beginning_of_body; int indent = 4; const char *msg = commit->buffer; int plain_non_ascii = 0; char *reencoded; const char *encoding; - char *buf; - if (fmt == CMIT_FMT_USERFORMAT) - return format_commit_message(commit, user_format, buf_p, space_p); + if (fmt == CMIT_FMT_USERFORMAT) { + format_commit_message(commit, user_format, sb); + return; + } encoding = (git_log_output_encoding ? git_log_output_encoding @@ -1175,7 +1108,6 @@ unsigned long pretty_print_commit(enum cmit_fmt fmt, reencoded = logmsg_reencode(commit, encoding); if (reencoded) { msg = reencoded; - len = strlen(reencoded); } if (fmt == CMIT_FMT_ONELINE || fmt == CMIT_FMT_EMAIL) @@ -1190,14 +1122,13 @@ unsigned long pretty_print_commit(enum cmit_fmt fmt, if (fmt == CMIT_FMT_EMAIL && !after_subject) { int i, ch, in_body; - for (in_body = i = 0; (ch = msg[i]) && i < len; i++) { + for (in_body = i = 0; (ch = msg[i]); i++) { if (!in_body) { /* author could be non 7-bit ASCII but * the log may be so; skip over the * header part first. */ - if (ch == '\n' && - i + 1 < len && msg[i+1] == '\n') + if (ch == '\n' && msg[i+1] == '\n') in_body = 1; } else if (non_ascii(ch)) { @@ -1207,59 +1138,44 @@ unsigned long pretty_print_commit(enum cmit_fmt fmt, } } - pp_header(fmt, abbrev, dmode, encoding, - commit, &msg, &len, - &offset, buf_p, space_p); + pp_header(fmt, abbrev, dmode, encoding, commit, &msg, sb); if (fmt != CMIT_FMT_ONELINE && !subject) { - ALLOC_GROW(*buf_p, offset + 20, *space_p); - (*buf_p)[offset++] = '\n'; + strbuf_addch(sb, '\n'); } /* Skip excess blank lines at the beginning of body, if any... */ for (;;) { - int linelen = get_one_line(msg, len); + int linelen = get_one_line(msg); int ll = linelen; if (!linelen) break; if (!is_empty_line(msg, &ll)) break; msg += linelen; - len -= linelen; } /* These formats treat the title line specially. */ - if (fmt == CMIT_FMT_ONELINE - || fmt == CMIT_FMT_EMAIL) - pp_title_line(fmt, &msg, &len, &offset, - buf_p, space_p, indent, - subject, after_subject, encoding, - plain_non_ascii); - - beginning_of_body = offset; - if (fmt != CMIT_FMT_ONELINE) - pp_remainder(fmt, &msg, &len, &offset, - buf_p, space_p, indent); - - while (offset && isspace((*buf_p)[offset-1])) - offset--; + if (fmt == CMIT_FMT_ONELINE || fmt == CMIT_FMT_EMAIL) + pp_title_line(fmt, &msg, sb, subject, + after_subject, encoding, plain_non_ascii); - ALLOC_GROW(*buf_p, offset + 20, *space_p); - buf = *buf_p; + beginning_of_body = sb->len; + if (fmt != CMIT_FMT_ONELINE) + pp_remainder(fmt, &msg, sb, indent); + strbuf_rtrim(sb); /* Make sure there is an EOLN for the non-oneline case */ if (fmt != CMIT_FMT_ONELINE) - buf[offset++] = '\n'; + strbuf_addch(sb, '\n'); /* * The caller may append additional body text in e-mail * format. Make sure we did not strip the blank line * between the header and the body. */ - if (fmt == CMIT_FMT_EMAIL && offset <= beginning_of_body) - buf[offset++] = '\n'; - buf[offset] = '\0'; + if (fmt == CMIT_FMT_EMAIL && sb->len <= beginning_of_body) + strbuf_addch(sb, '\n'); free(reencoded); - return offset; } struct commit *pop_commit(struct commit_list **stack) @@ -1338,12 +1254,12 @@ void sort_in_topological_order_fn(struct commit_list ** list, int lifo, next=next->next; } /* - * find the tips - * - * tips are nodes not reachable from any other node in the list - * - * the tips serve as a starting set for the work queue. - */ + * find the tips + * + * tips are nodes not reachable from any other node in the list + * + * the tips serve as a starting set for the work queue. + */ next=*list; insert = &work; while (next) { @@ -1370,9 +1286,9 @@ void sort_in_topological_order_fn(struct commit_list ** list, int lifo, if (pn) { /* * parents are only enqueued for emission - * when all their children have been emitted thereby - * guaranteeing topological order. - */ + * when all their children have been emitted thereby + * guaranteeing topological order. + */ pn->indegree--; if (!pn->indegree) { if (!lifo) @@ -1384,9 +1300,9 @@ void sort_in_topological_order_fn(struct commit_list ** list, int lifo, parents=parents->next; } /* - * work_item is a commit all of whose children - * have already been emitted. we can emit it now. - */ + * work_item is a commit all of whose children + * have already been emitted. we can emit it now. + */ *pptr = work_node->list_item; pptr = &(*pptr)->next; *pptr = NULL; @@ -1482,8 +1398,7 @@ static struct commit_list *merge_bases(struct commit *one, struct commit *two) } struct commit_list *get_merge_bases(struct commit *one, - struct commit *two, - int cleanup) + struct commit *two, int cleanup) { struct commit_list *list; struct commit **rslt; diff --git a/commit.h b/commit.h index a8d76616d2..b779de8cbc 100644 --- a/commit.h +++ b/commit.h @@ -3,6 +3,7 @@ #include "object.h" #include "tree.h" +#include "strbuf.h" #include "decorate.h" struct commit_list { @@ -61,8 +62,12 @@ enum cmit_fmt { }; extern enum cmit_fmt get_commit_format(const char *arg); -extern long format_commit_message(const struct commit *commit, const void *template, char **buf_p, unsigned long *space_p); -extern unsigned long pretty_print_commit(enum cmit_fmt fmt, const struct commit *, unsigned long len, char **buf_p, unsigned long *space_p, int abbrev, const char *subject, const char *after_subject, enum date_mode dmode); +extern void format_commit_message(const struct commit *commit, + const void *format, struct strbuf *sb); +extern void pretty_print_commit(enum cmit_fmt fmt, const struct commit*, + struct strbuf *, + int abbrev, const char *subject, + const char *after_subject, enum date_mode); /** Removes the first commit from a list sorted by date, and adds all * of its parents. diff --git a/log-tree.c b/log-tree.c index a6423718e7..3e5e6acfaf 100644 --- a/log-tree.c +++ b/log-tree.c @@ -79,25 +79,14 @@ static int detect_any_signoff(char *letter, int size) return seen_head && seen_name; } -static unsigned long append_signoff(char **buf_p, unsigned long *buf_sz_p, - unsigned long at, const char *signoff) +static void append_signoff(struct strbuf *sb, const char *signoff) { static const char signed_off_by[] = "Signed-off-by: "; size_t signoff_len = strlen(signoff); int has_signoff = 0; char *cp; - char *buf; - unsigned long buf_sz; - - buf = *buf_p; - buf_sz = *buf_sz_p; - if (buf_sz <= at + strlen(signed_off_by) + signoff_len + 3) { - buf_sz += strlen(signed_off_by) + signoff_len + 3; - buf = xrealloc(buf, buf_sz); - *buf_p = buf; - *buf_sz_p = buf_sz; - } - cp = buf; + + cp = sb->buf; /* First see if we already have the sign-off by the signer */ while ((cp = strstr(cp, signed_off_by))) { @@ -105,29 +94,25 @@ static unsigned long append_signoff(char **buf_p, unsigned long *buf_sz_p, has_signoff = 1; cp += strlen(signed_off_by); - if (cp + signoff_len >= buf + at) + if (cp + signoff_len >= sb->buf + sb->len) break; if (strncmp(cp, signoff, signoff_len)) continue; if (!isspace(cp[signoff_len])) continue; /* we already have him */ - return at; + return; } if (!has_signoff) - has_signoff = detect_any_signoff(buf, at); + has_signoff = detect_any_signoff(sb->buf, sb->len); if (!has_signoff) - buf[at++] = '\n'; - - strcpy(buf + at, signed_off_by); - at += strlen(signed_off_by); - strcpy(buf + at, signoff); - at += signoff_len; - buf[at++] = '\n'; - buf[at] = 0; - return at; + strbuf_addch(sb, '\n'); + + strbuf_addstr(sb, signed_off_by); + strbuf_add(sb, signoff, signoff_len); + strbuf_addch(sb, '\n'); } static unsigned int digits_in_number(unsigned int number) @@ -142,14 +127,12 @@ static unsigned int digits_in_number(unsigned int number) void show_log(struct rev_info *opt, const char *sep) { - char *msgbuf = NULL; - unsigned long msgbuf_len = 0; + struct strbuf msgbuf; struct log_info *log = opt->loginfo; struct commit *commit = log->commit, *parent = log->parent; int abbrev = opt->diffopt.abbrev; int abbrev_commit = opt->abbrev_commit ? opt->abbrev : 40; const char *extra; - int len; const char *subject = NULL, *extra_headers = opt->extra_headers; opt->loginfo = NULL; @@ -288,18 +271,17 @@ void show_log(struct rev_info *opt, const char *sep) /* * And then the pretty-printed message itself */ - len = pretty_print_commit(opt->commit_format, commit, ~0u, - &msgbuf, &msgbuf_len, abbrev, subject, - extra_headers, opt->date_mode); + strbuf_init(&msgbuf, 0); + pretty_print_commit(opt->commit_format, commit, &msgbuf, + abbrev, subject, extra_headers, opt->date_mode); if (opt->add_signoff) - len = append_signoff(&msgbuf, &msgbuf_len, len, - opt->add_signoff); + append_signoff(&msgbuf, opt->add_signoff); if (opt->show_log_size) - printf("log size %i\n", len); + printf("log size %i\n", (int)msgbuf.len); - printf("%s%s%s", msgbuf, extra, sep); - free(msgbuf); + printf("%s%s%s", msgbuf.buf, extra, sep); + strbuf_release(&msgbuf); } int log_tree_diff_flush(struct rev_info *opt) -- cgit v1.2.3 From 586801650824f0f7b62c34a206b6a60ffbcd8be0 Mon Sep 17 00:00:00 2001 From: Kristian Høgsberg Date: Mon, 17 Sep 2007 20:06:44 -0400 Subject: Introduce entry point add_interactive and add_files_to_cache MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This refactors builtin-add.c a little to provide a unique entry point for launching git add --interactive, which will be used by builtin-commit too. If we later want to make add --interactive a builtin or change how it is launched, we just start from this function. It also exports the private function update() which is used to add all modified paths to the index as add_files_to_cache(). Signed-off-by: Kristian Høgsberg Signed-off-by: Junio C Hamano --- builtin-add.c | 23 ++++++++++++++--------- commit.h | 4 ++++ 2 files changed, 18 insertions(+), 9 deletions(-) (limited to 'commit.h') diff --git a/builtin-add.c b/builtin-add.c index f9a65803d8..966e145038 100644 --- a/builtin-add.c +++ b/builtin-add.c @@ -12,6 +12,7 @@ #include "diffcore.h" #include "commit.h" #include "revision.h" +#include "run-command.h" static const char builtin_add_usage[] = "git-add [-n] [-v] [-f] [--interactive | -i] [-u] [--refresh] [--] ..."; @@ -106,7 +107,7 @@ static void update_callback(struct diff_queue_struct *q, } } -static void update(int verbose, const char *prefix, const char **files) +void add_files_to_cache(int verbose, const char *prefix, const char **files) { struct rev_info rev; init_revisions(&rev, prefix); @@ -115,8 +116,6 @@ static void update(int verbose, const char *prefix, const char **files) rev.diffopt.output_format = DIFF_FORMAT_CALLBACK; rev.diffopt.format_callback = update_callback; rev.diffopt.format_callback_data = &verbose; - if (read_cache() < 0) - die("index file corrupt"); run_diff_files(&rev, 0); } @@ -149,6 +148,13 @@ static int git_add_config(const char *var, const char *value) return git_default_config(var, value); } +int interactive_add(void) +{ + const char *argv[2] = { "add--interactive", NULL }; + + return run_command_v_opt(argv, RUN_GIT_CMD); +} + static struct lock_file lock_file; static const char ignore_error[] = @@ -168,12 +174,9 @@ int cmd_add(int argc, const char **argv, const char *prefix) add_interactive++; } if (add_interactive) { - const char *args[] = { "add--interactive", NULL }; - - if (add_interactive != 1 || argc != 2) + if (argc != 2) die("add --interactive does not take any parameters"); - execv_git_cmd(args); - exit(1); + exit(interactive_add()); } git_config(git_add_config); @@ -213,7 +216,9 @@ int cmd_add(int argc, const char **argv, const char *prefix) } if (take_worktree_changes) { - update(verbose, prefix, argv + i); + if (read_cache() < 0) + die("index file corrupt"); + add_files_to_cache(verbose, prefix, argv + i); goto finish; } diff --git a/commit.h b/commit.h index b779de8cbc..b50c30e255 100644 --- a/commit.h +++ b/commit.h @@ -128,4 +128,8 @@ extern struct commit_list *get_shallow_commits(struct object_array *heads, int depth, int shallow_flag, int not_shallow_flag); int in_merge_bases(struct commit *, struct commit **, int); + +extern int interactive_add(void); +extern void add_files_to_cache(int verbose, const char *prefix, const char **files); + #endif /* COMMIT_H */ -- cgit v1.2.3 From d8b7db0abfd0c74478964f5a9b08ad141f4f7f82 Mon Sep 17 00:00:00 2001 From: Kristian Høgsberg Date: Mon, 17 Sep 2007 20:06:47 -0400 Subject: Export rerere() and launch_editor(). MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Kristian Høgsberg Signed-off-by: Junio C Hamano --- builtin-rerere.c | 31 ++++++++++++++++++++++++++----- commit.h | 1 + 2 files changed, 27 insertions(+), 5 deletions(-) (limited to 'commit.h') diff --git a/builtin-rerere.c b/builtin-rerere.c index b8206744c1..74493237c9 100644 --- a/builtin-rerere.c +++ b/builtin-rerere.c @@ -389,18 +389,39 @@ static int is_rerere_enabled(void) return 1; } -int cmd_rerere(int argc, const char **argv, const char *prefix) +static int setup_rerere(struct path_list *merge_rr) { - struct path_list merge_rr = { NULL, 0, 0, 1 }; - int i, fd = -1; + int fd; git_config(git_rerere_config); if (!is_rerere_enabled()) - return 0; + return -1; merge_rr_path = xstrdup(git_path("rr-cache/MERGE_RR")); fd = hold_lock_file_for_update(&write_lock, merge_rr_path, 1); - read_rr(&merge_rr); + read_rr(merge_rr); + return fd; +} + +int rerere(void) +{ + struct path_list merge_rr = { NULL, 0, 0, 1 }; + int fd; + + fd = setup_rerere(&merge_rr); + if (fd < 0) + return 0; + return do_plain_rerere(&merge_rr, fd); +} + +int cmd_rerere(int argc, const char **argv, const char *prefix) +{ + struct path_list merge_rr = { NULL, 0, 0, 1 }; + int i, fd; + + fd = setup_rerere(&merge_rr); + if (fd < 0) + return 0; if (argc < 2) return do_plain_rerere(&merge_rr, fd); diff --git a/commit.h b/commit.h index b50c30e255..b661503972 100644 --- a/commit.h +++ b/commit.h @@ -131,5 +131,6 @@ int in_merge_bases(struct commit *, struct commit **, int); extern int interactive_add(void); extern void add_files_to_cache(int verbose, const char *prefix, const char **files); +extern int rerere(void); #endif /* COMMIT_H */ -- cgit v1.2.3 From 4593fb84051d39f65cec81958e91056986e4682f Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Wed, 31 Oct 2007 14:55:17 -0700 Subject: format-patch -s: add MIME encoding header if signer's name requires so When the body of the commit log message contains a non-ASCII character, format-patch correctly emitted the encoding header to mark the resulting message as such. However, if the original message was fully ASCII, the command line switch "-s" was given to add a new sign-off, and the signer's name was not ASCII only, the resulting message would have contained non-ASCII character but was not marked as such. Signed-off-by: Junio C Hamano --- builtin-branch.c | 2 +- builtin-log.c | 2 +- builtin-rev-list.c | 3 ++- builtin-show-branch.c | 2 +- commit.c | 5 ++--- commit.h | 4 +++- log-tree.c | 15 ++++++++++++++- 7 files changed, 24 insertions(+), 9 deletions(-) (limited to 'commit.h') diff --git a/builtin-branch.c b/builtin-branch.c index 3da8b55b8f..3e020ccf17 100644 --- a/builtin-branch.c +++ b/builtin-branch.c @@ -276,7 +276,7 @@ static void print_ref_item(struct ref_item *item, int maxwidth, int verbose, commit = lookup_commit(item->sha1); if (commit && !parse_commit(commit)) { pretty_print_commit(CMIT_FMT_ONELINE, commit, - &subject, 0, NULL, NULL, 0); + &subject, 0, NULL, NULL, 0, 0); sub = subject.buf; } printf("%c %s%-*s%s %s %s\n", c, branch_get_color(color), diff --git a/builtin-log.c b/builtin-log.c index e8b982db7c..8b2bf632c5 100644 --- a/builtin-log.c +++ b/builtin-log.c @@ -787,7 +787,7 @@ int cmd_cherry(int argc, const char **argv, const char *prefix) struct strbuf buf; strbuf_init(&buf, 0); pretty_print_commit(CMIT_FMT_ONELINE, commit, - &buf, 0, NULL, NULL, 0); + &buf, 0, NULL, NULL, 0, 0); printf("%c %s %s\n", sign, sha1_to_hex(commit->object.sha1), buf.buf); strbuf_release(&buf); diff --git a/builtin-rev-list.c b/builtin-rev-list.c index 44393320e8..697046723f 100644 --- a/builtin-rev-list.c +++ b/builtin-rev-list.c @@ -86,7 +86,8 @@ static void show_commit(struct commit *commit) struct strbuf buf; strbuf_init(&buf, 0); pretty_print_commit(revs.commit_format, commit, - &buf, revs.abbrev, NULL, NULL, revs.date_mode); + &buf, revs.abbrev, NULL, NULL, + revs.date_mode, 0); if (buf.len) printf("%s%c", buf.buf, hdr_termination); strbuf_release(&buf); diff --git a/builtin-show-branch.c b/builtin-show-branch.c index 07a0c2316b..6dc835d30a 100644 --- a/builtin-show-branch.c +++ b/builtin-show-branch.c @@ -266,7 +266,7 @@ static void show_one_commit(struct commit *commit, int no_name) strbuf_init(&pretty, 0); if (commit->object.parsed) { pretty_print_commit(CMIT_FMT_ONELINE, commit, - &pretty, 0, NULL, NULL, 0); + &pretty, 0, NULL, NULL, 0, 0); pretty_str = pretty.buf; } if (!prefixcmp(pretty_str, "[PATCH] ")) diff --git a/commit.c b/commit.c index ac24266e93..8262f6ac58 100644 --- a/commit.c +++ b/commit.c @@ -479,7 +479,7 @@ static int get_one_line(const char *msg) } /* High bit set, or ISO-2022-INT */ -static int non_ascii(int ch) +int non_ascii(int ch) { ch = (ch & 0xff); return ((ch & 0x80) || (ch == 0x1b)); @@ -1046,12 +1046,11 @@ static void pp_remainder(enum cmit_fmt fmt, void pretty_print_commit(enum cmit_fmt fmt, const struct commit *commit, struct strbuf *sb, int abbrev, const char *subject, const char *after_subject, - enum date_mode dmode) + enum date_mode dmode, int plain_non_ascii) { unsigned long beginning_of_body; int indent = 4; const char *msg = commit->buffer; - int plain_non_ascii = 0; char *reencoded; const char *encoding; diff --git a/commit.h b/commit.h index b661503972..13b537293d 100644 --- a/commit.h +++ b/commit.h @@ -61,13 +61,15 @@ enum cmit_fmt { CMIT_FMT_UNSPECIFIED, }; +extern int non_ascii(int); extern enum cmit_fmt get_commit_format(const char *arg); extern void format_commit_message(const struct commit *commit, const void *format, struct strbuf *sb); extern void pretty_print_commit(enum cmit_fmt fmt, const struct commit*, struct strbuf *, int abbrev, const char *subject, - const char *after_subject, enum date_mode); + const char *after_subject, enum date_mode, + int non_ascii_present); /** Removes the first commit from a list sorted by date, and adds all * of its parents. diff --git a/log-tree.c b/log-tree.c index 3763ce94fc..a34beb0b02 100644 --- a/log-tree.c +++ b/log-tree.c @@ -125,6 +125,18 @@ static unsigned int digits_in_number(unsigned int number) return result; } +static int has_non_ascii(const char *s) +{ + int ch; + if (!s) + return 0; + while ((ch = *s++) != '\0') { + if (non_ascii(ch)) + return 1; + } + return 0; +} + void show_log(struct rev_info *opt, const char *sep) { struct strbuf msgbuf; @@ -273,7 +285,8 @@ void show_log(struct rev_info *opt, const char *sep) */ strbuf_init(&msgbuf, 0); pretty_print_commit(opt->commit_format, commit, &msgbuf, - abbrev, subject, extra_headers, opt->date_mode); + abbrev, subject, extra_headers, opt->date_mode, + has_non_ascii(opt->add_signoff)); if (opt->add_signoff) append_signoff(&msgbuf, opt->add_signoff); -- cgit v1.2.3 From 23c17d4a4a0e1fc9a5fa347f1fc6be3cf477e543 Mon Sep 17 00:00:00 2001 From: Linus Torvalds Date: Fri, 2 Nov 2007 13:32:58 -0700 Subject: Simplify topo-sort logic .. by not using quite so much indirection. This currently grows the "struct commit" a bit, which could be avoided by using a union for "util" and "indegree" (the topo-sort used to use "util" anyway, so you cannot use them together), but for now the goal of this was to simplify, not optimize. Signed-off-by: Linus Torvalds --- commit.c | 150 +++++++++++++++++++++---------------------------------------- commit.h | 20 +-------- revision.c | 7 +-- revision.h | 4 +- 4 files changed, 55 insertions(+), 126 deletions(-) (limited to 'commit.h') diff --git a/commit.c b/commit.c index 8262f6ac58..ab4eb8bdd1 100644 --- a/commit.c +++ b/commit.c @@ -9,22 +9,6 @@ int save_commit_buffer = 1; -struct sort_node -{ - /* - * the number of children of the associated commit - * that also occur in the list being sorted. - */ - unsigned int indegree; - - /* - * reference to original list item that we will re-use - * on output. - */ - struct commit_list * list_item; - -}; - const char *commit_type = "commit"; static struct cmt_fmt_map { @@ -1149,69 +1133,38 @@ struct commit *pop_commit(struct commit_list **stack) return item; } -void topo_sort_default_setter(struct commit *c, void *data) -{ - c->util = data; -} - -void *topo_sort_default_getter(struct commit *c) -{ - return c->util; -} - /* * Performs an in-place topological sort on the list supplied. */ void sort_in_topological_order(struct commit_list ** list, int lifo) { - sort_in_topological_order_fn(list, lifo, topo_sort_default_setter, - topo_sort_default_getter); -} - -void sort_in_topological_order_fn(struct commit_list ** list, int lifo, - topo_sort_set_fn_t setter, - topo_sort_get_fn_t getter) -{ - struct commit_list * next = *list; - struct commit_list * work = NULL, **insert; - struct commit_list ** pptr = list; - struct sort_node * nodes; - struct sort_node * next_nodes; - int count = 0; - - /* determine the size of the list */ - while (next) { - next = next->next; - count++; - } + struct commit_list *next, *orig = *list; + struct commit_list *work, **insert; + struct commit_list **pptr; - if (!count) + if (!orig) return; - /* allocate an array to help sort the list */ - nodes = xcalloc(count, sizeof(*nodes)); - /* link the list to the array */ - next_nodes = nodes; - next=*list; - while (next) { - next_nodes->list_item = next; - setter(next->item, next_nodes); - next_nodes++; - next = next->next; + *list = NULL; + + /* Mark them and clear the indegree */ + for (next = orig; next; next = next->next) { + struct commit *commit = next->item; + commit->object.flags |= TOPOSORT; + commit->indegree = 0; } + /* update the indegree */ - next=*list; - while (next) { + for (next = orig; next; next = next->next) { struct commit_list * parents = next->item->parents; while (parents) { - struct commit * parent=parents->item; - struct sort_node * pn = (struct sort_node *) getter(parent); + struct commit *parent = parents->item; - if (pn) - pn->indegree++; - parents=parents->next; + if (parent->object.flags & TOPOSORT) + parent->indegree++; + parents = parents->next; } - next=next->next; } + /* * find the tips * @@ -1219,55 +1172,56 @@ void sort_in_topological_order_fn(struct commit_list ** list, int lifo, * * the tips serve as a starting set for the work queue. */ - next=*list; + work = NULL; insert = &work; - while (next) { - struct sort_node * node = (struct sort_node *) getter(next->item); + for (next = orig; next; next = next->next) { + struct commit *commit = next->item; - if (node->indegree == 0) { - insert = &commit_list_insert(next->item, insert)->next; - } - next=next->next; + if (!commit->indegree) + insert = &commit_list_insert(commit, insert)->next; } /* process the list in topological order */ if (!lifo) sort_by_date(&work); + + pptr = list; + *list = NULL; while (work) { - struct commit * work_item = pop_commit(&work); - struct sort_node * work_node = (struct sort_node *) getter(work_item); - struct commit_list * parents = work_item->parents; + struct commit *commit; + struct commit_list *parents, *work_item; - while (parents) { - struct commit * parent=parents->item; - struct sort_node * pn = (struct sort_node *) getter(parent); - - if (pn) { - /* - * parents are only enqueued for emission - * when all their children have been emitted thereby - * guaranteeing topological order. - */ - pn->indegree--; - if (!pn->indegree) { - if (!lifo) - insert_by_date(parent, &work); - else - commit_list_insert(parent, &work); - } + work_item = work; + work = work_item->next; + work_item->next = NULL; + + commit = work_item->item; + for (parents = commit->parents; parents ; parents = parents->next) { + struct commit *parent=parents->item; + + if (!(parent->object.flags & TOPOSORT)) + continue; + + /* + * parents are only enqueued for emission + * when all their children have been emitted thereby + * guaranteeing topological order. + */ + if (!--parent->indegree) { + if (!lifo) + insert_by_date(parent, &work); + else + commit_list_insert(parent, &work); } - parents=parents->next; } /* * work_item is a commit all of whose children * have already been emitted. we can emit it now. */ - *pptr = work_node->list_item; - pptr = &(*pptr)->next; - *pptr = NULL; - setter(work_item, NULL); + commit->object.flags &= ~TOPOSORT; + *pptr = work_item; + pptr = &work_item->next; } - free(nodes); } /* merge-base stuff */ diff --git a/commit.h b/commit.h index 13b537293d..4ed0c1cf7f 100644 --- a/commit.h +++ b/commit.h @@ -14,6 +14,7 @@ struct commit_list { struct commit { struct object object; void *util; + unsigned int indegree; unsigned long date; struct commit_list *parents; struct tree *tree; @@ -84,31 +85,12 @@ void clear_commit_marks(struct commit *commit, unsigned int mark); /* * Performs an in-place topological sort of list supplied. * - * Pre-conditions for sort_in_topological_order: - * all commits in input list and all parents of those - * commits must have object.util == NULL - * - * Pre-conditions for sort_in_topological_order_fn: - * all commits in input list and all parents of those - * commits must have getter(commit) == NULL - * - * Post-conditions: * invariant of resulting list is: * a reachable from b => ord(b) < ord(a) * in addition, when lifo == 0, commits on parallel tracks are * sorted in the dates order. */ - -typedef void (*topo_sort_set_fn_t)(struct commit*, void *data); -typedef void* (*topo_sort_get_fn_t)(struct commit*); - -void topo_sort_default_setter(struct commit *c, void *data); -void *topo_sort_default_getter(struct commit *c); - void sort_in_topological_order(struct commit_list ** list, int lifo); -void sort_in_topological_order_fn(struct commit_list ** list, int lifo, - topo_sort_set_fn_t setter, - topo_sort_get_fn_t getter); struct commit_graft { unsigned char sha1[20]; diff --git a/revision.c b/revision.c index e76da0d448..e85b4af392 100644 --- a/revision.c +++ b/revision.c @@ -677,9 +677,6 @@ void init_revisions(struct rev_info *revs, const char *prefix) revs->prune_fn = NULL; revs->prune_data = NULL; - revs->topo_setter = topo_sort_default_setter; - revs->topo_getter = topo_sort_default_getter; - revs->commit_format = CMIT_FMT_DEFAULT; diff_setup(&revs->diffopt); @@ -1303,9 +1300,7 @@ int prepare_revision_walk(struct rev_info *revs) if (limit_list(revs) < 0) return -1; if (revs->topo_order) - sort_in_topological_order_fn(&revs->commits, revs->lifo, - revs->topo_setter, - revs->topo_getter); + sort_in_topological_order(&revs->commits, revs->lifo); return 0; } diff --git a/revision.h b/revision.h index 98a0a8f3fa..1f645764a5 100644 --- a/revision.h +++ b/revision.h @@ -10,6 +10,7 @@ #define CHILD_SHOWN (1u<<6) #define ADDED (1u<<7) /* Parents already parsed and added? */ #define SYMMETRIC_LEFT (1u<<8) +#define TOPOSORT (1u<<9) /* In the active toposort list.. */ struct rev_info; struct log_info; @@ -96,9 +97,6 @@ struct rev_info { struct diff_options diffopt; struct diff_options pruning; - topo_sort_set_fn_t topo_setter; - topo_sort_get_fn_t topo_getter; - struct reflog_walk_info *reflog_info; }; -- cgit v1.2.3 From 53b2c823f6e862e0c83a4a25bab43e8c32e9c289 Mon Sep 17 00:00:00 2001 From: Linus Torvalds Date: Mon, 5 Nov 2007 13:22:34 -0800 Subject: revision walker: mini clean-up This removes the unnecessary indirection of "revs->prune_fn", since that function is always the same one (or NULL), and there is in fact not even an abstraction reason to make it a function (i.e. its not called from some other file and doesn't allow us to keep the function itself static or anything like that). It then just replaces it with a bit that says "prune or not", and if not pruning, every commit gets TREECHANGE. That in turn means that - if (!revs->prune_fn || (flags & TREECHANGE)) - if (revs->prune_fn && !(flags & TREECHANGE)) just become - if (flags & TREECHANGE) - if (!(flags & TREECHANGE)) respectively. Together with adding the "single_parent()" helper function, the "complex" conditional now becomes if (!(flags & TREECHANGE) && rev->dense && single_parent(commit)) continue; Also indirection of "revs->dense" checking is thrown away the same way, because TREECHANGE bit is set appropriately now. Signed-off-by: Linus Torvalds Signed-off-by: Junio C Hamano --- builtin-log.c | 10 ++-------- builtin-rev-list.c | 14 +++++++------- commit.h | 5 +++++ revision.c | 27 ++++++++++++++++++++------- revision.h | 5 +---- 5 files changed, 35 insertions(+), 26 deletions(-) (limited to 'commit.h') diff --git a/builtin-log.c b/builtin-log.c index 981f38872c..d6845bc7f8 100644 --- a/builtin-log.c +++ b/builtin-log.c @@ -88,15 +88,9 @@ static int estimate_commit_count(struct rev_info *rev, struct commit_list *list) while (list) { struct commit *commit = list->item; unsigned int flags = commit->object.flags; - list = list->next; - if (flags & UNINTERESTING) - continue; - if (rev->prune_fn && rev->dense && !(flags & TREECHANGE)) { - if (commit->parents && !commit->parents->next) - continue; - } - n++; + if ((flags & TREECHANGE) && !(flags & UNINTERESTING)) + n++; } return n; } diff --git a/builtin-rev-list.c b/builtin-rev-list.c index 697046723f..2dec8873f8 100644 --- a/builtin-rev-list.c +++ b/builtin-rev-list.c @@ -142,7 +142,7 @@ static int count_distance(struct commit_list *entry) if (commit->object.flags & (UNINTERESTING | COUNTED)) break; - if (!revs.prune_fn || (commit->object.flags & TREECHANGE)) + if (commit->object.flags & TREECHANGE) nr++; commit->object.flags |= COUNTED; p = commit->parents; @@ -198,7 +198,7 @@ static inline int halfway(struct commit_list *p, int nr) /* * Don't short-cut something we are not going to return! */ - if (revs.prune_fn && !(p->item->object.flags & TREECHANGE)) + if (!(p->item->object.flags & TREECHANGE)) return 0; if (DEBUG_BISECT) return 0; @@ -268,7 +268,7 @@ static struct commit_list *best_bisection(struct commit_list *list, int nr) int distance; unsigned flags = p->item->object.flags; - if (revs.prune_fn && !(flags & TREECHANGE)) + if (!(flags & TREECHANGE)) continue; distance = weight(p); if (nr - distance < distance) @@ -308,7 +308,7 @@ static struct commit_list *best_bisection_sorted(struct commit_list *list, int n int distance; unsigned flags = p->item->object.flags; - if (revs.prune_fn && !(flags & TREECHANGE)) + if (!(flags & TREECHANGE)) continue; distance = weight(p); if (nr - distance < distance) @@ -362,7 +362,7 @@ static struct commit_list *do_find_bisection(struct commit_list *list, p->item->util = &weights[n++]; switch (count_interesting_parents(commit)) { case 0: - if (!revs.prune_fn || (flags & TREECHANGE)) { + if (flags & TREECHANGE) { weight_set(p, 1); counted++; show_list("bisection 2 count one", @@ -435,7 +435,7 @@ static struct commit_list *do_find_bisection(struct commit_list *list, * add one for p itself if p is to be counted, * otherwise inherit it from q directly. */ - if (!revs.prune_fn || (flags & TREECHANGE)) { + if (flags & TREECHANGE) { weight_set(p, weight(q)+1); counted++; show_list("bisection 2 count one", @@ -482,7 +482,7 @@ static struct commit_list *find_bisection(struct commit_list *list, continue; p->next = last; last = p; - if (!revs.prune_fn || (flags & TREECHANGE)) + if (flags & TREECHANGE) nr++; on_list++; } diff --git a/commit.h b/commit.h index 4ed0c1cf7f..aa679867a9 100644 --- a/commit.h +++ b/commit.h @@ -117,4 +117,9 @@ extern int interactive_add(void); extern void add_files_to_cache(int verbose, const char *prefix, const char **files); extern int rerere(void); +static inline int single_parent(struct commit *commit) +{ + return commit->parents && !commit->parents->next; +} + #endif /* COMMIT_H */ diff --git a/revision.c b/revision.c index 2e6121fa1b..931f978af9 100644 --- a/revision.c +++ b/revision.c @@ -308,6 +308,14 @@ static void try_to_simplify_commit(struct rev_info *revs, struct commit *commit) struct commit_list **pp, *parent; int tree_changed = 0, tree_same = 0; + /* + * If we don't do pruning, everything is interesting + */ + if (!revs->prune) { + commit->object.flags |= TREECHANGE; + return; + } + if (!commit->tree) return; @@ -317,6 +325,15 @@ static void try_to_simplify_commit(struct rev_info *revs, struct commit *commit) return; } + /* + * Normal non-merge commit? If we don't want to make the + * history dense, we consider it always to be a change.. + */ + if (!revs->dense && !commit->parents->next) { + commit->object.flags |= TREECHANGE; + return; + } + pp = &commit->parents; while ((parent = *pp) != NULL) { struct commit *p = parent->item; @@ -415,8 +432,7 @@ static int add_parents_to_list(struct rev_info *revs, struct commit *commit, str * simplify the commit history and find the parent * that has no differences in the path set if one exists. */ - if (revs->prune_fn) - revs->prune_fn(revs, commit); + try_to_simplify_commit(revs, commit); if (revs->no_walk) return 0; @@ -684,9 +700,6 @@ void init_revisions(struct rev_info *revs, const char *prefix) revs->skip_count = -1; revs->max_count = -1; - revs->prune_fn = NULL; - revs->prune_data = NULL; - revs->commit_format = CMIT_FMT_DEFAULT; diff_setup(&revs->diffopt); @@ -1271,7 +1284,7 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, const ch diff_tree_setup_paths(revs->prune_data, &revs->pruning); /* Can't prune commits with rename following: the paths change.. */ if (!revs->diffopt.follow_renames) - revs->prune_fn = try_to_simplify_commit; + revs->prune = 1; if (!revs->full_diff) diff_tree_setup_paths(revs->prune_data, &revs->diffopt); } @@ -1412,7 +1425,7 @@ enum commit_action simplify_commit(struct rev_info *revs, struct commit *commit) return commit_ignore; if (!commit_match(commit, revs)) return commit_ignore; - if (revs->prune_fn && revs->dense) { + if (revs->prune && revs->dense) { /* Commit without changes? */ if (!(commit->object.flags & TREECHANGE)) { /* drop merges unless we want parenthood */ diff --git a/revision.h b/revision.h index 2232247be4..a79851449c 100644 --- a/revision.h +++ b/revision.h @@ -15,8 +15,6 @@ struct rev_info; struct log_info; -typedef void (prune_fn_t)(struct rev_info *revs, struct commit *commit); - struct rev_info { /* Starting list */ struct commit_list *commits; @@ -28,12 +26,11 @@ struct rev_info { /* Basic information */ const char *prefix; void *prune_data; - prune_fn_t *prune_fn; - unsigned int early_output; /* Traversal flags */ unsigned int dense:1, + prune:1, no_merges:1, no_walk:1, remove_empty_trees:1, -- cgit v1.2.3 From 7c0ab4458994aa895855abc4a504cf693ecc0cf1 Mon Sep 17 00:00:00 2001 From: Wincent Colaiuta Date: Thu, 22 Nov 2007 01:02:52 +0100 Subject: Teach builtin-add to pass multiple paths to git-add--interactive Instead of just accepting a single file parameter, git-add now accepts any number of path parameters, fowarding them to git-add--interactive. Signed-off-by: Wincent Colaiuta Signed-off-by: Junio C Hamano --- builtin-add.c | 23 +++++++++++++---------- commit.h | 2 +- 2 files changed, 14 insertions(+), 11 deletions(-) (limited to 'commit.h') diff --git a/builtin-add.c b/builtin-add.c index cf815a0b8e..9e3beafe5b 100644 --- a/builtin-add.c +++ b/builtin-add.c @@ -135,11 +135,17 @@ static void refresh(int verbose, const char **pathspec) free(seen); } -int interactive_add(void) +int interactive_add(int argc, const char **argv) { - const char *argv[2] = { "add--interactive", NULL }; - - return run_command_v_opt(argv, RUN_GIT_CMD); + int status; + const char **args = xmalloc(sizeof(const char *) * (argc + 1)); + args[0] = "add--interactive"; + memcpy((void *)args + sizeof(const char *), argv, sizeof(const char *) * argc); + args[argc + 1] = NULL; + + status = run_command_v_opt(args, RUN_GIT_CMD); + free(args); + return status; } static struct lock_file lock_file; @@ -163,17 +169,14 @@ static struct option builtin_add_options[] = { int cmd_add(int argc, const char **argv, const char *prefix) { - int i, newfd, orig_argc = argc; + int i, newfd; const char **pathspec; struct dir_struct dir; argc = parse_options(argc, argv, builtin_add_options, builtin_add_usage, 0); - if (add_interactive) { - if (add_interactive != 1 || orig_argc != 2) - die("add --interactive does not take any parameters"); - exit(interactive_add()); - } + if (add_interactive) + exit(interactive_add(argc, argv)); git_config(git_default_config); diff --git a/commit.h b/commit.h index aa679867a9..d82b8bc300 100644 --- a/commit.h +++ b/commit.h @@ -113,7 +113,7 @@ extern struct commit_list *get_shallow_commits(struct object_array *heads, int in_merge_bases(struct commit *, struct commit **, int); -extern int interactive_add(void); +extern int interactive_add(int argc, const char **argv); extern void add_files_to_cache(int verbose, const char *prefix, const char **files); extern int rerere(void); -- cgit v1.2.3 From b6ec1d619fb54642388063a88e2255556cf5de06 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Sun, 18 Nov 2007 01:12:04 -0800 Subject: Fix add_files_to_cache() to take pathspec, not user specified list of files This separates the logic to limit the extent of change to the index by where you are (controlled by "prefix") and what you specify from the command line (controlled by "pathspec"). Signed-off-by: Junio C Hamano --- builtin-add.c | 8 +++++--- cache.h | 4 +++- commit.h | 1 - 3 files changed, 8 insertions(+), 5 deletions(-) (limited to 'commit.h') diff --git a/builtin-add.c b/builtin-add.c index cf815a0b8e..03508d3dcb 100644 --- a/builtin-add.c +++ b/builtin-add.c @@ -105,12 +105,12 @@ static void update_callback(struct diff_queue_struct *q, } } -void add_files_to_cache(int verbose, const char *prefix, const char **files) +void add_files_to_cache(int verbose, const char *prefix, const char **pathspec) { struct rev_info rev; init_revisions(&rev, prefix); setup_revisions(0, NULL, &rev, NULL); - rev.prune_data = get_pathspec(prefix, files); + rev.prune_data = pathspec; rev.diffopt.output_format = DIFF_FORMAT_CALLBACK; rev.diffopt.format_callback = update_callback; rev.diffopt.format_callback_data = &verbose; @@ -180,9 +180,11 @@ int cmd_add(int argc, const char **argv, const char *prefix) newfd = hold_locked_index(&lock_file, 1); if (take_worktree_changes) { + const char **pathspec; if (read_cache() < 0) die("index file corrupt"); - add_files_to_cache(verbose, prefix, argv); + pathspec = get_pathspec(prefix, argv); + add_files_to_cache(verbose, prefix, pathspec); goto finish; } diff --git a/cache.h b/cache.h index 26eec229eb..cf0bdc674c 100644 --- a/cache.h +++ b/cache.h @@ -604,13 +604,15 @@ extern void trace_argv_printf(const char **argv, int count, const char *format, extern int convert_to_git(const char *path, const char *src, size_t len, struct strbuf *dst); extern int convert_to_working_tree(const char *path, const char *src, size_t len, struct strbuf *dst); +/* add */ +void add_files_to_cache(int verbose, const char *prefix, const char **pathspec); + /* diff.c */ extern int diff_auto_refresh_index; /* match-trees.c */ void shift_tree(const unsigned char *, const unsigned char *, unsigned char *, int); - /* ls-files */ int pathspec_match(const char **spec, char *matched, const char *filename, int skiplen); int report_path_error(const char *ps_matched, const char **pathspec, int prefix_offset); diff --git a/commit.h b/commit.h index aa679867a9..f450aae8aa 100644 --- a/commit.h +++ b/commit.h @@ -114,7 +114,6 @@ extern struct commit_list *get_shallow_commits(struct object_array *heads, int in_merge_bases(struct commit *, struct commit **, int); extern int interactive_add(void); -extern void add_files_to_cache(int verbose, const char *prefix, const char **files); extern int rerere(void); static inline int single_parent(struct commit *commit) -- cgit v1.2.3 From 3f061887c562b20d3ed3d1f764462cf986a1ad12 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Sun, 25 Nov 2007 10:10:10 -0800 Subject: add -i: Fix running from a subdirectory This fixes the pathspec interactive_add() passes to the underlying git-add--interactive helper. When the command was run from a subdirectory, cmd_add() already has gone up to the toplevel of the work tree, and the helper will be spawned from there. The pathspec given on the command line from the user needs to be adjusted for this. This adds "validate_pathspec()" function in the callchain, but it does not validate yet. The function can be changed to barf if there are unmatching pathspec given by the user, but that is not strictly necessary. Signed-off-by: Junio C Hamano --- builtin-add.c | 24 ++++++++++++++++++++---- builtin-commit.c | 2 +- commit.h | 2 +- 3 files changed, 22 insertions(+), 6 deletions(-) (limited to 'commit.h') diff --git a/builtin-add.c b/builtin-add.c index 7c6a296af1..865c475ec9 100644 --- a/builtin-add.c +++ b/builtin-add.c @@ -135,13 +135,29 @@ static void refresh(int verbose, const char **pathspec) free(seen); } -int interactive_add(int argc, const char **argv) +static const char **validate_pathspec(int argc, const char **argv, const char *prefix) +{ + const char **pathspec = get_pathspec(prefix, argv); + + return pathspec; +} + +int interactive_add(int argc, const char **argv, const char *prefix) { int status; - const char **args = xcalloc(sizeof(const char *), (argc + 2)); + const char **args; + const char **pathspec = NULL; + + if (argc) { + pathspec = validate_pathspec(argc, argv, prefix); + if (!pathspec) + return -1; + } + args = xcalloc(sizeof(const char *), (argc + 2)); args[0] = "add--interactive"; - memcpy(&(args[1]), argv, sizeof(const char *) * argc); + if (argc) + memcpy(&(args[1]), pathspec, sizeof(const char *) * argc); args[argc + 1] = NULL; status = run_command_v_opt(args, RUN_GIT_CMD); @@ -177,7 +193,7 @@ int cmd_add(int argc, const char **argv, const char *prefix) argc = parse_options(argc, argv, builtin_add_options, builtin_add_usage, 0); if (add_interactive) - exit(interactive_add(argc, argv)); + exit(interactive_add(argc, argv, prefix)); git_config(git_default_config); diff --git a/builtin-commit.c b/builtin-commit.c index 5d27102a62..45e51b1d5f 100644 --- a/builtin-commit.c +++ b/builtin-commit.c @@ -165,7 +165,7 @@ static char *prepare_index(int argc, const char **argv, const char *prefix) const char **pathspec = NULL; if (interactive) { - interactive_add(argc, argv); + interactive_add(argc, argv, prefix); commit_style = COMMIT_AS_IS; return get_index_file(); } diff --git a/commit.h b/commit.h index 9f0765bd9c..10e2b5d4cf 100644 --- a/commit.h +++ b/commit.h @@ -113,7 +113,7 @@ extern struct commit_list *get_shallow_commits(struct object_array *heads, int in_merge_bases(struct commit *, struct commit **, int); -extern int interactive_add(int argc, const char **argv); +extern int interactive_add(int argc, const char **argv, const char *prefix); extern int rerere(void); static inline int single_parent(struct commit *commit) -- cgit v1.2.3 From b02bd65f679024ce25afeddf7e96d6d7aea5fca6 Mon Sep 17 00:00:00 2001 From: Daniel Barkalow Date: Mon, 18 Feb 2008 22:56:08 -0500 Subject: Export some email and pretty-printing functions These will be used for generating the cover letter in addition to the patch emails. Signed-off-by: Daniel Barkalow Signed-off-by: Junio C Hamano --- commit.h | 15 ++++++++ log-tree.c | 126 +++++++++++++++++++++++++++++++++---------------------------- log-tree.h | 2 + pretty.c | 34 ++++++++--------- 4 files changed, 102 insertions(+), 75 deletions(-) (limited to 'commit.h') diff --git a/commit.h b/commit.h index 10e2b5d4cf..80d65b96da 100644 --- a/commit.h +++ b/commit.h @@ -71,6 +71,21 @@ extern void pretty_print_commit(enum cmit_fmt fmt, const struct commit*, int abbrev, const char *subject, const char *after_subject, enum date_mode, int non_ascii_present); +void pp_user_info(const char *what, enum cmit_fmt fmt, struct strbuf *sb, + const char *line, enum date_mode dmode, + const char *encoding); +void pp_title_line(enum cmit_fmt fmt, + const char **msg_p, + struct strbuf *sb, + const char *subject, + const char *after_subject, + const char *encoding, + int plain_non_ascii); +void pp_remainder(enum cmit_fmt fmt, + const char **msg_p, + struct strbuf *sb, + int indent); + /** Removes the first commit from a list sorted by date, and adds all * of its parents. diff --git a/log-tree.c b/log-tree.c index 1f3fcf16ad..1b084dc27b 100644 --- a/log-tree.c +++ b/log-tree.c @@ -137,6 +137,72 @@ static int has_non_ascii(const char *s) return 0; } +void log_write_email_headers(struct rev_info *opt, const char *name, + const char **subject_p, const char **extra_headers_p) +{ + const char *subject = NULL; + const char *extra_headers = opt->extra_headers; + if (opt->total > 0) { + static char buffer[64]; + snprintf(buffer, sizeof(buffer), + "Subject: [%s %0*d/%d] ", + opt->subject_prefix, + digits_in_number(opt->total), + opt->nr, opt->total); + subject = buffer; + } else if (opt->total == 0 && opt->subject_prefix && *opt->subject_prefix) { + static char buffer[256]; + snprintf(buffer, sizeof(buffer), + "Subject: [%s] ", + opt->subject_prefix); + subject = buffer; + } else { + subject = "Subject: "; + } + + printf("From %s Mon Sep 17 00:00:00 2001\n", name); + if (opt->message_id) + printf("Message-Id: <%s>\n", opt->message_id); + if (opt->ref_message_id) + printf("In-Reply-To: <%s>\nReferences: <%s>\n", + opt->ref_message_id, opt->ref_message_id); + if (opt->mime_boundary) { + static char subject_buffer[1024]; + static char buffer[1024]; + snprintf(subject_buffer, sizeof(subject_buffer) - 1, + "%s" + "MIME-Version: 1.0\n" + "Content-Type: multipart/mixed;" + " boundary=\"%s%s\"\n" + "\n" + "This is a multi-part message in MIME " + "format.\n" + "--%s%s\n" + "Content-Type: text/plain; " + "charset=UTF-8; format=fixed\n" + "Content-Transfer-Encoding: 8bit\n\n", + extra_headers ? extra_headers : "", + mime_boundary_leader, opt->mime_boundary, + mime_boundary_leader, opt->mime_boundary); + extra_headers = subject_buffer; + + snprintf(buffer, sizeof(buffer) - 1, + "--%s%s\n" + "Content-Type: text/x-patch;" + " name=\"%s.diff\"\n" + "Content-Transfer-Encoding: 8bit\n" + "Content-Disposition: %s;" + " filename=\"%s.diff\"\n\n", + mime_boundary_leader, opt->mime_boundary, + name, + opt->no_inline ? "attachment" : "inline", + name); + opt->diffopt.stat_sep = buffer; + } + *subject_p = subject; + *extra_headers_p = extra_headers; +} + void show_log(struct rev_info *opt, const char *sep) { struct strbuf msgbuf; @@ -186,64 +252,8 @@ void show_log(struct rev_info *opt, const char *sep) */ if (opt->commit_format == CMIT_FMT_EMAIL) { - char *sha1 = sha1_to_hex(commit->object.sha1); - if (opt->total > 0) { - static char buffer[64]; - snprintf(buffer, sizeof(buffer), - "Subject: [%s %0*d/%d] ", - opt->subject_prefix, - digits_in_number(opt->total), - opt->nr, opt->total); - subject = buffer; - } else if (opt->total == 0 && opt->subject_prefix && *opt->subject_prefix) { - static char buffer[256]; - snprintf(buffer, sizeof(buffer), - "Subject: [%s] ", - opt->subject_prefix); - subject = buffer; - } else { - subject = "Subject: "; - } - - printf("From %s Mon Sep 17 00:00:00 2001\n", sha1); - if (opt->message_id) - printf("Message-Id: <%s>\n", opt->message_id); - if (opt->ref_message_id) - printf("In-Reply-To: <%s>\nReferences: <%s>\n", - opt->ref_message_id, opt->ref_message_id); - if (opt->mime_boundary) { - static char subject_buffer[1024]; - static char buffer[1024]; - snprintf(subject_buffer, sizeof(subject_buffer) - 1, - "%s" - "MIME-Version: 1.0\n" - "Content-Type: multipart/mixed;" - " boundary=\"%s%s\"\n" - "\n" - "This is a multi-part message in MIME " - "format.\n" - "--%s%s\n" - "Content-Type: text/plain; " - "charset=UTF-8; format=fixed\n" - "Content-Transfer-Encoding: 8bit\n\n", - extra_headers ? extra_headers : "", - mime_boundary_leader, opt->mime_boundary, - mime_boundary_leader, opt->mime_boundary); - extra_headers = subject_buffer; - - snprintf(buffer, sizeof(buffer) - 1, - "--%s%s\n" - "Content-Type: text/x-patch;" - " name=\"%s.diff\"\n" - "Content-Transfer-Encoding: 8bit\n" - "Content-Disposition: %s;" - " filename=\"%s.diff\"\n\n", - mime_boundary_leader, opt->mime_boundary, - sha1, - opt->no_inline ? "attachment" : "inline", - sha1); - opt->diffopt.stat_sep = buffer; - } + log_write_email_headers(opt, sha1_to_hex(commit->object.sha1), + &subject, &extra_headers); } else if (opt->commit_format != CMIT_FMT_USERFORMAT) { fputs(diff_get_color_opt(&opt->diffopt, DIFF_COMMIT), stdout); if (opt->commit_format != CMIT_FMT_ONELINE) diff --git a/log-tree.h b/log-tree.h index b33f7cd7ac..0cc9344eab 100644 --- a/log-tree.h +++ b/log-tree.h @@ -13,5 +13,7 @@ int log_tree_commit(struct rev_info *, struct commit *); int log_tree_opt_parse(struct rev_info *, const char **, int); void show_log(struct rev_info *opt, const char *sep); void show_decorations(struct commit *commit); +void log_write_email_headers(struct rev_info *opt, const char *name, + const char **subject_p, const char **extra_headers_p); #endif diff --git a/pretty.c b/pretty.c index b987ff245b..d5db1bd872 100644 --- a/pretty.c +++ b/pretty.c @@ -110,9 +110,9 @@ needquote: strbuf_addstr(sb, "?="); } -static void add_user_info(const char *what, enum cmit_fmt fmt, struct strbuf *sb, - const char *line, enum date_mode dmode, - const char *encoding) +void pp_user_info(const char *what, enum cmit_fmt fmt, struct strbuf *sb, + const char *line, enum date_mode dmode, + const char *encoding) { char *date; int namelen; @@ -295,7 +295,7 @@ static void format_person_part(struct strbuf *sb, char part, /* * If it does not even have a '<' and '>', that is * quite a bogus commit author and we discard it; - * this is in line with add_user_info() that is used + * this is in line with pp_user_info() that is used * in the normal codepath. When end points at the '<' * that we found, it should have matching '>' later, * which means start (beginning of email address) must @@ -643,23 +643,23 @@ static void pp_header(enum cmit_fmt fmt, */ if (!memcmp(line, "author ", 7)) { strbuf_grow(sb, linelen + 80); - add_user_info("Author", fmt, sb, line + 7, dmode, encoding); + pp_user_info("Author", fmt, sb, line + 7, dmode, encoding); } if (!memcmp(line, "committer ", 10) && (fmt == CMIT_FMT_FULL || fmt == CMIT_FMT_FULLER)) { strbuf_grow(sb, linelen + 80); - add_user_info("Commit", fmt, sb, line + 10, dmode, encoding); + pp_user_info("Commit", fmt, sb, line + 10, dmode, encoding); } } } -static void pp_title_line(enum cmit_fmt fmt, - const char **msg_p, - struct strbuf *sb, - const char *subject, - const char *after_subject, - const char *encoding, - int plain_non_ascii) +void pp_title_line(enum cmit_fmt fmt, + const char **msg_p, + struct strbuf *sb, + const char *subject, + const char *after_subject, + const char *encoding, + int plain_non_ascii) { struct strbuf title; @@ -708,10 +708,10 @@ static void pp_title_line(enum cmit_fmt fmt, strbuf_release(&title); } -static void pp_remainder(enum cmit_fmt fmt, - const char **msg_p, - struct strbuf *sb, - int indent) +void pp_remainder(enum cmit_fmt fmt, + const char **msg_p, + struct strbuf *sb, + int indent) { int first = 1; for (;;) { -- cgit v1.2.3 From 45163382437c3862d3beb88134b7a975a3a26443 Mon Sep 17 00:00:00 2001 From: Martin Koegler Date: Mon, 25 Feb 2008 22:46:07 +0100 Subject: builtin-fsck: reports missing parent commits parse_commit ignores parent commits with certain errors (eg. a non commit object is already loaded under the sha1 of the parent). To make fsck reports such errors, it has to compare the nummer of parent commits returned by parse commit with the number of parent commits in the object or in the graft/shallow file. Signed-off-by: Martin Koegler Signed-off-by: Junio C Hamano --- builtin-fsck.c | 24 ++++++++++++++++++++++++ commit.c | 2 +- commit.h | 1 + 3 files changed, 26 insertions(+), 1 deletion(-) (limited to 'commit.h') diff --git a/builtin-fsck.c b/builtin-fsck.c index 7321ab236b..727310afc2 100644 --- a/builtin-fsck.c +++ b/builtin-fsck.c @@ -397,6 +397,8 @@ static int fsck_commit(struct commit *commit) { char *buffer = commit->buffer; unsigned char tree_sha1[20], sha1[20]; + struct commit_graft *graft; + int parents = 0; if (verbose) fprintf(stderr, "Checking commit %s\n", @@ -411,6 +413,28 @@ static int fsck_commit(struct commit *commit) if (get_sha1_hex(buffer+7, sha1) || buffer[47] != '\n') return objerror(&commit->object, "invalid 'parent' line format - bad sha1"); buffer += 48; + parents++; + } + graft = lookup_commit_graft(commit->object.sha1); + if (graft) { + struct commit_list *p = commit->parents; + parents = 0; + while (p) { + p = p->next; + parents++; + } + if (graft->nr_parent == -1 && !parents) + ; /* shallow commit */ + else if (graft->nr_parent != parents) + return objerror(&commit->object, "graft objects missing"); + } else { + struct commit_list *p = commit->parents; + while (p && parents) { + p = p->next; + parents--; + } + if (p || parents) + return objerror(&commit->object, "parent objects missing"); } if (memcmp(buffer, "author ", 7)) return objerror(&commit->object, "invalid format - expected 'author' line"); diff --git a/commit.c b/commit.c index 6684c4e731..94d5b3d261 100644 --- a/commit.c +++ b/commit.c @@ -193,7 +193,7 @@ static void prepare_commit_graft(void) commit_graft_prepared = 1; } -static struct commit_graft *lookup_commit_graft(const unsigned char *sha1) +struct commit_graft *lookup_commit_graft(const unsigned char *sha1) { int pos; prepare_commit_graft(); diff --git a/commit.h b/commit.h index 10e2b5d4cf..3ad3dd9af1 100644 --- a/commit.h +++ b/commit.h @@ -101,6 +101,7 @@ struct commit_graft { struct commit_graft *read_graft_line(char *buf, int len); int register_commit_graft(struct commit_graft *, int); int read_graft_file(const char *graft_file); +struct commit_graft *lookup_commit_graft(const unsigned char *sha1); extern struct commit_list *get_merge_bases(struct commit *rev1, struct commit *rev2, int cleanup); -- cgit v1.2.3 From 6bf4f1b4c9d78b2061bd5f3bf77bb21112b755be Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Fri, 14 Mar 2008 17:10:09 -0700 Subject: format-patch: generate MIME header as needed even when there is format.header Earlier, the callchain from pretty_print_commit() down to pp_title_line() had an unwarranted assumption that the presense of "after_subject" parameter, means the caller has already output MIME headers for attachments. The parameter's primary purpose is to give extra header lines the caller wants to place after pp_title_line() generates the "Subject: " line. This assumption does not hold when the user used the format.header configuration variable to pass extra headers, and caused a message with non-ASCII character to lack proper MIME headers (e.g. 8-bit CTE header). The earlier logic also failed to suppress duplicated MIME headers when "format-patch -s --attach" is asked for and the signer's name demanded 8-bit clean transport. This patch fixes the logic by introducing a separate need_8bit_cte parameter passed down the callchain. This can have one of these values: -1 : we've already done MIME crap and we do not want to add extra header to say this is 8bit in pp_title_line(); 0 : we haven't done MIME and we have not seen anything that is 8bit yet; 1 : we haven't done MIME and we have seen something that is 8bit; pp_title_line() must add MIME header. It adds two tests by Jeff King who independently diagnosed this issue. Signed-off-by: Junio C Hamano --- commit.h | 2 +- log-tree.c | 7 ++++++- pretty.c | 24 +++++++++++------------- t/t4021-format-patch-signer-mime.sh | 10 +++++++++- t/t4028-format-patch-mime-headers.sh | 30 ++++++++++++++++++++++++++++++ 5 files changed, 57 insertions(+), 16 deletions(-) create mode 100755 t/t4028-format-patch-mime-headers.sh (limited to 'commit.h') diff --git a/commit.h b/commit.h index 10e2b5d4cf..000528a67b 100644 --- a/commit.h +++ b/commit.h @@ -70,7 +70,7 @@ extern void pretty_print_commit(enum cmit_fmt fmt, const struct commit*, struct strbuf *, int abbrev, const char *subject, const char *after_subject, enum date_mode, - int non_ascii_present); + int need_8bit_cte); /** Removes the first commit from a list sorted by date, and adds all * of its parents. diff --git a/log-tree.c b/log-tree.c index 1f3fcf16ad..dd94f393a0 100644 --- a/log-tree.c +++ b/log-tree.c @@ -146,6 +146,7 @@ void show_log(struct rev_info *opt, const char *sep) int abbrev_commit = opt->abbrev_commit ? opt->abbrev : 40; const char *extra; const char *subject = NULL, *extra_headers = opt->extra_headers; + int need_8bit_cte = 0; opt->loginfo = NULL; if (!opt->verbose_header) { @@ -214,6 +215,8 @@ void show_log(struct rev_info *opt, const char *sep) if (opt->mime_boundary) { static char subject_buffer[1024]; static char buffer[1024]; + + need_8bit_cte = -1; /* never */ snprintf(subject_buffer, sizeof(subject_buffer) - 1, "%s" "MIME-Version: 1.0\n" @@ -282,9 +285,11 @@ void show_log(struct rev_info *opt, const char *sep) * And then the pretty-printed message itself */ strbuf_init(&msgbuf, 0); + if (need_8bit_cte >= 0) + need_8bit_cte = has_non_ascii(opt->add_signoff); pretty_print_commit(opt->commit_format, commit, &msgbuf, abbrev, subject, extra_headers, opt->date_mode, - has_non_ascii(opt->add_signoff)); + need_8bit_cte); if (opt->add_signoff) append_signoff(&msgbuf, opt->add_signoff); diff --git a/pretty.c b/pretty.c index b987ff245b..0963bb08c1 100644 --- a/pretty.c +++ b/pretty.c @@ -659,7 +659,7 @@ static void pp_title_line(enum cmit_fmt fmt, const char *subject, const char *after_subject, const char *encoding, - int plain_non_ascii) + int need_8bit_cte) { struct strbuf title; @@ -692,7 +692,7 @@ static void pp_title_line(enum cmit_fmt fmt, } strbuf_addch(sb, '\n'); - if (plain_non_ascii) { + if (need_8bit_cte > 0) { const char *header_fmt = "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=%s\n" @@ -741,9 +741,9 @@ static void pp_remainder(enum cmit_fmt fmt, } void pretty_print_commit(enum cmit_fmt fmt, const struct commit *commit, - struct strbuf *sb, int abbrev, - const char *subject, const char *after_subject, - enum date_mode dmode, int plain_non_ascii) + struct strbuf *sb, int abbrev, + const char *subject, const char *after_subject, + enum date_mode dmode, int need_8bit_cte) { unsigned long beginning_of_body; int indent = 4; @@ -769,13 +769,11 @@ void pretty_print_commit(enum cmit_fmt fmt, const struct commit *commit, if (fmt == CMIT_FMT_ONELINE || fmt == CMIT_FMT_EMAIL) indent = 0; - /* After-subject is used to pass in Content-Type: multipart - * MIME header; in that case we do not have to do the - * plaintext content type even if the commit message has - * non 7-bit ASCII character. Otherwise, check if we need - * to say this is not a 7-bit ASCII. + /* + * We need to check and emit Content-type: to mark it + * as 8-bit if we haven't done so. */ - if (fmt == CMIT_FMT_EMAIL && !after_subject) { + if (fmt == CMIT_FMT_EMAIL && need_8bit_cte == 0) { int i, ch, in_body; for (in_body = i = 0; (ch = msg[i]); i++) { @@ -788,7 +786,7 @@ void pretty_print_commit(enum cmit_fmt fmt, const struct commit *commit, in_body = 1; } else if (non_ascii(ch)) { - plain_non_ascii = 1; + need_8bit_cte = 1; break; } } @@ -813,7 +811,7 @@ void pretty_print_commit(enum cmit_fmt fmt, const struct commit *commit, /* These formats treat the title line specially. */ if (fmt == CMIT_FMT_ONELINE || fmt == CMIT_FMT_EMAIL) pp_title_line(fmt, &msg, sb, subject, - after_subject, encoding, plain_non_ascii); + after_subject, encoding, need_8bit_cte); beginning_of_body = sb->len; if (fmt != CMIT_FMT_ONELINE) diff --git a/t/t4021-format-patch-signer-mime.sh b/t/t4021-format-patch-signer-mime.sh index 67a70fadab..ba43f18549 100755 --- a/t/t4021-format-patch-signer-mime.sh +++ b/t/t4021-format-patch-signer-mime.sh @@ -32,11 +32,19 @@ test_expect_success 'format with signoff without funny signer name' ' test_expect_success 'format with non ASCII signer name' ' - GIT_COMMITTER_NAME="$B$O$^$N(B $B$U$K$*$&(B" \ + GIT_COMMITTER_NAME="はまの ふにおう" \ git format-patch -s --stdout -1 >output && grep Content-Type output ' +test_expect_success 'attach and signoff do not duplicate mime headers' ' + + GIT_COMMITTER_NAME="はまの ふにおう" \ + git format-patch -s --stdout -1 --attach >output && + test `grep -ci ^MIME-Version: output` = 1 + +' + test_done diff --git a/t/t4028-format-patch-mime-headers.sh b/t/t4028-format-patch-mime-headers.sh new file mode 100755 index 0000000000..204ba673cb --- /dev/null +++ b/t/t4028-format-patch-mime-headers.sh @@ -0,0 +1,30 @@ +#!/bin/sh + +test_description='format-patch mime headers and extra headers do not conflict' +. ./test-lib.sh + +test_expect_success 'create commit with utf-8 body' ' + echo content >file && + git add file && + git commit -m one && + echo more >>file && + git commit -a -m "two + + utf-8 body: ñ" +' + +test_expect_success 'patch has mime headers' ' + rm -f 0001-two.patch && + git format-patch HEAD^ && + grep -i "content-type: text/plain; charset=utf-8" 0001-two.patch +' + +test_expect_success 'patch has mime and extra headers' ' + rm -f 0001-two.patch && + git config format.headers "x-foo: bar" && + git format-patch HEAD^ && + grep -i "x-foo: bar" 0001-two.patch && + grep -i "content-type: text/plain; charset=utf-8" 0001-two.patch +' + +test_done -- cgit v1.2.3 From 4da45bef56e1547eb6525015ada0fdfc01d8295b Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Mon, 7 Apr 2008 17:11:34 -0700 Subject: log: teach "terminator" vs "separator" mode to "--pretty=format" This attached patch introduces a single bit "use_terminator" in "struct rev_info", which is normally false (i.e. most formats use separator semantics) but by flipping it to true, you can ask for terminator semantics just like oneline format does. The function get_commit_format(), which is what parses "--pretty=" option, now takes a pointer to "struct rev_info" and updates its commit_format and use_terminator fields. It used to return the value of type "enum cmit_fmt", but all the callers assigned it to rev->commit_format. There are only two cases the code turns use_terminator on. Obviously, the traditional oneline format (--pretty=oneline) is one of them, and the new case is --pretty=tformat:... that acts like --pretty=format:... but flips the bit on. With this, "--pretty=tformat:%H %s" acts like --pretty=oneline. Signed-off-by: Junio C Hamano --- builtin-commit.c | 2 +- builtin-log.c | 3 ++- commit.h | 3 ++- log-tree.c | 4 ++-- pretty.c | 57 ++++++++++++++++++++++++++++++++------------------------ revision.c | 2 +- revision.h | 3 ++- 7 files changed, 43 insertions(+), 31 deletions(-) (limited to 'commit.h') diff --git a/builtin-commit.c b/builtin-commit.c index 660a3458f7..8bf35033e4 100644 --- a/builtin-commit.c +++ b/builtin-commit.c @@ -810,7 +810,7 @@ static void print_summary(const char *prefix, const unsigned char *sha1) rev.verbose_header = 1; rev.show_root_diff = 1; - rev.commit_format = get_commit_format("format:%h: %s"); + get_commit_format("format:%h: %s", &rev); rev.always_show_header = 0; rev.diffopt.detect_rename = 1; rev.diffopt.rename_limit = 100; diff --git a/builtin-log.c b/builtin-log.c index 5c00725f03..1670d0b334 100644 --- a/builtin-log.c +++ b/builtin-log.c @@ -56,7 +56,7 @@ 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) - rev->commit_format = get_commit_format(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; @@ -400,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; /* diff --git a/commit.h b/commit.h index 2f63bc8b2f..2d94d4148e 100644 --- a/commit.h +++ b/commit.h @@ -63,7 +63,8 @@ enum cmit_fmt { }; extern int non_ascii(int); -extern enum cmit_fmt get_commit_format(const char *arg); +struct rev_info; /* in revision.h, it circularly uses enum cmit_fmt */ +extern void get_commit_format(const char *arg, struct rev_info *); extern void format_commit_message(const struct commit *commit, const void *format, struct strbuf *sb); extern void pretty_print_commit(enum cmit_fmt fmt, const struct commit*, diff --git a/log-tree.c b/log-tree.c index 9d54061601..8f5436b747 100644 --- a/log-tree.c +++ b/log-tree.c @@ -249,9 +249,9 @@ void show_log(struct rev_info *opt, const char *sep) * not have an empty line between entries. */ extra = ""; - if (*sep != '\n' && opt->commit_format == CMIT_FMT_ONELINE) + if (*sep != '\n' && opt->use_terminator) extra = "\n"; - if (opt->shown_one && opt->commit_format != CMIT_FMT_ONELINE) + if (opt->shown_one && !opt->use_terminator) putchar(opt->diffopt.line_termination); opt->shown_one = 1; diff --git a/pretty.c b/pretty.c index 6c04176cb8..687293224c 100644 --- a/pretty.c +++ b/pretty.c @@ -4,40 +4,49 @@ #include "diff.h" #include "revision.h" -static struct cmt_fmt_map { - const char *n; - size_t cmp_len; - enum cmit_fmt v; -} cmt_fmts[] = { - { "raw", 1, CMIT_FMT_RAW }, - { "medium", 1, CMIT_FMT_MEDIUM }, - { "short", 1, CMIT_FMT_SHORT }, - { "email", 1, CMIT_FMT_EMAIL }, - { "full", 5, CMIT_FMT_FULL }, - { "fuller", 5, CMIT_FMT_FULLER }, - { "oneline", 1, CMIT_FMT_ONELINE }, - { "format:", 7, CMIT_FMT_USERFORMAT}, -}; - static char *user_format; -enum cmit_fmt get_commit_format(const char *arg) +void get_commit_format(const char *arg, struct rev_info *rev) { int i; - - if (!arg || !*arg) - return CMIT_FMT_DEFAULT; + static struct cmt_fmt_map { + const char *n; + size_t cmp_len; + enum cmit_fmt v; + } cmt_fmts[] = { + { "raw", 1, CMIT_FMT_RAW }, + { "medium", 1, CMIT_FMT_MEDIUM }, + { "short", 1, CMIT_FMT_SHORT }, + { "email", 1, CMIT_FMT_EMAIL }, + { "full", 5, CMIT_FMT_FULL }, + { "fuller", 5, CMIT_FMT_FULLER }, + { "oneline", 1, CMIT_FMT_ONELINE }, + }; + + rev->use_terminator = 0; + if (!arg || !*arg) { + rev->commit_format = CMIT_FMT_DEFAULT; + return; + } if (*arg == '=') arg++; - if (!prefixcmp(arg, "format:")) { + if (!prefixcmp(arg, "format:") || !prefixcmp(arg, "tformat:")) { + const char *cp = strchr(arg, ':') + 1; free(user_format); - user_format = xstrdup(arg + 7); - return CMIT_FMT_USERFORMAT; + user_format = xstrdup(cp); + if (arg[0] == 't') + rev->use_terminator = 1; + rev->commit_format = CMIT_FMT_USERFORMAT; + return; } for (i = 0; i < ARRAY_SIZE(cmt_fmts); i++) { if (!strncmp(arg, cmt_fmts[i].n, cmt_fmts[i].cmp_len) && - !strncmp(arg, cmt_fmts[i].n, strlen(arg))) - return cmt_fmts[i].v; + !strncmp(arg, cmt_fmts[i].n, strlen(arg))) { + if (cmt_fmts[i].v == CMIT_FMT_ONELINE) + rev->use_terminator = 1; + rev->commit_format = cmt_fmts[i].v; + return; + } } die("invalid --pretty format: %s", arg); diff --git a/revision.c b/revision.c index 196fedc9d1..781c503dfc 100644 --- a/revision.c +++ b/revision.c @@ -1198,7 +1198,7 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, const ch } if (!prefixcmp(arg, "--pretty")) { revs->verbose_header = 1; - revs->commit_format = get_commit_format(arg+8); + get_commit_format(arg+8, revs); continue; } if (!strcmp(arg, "--root")) { diff --git a/revision.h b/revision.h index c8b3b948ec..31217f8c67 100644 --- a/revision.h +++ b/revision.h @@ -64,7 +64,8 @@ struct rev_info { /* Format info */ unsigned int shown_one:1, - abbrev_commit:1; + abbrev_commit:1, + use_terminator:1; enum date_mode date_mode; const char **ignore_packed; /* pretend objects in these are unpacked */ -- cgit v1.2.3 From 653194758ee338b7c87d011007c532ed5cf68d45 Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Fri, 27 Jun 2008 18:21:55 +0200 Subject: Move commit_list_count() to commit.c This function is useful outside builtin-merge-recursive, for example in builtin-merge. Signed-off-by: Miklos Vajna Signed-off-by: Junio C Hamano --- builtin-merge-recursive.c | 8 -------- commit.c | 8 ++++++++ commit.h | 1 + 3 files changed, 9 insertions(+), 8 deletions(-) (limited to 'commit.h') diff --git a/builtin-merge-recursive.c b/builtin-merge-recursive.c index 43bf6aa45e..3731853f83 100644 --- a/builtin-merge-recursive.c +++ b/builtin-merge-recursive.c @@ -42,14 +42,6 @@ static struct tree *shift_tree_object(struct tree *one, struct tree *two) * - *(int *)commit->object.sha1 set to the virtual id. */ -static unsigned commit_list_count(const struct commit_list *l) -{ - unsigned c = 0; - for (; l; l = l->next ) - c++; - return c; -} - static struct commit *make_virtual_commit(struct tree *tree, const char *comment) { struct commit *commit = xcalloc(1, sizeof(struct commit)); diff --git a/commit.c b/commit.c index e2d8624d9c..bbf9c75416 100644 --- a/commit.c +++ b/commit.c @@ -325,6 +325,14 @@ struct commit_list *commit_list_insert(struct commit *item, struct commit_list * return new_list; } +unsigned commit_list_count(const struct commit_list *l) +{ + unsigned c = 0; + for (; l; l = l->next ) + c++; + return c; +} + void free_commit_list(struct commit_list *list) { while (list) { diff --git a/commit.h b/commit.h index 2d94d4148e..7f8c5ee0fc 100644 --- a/commit.h +++ b/commit.h @@ -41,6 +41,7 @@ int parse_commit_buffer(struct commit *item, void *buffer, unsigned long size); int parse_commit(struct commit *item); struct commit_list * commit_list_insert(struct commit *item, struct commit_list **list_p); +unsigned commit_list_count(const struct commit_list *l); struct commit_list * insert_by_date(struct commit *item, struct commit_list **list); void free_commit_list(struct commit_list *list); -- cgit v1.2.3 From 5240c9d75d8e1b747da427ba6320432d3201168a Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Fri, 27 Jun 2008 18:22:00 +0200 Subject: Introduce get_octopus_merge_bases() in commit.c This is like get_merge_bases() but it works for multiple heads, like show-branch --merge-base. Signed-off-by: Miklos Vajna Signed-off-by: Junio C Hamano --- commit.c | 27 +++++++++++++++++++++++++++ commit.h | 1 + 2 files changed, 28 insertions(+) (limited to 'commit.h') diff --git a/commit.c b/commit.c index bbf9c75416..6052ca34c8 100644 --- a/commit.c +++ b/commit.c @@ -600,6 +600,33 @@ static struct commit_list *merge_bases(struct commit *one, struct commit *two) return result; } +struct commit_list *get_octopus_merge_bases(struct commit_list *in) +{ + struct commit_list *i, *j, *k, *ret = NULL; + struct commit_list **pptr = &ret; + + for (i = in; i; i = i->next) { + if (!ret) + pptr = &commit_list_insert(i->item, pptr)->next; + else { + struct commit_list *new = NULL, *end = NULL; + + for (j = ret; j; j = j->next) { + struct commit_list *bases; + bases = get_merge_bases(i->item, j->item, 1); + if (!new) + new = bases; + else + end->next = bases; + for (k = bases; k; k = k->next) + end = k; + } + ret = new; + } + } + return ret; +} + struct commit_list *get_merge_bases(struct commit *one, struct commit *two, int cleanup) { diff --git a/commit.h b/commit.h index 7f8c5ee0fc..dcec7fb9a2 100644 --- a/commit.h +++ b/commit.h @@ -121,6 +121,7 @@ int read_graft_file(const char *graft_file); struct commit_graft *lookup_commit_graft(const unsigned char *sha1); extern struct commit_list *get_merge_bases(struct commit *rev1, struct commit *rev2, int cleanup); +extern struct commit_list *get_octopus_merge_bases(struct commit_list *in); extern int register_shallow(const unsigned char *sha1); extern int unregister_shallow(const unsigned char *sha1); -- cgit v1.2.3 From 98cf9c3bd7504d36e6049939bf9cc624f2cf5b9f Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Fri, 27 Jun 2008 18:22:03 +0200 Subject: Introduce reduce_heads() The new function reduce_heads() is given a list of commits, and removes ones that can be reached from other commits in the list. It is useful for reducing the commits randomly thrown at the git-merge command and remove redundant commits that the user shouldn't have given to it. The implementation uses the get_merge_bases_many() introduced in the previous commit. If the merge base between one commit taken from the list and the remaining commits is the commit itself, that means the commit is reachable from some of the other commits. Signed-off-by: Junio C Hamano --- commit.c | 45 +++++++++++++++++++++++++++++++++++++++++++++ commit.h | 2 ++ 2 files changed, 47 insertions(+) (limited to 'commit.h') diff --git a/commit.c b/commit.c index cafed26928..d20b14ee3e 100644 --- a/commit.c +++ b/commit.c @@ -725,3 +725,48 @@ int in_merge_bases(struct commit *commit, struct commit **reference, int num) free_commit_list(bases); return ret; } + +struct commit_list *reduce_heads(struct commit_list *heads) +{ + struct commit_list *p; + struct commit_list *result = NULL, **tail = &result; + struct commit **other; + size_t num_head, num_other; + + if (!heads) + return NULL; + + /* Avoid unnecessary reallocations */ + for (p = heads, num_head = 0; p; p = p->next) + num_head++; + other = xcalloc(sizeof(*other), num_head); + + /* For each commit, see if it can be reached by others */ + for (p = heads; p; p = p->next) { + struct commit_list *q, *base; + + num_other = 0; + for (q = heads; q; q = q->next) { + if (p == q) + continue; + other[num_other++] = q->item; + } + if (num_other) { + base = get_merge_bases_many(p->item, num_other, other, 1); + } else + base = NULL; + /* + * If p->item does not have anything common with other + * commits, there won't be any merge base. If it is + * reachable from some of the others, p->item will be + * the merge base. If its history is connected with + * others, but p->item is not reachable by others, we + * will get something other than p->item back. + */ + if (!base || (base->item != p->item)) + tail = &(commit_list_insert(p->item, tail)->next); + free_commit_list(base); + } + free(other); + return result; +} diff --git a/commit.h b/commit.h index dcec7fb9a2..2acfc79d34 100644 --- a/commit.h +++ b/commit.h @@ -140,4 +140,6 @@ static inline int single_parent(struct commit *commit) return commit->parents && !commit->parents->next; } +struct commit_list *reduce_heads(struct commit_list *heads); + #endif /* COMMIT_H */ -- cgit v1.2.3 From 5b2fd95606cd6d564f96d9d253e7cd19263bc352 Mon Sep 17 00:00:00 2001 From: Stephan Beyer Date: Wed, 9 Jul 2008 14:58:57 +0200 Subject: rerere: Separate libgit and builtin functions This patch moves rerere()-related functions into a newly created rerere.c file. The setup_rerere() function is needed by both rerere() and cmd_rerere(), so this function is moved to rerere.c and declared non-static (and "extern") in newly created rerere.h file. Signed-off-by: Stephan Beyer Signed-off-by: Junio C Hamano --- Makefile | 2 + builtin-commit.c | 1 + builtin-rerere.c | 372 +++---------------------------------------------------- commit.h | 1 - rerere.c | 360 +++++++++++++++++++++++++++++++++++++++++++++++++++++ rerere.h | 9 ++ 6 files changed, 390 insertions(+), 355 deletions(-) create mode 100644 rerere.c create mode 100644 rerere.h (limited to 'commit.h') diff --git a/Makefile b/Makefile index 4796565ab3..de151638bb 100644 --- a/Makefile +++ b/Makefile @@ -363,6 +363,7 @@ LIB_H += quote.h LIB_H += reflog-walk.h LIB_H += refs.h LIB_H += remote.h +LIB_H += rerere.h LIB_H += revision.h LIB_H += run-command.h LIB_H += sha1-lookup.h @@ -447,6 +448,7 @@ LIB_OBJS += read-cache.o LIB_OBJS += reflog-walk.o LIB_OBJS += refs.o LIB_OBJS += remote.o +LIB_OBJS += rerere.o LIB_OBJS += revision.o LIB_OBJS += run-command.o LIB_OBJS += server-info.o diff --git a/builtin-commit.c b/builtin-commit.c index 745c11e773..bdc83df55b 100644 --- a/builtin-commit.c +++ b/builtin-commit.c @@ -22,6 +22,7 @@ #include "utf8.h" #include "parse-options.h" #include "path-list.h" +#include "rerere.h" #include "unpack-trees.h" static const char * const builtin_commit_usage[] = { diff --git a/builtin-rerere.c b/builtin-rerere.c index 69c3a52d5e..5d40e16932 100644 --- a/builtin-rerere.c +++ b/builtin-rerere.c @@ -1,11 +1,10 @@ #include "builtin.h" #include "cache.h" #include "path-list.h" +#include "rerere.h" #include "xdiff/xdiff.h" #include "xdiff-interface.h" -#include - static const char git_rerere_usage[] = "git-rerere [clear | status | diff | gc]"; @@ -13,14 +12,6 @@ static const char git_rerere_usage[] = static int cutoff_noresolve = 15; static int cutoff_resolve = 60; -/* if rerere_enabled == -1, fall back to detection of .git/rr-cache */ -static int rerere_enabled = -1; - -/* automatically update cleanly resolved paths to the index */ -static int rerere_autoupdate; - -static char *merge_rr_path; - static const char *rr_path(const char *name, const char *file) { return git_path("rr-cache/%s/%s", name, file); @@ -38,189 +29,6 @@ static int has_resolution(const char *name) return !stat(rr_path(name, "postimage"), &st); } -static void read_rr(struct path_list *rr) -{ - unsigned char sha1[20]; - char buf[PATH_MAX]; - FILE *in = fopen(merge_rr_path, "r"); - if (!in) - return; - while (fread(buf, 40, 1, in) == 1) { - int i; - char *name; - if (get_sha1_hex(buf, sha1)) - die("corrupt MERGE_RR"); - buf[40] = '\0'; - name = xstrdup(buf); - if (fgetc(in) != '\t') - die("corrupt MERGE_RR"); - for (i = 0; i < sizeof(buf) && (buf[i] = fgetc(in)); i++) - ; /* do nothing */ - if (i == sizeof(buf)) - die("filename too long"); - path_list_insert(buf, rr)->util = name; - } - fclose(in); -} - -static struct lock_file write_lock; - -static int write_rr(struct path_list *rr, int out_fd) -{ - int i; - for (i = 0; i < rr->nr; i++) { - const char *path; - int length; - if (!rr->items[i].util) - continue; - path = rr->items[i].path; - length = strlen(path) + 1; - if (write_in_full(out_fd, rr->items[i].util, 40) != 40 || - write_in_full(out_fd, "\t", 1) != 1 || - write_in_full(out_fd, path, length) != length) - die("unable to write rerere record"); - } - if (commit_lock_file(&write_lock) != 0) - die("unable to write rerere record"); - return 0; -} - -static int handle_file(const char *path, - unsigned char *sha1, const char *output) -{ - SHA_CTX ctx; - char buf[1024]; - int hunk = 0, hunk_no = 0; - struct strbuf one, two; - FILE *f = fopen(path, "r"); - FILE *out = NULL; - - if (!f) - return error("Could not open %s", path); - - if (output) { - out = fopen(output, "w"); - if (!out) { - fclose(f); - return error("Could not write %s", output); - } - } - - if (sha1) - SHA1_Init(&ctx); - - strbuf_init(&one, 0); - strbuf_init(&two, 0); - while (fgets(buf, sizeof(buf), f)) { - if (!prefixcmp(buf, "<<<<<<< ")) { - if (hunk) - goto bad; - hunk = 1; - } else if (!prefixcmp(buf, "=======") && isspace(buf[7])) { - if (hunk != 1) - goto bad; - hunk = 2; - } else if (!prefixcmp(buf, ">>>>>>> ")) { - if (hunk != 2) - goto bad; - if (strbuf_cmp(&one, &two) > 0) - strbuf_swap(&one, &two); - hunk_no++; - hunk = 0; - if (out) { - fputs("<<<<<<<\n", out); - fwrite(one.buf, one.len, 1, out); - fputs("=======\n", out); - fwrite(two.buf, two.len, 1, out); - fputs(">>>>>>>\n", out); - } - if (sha1) { - SHA1_Update(&ctx, one.buf ? one.buf : "", - one.len + 1); - SHA1_Update(&ctx, two.buf ? two.buf : "", - two.len + 1); - } - strbuf_reset(&one); - strbuf_reset(&two); - } else if (hunk == 1) - strbuf_addstr(&one, buf); - else if (hunk == 2) - strbuf_addstr(&two, buf); - else if (out) - fputs(buf, out); - continue; - bad: - hunk = 99; /* force error exit */ - break; - } - strbuf_release(&one); - strbuf_release(&two); - - fclose(f); - if (out) - fclose(out); - if (sha1) - SHA1_Final(sha1, &ctx); - if (hunk) { - if (output) - unlink(output); - return error("Could not parse conflict hunks in %s", path); - } - return hunk_no; -} - -static int find_conflict(struct path_list *conflict) -{ - int i; - if (read_cache() < 0) - return error("Could not read index"); - for (i = 0; i+1 < active_nr; i++) { - struct cache_entry *e2 = active_cache[i]; - struct cache_entry *e3 = active_cache[i+1]; - if (ce_stage(e2) == 2 && - ce_stage(e3) == 3 && - ce_same_name(e2, e3) && - S_ISREG(e2->ce_mode) && - S_ISREG(e3->ce_mode)) { - path_list_insert((const char *)e2->name, conflict); - i++; /* skip over both #2 and #3 */ - } - } - return 0; -} - -static int merge(const char *name, const char *path) -{ - int ret; - mmfile_t cur, base, other; - mmbuffer_t result = {NULL, 0}; - xpparam_t xpp = {XDF_NEED_MINIMAL}; - - if (handle_file(path, NULL, rr_path(name, "thisimage")) < 0) - return 1; - - if (read_mmfile(&cur, rr_path(name, "thisimage")) || - read_mmfile(&base, rr_path(name, "preimage")) || - read_mmfile(&other, rr_path(name, "postimage"))) - return 1; - ret = xdl_merge(&base, &cur, "", &other, "", - &xpp, XDL_MERGE_ZEALOUS, &result); - if (!ret) { - FILE *f = fopen(path, "w"); - if (!f) - return error("Could not write to %s", path); - fwrite(result.ptr, result.size, 1, f); - fclose(f); - } - - free(cur.ptr); - free(base.ptr); - free(other.ptr); - free(result.ptr); - - return ret; -} - static void unlink_rr_item(const char *name) { unlink(rr_path(name, "thisimage")); @@ -229,6 +37,17 @@ static void unlink_rr_item(const char *name) rmdir(git_path("rr-cache/%s", name)); } +static int git_rerere_gc_config(const char *var, const char *value, void *cb) +{ + if (!strcmp(var, "gc.rerereresolved")) + cutoff_resolve = git_config_int(var, value); + else if (!strcmp(var, "gc.rerereunresolved")) + cutoff_noresolve = git_config_int(var, value); + else + return git_default_config(var, value, cb); + return 0; +} + static void garbage_collect(struct path_list *rr) { struct path_list to_remove = { NULL, 0, 0, 1 }; @@ -237,6 +56,7 @@ static void garbage_collect(struct path_list *rr) int i, cutoff; time_t now = time(NULL), then; + git_config(git_rerere_gc_config, NULL); dir = opendir(git_path("rr-cache")); while ((e = readdir(dir))) { const char *name = e->d_name; @@ -289,181 +109,25 @@ static int diff_two(const char *file1, const char *label1, return 0; } -static struct lock_file index_lock; - -static int update_paths(struct path_list *update) -{ - int i; - int fd = hold_locked_index(&index_lock, 0); - int status = 0; - - if (fd < 0) - return -1; - - for (i = 0; i < update->nr; i++) { - struct path_list_item *item = &update->items[i]; - if (add_file_to_cache(item->path, ADD_CACHE_IGNORE_ERRORS)) - status = -1; - } - - if (!status && active_cache_changed) { - if (write_cache(fd, active_cache, active_nr) || - commit_locked_index(&index_lock)) - die("Unable to write new index file"); - } else if (fd >= 0) - rollback_lock_file(&index_lock); - return status; -} - -static int do_plain_rerere(struct path_list *rr, int fd) -{ - struct path_list conflict = { NULL, 0, 0, 1 }; - struct path_list update = { NULL, 0, 0, 1 }; - int i; - - find_conflict(&conflict); - - /* - * MERGE_RR records paths with conflicts immediately after merge - * failed. Some of the conflicted paths might have been hand resolved - * in the working tree since then, but the initial run would catch all - * and register their preimages. - */ - - for (i = 0; i < conflict.nr; i++) { - const char *path = conflict.items[i].path; - if (!path_list_has_path(rr, path)) { - unsigned char sha1[20]; - char *hex; - int ret; - ret = handle_file(path, sha1, NULL); - if (ret < 1) - continue; - hex = xstrdup(sha1_to_hex(sha1)); - path_list_insert(path, rr)->util = hex; - if (mkdir(git_path("rr-cache/%s", hex), 0755)) - continue;; - handle_file(path, NULL, rr_path(hex, "preimage")); - fprintf(stderr, "Recorded preimage for '%s'\n", path); - } - } - - /* - * Now some of the paths that had conflicts earlier might have been - * hand resolved. Others may be similar to a conflict already that - * was resolved before. - */ - - for (i = 0; i < rr->nr; i++) { - int ret; - const char *path = rr->items[i].path; - const char *name = (const char *)rr->items[i].util; - - if (has_resolution(name)) { - if (!merge(name, path)) { - fprintf(stderr, "Resolved '%s' using " - "previous resolution.\n", path); - if (rerere_autoupdate) - path_list_insert(path, &update); - goto mark_resolved; - } - } - - /* Let's see if we have resolved it. */ - ret = handle_file(path, NULL, NULL); - if (ret) - continue; - - fprintf(stderr, "Recorded resolution for '%s'.\n", path); - copy_file(rr_path(name, "postimage"), path, 0666); - mark_resolved: - rr->items[i].util = NULL; - } - - if (update.nr) - update_paths(&update); - - return write_rr(rr, fd); -} - -static int git_rerere_config(const char *var, const char *value, void *cb) -{ - if (!strcmp(var, "gc.rerereresolved")) - cutoff_resolve = git_config_int(var, value); - else if (!strcmp(var, "gc.rerereunresolved")) - cutoff_noresolve = git_config_int(var, value); - else if (!strcmp(var, "rerere.enabled")) - rerere_enabled = git_config_bool(var, value); - else if (!strcmp(var, "rerere.autoupdate")) - rerere_autoupdate = git_config_bool(var, value); - else - return git_default_config(var, value, cb); - return 0; -} - -static int is_rerere_enabled(void) -{ - struct stat st; - const char *rr_cache; - int rr_cache_exists; - - if (!rerere_enabled) - return 0; - - rr_cache = git_path("rr-cache"); - rr_cache_exists = !stat(rr_cache, &st) && S_ISDIR(st.st_mode); - if (rerere_enabled < 0) - return rr_cache_exists; - - if (!rr_cache_exists && - (mkdir(rr_cache, 0777) || adjust_shared_perm(rr_cache))) - die("Could not create directory %s", rr_cache); - return 1; -} - -static int setup_rerere(struct path_list *merge_rr) -{ - int fd; - - git_config(git_rerere_config, NULL); - if (!is_rerere_enabled()) - return -1; - - merge_rr_path = xstrdup(git_path("rr-cache/MERGE_RR")); - fd = hold_lock_file_for_update(&write_lock, merge_rr_path, 1); - read_rr(merge_rr); - return fd; -} - -int rerere(void) -{ - struct path_list merge_rr = { NULL, 0, 0, 1 }; - int fd; - - fd = setup_rerere(&merge_rr); - if (fd < 0) - return 0; - return do_plain_rerere(&merge_rr, fd); -} - int cmd_rerere(int argc, const char **argv, const char *prefix) { struct path_list merge_rr = { NULL, 0, 0, 1 }; int i, fd; + if (argc < 2) + return rerere(); + fd = setup_rerere(&merge_rr); if (fd < 0) return 0; - if (argc < 2) - return do_plain_rerere(&merge_rr, fd); - else if (!strcmp(argv[1], "clear")) { + if (!strcmp(argv[1], "clear")) { for (i = 0; i < merge_rr.nr; i++) { const char *name = (const char *)merge_rr.items[i].util; if (!has_resolution(name)) unlink_rr_item(name); } - unlink(merge_rr_path); + unlink(git_path("rr-cache/MERGE_RR")); } else if (!strcmp(argv[1], "gc")) garbage_collect(&merge_rr); else if (!strcmp(argv[1], "status")) diff --git a/commit.h b/commit.h index 2d94d4148e..fda7ad03c0 100644 --- a/commit.h +++ b/commit.h @@ -131,7 +131,6 @@ extern struct commit_list *get_shallow_commits(struct object_array *heads, int in_merge_bases(struct commit *, struct commit **, int); extern int interactive_add(int argc, const char **argv, const char *prefix); -extern int rerere(void); static inline int single_parent(struct commit *commit) { diff --git a/rerere.c b/rerere.c new file mode 100644 index 0000000000..eec2b50107 --- /dev/null +++ b/rerere.c @@ -0,0 +1,360 @@ +#include "cache.h" +#include "path-list.h" +#include "rerere.h" +#include "xdiff/xdiff.h" +#include "xdiff-interface.h" + +/* if rerere_enabled == -1, fall back to detection of .git/rr-cache */ +static int rerere_enabled = -1; + +/* automatically update cleanly resolved paths to the index */ +static int rerere_autoupdate; + +static char *merge_rr_path; + +static const char *rr_path(const char *name, const char *file) +{ + return git_path("rr-cache/%s/%s", name, file); +} + +static int has_resolution(const char *name) +{ + struct stat st; + return !stat(rr_path(name, "postimage"), &st); +} + +static void read_rr(struct path_list *rr) +{ + unsigned char sha1[20]; + char buf[PATH_MAX]; + FILE *in = fopen(merge_rr_path, "r"); + if (!in) + return; + while (fread(buf, 40, 1, in) == 1) { + int i; + char *name; + if (get_sha1_hex(buf, sha1)) + die("corrupt MERGE_RR"); + buf[40] = '\0'; + name = xstrdup(buf); + if (fgetc(in) != '\t') + die("corrupt MERGE_RR"); + for (i = 0; i < sizeof(buf) && (buf[i] = fgetc(in)); i++) + ; /* do nothing */ + if (i == sizeof(buf)) + die("filename too long"); + path_list_insert(buf, rr)->util = name; + } + fclose(in); +} + +static struct lock_file write_lock; + +static int write_rr(struct path_list *rr, int out_fd) +{ + int i; + for (i = 0; i < rr->nr; i++) { + const char *path; + int length; + if (!rr->items[i].util) + continue; + path = rr->items[i].path; + length = strlen(path) + 1; + if (write_in_full(out_fd, rr->items[i].util, 40) != 40 || + write_in_full(out_fd, "\t", 1) != 1 || + write_in_full(out_fd, path, length) != length) + die("unable to write rerere record"); + } + if (commit_lock_file(&write_lock) != 0) + die("unable to write rerere record"); + return 0; +} + +static int handle_file(const char *path, + unsigned char *sha1, const char *output) +{ + SHA_CTX ctx; + char buf[1024]; + int hunk = 0, hunk_no = 0; + struct strbuf one, two; + FILE *f = fopen(path, "r"); + FILE *out = NULL; + + if (!f) + return error("Could not open %s", path); + + if (output) { + out = fopen(output, "w"); + if (!out) { + fclose(f); + return error("Could not write %s", output); + } + } + + if (sha1) + SHA1_Init(&ctx); + + strbuf_init(&one, 0); + strbuf_init(&two, 0); + while (fgets(buf, sizeof(buf), f)) { + if (!prefixcmp(buf, "<<<<<<< ")) { + if (hunk) + goto bad; + hunk = 1; + } else if (!prefixcmp(buf, "=======") && isspace(buf[7])) { + if (hunk != 1) + goto bad; + hunk = 2; + } else if (!prefixcmp(buf, ">>>>>>> ")) { + if (hunk != 2) + goto bad; + if (strbuf_cmp(&one, &two) > 0) + strbuf_swap(&one, &two); + hunk_no++; + hunk = 0; + if (out) { + fputs("<<<<<<<\n", out); + fwrite(one.buf, one.len, 1, out); + fputs("=======\n", out); + fwrite(two.buf, two.len, 1, out); + fputs(">>>>>>>\n", out); + } + if (sha1) { + SHA1_Update(&ctx, one.buf ? one.buf : "", + one.len + 1); + SHA1_Update(&ctx, two.buf ? two.buf : "", + two.len + 1); + } + strbuf_reset(&one); + strbuf_reset(&two); + } else if (hunk == 1) + strbuf_addstr(&one, buf); + else if (hunk == 2) + strbuf_addstr(&two, buf); + else if (out) + fputs(buf, out); + continue; + bad: + hunk = 99; /* force error exit */ + break; + } + strbuf_release(&one); + strbuf_release(&two); + + fclose(f); + if (out) + fclose(out); + if (sha1) + SHA1_Final(sha1, &ctx); + if (hunk) { + if (output) + unlink(output); + return error("Could not parse conflict hunks in %s", path); + } + return hunk_no; +} + +static int find_conflict(struct path_list *conflict) +{ + int i; + if (read_cache() < 0) + return error("Could not read index"); + for (i = 0; i+1 < active_nr; i++) { + struct cache_entry *e2 = active_cache[i]; + struct cache_entry *e3 = active_cache[i+1]; + if (ce_stage(e2) == 2 && + ce_stage(e3) == 3 && + ce_same_name(e2, e3) && + S_ISREG(e2->ce_mode) && + S_ISREG(e3->ce_mode)) { + path_list_insert((const char *)e2->name, conflict); + i++; /* skip over both #2 and #3 */ + } + } + return 0; +} + +static int merge(const char *name, const char *path) +{ + int ret; + mmfile_t cur, base, other; + mmbuffer_t result = {NULL, 0}; + xpparam_t xpp = {XDF_NEED_MINIMAL}; + + if (handle_file(path, NULL, rr_path(name, "thisimage")) < 0) + return 1; + + if (read_mmfile(&cur, rr_path(name, "thisimage")) || + read_mmfile(&base, rr_path(name, "preimage")) || + read_mmfile(&other, rr_path(name, "postimage"))) + return 1; + ret = xdl_merge(&base, &cur, "", &other, "", + &xpp, XDL_MERGE_ZEALOUS, &result); + if (!ret) { + FILE *f = fopen(path, "w"); + if (!f) + return error("Could not write to %s", path); + fwrite(result.ptr, result.size, 1, f); + fclose(f); + } + + free(cur.ptr); + free(base.ptr); + free(other.ptr); + free(result.ptr); + + return ret; +} + +static struct lock_file index_lock; + +static int update_paths(struct path_list *update) +{ + int i; + int fd = hold_locked_index(&index_lock, 0); + int status = 0; + + if (fd < 0) + return -1; + + for (i = 0; i < update->nr; i++) { + struct path_list_item *item = &update->items[i]; + if (add_file_to_cache(item->path, ADD_CACHE_IGNORE_ERRORS)) + status = -1; + } + + if (!status && active_cache_changed) { + if (write_cache(fd, active_cache, active_nr) || + commit_locked_index(&index_lock)) + die("Unable to write new index file"); + } else if (fd >= 0) + rollback_lock_file(&index_lock); + return status; +} + +static int do_plain_rerere(struct path_list *rr, int fd) +{ + struct path_list conflict = { NULL, 0, 0, 1 }; + struct path_list update = { NULL, 0, 0, 1 }; + int i; + + find_conflict(&conflict); + + /* + * MERGE_RR records paths with conflicts immediately after merge + * failed. Some of the conflicted paths might have been hand resolved + * in the working tree since then, but the initial run would catch all + * and register their preimages. + */ + + for (i = 0; i < conflict.nr; i++) { + const char *path = conflict.items[i].path; + if (!path_list_has_path(rr, path)) { + unsigned char sha1[20]; + char *hex; + int ret; + ret = handle_file(path, sha1, NULL); + if (ret < 1) + continue; + hex = xstrdup(sha1_to_hex(sha1)); + path_list_insert(path, rr)->util = hex; + if (mkdir(git_path("rr-cache/%s", hex), 0755)) + continue;; + handle_file(path, NULL, rr_path(hex, "preimage")); + fprintf(stderr, "Recorded preimage for '%s'\n", path); + } + } + + /* + * Now some of the paths that had conflicts earlier might have been + * hand resolved. Others may be similar to a conflict already that + * was resolved before. + */ + + for (i = 0; i < rr->nr; i++) { + int ret; + const char *path = rr->items[i].path; + const char *name = (const char *)rr->items[i].util; + + if (has_resolution(name)) { + if (!merge(name, path)) { + fprintf(stderr, "Resolved '%s' using " + "previous resolution.\n", path); + if (rerere_autoupdate) + path_list_insert(path, &update); + goto mark_resolved; + } + } + + /* Let's see if we have resolved it. */ + ret = handle_file(path, NULL, NULL); + if (ret) + continue; + + fprintf(stderr, "Recorded resolution for '%s'.\n", path); + copy_file(rr_path(name, "postimage"), path, 0666); + mark_resolved: + rr->items[i].util = NULL; + } + + if (update.nr) + update_paths(&update); + + return write_rr(rr, fd); +} + +static int git_rerere_config(const char *var, const char *value, void *cb) +{ + if (!strcmp(var, "rerere.enabled")) + rerere_enabled = git_config_bool(var, value); + else if (!strcmp(var, "rerere.autoupdate")) + rerere_autoupdate = git_config_bool(var, value); + else + return git_default_config(var, value, cb); + return 0; +} + +static int is_rerere_enabled(void) +{ + struct stat st; + const char *rr_cache; + int rr_cache_exists; + + if (!rerere_enabled) + return 0; + + rr_cache = git_path("rr-cache"); + rr_cache_exists = !stat(rr_cache, &st) && S_ISDIR(st.st_mode); + if (rerere_enabled < 0) + return rr_cache_exists; + + if (!rr_cache_exists && + (mkdir(rr_cache, 0777) || adjust_shared_perm(rr_cache))) + die("Could not create directory %s", rr_cache); + return 1; +} + +int setup_rerere(struct path_list *merge_rr) +{ + int fd; + + git_config(git_rerere_config, NULL); + if (!is_rerere_enabled()) + return -1; + + merge_rr_path = xstrdup(git_path("rr-cache/MERGE_RR")); + fd = hold_lock_file_for_update(&write_lock, merge_rr_path, 1); + read_rr(merge_rr); + return fd; +} + +int rerere(void) +{ + struct path_list merge_rr = { NULL, 0, 0, 1 }; + int fd; + + fd = setup_rerere(&merge_rr); + if (fd < 0) + return 0; + return do_plain_rerere(&merge_rr, fd); +} diff --git a/rerere.h b/rerere.h new file mode 100644 index 0000000000..35b0fa86a3 --- /dev/null +++ b/rerere.h @@ -0,0 +1,9 @@ +#ifndef RERERE_H +#define RERERE_H + +#include "path-list.h" + +extern int setup_rerere(struct path_list *); +extern int rerere(void); + +#endif -- cgit v1.2.3 From 53eda89b2fe13e974ca85367255f9a5e9ab9171f Mon Sep 17 00:00:00 2001 From: Christian Couder Date: Wed, 30 Jul 2008 07:04:14 +0200 Subject: merge-base: teach "git merge-base" to drive underlying merge_bases_many() Even though the underlying function for get_merge_bases() can compute a merge base between one existing commit and another (possibly nonexistent) commit that would be created by merging many commits, the facility was not available to git-merge-base. Signed-off-by: Christian Couder Signed-off-by: Junio C Hamano --- builtin-merge-base.c | 24 ++++++++++++++++-------- commit.h | 1 + 2 files changed, 17 insertions(+), 8 deletions(-) (limited to 'commit.h') diff --git a/builtin-merge-base.c b/builtin-merge-base.c index 3382b1382a..b08da516e4 100644 --- a/builtin-merge-base.c +++ b/builtin-merge-base.c @@ -2,9 +2,11 @@ #include "cache.h" #include "commit.h" -static int show_merge_base(struct commit *rev1, struct commit *rev2, int show_all) +static int show_merge_base(struct commit **rev, int rev_nr, int show_all) { - struct commit_list *result = get_merge_bases(rev1, rev2, 0); + struct commit_list *result; + + result = get_merge_bases_many(rev[0], rev_nr - 1, rev + 1, 0); if (!result) return 1; @@ -20,7 +22,7 @@ static int show_merge_base(struct commit *rev1, struct commit *rev2, int show_al } static const char merge_base_usage[] = -"git merge-base [--all] "; +"git merge-base [--all] ..."; static struct commit *get_commit_reference(const char *arg) { @@ -38,7 +40,8 @@ static struct commit *get_commit_reference(const char *arg) int cmd_merge_base(int argc, const char **argv, const char *prefix) { - struct commit *rev1, *rev2; + struct commit **rev; + int rev_nr = 0; int show_all = 0; git_config(git_default_config, NULL); @@ -51,10 +54,15 @@ int cmd_merge_base(int argc, const char **argv, const char *prefix) usage(merge_base_usage); argc--; argv++; } - if (argc != 3) + if (argc < 3) usage(merge_base_usage); - rev1 = get_commit_reference(argv[1]); - rev2 = get_commit_reference(argv[2]); - return show_merge_base(rev1, rev2, show_all); + rev = xmalloc((argc - 1) * sizeof(*rev)); + + do { + rev[rev_nr++] = get_commit_reference(argv[1]); + argc--; argv++; + } while (argc > 1); + + return show_merge_base(rev, rev_nr, show_all); } diff --git a/commit.h b/commit.h index 77de9621d9..d163c7487b 100644 --- a/commit.h +++ b/commit.h @@ -121,6 +121,7 @@ int read_graft_file(const char *graft_file); struct commit_graft *lookup_commit_graft(const unsigned char *sha1); extern struct commit_list *get_merge_bases(struct commit *rev1, struct commit *rev2, int cleanup); +extern struct commit_list *get_merge_bases_many(struct commit *one, int n, struct commit **twos, int cleanup); extern struct commit_list *get_octopus_merge_bases(struct commit_list *in); extern int register_shallow(const unsigned char *sha1); -- cgit v1.2.3 From d36f8679e94c2a0d4d15d6adcea434634af6d627 Mon Sep 17 00:00:00 2001 From: Jeff King Date: Thu, 28 Aug 2008 20:54:59 -0400 Subject: pretty=format: respect date format options When running a command like: git log --pretty=format:%ad --date=short the date option was ignored. This patch causes it to use whatever format was specified by --date (or by --relative-date, etc), just as the non-user formats would do. Signed-off-by: Jeff King Signed-off-by: Junio C Hamano --- Documentation/pretty-formats.txt | 2 +- archive.c | 2 +- builtin-commit.c | 2 +- commit.h | 3 ++- pretty.c | 17 +++++++++++------ t/t6006-rev-list-format.sh | 6 ++++++ 6 files changed, 22 insertions(+), 10 deletions(-) (limited to 'commit.h') diff --git a/Documentation/pretty-formats.txt b/Documentation/pretty-formats.txt index c11d495771..388d4925e6 100644 --- a/Documentation/pretty-formats.txt +++ b/Documentation/pretty-formats.txt @@ -103,7 +103,7 @@ The placeholders are: - '%an': author name - '%aN': author name (respecting .mailmap) - '%ae': author email -- '%ad': author date +- '%ad': author date (format respects --date= option) - '%aD': author date, RFC2822 style - '%ar': author date, relative - '%at': author date, UNIX timestamp diff --git a/archive.c b/archive.c index 5b40e261f1..e2280df567 100644 --- a/archive.c +++ b/archive.c @@ -48,7 +48,7 @@ static void format_subst(const struct commit *commit, strbuf_add(&fmt, b + 8, c - b - 8); strbuf_add(buf, src, b - src); - format_commit_message(commit, fmt.buf, buf); + format_commit_message(commit, fmt.buf, buf, DATE_NORMAL); len -= c + 1 - src; src = c + 1; } diff --git a/builtin-commit.c b/builtin-commit.c index 649c8beb3e..c870037b07 100644 --- a/builtin-commit.c +++ b/builtin-commit.c @@ -882,7 +882,7 @@ static void print_summary(const char *prefix, const unsigned char *sha1) if (!log_tree_commit(&rev, commit)) { struct strbuf buf = STRBUF_INIT; - format_commit_message(commit, "%h: %s", &buf); + format_commit_message(commit, "%h: %s", &buf, DATE_NORMAL); printf("%s\n", buf.buf); strbuf_release(&buf); } diff --git a/commit.h b/commit.h index 77de9621d9..ecdd5733f9 100644 --- a/commit.h +++ b/commit.h @@ -67,7 +67,8 @@ extern int non_ascii(int); struct rev_info; /* in revision.h, it circularly uses enum cmit_fmt */ extern void get_commit_format(const char *arg, struct rev_info *); extern void format_commit_message(const struct commit *commit, - const void *format, struct strbuf *sb); + const void *format, struct strbuf *sb, + enum date_mode dmode); extern void pretty_print_commit(enum cmit_fmt fmt, const struct commit*, struct strbuf *, int abbrev, const char *subject, diff --git a/pretty.c b/pretty.c index 33ef34a411..a29c290009 100644 --- a/pretty.c +++ b/pretty.c @@ -310,7 +310,7 @@ static int mailmap_name(struct strbuf *sb, const char *email) } static size_t format_person_part(struct strbuf *sb, char part, - const char *msg, int len) + const char *msg, int len, enum date_mode dmode) { /* currently all placeholders have same length */ const int placeholder_len = 2; @@ -377,7 +377,7 @@ static size_t format_person_part(struct strbuf *sb, char part, switch (part) { case 'd': /* date */ - strbuf_addstr(sb, show_date(date, tz, DATE_NORMAL)); + strbuf_addstr(sb, show_date(date, tz, dmode)); return placeholder_len; case 'D': /* date, RFC2822 style */ strbuf_addstr(sb, show_date(date, tz, DATE_RFC2822)); @@ -409,6 +409,7 @@ struct chunk { struct format_commit_context { const struct commit *commit; + enum date_mode dmode; /* These offsets are relative to the start of the commit message. */ int commit_header_parsed; @@ -584,10 +585,12 @@ static size_t format_commit_item(struct strbuf *sb, const char *placeholder, return 1; case 'a': /* author ... */ return format_person_part(sb, placeholder[1], - msg + c->author.off, c->author.len); + msg + c->author.off, c->author.len, + c->dmode); case 'c': /* committer ... */ return format_person_part(sb, placeholder[1], - msg + c->committer.off, c->committer.len); + msg + c->committer.off, c->committer.len, + c->dmode); case 'e': /* encoding */ strbuf_add(sb, msg + c->encoding.off, c->encoding.len); return 1; @@ -599,12 +602,14 @@ static size_t format_commit_item(struct strbuf *sb, const char *placeholder, } void format_commit_message(const struct commit *commit, - const void *format, struct strbuf *sb) + const void *format, struct strbuf *sb, + enum date_mode dmode) { struct format_commit_context context; memset(&context, 0, sizeof(context)); context.commit = commit; + context.dmode = dmode; strbuf_expand(sb, format, format_commit_item, &context); } @@ -770,7 +775,7 @@ void pretty_print_commit(enum cmit_fmt fmt, const struct commit *commit, const char *encoding; if (fmt == CMIT_FMT_USERFORMAT) { - format_commit_message(commit, user_format, sb); + format_commit_message(commit, user_format, sb, dmode); return; } diff --git a/t/t6006-rev-list-format.sh b/t/t6006-rev-list-format.sh index 9176484db2..485ad4d44a 100755 --- a/t/t6006-rev-list-format.sh +++ b/t/t6006-rev-list-format.sh @@ -139,6 +139,12 @@ commit 131a310eb913d107dd3c09a65d1651175898735d commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873 EOF +test_expect_success '%ad respects --date=' ' + echo 2005-04-07 >expect.ad-short && + git log -1 --date=short --pretty=tformat:%ad >output.ad-short master && + test_cmp expect.ad-short output.ad-short +' + test_expect_success 'empty email' ' test_tick && C=$(GIT_AUTHOR_EMAIL= git commit-tree HEAD^{tree} Date: Thu, 2 Oct 2008 19:14:30 +0900 Subject: commit.c: make read_graft_file() static This function is not called by any other file. Signed-off-by: Nanako Shiraishi Signed-off-by: Shawn O. Pearce --- commit.c | 2 +- commit.h | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) (limited to 'commit.h') diff --git a/commit.c b/commit.c index dc0c5bfdab..c99db162a4 100644 --- a/commit.c +++ b/commit.c @@ -160,7 +160,7 @@ struct commit_graft *read_graft_line(char *buf, int len) return graft; } -int read_graft_file(const char *graft_file) +static int read_graft_file(const char *graft_file) { FILE *fp = fopen(graft_file, "r"); char buf[1024]; diff --git a/commit.h b/commit.h index de15f4d715..4c05864fb4 100644 --- a/commit.h +++ b/commit.h @@ -118,7 +118,6 @@ struct commit_graft { struct commit_graft *read_graft_line(char *buf, int len); int register_commit_graft(struct commit_graft *, int); -int read_graft_file(const char *graft_file); struct commit_graft *lookup_commit_graft(const unsigned char *sha1); extern struct commit_list *get_merge_bases(struct commit *rev1, struct commit *rev2, int cleanup); -- cgit v1.2.3 From 69cd8f63427c65c65d9cd66bb8c05ca93dc3edef Mon Sep 17 00:00:00 2001 From: Alexander Gavrilov Date: Wed, 22 Oct 2008 00:55:57 +0400 Subject: builtin-blame: Reencode commit messages according to git-log rules. Currently git-blame outputs text from the commit messages (e.g. the author name and the summary string) as-is, without even providing any information about the encoding used for the data. It makes interpreting the data in multilingual environment very difficult. This commit changes the blame implementation to recode the messages using the rules used by other commands like git-log. Namely, the target encoding can be specified through the i18n.commitEncoding or i18n.logOutputEncoding options, or directly on the command line using the --encoding parameter. Converting the encoding before output seems to be more friendly to the porcelain tools than simply providing the value of the encoding header, and does not require changing the output format. If anybody needs the old behavior, it is possible to achieve it by specifying --encoding=none. Signed-off-by: Alexander Gavrilov Signed-off-by: Junio C Hamano --- Documentation/blame-options.txt | 7 ++++ Documentation/i18n.txt | 6 +-- builtin-blame.c | 16 ++++--- commit.h | 2 + pretty.c | 21 +++++++--- t/t8005-blame-i18n.sh | 92 +++++++++++++++++++++++++++++++++++++++++ t/t8005/cp1251.txt | 2 + t/t8005/sjis.txt | 2 + t/t8005/utf8.txt | 2 + 9 files changed, 136 insertions(+), 14 deletions(-) create mode 100755 t/t8005-blame-i18n.sh create mode 100644 t/t8005/cp1251.txt create mode 100644 t/t8005/sjis.txt create mode 100644 t/t8005/utf8.txt (limited to 'commit.h') diff --git a/Documentation/blame-options.txt b/Documentation/blame-options.txt index 5428111d73..1ab1b96cf9 100644 --- a/Documentation/blame-options.txt +++ b/Documentation/blame-options.txt @@ -49,6 +49,13 @@ of lines before or after the line given by . Show the result incrementally in a format designed for machine consumption. +--encoding=:: + Specifies the encoding used to output author names + and commit summaries. Setting it to `none` makes blame + output unconverted data. For more information see the + discussion about encoding in the linkgit:git-log[1] + manual page. + --contents :: When is not specified, the command annotates the changes starting backwards from the working tree copy. diff --git a/Documentation/i18n.txt b/Documentation/i18n.txt index d2970f8357..2cdacd94cd 100644 --- a/Documentation/i18n.txt +++ b/Documentation/i18n.txt @@ -37,9 +37,9 @@ of `i18n.commitencoding` in its `encoding` header. This is to help other people who look at them later. Lack of this header implies that the commit log message is encoded in UTF-8. -. 'git-log', 'git-show' and friends looks at the `encoding` - header of a commit object, and tries to re-code the log - message into UTF-8 unless otherwise specified. You can +. 'git-log', 'git-show', 'git-blame' and friends look at the + `encoding` header of a commit object, and try to re-code the + log message into UTF-8 unless otherwise specified. You can specify the desired output encoding with `i18n.logoutputencoding` in `.git/config` file, like this: + diff --git a/builtin-blame.c b/builtin-blame.c index 48cc0c175d..2457e71fc0 100644 --- a/builtin-blame.c +++ b/builtin-blame.c @@ -1431,7 +1431,7 @@ static void get_commit_info(struct commit *commit, int detailed) { int len; - char *tmp, *endp; + char *tmp, *endp, *reencoded, *message; static char author_buf[1024]; static char committer_buf[1024]; static char summary_buf[1024]; @@ -1449,24 +1449,29 @@ static void get_commit_info(struct commit *commit, die("Cannot read commit %s", sha1_to_hex(commit->object.sha1)); } + reencoded = reencode_commit_message(commit, NULL); + message = reencoded ? reencoded : commit->buffer; ret->author = author_buf; - get_ac_line(commit->buffer, "\nauthor ", + get_ac_line(message, "\nauthor ", sizeof(author_buf), author_buf, &ret->author_mail, &ret->author_time, &ret->author_tz); - if (!detailed) + if (!detailed) { + free(reencoded); return; + } ret->committer = committer_buf; - get_ac_line(commit->buffer, "\ncommitter ", + get_ac_line(message, "\ncommitter ", sizeof(committer_buf), committer_buf, &ret->committer_mail, &ret->committer_time, &ret->committer_tz); ret->summary = summary_buf; - tmp = strstr(commit->buffer, "\n\n"); + tmp = strstr(message, "\n\n"); if (!tmp) { error_out: sprintf(summary_buf, "(%s)", sha1_to_hex(commit->object.sha1)); + free(reencoded); return; } tmp += 2; @@ -1478,6 +1483,7 @@ static void get_commit_info(struct commit *commit, goto error_out; memcpy(summary_buf, tmp, len); summary_buf[len] = 0; + free(reencoded); } /* diff --git a/commit.h b/commit.h index 4c05864fb4..3a7b06a828 100644 --- a/commit.h +++ b/commit.h @@ -65,6 +65,8 @@ enum cmit_fmt { extern int non_ascii(int); struct rev_info; /* in revision.h, it circularly uses enum cmit_fmt */ +extern char *reencode_commit_message(const struct commit *commit, + const char **encoding_p); extern void get_commit_format(const char *arg, struct rev_info *); extern void format_commit_message(const struct commit *commit, const void *format, struct strbuf *sb, diff --git a/pretty.c b/pretty.c index 1e79943339..f6ff31264b 100644 --- a/pretty.c +++ b/pretty.c @@ -783,6 +783,20 @@ void pp_remainder(enum cmit_fmt fmt, } } +char *reencode_commit_message(const struct commit *commit, const char **encoding_p) +{ + const char *encoding; + + encoding = (git_log_output_encoding + ? git_log_output_encoding + : git_commit_encoding); + if (!encoding) + encoding = "utf-8"; + if (encoding_p) + *encoding_p = encoding; + return logmsg_reencode(commit, encoding); +} + void pretty_print_commit(enum cmit_fmt fmt, const struct commit *commit, struct strbuf *sb, int abbrev, const char *subject, const char *after_subject, @@ -799,12 +813,7 @@ void pretty_print_commit(enum cmit_fmt fmt, const struct commit *commit, return; } - encoding = (git_log_output_encoding - ? git_log_output_encoding - : git_commit_encoding); - if (!encoding) - encoding = "utf-8"; - reencoded = logmsg_reencode(commit, encoding); + reencoded = reencode_commit_message(commit, &encoding); if (reencoded) { msg = reencoded; } diff --git a/t/t8005-blame-i18n.sh b/t/t8005-blame-i18n.sh new file mode 100755 index 0000000000..4470a92bb2 --- /dev/null +++ b/t/t8005-blame-i18n.sh @@ -0,0 +1,92 @@ +#!/bin/sh + +test_description='git blame encoding conversion' +. ./test-lib.sh + +. "$TEST_DIRECTORY"/t8005/utf8.txt +. "$TEST_DIRECTORY"/t8005/cp1251.txt +. "$TEST_DIRECTORY"/t8005/sjis.txt + +test_expect_success 'setup the repository' ' + # Create the file + echo "UTF-8 LINE" > file && + git add file && + git commit --author "$UTF8_NAME " -m "$UTF8_MSG" && + + echo "CP1251 LINE" >> file && + git add file && + git config i18n.commitencoding cp1251 && + git commit --author "$CP1251_NAME " -m "$CP1251_MSG" && + + echo "SJIS LINE" >> file && + git add file && + git config i18n.commitencoding shift-jis && + git commit --author "$SJIS_NAME " -m "$SJIS_MSG" +' + +cat >expected < actual && + test_cmp actual expected +' + +cat >expected < actual && + test_cmp actual expected +' + +cat >expected < actual && + test_cmp actual expected +' + +cat >expected < actual && + test_cmp actual expected +' + +test_done diff --git a/t/t8005/cp1251.txt b/t/t8005/cp1251.txt new file mode 100644 index 0000000000..ce41e98b81 --- /dev/null +++ b/t/t8005/cp1251.txt @@ -0,0 +1,2 @@ +CP1251_NAME=" " +CP1251_MSG=" " diff --git a/t/t8005/sjis.txt b/t/t8005/sjis.txt new file mode 100644 index 0000000000..2ccfbad207 --- /dev/null +++ b/t/t8005/sjis.txt @@ -0,0 +1,2 @@ +SJIS_NAME="Irp~ Pury Rytr" +SJIS_MSG="Suru qu~yu" diff --git a/t/t8005/utf8.txt b/t/t8005/utf8.txt new file mode 100644 index 0000000000..f46cfc56d8 --- /dev/null +++ b/t/t8005/utf8.txt @@ -0,0 +1,2 @@ +UTF8_NAME="Иван Петрович Сидоров" +UTF8_MSG="Тестовое сообщение" -- cgit v1.2.3 From 7fcdb36e29f9a5e779bc9e44cd69f8f69fac9426 Mon Sep 17 00:00:00 2001 From: Jake Goulding Date: Mon, 26 Jan 2009 09:13:24 -0500 Subject: Make has_commit() non-static Move has_commit() from branch to a common location, in preparation for using it in "git-tag". Rename it to is_descendant_of() to make it more unique and descriptive. Signed-off-by: Jake Goulding Signed-off-by: Junio C Hamano --- builtin-branch.c | 20 +++----------------- commit.c | 15 +++++++++++++++ commit.h | 1 + 3 files changed, 19 insertions(+), 17 deletions(-) (limited to 'commit.h') diff --git a/builtin-branch.c b/builtin-branch.c index 82d6fb27c9..56a1971d69 100644 --- a/builtin-branch.c +++ b/builtin-branch.c @@ -193,21 +193,6 @@ struct ref_list { int kinds; }; -static int has_commit(struct commit *commit, struct commit_list *with_commit) -{ - if (!with_commit) - return 1; - while (with_commit) { - struct commit *other; - - other = with_commit->item; - with_commit = with_commit->next; - if (in_merge_bases(other, &commit, 1)) - return 1; - } - return 0; -} - static int append_ref(const char *refname, const unsigned char *sha1, int flags, void *cb_data) { struct ref_list *ref_list = (struct ref_list*)(cb_data); @@ -231,7 +216,7 @@ static int append_ref(const char *refname, const unsigned char *sha1, int flags, return error("branch '%s' does not point at a commit", refname); /* Filter with with_commit if specified */ - if (!has_commit(commit, ref_list->with_commit)) + if (!is_descendant_of(commit, ref_list->with_commit)) return 0; /* Don't add types the caller doesn't want */ @@ -401,7 +386,8 @@ static void print_ref_list(int kinds, int detached, int verbose, int abbrev, str qsort(ref_list.list, ref_list.index, sizeof(struct ref_item), ref_cmp); detached = (detached && (kinds & REF_LOCAL_BRANCH)); - if (detached && head_commit && has_commit(head_commit, with_commit)) { + if (detached && head_commit && + is_descendant_of(head_commit, with_commit)) { struct ref_item item; item.name = xstrdup("(no branch)"); item.kind = REF_LOCAL_BRANCH; diff --git a/commit.c b/commit.c index c99db162a4..aa3b35b6a8 100644 --- a/commit.c +++ b/commit.c @@ -705,6 +705,21 @@ struct commit_list *get_merge_bases(struct commit *one, struct commit *two, return get_merge_bases_many(one, 1, &two, cleanup); } +int is_descendant_of(struct commit *commit, struct commit_list *with_commit) +{ + if (!with_commit) + return 1; + while (with_commit) { + struct commit *other; + + other = with_commit->item; + with_commit = with_commit->next; + if (in_merge_bases(other, &commit, 1)) + return 1; + } + return 0; +} + int in_merge_bases(struct commit *commit, struct commit **reference, int num) { struct commit_list *bases, *b; diff --git a/commit.h b/commit.h index 3a7b06a828..ba9f63813e 100644 --- a/commit.h +++ b/commit.h @@ -133,6 +133,7 @@ extern int is_repository_shallow(void); extern struct commit_list *get_shallow_commits(struct object_array *heads, int depth, int shallow_flag, int not_shallow_flag); +int is_descendant_of(struct commit *, struct commit_list *); int in_merge_bases(struct commit *, struct commit **, int); extern int interactive_add(int argc, const char **argv, const char *prefix); -- cgit v1.2.3 From 836a3fd5b0c439642268fd1299cd16729f15e614 Mon Sep 17 00:00:00 2001 From: Christian Couder Date: Sun, 17 May 2009 17:36:45 +0200 Subject: commit: add function to unparse a commit and its parents This patch adds the "unparse_commit" function that returns a commit into an unparsed state by freeing its data and resetting its fields to 0. Its parents are recursively unparsed too, because they might have been changed. But its tree is not unparsed as it should not have been modifed. Note that as the "flags" and "used" fields may be used even if the object is not parsed, we have to reset them anyway. Signed-off-by: Christian Couder Signed-off-by: Junio C Hamano --- commit.c | 20 ++++++++++++++++++++ commit.h | 2 ++ 2 files changed, 22 insertions(+) (limited to 'commit.h') diff --git a/commit.c b/commit.c index aa3b35b6a8..8f6b703c55 100644 --- a/commit.c +++ b/commit.c @@ -316,6 +316,26 @@ int parse_commit(struct commit *item) return ret; } +static void unparse_commit_list(struct commit_list *list) +{ + for (; list; list = list->next) + unparse_commit(list->item); +} + +void unparse_commit(struct commit *item) +{ + item->object.flags = 0; + item->object.used = 0; + if (item->object.parsed) { + item->object.parsed = 0; + if (item->parents) { + unparse_commit_list(item->parents); + free_commit_list(item->parents); + item->parents = NULL; + } + } +} + struct commit_list *commit_list_insert(struct commit *item, struct commit_list **list_p) { struct commit_list *new_list = xmalloc(sizeof(struct commit_list)); diff --git a/commit.h b/commit.h index ba9f63813e..f3eaf1d048 100644 --- a/commit.h +++ b/commit.h @@ -40,6 +40,8 @@ int parse_commit_buffer(struct commit *item, void *buffer, unsigned long size); int parse_commit(struct commit *item); +void unparse_commit(struct commit *item); + struct commit_list * commit_list_insert(struct commit *item, struct commit_list **list_p); unsigned commit_list_count(const struct commit_list *l); struct commit_list * insert_by_date(struct commit *item, struct commit_list **list); -- cgit v1.2.3 From 7a8e3895f68e9ae4e44e521c78fc98768c2a88ec Mon Sep 17 00:00:00 2001 From: Christian Couder Date: Wed, 27 May 2009 07:09:40 +0200 Subject: bisect: drop unparse_commit() and use clear_commit_marks() The goal of this patch series is to check if good revisions are ancestor of the bad revision without forking a process to launch "git rev-list $good ^$bad". This new version of this patch series does not use an "unparse_commit" function anymore, we use "clear_commit_marks" instead. Signed-off-by: Junio C Hamano --- bisect.c | 2 +- commit.c | 20 -------------------- commit.h | 2 -- 3 files changed, 1 insertion(+), 23 deletions(-) (limited to 'commit.h') diff --git a/bisect.c b/bisect.c index c43c120bde..18f9fa4062 100644 --- a/bisect.c +++ b/bisect.c @@ -771,7 +771,7 @@ static int check_ancestors(const char *prefix) /* Clean up objects used, as they will be reused. */ for (i = 0; i < pending_copy.nr; i++) { struct object *o = pending_copy.objects[i].item; - unparse_commit((struct commit *)o); + clear_commit_marks((struct commit *)o, ALL_REV_FLAGS); } return res; diff --git a/commit.c b/commit.c index 8f6b703c55..aa3b35b6a8 100644 --- a/commit.c +++ b/commit.c @@ -316,26 +316,6 @@ int parse_commit(struct commit *item) return ret; } -static void unparse_commit_list(struct commit_list *list) -{ - for (; list; list = list->next) - unparse_commit(list->item); -} - -void unparse_commit(struct commit *item) -{ - item->object.flags = 0; - item->object.used = 0; - if (item->object.parsed) { - item->object.parsed = 0; - if (item->parents) { - unparse_commit_list(item->parents); - free_commit_list(item->parents); - item->parents = NULL; - } - } -} - struct commit_list *commit_list_insert(struct commit *item, struct commit_list **list_p) { struct commit_list *new_list = xmalloc(sizeof(struct commit_list)); diff --git a/commit.h b/commit.h index f3eaf1d048..ba9f63813e 100644 --- a/commit.h +++ b/commit.h @@ -40,8 +40,6 @@ int parse_commit_buffer(struct commit *item, void *buffer, unsigned long size); int parse_commit(struct commit *item); -void unparse_commit(struct commit *item); - struct commit_list * commit_list_insert(struct commit *item, struct commit_list **list_p); unsigned commit_list_count(const struct commit_list *l); struct commit_list * insert_by_date(struct commit *item, struct commit_list **list); -- cgit v1.2.3