diff options
111 files changed, 1302 insertions, 492 deletions
diff --git a/.gitignore b/.gitignore index 2bcc604afe..52d61f3193 100644 --- a/.gitignore +++ b/.gitignore @@ -107,6 +107,7 @@ git-ssh-push git-ssh-upload git-status git-stripspace +git-svn git-svnimport git-symbolic-ref git-tag diff --git a/Documentation/SubmittingPatches b/Documentation/SubmittingPatches index 8601949e80..90722c21fa 100644 --- a/Documentation/SubmittingPatches +++ b/Documentation/SubmittingPatches @@ -49,7 +49,7 @@ People on the git mailing list need to be able to read and comment on the changes you are submitting. It is important for a developer to be able to "quote" your changes, using standard e-mail tools, so that they may comment on specific portions of -your code. For this reason, all patches should be submited +your code. For this reason, all patches should be submitted "inline". WARNING: Be wary of your MUAs word-wrap corrupting your patch. Do not cut-n-paste your patch; you can lose tabs that way if you are not careful. diff --git a/Documentation/config.txt b/Documentation/config.txt index f075f19815..0b434c1f19 100644 --- a/Documentation/config.txt +++ b/Documentation/config.txt @@ -110,10 +110,31 @@ apply.whitespace:: Tells `git-apply` how to handle whitespaces, in the same way as the '--whitespace' option. See gitlink:git-apply[1]. +diff.color:: + When true (or `always`), always use colors in patch. + When false (or `never`), never. When set to `auto`, use + colors only when the output is to the terminal. + +diff.color.<slot>:: + Use customized color for diff colorization. `<slot>` + specifies which part of the patch to use the specified + color, and is one of `plain` (context text), `meta` + (metainformation), `frag` (hunk header), `old` (removed + lines), or `new` (added lines). The value for these + configuration variables can be one of: `normal`, `bold`, + `dim`, `ul`, `blink`, `reverse`, `reset`, `black`, + `red`, `green`, `yellow`, `blue`, `magenta`, `cyan`, or + `white`. + diff.renameLimit:: The number of files to consider when performing the copy/rename detection; equivalent to the git diff option '-l'. +diff.renames:: + Tells git to detect renames. If set to any boolean value, it + will enable basic rename detection. If set to "copies" or + "copy", it will detect copies, as well. + format.headers:: Additional email headers to include in a patch to be submitted by mail. See gitlink:git-format-patch[1]. diff --git a/Documentation/cvs-migration.txt b/Documentation/cvs-migration.txt index 1fbca83141..d2b0bd38de 100644 --- a/Documentation/cvs-migration.txt +++ b/Documentation/cvs-migration.txt @@ -93,7 +93,7 @@ machine where the repository is hosted. If you don't want to give them a full shell on the machine, there is a restricted shell which only allows users to do git pushes and pulls; see gitlink:git-shell[1]. -Put all the committers should in the same group, and make the repository +Put all the committers in the same group, and make the repository writable by that group: ------------------------------------------------ diff --git a/Documentation/diff-options.txt b/Documentation/diff-options.txt index 1a936295d8..47ba9a403a 100644 --- a/Documentation/diff-options.txt +++ b/Documentation/diff-options.txt @@ -4,18 +4,21 @@ -u:: Synonym for "-p". +--raw:: + Generate the raw format. + --patch-with-raw:: - Generate patch but keep also the default raw diff output. + Synonym for "-p --raw". --stat:: - Generate a diffstat instead of a patch. + Generate a diffstat. --summary:: Output a condensed summary of extended header information such as creations, renames and mode changes. --patch-with-stat:: - Generate patch and prepend its diffstat. + Synonym for "-p --stat". -z:: \0 line termination on output @@ -26,10 +29,25 @@ --name-status:: Show only names and status of changed files. +--color:: + Show colored diff. + +--no-color:: + Turn off colored diff, even when the configuration file + gives the default to color output. + +--no-renames:: + Turn off rename detection, even when the configuration + file gives the default to do so. + --full-index:: Instead of the first handful characters, show full object name of pre- and post-image blob on the "index" - line when generating a patch format output. + line when generating a patch format output. + +--binary:: + In addition to --full-index, output "binary diff" that + can be applied with "git apply". --abbrev[=<n>]:: Instead of showing the full 40-byte hexadecimal object diff --git a/Documentation/git-cvsexportcommit.txt b/Documentation/git-cvsexportcommit.txt index 56bd3e517d..27ac72d98f 100644 --- a/Documentation/git-cvsexportcommit.txt +++ b/Documentation/git-cvsexportcommit.txt @@ -8,7 +8,7 @@ git-cvsexportcommit - Export a commit to a CVS checkout SYNOPSIS -------- -'git-cvsexportcommmit' [-h] [-v] [-c] [-p] [-f] [-m msgprefix] [PARENTCOMMIT] COMMITID +'git-cvsexportcommit' [-h] [-v] [-c] [-p] [-f] [-m msgprefix] [PARENTCOMMIT] COMMITID DESCRIPTION diff --git a/Documentation/git-diff-files.txt b/Documentation/git-diff-files.txt index 481b8b3aa0..7248b35d95 100644 --- a/Documentation/git-diff-files.txt +++ b/Documentation/git-diff-files.txt @@ -37,7 +37,7 @@ omit diff output for unmerged entries and just show "Unmerged". commit with these flags. -q:: - Remain silent even on nonexisting files + Remain silent even on nonexistent files Output format ------------- diff --git a/Documentation/git-diff.txt b/Documentation/git-diff.txt index 7ab2080376..228c4d95bd 100644 --- a/Documentation/git-diff.txt +++ b/Documentation/git-diff.txt @@ -8,24 +8,24 @@ git-diff - Show changes between commits, commit and working tree, etc SYNOPSIS -------- -'git-diff' [ --diff-options ] <ent>{0,2} [<path>...] +'git-diff' [ --diff-options ] <tree-ish>{0,2} [<path>...] DESCRIPTION ----------- -Show changes between two ents, an ent and the working tree, an -ent and the index file, or the index file and the working tree. +Show changes between two trees, a tree and the working tree, a +tree and the index file, or the index file and the working tree. The combination of what is compared with what is determined by -the number of ents given to the command. +the number of trees given to the command. -* When no <ent> is given, the working tree and the index - file is compared, using `git-diff-files`. +* When no <tree-ish> is given, the working tree and the index + file are compared, using `git-diff-files`. -* When one <ent> is given, the working tree and the named - tree is compared, using `git-diff-index`. The option +* When one <tree-ish> is given, the working tree and the named + tree are compared, using `git-diff-index`. The option `--cached` can be given to compare the index file and the named tree. -* When two <ent>s are given, these two trees are compared +* When two <tree-ish>s are given, these two trees are compared using `git-diff-tree`. OPTIONS diff --git a/Documentation/git-init-db.txt b/Documentation/git-init-db.txt index 8a150d861f..0a4fc14b97 100644 --- a/Documentation/git-init-db.txt +++ b/Documentation/git-init-db.txt @@ -25,7 +25,7 @@ DESCRIPTION ----------- This command creates an empty git repository - basically a `.git` directory with subdirectories for `objects`, `refs/heads`, `refs/tags`, and -templated files. +template files. An initial `HEAD` file that references the HEAD of the master branch is also created. diff --git a/Documentation/git-mailsplit.txt b/Documentation/git-mailsplit.txt index 209e36bacb..5a17801f6a 100644 --- a/Documentation/git-mailsplit.txt +++ b/Documentation/git-mailsplit.txt @@ -25,7 +25,7 @@ OPTIONS -b:: If any file doesn't begin with a From line, assume it is a - single mail message instead of signalling error. + single mail message instead of signaling error. -d<prec>:: Instead of the default 4 digits with leading zeros, diff --git a/Documentation/git-merge.txt b/Documentation/git-merge.txt index 4ce799b520..bebf30ad3d 100644 --- a/Documentation/git-merge.txt +++ b/Documentation/git-merge.txt @@ -83,7 +83,7 @@ your local modifications interfere with the merge, again, it stops before touching anything. So in the above two "failed merge" case, you do not have to -worry about lossage of data --- you simply were not ready to do +worry about loss of data --- you simply were not ready to do a merge, so no merge happened at all. You may want to finish whatever you were in the middle of doing, and retry the same pull after you are done and ready. diff --git a/Documentation/git-name-rev.txt b/Documentation/git-name-rev.txt index 39a1434a0e..37fbf66efb 100644 --- a/Documentation/git-name-rev.txt +++ b/Documentation/git-name-rev.txt @@ -26,14 +26,14 @@ OPTIONS List all commits reachable from all refs --stdin:: - Read from stdin, append "(<rev_name>)" to all sha1's of name'able + Read from stdin, append "(<rev_name>)" to all sha1's of nameable commits, and pass to stdout EXAMPLE ------- Given a commit, find out where it is relative to the local refs. Say somebody -wrote you about that phantastic commit 33db5f4d9027a10e477ccf054b2c1ab94f74c85a. +wrote you about that fantastic commit 33db5f4d9027a10e477ccf054b2c1ab94f74c85a. Of course, you look into the commit, but that only tells you what happened, but not the context. diff --git a/Documentation/git-p4import.txt b/Documentation/git-p4import.txt index 0858e5efbe..ee9e8fa909 100644 --- a/Documentation/git-p4import.txt +++ b/Documentation/git-p4import.txt @@ -128,7 +128,7 @@ Tags A git tag of the form p4/xx is created for every change imported from the Perforce repository where xx is the Perforce changeset number. Therefore after the import you can use git to access any commit by its -Perforce number, eg. git show p4/327. +Perforce number, e.g. git show p4/327. The tag associated with the HEAD commit is also how `git-p4import` determines if there are new changes to incrementally import from the @@ -143,7 +143,7 @@ may delete the tags. Notes ----- -You can interrupt the import (eg. ctrl-c) at any time and restart it +You can interrupt the import (e.g. ctrl-c) at any time and restart it without worry. Author information is automatically determined by querying the diff --git a/Documentation/git-pack-redundant.txt b/Documentation/git-pack-redundant.txt index 8fb0659438..7d54b17e37 100644 --- a/Documentation/git-pack-redundant.txt +++ b/Documentation/git-pack-redundant.txt @@ -29,7 +29,7 @@ OPTIONS --all:: - Processes all packs. Any filenames on the commandline are ignored. + Processes all packs. Any filenames on the command line are ignored. --alt-odb:: Don't require objects present in packs from alternate object diff --git a/Documentation/git-push.txt b/Documentation/git-push.txt index d5b5ca167c..56afd64f42 100644 --- a/Documentation/git-push.txt +++ b/Documentation/git-push.txt @@ -67,7 +67,7 @@ Some short-cut notations are also supported. -f, \--force:: Usually, the command refuses to update a remote ref that is - not a descendent of the local ref used to overwrite it. + not a descendant of the local ref used to overwrite it. This flag disables the check. This can cause the remote repository to lose commits; use it with care. diff --git a/Documentation/git-repo-config.txt b/Documentation/git-repo-config.txt index 803c0d5cae..b03d66f61c 100644 --- a/Documentation/git-repo-config.txt +++ b/Documentation/git-repo-config.txt @@ -119,8 +119,8 @@ you can set the filemode to true with % git repo-config core.filemode true ------------ -The hypothetic proxy command entries actually have a postfix to discern -to what URL they apply. Here is how to change the entry for kernel.org +The hypothetical proxy command entries actually have a postfix to discern +what URL they apply to. Here is how to change the entry for kernel.org to "ssh". ------------ diff --git a/Documentation/git-rev-list.txt b/Documentation/git-rev-list.txt index 6c370e1bef..f60eacd93e 100644 --- a/Documentation/git-rev-list.txt +++ b/Documentation/git-rev-list.txt @@ -56,6 +56,9 @@ OPTIONS Print the contents of the commit in raw-format; each record is separated with a NUL character. +--parents:: + Print the parents of the commit. + --objects:: Print the object IDs of any object referenced by the listed commits. 'git-rev-list --objects foo ^bar' thus means "send me all object IDs @@ -64,7 +67,7 @@ OPTIONS --objects-edge:: Similar to `--objects`, but also print the IDs of - excluded commits refixed with a `-` character. This is + excluded commits prefixed with a `-` character. This is used by `git-pack-objects` to build 'thin' pack, which records objects in deltified form based on objects contained in these excluded commits to reduce network @@ -102,6 +105,9 @@ OPTIONS --remove-empty:: Stop when a given path disappears from the tree. +--no-merges:: + Do not print commits with more than one parent. + --not:: Reverses the meaning of the '{caret}' prefix (or lack thereof) for all following revision specifiers, up to diff --git a/contrib/git-svn/git-svn.txt b/Documentation/git-svn.txt index f7d3de48f0..7d86809844 100644 --- a/contrib/git-svn/git-svn.txt +++ b/Documentation/git-svn.txt @@ -224,7 +224,7 @@ Merge tracking in Subversion is lacking and doing branched development with Subversion is cumbersome as a result. git-svn completely forgoes any automated merge/branch tracking on the Subversion side and leaves it entirely up to the user on the git side. It's simply not worth it to do -a useful translation when the the original signal is weak. +a useful translation when the original signal is weak. TRACKING MULTIPLE REPOSITORIES OR BRANCHES ------------------------------------------ diff --git a/Documentation/git-tools.txt b/Documentation/git-tools.txt index d79523f56d..0914cbb0ba 100644 --- a/Documentation/git-tools.txt +++ b/Documentation/git-tools.txt @@ -42,7 +42,7 @@ History Viewers - *gitk* (shipped with git-core) - gitk is a simple TK GUI for browsing history of GIT repositories easily. + gitk is a simple Tk GUI for browsing history of GIT repositories easily. - *gitview* (contrib/) diff --git a/Documentation/git-upload-tar.txt b/Documentation/git-upload-tar.txt index a1019a0231..394af62015 100644 --- a/Documentation/git-upload-tar.txt +++ b/Documentation/git-upload-tar.txt @@ -17,7 +17,7 @@ to the other end over the git protocol. This command is usually not invoked directly by the end user. The UI for the protocol is on the 'git-tar-tree' side, and the -program pair is meant to be used to get a tar achive from a +program pair is meant to be used to get a tar archive from a remote repository. diff --git a/Documentation/git.txt b/Documentation/git.txt index 51f20c6e67..d00cc3ea52 100644 --- a/Documentation/git.txt +++ b/Documentation/git.txt @@ -478,7 +478,7 @@ Configuration Mechanism Starting from 0.99.9 (actually mid 0.99.8.GIT), `.git/config` file is used to hold per-repository configuration options. It is a -simple text file modelled after `.ini` format familiar to some +simple text file modeled after `.ini` format familiar to some people. Here is an example: ------------ diff --git a/Documentation/glossary.txt b/Documentation/glossary.txt index 116ddb7fbf..14449ca8ba 100644 --- a/Documentation/glossary.txt +++ b/Documentation/glossary.txt @@ -86,7 +86,7 @@ directory:: ent:: Favorite synonym to "tree-ish" by some total geeks. See `http://en.wikipedia.org/wiki/Ent_(Middle-earth)` for an in-depth - explanation. + explanation. Avoid this term, not to confuse people. fast forward:: A fast-forward is a special type of merge where you have diff --git a/Documentation/howto/isolate-bugs-with-bisect.txt b/Documentation/howto/isolate-bugs-with-bisect.txt index edbcd4c661..926bbdc3cb 100644 --- a/Documentation/howto/isolate-bugs-with-bisect.txt +++ b/Documentation/howto/isolate-bugs-with-bisect.txt @@ -28,7 +28,7 @@ Then do and at this point "git bisect" will churn for a while, and tell you what the mid-point between those two commits are, and check that state out as -the head of the bew "bisect" branch. +the head of the new "bisect" branch. Compile and reboot. diff --git a/Documentation/howto/rebase-from-internal-branch.txt b/Documentation/howto/rebase-from-internal-branch.txt index c2d4a91c7c..fcd64e9b9b 100644 --- a/Documentation/howto/rebase-from-internal-branch.txt +++ b/Documentation/howto/rebase-from-internal-branch.txt @@ -124,7 +124,7 @@ up your changes, along with other changes. The two commits #2' and #3' in the above picture record the same changes your e-mail submission for #2 and #3 contained, but -probably with the new sign-off line added by the upsteam +probably with the new sign-off line added by the upstream maintainer and definitely with different committer and ancestry information, they are different objects from #2 and #3 commits. diff --git a/Documentation/technical/pack-heuristics.txt b/Documentation/technical/pack-heuristics.txt index 9aadd5cee5..103eb5d989 100644 --- a/Documentation/technical/pack-heuristics.txt +++ b/Documentation/technical/pack-heuristics.txt @@ -73,7 +73,7 @@ The traditional insight: <pasky> yes -And Bable-like confusion flowed. +And Babel-like confusion flowed. <njs`> oh, hmm, and I'm not sure what this sliding window means either @@ -257,7 +257,7 @@ proclaim it a non-issue. Good style too! (type, basename, size)). Then we walk through this list, and calculate a delta of - each object against the last n (tunable paramater) objects, + each object against the last n (tunable parameter) objects, and pick the smallest of these deltas. Vastly simplified, but the essence is there! @@ -395,7 +395,7 @@ used as setup for a later optimization, which is a real word: do "object name->location in packfile" translation. <njs`> I'm assuming the real win for delta-ing large->small is - more homogenous statistics for gzip to run over? + more homogeneous statistics for gzip to run over? (You have to put the bytes in one place or another, but putting them in a larger blob wins on compression) @@ -448,7 +448,7 @@ design options, etc. Bugs happen, but they are "simple" bugs. And bugs that actually get some object store detail wrong are almost always - so obious that they never go anywhere. + so obvious that they never go anywhere. <njs`> Yeah. diff --git a/Documentation/urls.txt b/Documentation/urls.txt index 74774134e3..9abec806d9 100644 --- a/Documentation/urls.txt +++ b/Documentation/urls.txt @@ -10,9 +10,9 @@ to name the remote repository: - https://host.xz/path/to/repo.git/ - git://host.xz/path/to/repo.git/ - git://host.xz/~user/path/to/repo.git/ -- ssh://host.xz/path/to/repo.git/ -- ssh://host.xz/~user/path/to/repo.git/ -- ssh://host.xz/~/path/to/repo.git +- ssh://[user@]host.xz/path/to/repo.git/ +- ssh://[user@]host.xz/~user/path/to/repo.git/ +- ssh://[user@]host.xz/~/path/to/repo.git =============================================================== SSH Is the default transport protocol and also supports an @@ -47,7 +47,7 @@ Then such a short-hand is specified in place of <repository> without <refspec> parameters on the command line, <refspec> specified on `Push:` lines or `Pull:` lines are used for `git-push` and `git-fetch`/`git-pull`, -respectively. Multiple `Push:` and and `Pull:` lines may +respectively. Multiple `Push:` and `Pull:` lines may be specified for additional branch mappings. The name of a file in `$GIT_DIR/branches` directory can be @@ -44,7 +44,7 @@ Issues of note: - "libcurl" and "curl" executable. git-http-fetch and git-fetch use them. If you do not use http - transfer, you are probabaly OK if you do not have + transfer, you are probably OK if you do not have them. - expat library; git-http-push uses it for remote lock @@ -69,7 +69,7 @@ Issues of note: git, and if you only use git to track other peoples work you'll never notice the lack of it. - - "wish", the TCL/Tk windowing shell is used in gitk to show the + - "wish", the Tcl/Tk windowing shell is used in gitk to show the history graphically - "ssh" is used to push and pull over the net @@ -33,6 +33,10 @@ all: # Define NO_SYMLINK_HEAD if you never want .git/HEAD to be a symbolic link. # Enable it on Windows. By default, symrefs are still used. # +# Define NO_SVN_TESTS if you want to skip time-consuming SVN interoperability +# tests. These tests take up a significant amount of the total test time +# but are not needed unless you plan to talk to SVN repos. +# # Define PPC_SHA1 environment variable when running make to make use of # a bundled SHA1 routine optimized for PowerPC. # @@ -60,7 +64,7 @@ all: # Define NO_ACCURATE_DIFF if your diff program at least sometimes misses # a missing newline at the end of the file. # -# Define NO_PYTHON if you want to loose all benefits of the recursive merge. +# Define NO_PYTHON if you want to lose all benefits of the recursive merge. # # Define COLLISION_CHECK below if you believe that SHA1's # 1461501637330902918203684832716283019655932542976 hashes do not give you @@ -134,7 +138,7 @@ SCRIPT_PERL = \ git-shortlog.perl git-rerere.perl \ git-annotate.perl git-cvsserver.perl \ git-svnimport.perl git-mv.perl git-cvsexportcommit.perl \ - git-send-email.perl + git-send-email.perl git-svn.perl SCRIPT_PYTHON = \ git-merge-recursive.py @@ -218,7 +222,7 @@ LIB_OBJS = \ server-info.o setup.o sha1_file.o sha1_name.o strbuf.o \ tag.o tree.o usage.o config.o environment.o ctype.o copy.o \ fetch-clone.o revision.o pager.o tree-walk.o xdiff-interface.o \ - alloc.o $(DIFF_OBJS) + alloc.o merge-file.o $(DIFF_OBJS) BUILTIN_OBJS = \ builtin-log.o builtin-help.o builtin-count.o builtin-diff.o builtin-push.o \ @@ -469,7 +473,7 @@ ifdef NO_ACCURATE_DIFF ALL_CFLAGS += -DNO_ACCURATE_DIFF endif -# Shell quote (do not use $(call) to accomodate ancient setups); +# Shell quote (do not use $(call) to accommodate ancient setups); SHA1_HEADER_SQ = $(subst ','\'',$(SHA1_HEADER)) @@ -653,6 +657,7 @@ GIT-CFLAGS: .FORCE-GIT-CFLAGS # with that. export NO_PYTHON +export NO_SVN_TESTS test: all $(MAKE) -C t/ all @@ -21,11 +21,11 @@ #define DEBUG 0 static const char blame_usage[] = "[-c] [-l] [-t] [-S <revs-file>] [--] file [commit]\n" - " -c, --compability Use the same output mode as git-annotate (Default: off)\n" - " -l, --long Show long commit SHA1 (Default: off)\n" - " -t, --time Show raw timestamp (Default: off)\n" - " -S, --revs-file Use revisions from revs-file instead of calling git-rev-list\n" - " -h, --help This message"; + " -c, --compatibility Use the same output mode as git-annotate (Default: off)\n" + " -l, --long Show long commit SHA1 (Default: off)\n" + " -t, --time Show raw timestamp (Default: off)\n" + " -S, --revs-file Use revisions from revs-file instead of calling git-rev-list\n" + " -h, --help This message"; static struct commit **blame_lines; static int num_blame_lines; @@ -44,8 +44,8 @@ struct util_info { }; struct chunk { - int off1, len1; // --- - int off2, len2; // +++ + int off1, len1; /* --- */ + int off2, len2; /* +++ */ }; struct patch { @@ -255,7 +255,7 @@ static void print_map(struct commit *cmit, struct commit *other) } #endif -// p is a patch from commit to other. +/* p is a patch from commit to other. */ static void fill_line_map(struct commit *commit, struct commit *other, struct patch *p) { @@ -747,7 +747,7 @@ int main(int argc, const char **argv) const char *filename = NULL, *commit = NULL; char filename_buf[256]; int sha1_len = 8; - int compability = 0; + int compatibility = 0; int show_raw_time = 0; int options = 1; struct commit* start_commit; @@ -774,8 +774,8 @@ int main(int argc, const char **argv) sha1_len = 40; continue; } else if(!strcmp(argv[i], "-c") || - !strcmp(argv[i], "--compability")) { - compability = 1; + !strcmp(argv[i], "--compatibility")) { + compatibility = 1; continue; } else if(!strcmp(argv[i], "-t") || !strcmp(argv[i], "--time")) { @@ -784,7 +784,7 @@ int main(int argc, const char **argv) } else if(!strcmp(argv[i], "-S")) { if (i + 1 < argc && !read_ancestry(argv[i + 1], &sha1_p)) { - compability = 1; + compatibility = 1; i++; continue; } @@ -884,7 +884,7 @@ int main(int argc, const char **argv) u = c->util; get_commit_info(c, &ci); fwrite(sha1_to_hex(c->object.sha1), sha1_len, 1, stdout); - if(compability) { + if(compatibility) { printf("\t(%10s\t%10s\t%d)", ci.author, format_time(ci.author_time, ci.author_tz, show_raw_time), diff --git a/builtin-apply.c b/builtin-apply.c index c3af48917c..c903146bb6 100644 --- a/builtin-apply.c +++ b/builtin-apply.c @@ -14,14 +14,15 @@ #include "delta.h" #include "builtin.h" -// --check turns on checking that the working tree matches the -// files that are being modified, but doesn't apply the patch -// --stat does just a diffstat, and doesn't actually apply -// --numstat does numeric diffstat, and doesn't actually apply -// --index-info shows the old and new index info for paths if available. -// --index updates the cache as well. -// --cached updates only the cache without ever touching the working tree. -// +/* + * --check turns on checking that the working tree matches the + * files that are being modified, but doesn't apply the patch + * --stat does just a diffstat, and doesn't actually apply + * --numstat does numeric diffstat, and doesn't actually apply + * --index-info shows the old and new index info for paths if available. + * --index updates the cache as well. + * --cached updates only the cache without ever touching the working tree. + */ static const char *prefix; static int prefix_length = -1; static int newfd = -1; @@ -284,8 +285,8 @@ static void parse_traditional_patch(const char *first, const char *second, struc { char *name; - first += 4; // skip "--- " - second += 4; // skip "+++ " + first += 4; /* skip "--- " */ + second += 4; /* skip "+++ " */ if (is_dev_null(first)) { patch->is_new = 1; patch->is_delete = 0; @@ -765,7 +766,7 @@ static int find_header(char *line, unsigned long size, int *hdrsize, struct patc continue; /* - * Make sure we don't find any unconnected patch fragmants. + * Make sure we don't find any unconnected patch fragments. * That's a sign that we didn't find a header, and that a * patch has become corrupted/broken up. */ @@ -990,7 +991,7 @@ static int parse_binary(char *buffer, unsigned long size, struct patch *patch) * so one line can fit up to 13 groups that would decode * to 52 bytes max. The length byte 'A'-'Z' corresponds * to 1-26 bytes, and 'a'-'z' corresponds to 27-52 bytes. - * The end of binary is signalled with an empty line. + * The end of binary is signaled with an empty line. */ int llen, used; struct fragment *fragment; diff --git a/builtin-diff-files.c b/builtin-diff-files.c index a655eea91e..81ac2fe64a 100644 --- a/builtin-diff-files.c +++ b/builtin-diff-files.c @@ -18,7 +18,7 @@ int cmd_diff_files(int argc, const char **argv, char **envp) struct rev_info rev; int silent = 0; - git_config(git_diff_config); + git_config(git_default_config); /* no "diff" UI options */ init_revisions(&rev); rev.abbrev = 0; diff --git a/builtin-diff-index.c b/builtin-diff-index.c index b37c9e8ccb..a1fa1b85cf 100644 --- a/builtin-diff-index.c +++ b/builtin-diff-index.c @@ -15,7 +15,7 @@ int cmd_diff_index(int argc, const char **argv, char **envp) int cached = 0; int i; - git_config(git_diff_config); + git_config(git_default_config); /* no "diff" UI options */ init_revisions(&rev); rev.abbrev = 0; diff --git a/builtin-diff-stages.c b/builtin-diff-stages.c index 30931fe049..9c62702941 100644 --- a/builtin-diff-stages.c +++ b/builtin-diff-stages.c @@ -61,7 +61,7 @@ int cmd_diff_stages(int ac, const char **av, char **envp) const char *prefix = setup_git_directory(); const char **pathspec = NULL; - git_config(git_diff_config); + git_config(git_default_config); /* no "diff" UI options */ read_cache(); diff_setup(&diff_options); while (1 < ac && av[1][0] == '-') { diff --git a/builtin-diff-tree.c b/builtin-diff-tree.c index ae1cde9d00..b610668594 100644 --- a/builtin-diff-tree.c +++ b/builtin-diff-tree.c @@ -67,7 +67,7 @@ int cmd_diff_tree(int argc, const char **argv, char **envp) static struct rev_info *opt = &log_tree_opt; int read_stdin = 0; - git_config(git_diff_config); + git_config(git_default_config); /* no "diff" UI options */ nr_sha1 = 0; init_revisions(opt); opt->abbrev = 0; diff --git a/builtin-diff.c b/builtin-diff.c index d520c7ca29..ae901dd25e 100644 --- a/builtin-diff.c +++ b/builtin-diff.c @@ -176,7 +176,7 @@ static int builtin_diff_tree(struct rev_info *revs, usage(builtin_diff_usage); /* We saw two trees, ent[0] and ent[1]. - * if ent[1] is unintesting, they are swapped + * if ent[1] is uninteresting, they are swapped */ if (ent[1].item->flags & UNINTERESTING) swap = 1; @@ -250,7 +250,7 @@ int cmd_diff(int argc, const char **argv, char **envp) * Other cases are errors. */ - git_config(git_diff_config); + git_config(git_diff_ui_config); init_revisions(&rev); argc = setup_revisions(argc, argv, &rev, NULL); diff --git a/builtin-fmt-merge-msg.c b/builtin-fmt-merge-msg.c index 65274824d3..fe0ef44b40 100644 --- a/builtin-fmt-merge-msg.c +++ b/builtin-fmt-merge-msg.c @@ -76,6 +76,7 @@ static int handle_line(char *line) unsigned char *sha1; char *src, *origin; struct src_data *src_data; + int pulling_head = 0; if (len < 43 || line[40] != '\t') return 1; @@ -101,8 +102,11 @@ static int handle_line(char *line) if (src) { *src = 0; src += 4; - } else - src = "HEAD"; + pulling_head = 0; + } else { + src = line; + pulling_head = 1; + } i = find_in_list(&srcs, src); if (i < 0) { @@ -112,7 +116,10 @@ static int handle_line(char *line) } src_data = srcs.payload[i]; - if (!strncmp(line, "branch ", 7)) { + if (pulling_head) { + origin = strdup(src); + src_data->head_status |= 1; + } else if (!strncmp(line, "branch ", 7)) { origin = strdup(line + 7); append_to_list(&src_data->branch, origin, NULL); src_data->head_status |= 2; @@ -124,9 +131,6 @@ static int handle_line(char *line) origin = strdup(line + 14); append_to_list(&src_data->r_branch, origin, NULL); src_data->head_status |= 2; - } else if (!strcmp(line, "HEAD")) { - origin = strdup(src); - src_data->head_status |= 1; } else { origin = strdup(src); append_to_list(&src_data->generic, strdup(line), NULL); diff --git a/builtin-grep.c b/builtin-grep.c index 6973c66704..4c2f7dfe03 100644 --- a/builtin-grep.c +++ b/builtin-grep.c @@ -82,17 +82,47 @@ static int pathspec_matches(const char **paths, const char *name) return 0; } +enum grep_pat_token { + GREP_PATTERN, + GREP_AND, + GREP_OPEN_PAREN, + GREP_CLOSE_PAREN, + GREP_NOT, + GREP_OR, +}; + struct grep_pat { struct grep_pat *next; const char *origin; int no; + enum grep_pat_token token; const char *pattern; regex_t regexp; }; +enum grep_expr_node { + GREP_NODE_ATOM, + GREP_NODE_NOT, + GREP_NODE_AND, + GREP_NODE_OR, +}; + +struct grep_expr { + enum grep_expr_node node; + union { + struct grep_pat *atom; + struct grep_expr *unary; + struct { + struct grep_expr *left; + struct grep_expr *right; + } binary; + } u; +}; + struct grep_opt { struct grep_pat *pattern_list; struct grep_pat **pattern_tail; + struct grep_expr *pattern_expression; regex_t regexp; unsigned linenum:1; unsigned invert:1; @@ -105,43 +135,224 @@ struct grep_opt { #define GREP_BINARY_NOMATCH 1 #define GREP_BINARY_TEXT 2 unsigned binary:2; + unsigned extended:1; int regflags; unsigned pre_context; unsigned post_context; }; static void add_pattern(struct grep_opt *opt, const char *pat, - const char *origin, int no) + const char *origin, int no, enum grep_pat_token t) { struct grep_pat *p = xcalloc(1, sizeof(*p)); p->pattern = pat; p->origin = origin; p->no = no; + p->token = t; *opt->pattern_tail = p; opt->pattern_tail = &p->next; p->next = NULL; } +static void compile_regexp(struct grep_pat *p, struct grep_opt *opt) +{ + int err = regcomp(&p->regexp, p->pattern, opt->regflags); + if (err) { + char errbuf[1024]; + char where[1024]; + if (p->no) + sprintf(where, "In '%s' at %d, ", + p->origin, p->no); + else if (p->origin) + sprintf(where, "%s, ", p->origin); + else + where[0] = 0; + regerror(err, &p->regexp, errbuf, 1024); + regfree(&p->regexp); + die("%s'%s': %s", where, p->pattern, errbuf); + } +} + +#if DEBUG +static inline void indent(int in) +{ + int i; + for (i = 0; i < in; i++) putchar(' '); +} + +static void dump_pattern_exp(struct grep_expr *x, int in) +{ + switch (x->node) { + case GREP_NODE_ATOM: + indent(in); + puts(x->u.atom->pattern); + break; + case GREP_NODE_NOT: + indent(in); + puts("--not"); + dump_pattern_exp(x->u.unary, in+1); + break; + case GREP_NODE_AND: + dump_pattern_exp(x->u.binary.left, in+1); + indent(in); + puts("--and"); + dump_pattern_exp(x->u.binary.right, in+1); + break; + case GREP_NODE_OR: + dump_pattern_exp(x->u.binary.left, in+1); + indent(in); + puts("--or"); + dump_pattern_exp(x->u.binary.right, in+1); + break; + } +} + +static void looking_at(const char *msg, struct grep_pat **list) +{ + struct grep_pat *p = *list; + fprintf(stderr, "%s: looking at ", msg); + if (!p) + fprintf(stderr, "empty\n"); + else + fprintf(stderr, "<%s>\n", p->pattern); +} +#else +#define looking_at(a,b) do {} while(0) +#endif + +static struct grep_expr *compile_pattern_expr(struct grep_pat **); +static struct grep_expr *compile_pattern_atom(struct grep_pat **list) +{ + struct grep_pat *p; + struct grep_expr *x; + + looking_at("atom", list); + + p = *list; + switch (p->token) { + case GREP_PATTERN: /* atom */ + x = xcalloc(1, sizeof (struct grep_expr)); + x->node = GREP_NODE_ATOM; + x->u.atom = p; + *list = p->next; + return x; + case GREP_OPEN_PAREN: + *list = p->next; + x = compile_pattern_expr(list); + if (!x) + return NULL; + if (!*list || (*list)->token != GREP_CLOSE_PAREN) + die("unmatched parenthesis"); + *list = (*list)->next; + return x; + default: + return NULL; + } +} + +static struct grep_expr *compile_pattern_not(struct grep_pat **list) +{ + struct grep_pat *p; + struct grep_expr *x; + + looking_at("not", list); + + p = *list; + switch (p->token) { + case GREP_NOT: + if (!p->next) + die("--not not followed by pattern expression"); + *list = p->next; + x = xcalloc(1, sizeof (struct grep_expr)); + x->node = GREP_NODE_NOT; + x->u.unary = compile_pattern_not(list); + if (!x->u.unary) + die("--not followed by non pattern expression"); + return x; + default: + return compile_pattern_atom(list); + } +} + +static struct grep_expr *compile_pattern_and(struct grep_pat **list) +{ + struct grep_pat *p; + struct grep_expr *x, *y, *z; + + looking_at("and", list); + + x = compile_pattern_not(list); + p = *list; + if (p && p->token == GREP_AND) { + if (!p->next) + die("--and not followed by pattern expression"); + *list = p->next; + y = compile_pattern_and(list); + if (!y) + die("--and not followed by pattern expression"); + z = xcalloc(1, sizeof (struct grep_expr)); + z->node = GREP_NODE_AND; + z->u.binary.left = x; + z->u.binary.right = y; + return z; + } + return x; +} + +static struct grep_expr *compile_pattern_or(struct grep_pat **list) +{ + struct grep_pat *p; + struct grep_expr *x, *y, *z; + + looking_at("or", list); + + x = compile_pattern_and(list); + p = *list; + if (x && p && p->token != GREP_CLOSE_PAREN) { + y = compile_pattern_or(list); + if (!y) + die("not a pattern expression %s", p->pattern); + z = xcalloc(1, sizeof (struct grep_expr)); + z->node = GREP_NODE_OR; + z->u.binary.left = x; + z->u.binary.right = y; + return z; + } + return x; +} + +static struct grep_expr *compile_pattern_expr(struct grep_pat **list) +{ + looking_at("expr", list); + + return compile_pattern_or(list); +} + static void compile_patterns(struct grep_opt *opt) { struct grep_pat *p; + + /* First compile regexps */ for (p = opt->pattern_list; p; p = p->next) { - int err = regcomp(&p->regexp, p->pattern, opt->regflags); - if (err) { - char errbuf[1024]; - char where[1024]; - if (p->no) - sprintf(where, "In '%s' at %d, ", - p->origin, p->no); - else if (p->origin) - sprintf(where, "%s, ", p->origin); - else - where[0] = 0; - regerror(err, &p->regexp, errbuf, 1024); - regfree(&p->regexp); - die("%s'%s': %s", where, p->pattern, errbuf); - } + if (p->token == GREP_PATTERN) + compile_regexp(p, opt); + else + opt->extended = 1; } + + if (!opt->extended) + return; + + /* Then bundle them up in an expression. + * A classic recursive descent parser would do. + */ + p = opt->pattern_list; + opt->pattern_expression = compile_pattern_expr(&p); +#if DEBUG + dump_pattern_exp(opt->pattern_expression, 0); +#endif + if (p) + die("incomplete pattern expression: %s", p->pattern); } static char *end_of_line(char *cp, unsigned long *left) @@ -196,6 +407,79 @@ static int fixmatch(const char *pattern, char *line, regmatch_t *match) } } +static int match_one_pattern(struct grep_opt *opt, struct grep_pat *p, char *bol, char *eol) +{ + int hit = 0; + regmatch_t pmatch[10]; + + if (!opt->fixed) { + regex_t *exp = &p->regexp; + hit = !regexec(exp, bol, ARRAY_SIZE(pmatch), + pmatch, 0); + } + else { + hit = !fixmatch(p->pattern, bol, pmatch); + } + + if (hit && opt->word_regexp) { + /* Match beginning must be either + * beginning of the line, or at word + * boundary (i.e. the last char must + * not be alnum or underscore). + */ + if ((pmatch[0].rm_so < 0) || + (eol - bol) <= pmatch[0].rm_so || + (pmatch[0].rm_eo < 0) || + (eol - bol) < pmatch[0].rm_eo) + die("regexp returned nonsense"); + if (pmatch[0].rm_so != 0 && + word_char(bol[pmatch[0].rm_so-1])) + hit = 0; + if (pmatch[0].rm_eo != (eol-bol) && + word_char(bol[pmatch[0].rm_eo])) + hit = 0; + } + return hit; +} + +static int match_expr_eval(struct grep_opt *opt, + struct grep_expr *x, + char *bol, char *eol) +{ + switch (x->node) { + case GREP_NODE_ATOM: + return match_one_pattern(opt, x->u.atom, bol, eol); + break; + case GREP_NODE_NOT: + return !match_expr_eval(opt, x->u.unary, bol, eol); + case GREP_NODE_AND: + return (match_expr_eval(opt, x->u.binary.left, bol, eol) && + match_expr_eval(opt, x->u.binary.right, bol, eol)); + case GREP_NODE_OR: + return (match_expr_eval(opt, x->u.binary.left, bol, eol) || + match_expr_eval(opt, x->u.binary.right, bol, eol)); + } + die("Unexpected node type (internal error) %d\n", x->node); +} + +static int match_expr(struct grep_opt *opt, char *bol, char *eol) +{ + struct grep_expr *x = opt->pattern_expression; + return match_expr_eval(opt, x, bol, eol); +} + +static int match_line(struct grep_opt *opt, char *bol, char *eol) +{ + struct grep_pat *p; + if (opt->extended) + return match_expr(opt, bol, eol); + for (p = opt->pattern_list; p; p = p->next) { + if (match_one_pattern(opt, p, bol, eol)) + return 1; + } + return 0; +} + static int grep_buffer(struct grep_opt *opt, const char *name, char *buf, unsigned long size) { @@ -231,46 +515,15 @@ static int grep_buffer(struct grep_opt *opt, const char *name, hunk_mark = "--\n"; while (left) { - regmatch_t pmatch[10]; char *eol, ch; int hit = 0; - struct grep_pat *p; eol = end_of_line(bol, &left); ch = *eol; *eol = 0; - for (p = opt->pattern_list; p; p = p->next) { - if (!opt->fixed) { - regex_t *exp = &p->regexp; - hit = !regexec(exp, bol, ARRAY_SIZE(pmatch), - pmatch, 0); - } - else { - hit = !fixmatch(p->pattern, bol, pmatch); - } + hit = match_line(opt, bol, eol); - if (hit && opt->word_regexp) { - /* Match beginning must be either - * beginning of the line, or at word - * boundary (i.e. the last char must - * not be alnum or underscore). - */ - if ((pmatch[0].rm_so < 0) || - (eol - bol) <= pmatch[0].rm_so || - (pmatch[0].rm_eo < 0) || - (eol - bol) < pmatch[0].rm_eo) - die("regexp returned nonsense"); - if (pmatch[0].rm_so != 0 && - word_char(bol[pmatch[0].rm_so-1])) - hit = 0; - if (pmatch[0].rm_eo != (eol-bol) && - word_char(bol[pmatch[0].rm_eo])) - hit = 0; - } - if (hit) - break; - } /* "grep -v -e foo -e bla" should list lines * that do not have either, so inversion should * be done outside. @@ -452,6 +705,8 @@ static int external_grep(struct grep_opt *opt, const char **paths, int cached) char *argptr = randarg; struct grep_pat *p; + if (opt->extended) + return -1; len = nr = 0; push_arg("grep"); if (opt->fixed) @@ -686,7 +941,7 @@ int cmd_grep(int argc, const char **argv, char **envp) * pattern, but then what follows it must be zero or more * valid refs up to the -- (if exists), and then existing * paths. If there is an explicit pattern, then the first - * unrecocnized non option is the beginning of the refs list + * unrecognized non option is the beginning of the refs list * that continues up to the -- (if exists), and then paths. */ @@ -813,16 +1068,36 @@ int cmd_grep(int argc, const char **argv, char **envp) /* ignore empty line like grep does */ if (!buf[0]) continue; - add_pattern(&opt, strdup(buf), argv[1], ++lno); + add_pattern(&opt, strdup(buf), argv[1], ++lno, + GREP_PATTERN); } fclose(patterns); argv++; argc--; continue; } + if (!strcmp("--not", arg)) { + add_pattern(&opt, arg, "command line", 0, GREP_NOT); + continue; + } + if (!strcmp("--and", arg)) { + add_pattern(&opt, arg, "command line", 0, GREP_AND); + continue; + } + if (!strcmp("--or", arg)) + continue; /* no-op */ + if (!strcmp("(", arg)) { + add_pattern(&opt, arg, "command line", 0, GREP_OPEN_PAREN); + continue; + } + if (!strcmp(")", arg)) { + add_pattern(&opt, arg, "command line", 0, GREP_CLOSE_PAREN); + continue; + } if (!strcmp("-e", arg)) { if (1 < argc) { - add_pattern(&opt, argv[1], "-e option", 0); + add_pattern(&opt, argv[1], "-e option", 0, + GREP_PATTERN); argv++; argc--; continue; @@ -840,7 +1115,8 @@ int cmd_grep(int argc, const char **argv, char **envp) /* First unrecognized non-option token */ if (!opt.pattern_list) { - add_pattern(&opt, arg, "command line", 0); + add_pattern(&opt, arg, "command line", 0, + GREP_PATTERN); break; } else { diff --git a/builtin-help.c b/builtin-help.c index 7470faa566..335fe5fedc 100644 --- a/builtin-help.c +++ b/builtin-help.c @@ -12,7 +12,7 @@ static const char git_usage[] = "Usage: git [--version] [--exec-path[=GIT_EXEC_PATH]] [--help] COMMAND [ ARGS ]"; -/* most gui terms set COLUMNS (although some don't export it) */ +/* most GUI terminals set COLUMNS (although some don't export it) */ static int term_columns(void) { char *col_string = getenv("COLUMNS"); diff --git a/builtin-log.c b/builtin-log.c index 0aeeaa4e20..7e5cab15c1 100644 --- a/builtin-log.c +++ b/builtin-log.c @@ -47,7 +47,7 @@ int cmd_whatchanged(int argc, const char **argv, char **envp) { struct rev_info rev; - git_config(git_diff_config); + git_config(git_diff_ui_config); init_revisions(&rev); rev.diff = 1; rev.diffopt.recursive = 1; @@ -62,7 +62,7 @@ int cmd_show(int argc, const char **argv, char **envp) { struct rev_info rev; - git_config(git_diff_config); + git_config(git_diff_ui_config); init_revisions(&rev); rev.diff = 1; rev.diffopt.recursive = 1; @@ -79,7 +79,7 @@ int cmd_log(int argc, const char **argv, char **envp) { struct rev_info rev; - git_config(git_diff_config); + git_config(git_diff_ui_config); init_revisions(&rev); rev.always_show_header = 1; cmd_log_init(argc, argv, envp, &rev); @@ -108,7 +108,7 @@ static int git_format_config(const char *var, const char *value) if (!strcmp(var, "diff.color")) { return 0; } - return git_diff_config(var, value); + return git_diff_ui_config(var, value); } diff --git a/builtin-mailinfo.c b/builtin-mailinfo.c index 3e40747cf5..ac53f76f68 100644 --- a/builtin-mailinfo.c +++ b/builtin-mailinfo.c @@ -348,7 +348,7 @@ static void cleanup_space(char *buf) } } -static void decode_header_bq(char *it); +static void decode_header(char *it); typedef int (*header_fn_t)(char *); struct header_def { const char *name; @@ -371,7 +371,7 @@ static void check_header(char *line, struct header_def *header) /* Unwrap inline B and Q encoding, and optionally * normalize the meta information to utf8. */ - decode_header_bq(line + len + 2); + decode_header(line + len + 2); header[i].func(line + len + 2); break; } @@ -566,16 +566,19 @@ static void convert_to_utf8(char *line, char *charset) #endif } -static void decode_header_bq(char *it) +static int decode_header_bq(char *it) { char *in, *out, *ep, *cp, *sp; char outbuf[1000]; + int rfc2047 = 0; in = it; out = outbuf; while ((ep = strstr(in, "=?")) != NULL) { int sz, encoding; char charset_q[256], piecebuf[256]; + rfc2047 = 1; + if (in != ep) { sz = ep - in; memcpy(out, in, sz); @@ -589,19 +592,19 @@ static void decode_header_bq(char *it) ep += 2; cp = strchr(ep, '?'); if (!cp) - return; /* no munging */ + return rfc2047; /* no munging */ for (sp = ep; sp < cp; sp++) charset_q[sp - ep] = tolower(*sp); charset_q[cp - ep] = 0; encoding = cp[1]; if (!encoding || cp[2] != '?') - return; /* no munging */ + return rfc2047; /* no munging */ ep = strstr(cp + 3, "?="); if (!ep) - return; /* no munging */ + return rfc2047; /* no munging */ switch (tolower(encoding)) { default: - return; /* no munging */ + return rfc2047; /* no munging */ case 'b': sz = decode_b_segment(cp + 3, piecebuf, ep); break; @@ -610,7 +613,7 @@ static void decode_header_bq(char *it) break; } if (sz < 0) - return; + return rfc2047; if (metainfo_charset) convert_to_utf8(piecebuf, charset_q); strcpy(out, piecebuf); @@ -619,6 +622,19 @@ static void decode_header_bq(char *it) } strcpy(out, in); strcpy(it, outbuf); + return rfc2047; +} + +static void decode_header(char *it) +{ + + if (decode_header_bq(it)) + return; + /* otherwise "it" is a straight copy of the input. + * This can be binary guck but there is no charset specified. + */ + if (metainfo_charset) + convert_to_utf8(it, ""); } static void decode_transfer_encoding(char *line) diff --git a/builtin-push.c b/builtin-push.c index 66b9407822..31cbfd7386 100644 --- a/builtin-push.c +++ b/builtin-push.c @@ -104,7 +104,7 @@ static int get_remotes_uri(const char *repo, const char *uri[MAX_URI]) if (n < MAX_URI) uri[n++] = strdup(s); else - error("more than %d URL's specified, ignoreing the rest", MAX_URI); + error("more than %d URL's specified, ignoring the rest", MAX_URI); } else if (is_refspec && !has_explicit_refspec) add_refspec(strdup(s)); @@ -273,7 +273,7 @@ static int do_push(const char *repo) int cmd_push(int argc, const char **argv, char **envp) { int i; - const char *repo = "origin"; // default repository + const char *repo = "origin"; /* default repository */ for (i = 1; i < argc; i++) { const char *arg = argv[i]; diff --git a/builtin-read-tree.c b/builtin-read-tree.c index 23a8d92a4b..6df5d7c5cb 100644 --- a/builtin-read-tree.c +++ b/builtin-read-tree.c @@ -43,10 +43,7 @@ struct tree_entry_list { const unsigned char *sha1; }; -static struct tree_entry_list df_conflict_list = { - .name = NULL, - .next = &df_conflict_list -}; +static struct tree_entry_list df_conflict_list; typedef int (*merge_fn_t)(struct cache_entry **src); @@ -333,14 +330,9 @@ static void setup_progress_signal(void) setitimer(ITIMER_REAL, &v, NULL); } +static struct checkout state; static void check_updates(struct cache_entry **src, int nr) { - static struct checkout state = { - .base_dir = "", - .force = 1, - .quiet = 1, - .refresh_cache = 1, - }; unsigned short mask = htons(CE_UPDATE); unsigned last_percent = 200, cnt = 0, total = 0; @@ -884,6 +876,12 @@ int cmd_read_tree(int argc, const char **argv, char **envp) unsigned char sha1[20]; merge_fn_t fn = NULL; + df_conflict_list.next = &df_conflict_list; + state.base_dir = ""; + state.force = 1; + state.quiet = 1; + state.refresh_cache = 1; + setup_git_directory(); git_config(git_default_config); diff --git a/builtin-rm.c b/builtin-rm.c index 875d8252fa..5deb811719 100644 --- a/builtin-rm.c +++ b/builtin-rm.c @@ -129,7 +129,7 @@ int cmd_rm(int argc, const char **argv, char **envp) * workspace. If we fail to remove the first one, we * abort the "git rm" (but once we've successfully removed * any file at all, we'll go ahead and commit to it all: - * by then we've already committed ourself and can't fail + * by then we've already committed ourselves and can't fail * in the middle) */ if (force) { diff --git a/builtin-update-ref.c b/builtin-update-ref.c index 00333c7e7c..83094abe0f 100644 --- a/builtin-update-ref.c +++ b/builtin-update-ref.c @@ -12,6 +12,7 @@ int cmd_update_ref(int argc, const char **argv, char **envp) unsigned char sha1[20], oldsha1[20]; int i; + setup_ident(); setup_git_directory(); git_config(git_default_config); @@ -219,8 +219,6 @@ int safe_create_leading_directories(char *path); char *enter_repo(char *path, int strict); /* Read and unpack a sha1 file into memory, write memory to a sha1 file */ -extern int unpack_sha1_header(z_stream *stream, void *map, unsigned long mapsize, void *buffer, unsigned long size); -extern int parse_sha1_header(char *hdr, char *type, unsigned long *sizep); extern int sha1_object_info(const unsigned char *, char *, unsigned long *); extern void * unpack_sha1_file(void *map, unsigned long mapsize, char *type, unsigned long *size); extern void * read_sha1_file(const unsigned char *sha1, char *type, unsigned long *size); @@ -382,6 +380,7 @@ extern int receive_keep_pack(int fd[2], const char *me, int quiet, int); /* pager.c */ extern void setup_pager(void); +extern int pager_in_use; /* base85 */ int decode_85(char *dst, char *line, int linelen); diff --git a/checkout-index.c b/checkout-index.c index 2927955508..61152f34b7 100644 --- a/checkout-index.c +++ b/checkout-index.c @@ -49,14 +49,7 @@ static int checkout_stage; /* default to checkout stage0 */ static int to_tempfile; static char topath[4][MAXPATHLEN+1]; -static struct checkout state = { - .base_dir = "", - .base_dir_len = 0, - .force = 0, - .quiet = 0, - .not_new = 0, - .refresh_cache = 0, -}; +static struct checkout state; static void write_tempfile_record (const char *name) { @@ -177,6 +170,7 @@ int main(int argc, char **argv) int all = 0; int read_from_stdin = 0; + state.base_dir = ""; prefix = setup_git_directory(); git_config(git_default_config); prefix_length = prefix ? strlen(prefix) : 0; diff --git a/combine-diff.c b/combine-diff.c index caffb926ea..1bc1484645 100644 --- a/combine-diff.c +++ b/combine-diff.c @@ -320,7 +320,7 @@ static int give_context(struct sline *sline, unsigned long cnt, int num_parent) unsigned long i; /* Two groups of interesting lines may have a short gap of - * unintersting lines. Connect such groups to give them a + * uninteresting lines. Connect such groups to give them a * bit of context. * * We first start from what the interesting() function says, diff --git a/compat/subprocess.py b/compat/subprocess.py index bbd26c7b0e..6474eab119 100644 --- a/compat/subprocess.py +++ b/compat/subprocess.py @@ -568,7 +568,7 @@ class Popen(object): # Windows methods # def _get_handles(self, stdin, stdout, stderr): - """Construct and return tupel with IO objects: + """Construct and return tuple with IO objects: p2cread, p2cwrite, c2pread, c2pwrite, errread, errwrite """ if stdin == None and stdout == None and stderr == None: @@ -635,7 +635,7 @@ class Popen(object): def _find_w9xpopen(self): - """Find and return absolut path to w9xpopen.exe""" + """Find and return absolute path to w9xpopen.exe""" w9xpopen = os.path.join(os.path.dirname(GetModuleFileName(0)), "w9xpopen.exe") if not os.path.exists(w9xpopen): @@ -812,7 +812,7 @@ class Popen(object): # POSIX methods # def _get_handles(self, stdin, stdout, stderr): - """Construct and return tupel with IO objects: + """Construct and return tuple with IO objects: p2cread, p2cwrite, c2pread, c2pwrite, errread, errwrite """ p2cread, p2cwrite = None, None diff --git a/contrib/colordiff/colordiff.perl b/contrib/colordiff/colordiff.perl index 5789cfb265..9566a765ef 100755 --- a/contrib/colordiff/colordiff.perl +++ b/contrib/colordiff/colordiff.perl @@ -110,7 +110,7 @@ foreach $config_file (@config_files) { } } -# colordiff specfic options here. Need to pre-declare if using variables +# colordiff specific options here. Need to pre-declare if using variables GetOptions( "no-banner" => sub { $show_banner = 0 }, "plain-text=s" => \&set_color, diff --git a/contrib/git-svn/.gitignore b/contrib/git-svn/.gitignore deleted file mode 100644 index d8d87e3af9..0000000000 --- a/contrib/git-svn/.gitignore +++ /dev/null @@ -1,4 +0,0 @@ -git-svn -git-svn.xml -git-svn.html -git-svn.1 diff --git a/contrib/git-svn/Makefile b/contrib/git-svn/Makefile deleted file mode 100644 index 7c20946943..0000000000 --- a/contrib/git-svn/Makefile +++ /dev/null @@ -1,44 +0,0 @@ -all: git-svn - -prefix?=$(HOME) -bindir=$(prefix)/bin -mandir=$(prefix)/man -man1=$(mandir)/man1 -INSTALL?=install -doc_conf=../../Documentation/asciidoc.conf --include ../../config.mak - -git-svn: git-svn.perl - cp $< $@ - chmod +x $@ - -install: all - $(INSTALL) -d -m755 $(DESTDIR)$(bindir) - $(INSTALL) git-svn $(DESTDIR)$(bindir) - -install-doc: doc - $(INSTALL) git-svn.1 $(DESTDIR)$(man1) - -doc: git-svn.1 -git-svn.1 : git-svn.xml - xmlto man git-svn.xml -git-svn.xml : git-svn.txt - asciidoc -b docbook -d manpage \ - -f ../../Documentation/asciidoc.conf $< -git-svn.html : git-svn.txt - asciidoc -b xhtml11 -d manpage \ - -f ../../Documentation/asciidoc.conf $< -test: git-svn - cd t && for i in t????-*.sh; do $(SHELL) ./$$i $(TEST_FLAGS); done - -# we can test NO_OPTIMIZE_COMMITS independently of LC_ALL -full-test: - $(MAKE) test GIT_SVN_NO_LIB=1 GIT_SVN_NO_OPTIMIZE_COMMITS=1 LC_ALL=C - $(MAKE) test GIT_SVN_NO_LIB=0 GIT_SVN_NO_OPTIMIZE_COMMITS=1 LC_ALL=C - $(MAKE) test GIT_SVN_NO_LIB=1 GIT_SVN_NO_OPTIMIZE_COMMITS=0 \ - LC_ALL=en_US.UTF-8 - $(MAKE) test GIT_SVN_NO_LIB=0 GIT_SVN_NO_OPTIMIZE_COMMITS=0 \ - LC_ALL=en_US.UTF-8 - -clean: - rm -f git-svn *.xml *.html *.1 diff --git a/contrib/git-svn/t/lib-git-svn.sh b/contrib/git-svn/t/lib-git-svn.sh deleted file mode 100644 index d7f972a0c8..0000000000 --- a/contrib/git-svn/t/lib-git-svn.sh +++ /dev/null @@ -1,45 +0,0 @@ -PATH=$PWD/../:$PATH -if test -d ../../../t -then - cd ../../../t -else - echo "Must be run in contrib/git-svn/t" >&2 - exit 1 -fi - -. ./test-lib.sh - -GIT_DIR=$PWD/.git -GIT_SVN_DIR=$GIT_DIR/svn/git-svn -SVN_TREE=$GIT_SVN_DIR/svn-tree - -svnadmin >/dev/null 2>&1 -if test $? != 1 -then - test_expect_success 'skipping contrib/git-svn test' : - test_done - exit -fi - -svn >/dev/null 2>&1 -if test $? != 1 -then - test_expect_success 'skipping contrib/git-svn test' : - test_done - exit -fi - -svnrepo=$PWD/svnrepo - -set -e - -if svnadmin create --help | grep fs-type >/dev/null -then - svnadmin create --fs-type fsfs "$svnrepo" -else - svnadmin create "$svnrepo" -fi - -svnrepo="file://$svnrepo/test-git-svn" - - diff --git a/convert-objects.c b/convert-objects.c index 0fabd8981c..ebea8e472b 100644 --- a/convert-objects.c +++ b/convert-objects.c @@ -240,14 +240,14 @@ static void convert_date(void *buffer, unsigned long size, unsigned char *result { char *new = xmalloc(size + 100); unsigned long newlen = 0; - - // "tree <sha1>\n" + + /* "tree <sha1>\n" */ memcpy(new + newlen, buffer, 46); newlen += 46; buffer = (char *) buffer + 46; size -= 46; - // "parent <sha1>\n" + /* "parent <sha1>\n" */ while (!memcmp(buffer, "parent ", 7)) { memcpy(new + newlen, buffer, 48); newlen += 48; @@ -255,12 +255,12 @@ static void convert_date(void *buffer, unsigned long size, unsigned char *result size -= 48; } - // "author xyz <xyz> date" + /* "author xyz <xyz> date" */ newlen += convert_date_line(new + newlen, &buffer, &size); - // "committer xyz <xyz> date" + /* "committer xyz <xyz> date" */ newlen += convert_date_line(new + newlen, &buffer, &size); - // Rest + /* Rest */ memcpy(new + newlen, buffer, size); newlen += size; diff --git a/diff-delta.c b/diff-delta.c index 8b9172aa2e..7da9205a5d 100644 --- a/diff-delta.c +++ b/diff-delta.c @@ -148,7 +148,7 @@ struct delta_index * create_delta_index(const void *buf, unsigned long bufsize) return NULL; /* Determine index hash size. Note that indexing skips the - first byte to allow for optimizing the rabin polynomial + first byte to allow for optimizing the Rabin's polynomial initialization in create_delta(). */ entries = (bufsize - 1) / RABIN_WINDOW; hsize = entries / 4; @@ -205,7 +205,7 @@ struct delta_index * create_delta_index(const void *buf, unsigned long bufsize) /* * Determine a limit on the number of entries in the same hash - * bucket. This guard us against patological data sets causing + * bucket. This guards us against pathological data sets causing * really bad hash distribution with most entries in the same hash * bucket that would bring us to O(m*n) computing costs (m and n * corresponding to reference and target buffer sizes). @@ -240,7 +240,7 @@ void free_delta_index(struct delta_index *index) /* * The maximum size for any opcode sequence, including the initial header - * plus rabin window plus biggest copy. + * plus Rabin window plus biggest copy. */ #define MAX_OP_SIZE (5 + 5 + 1 + RABIN_WINDOW + 7) @@ -13,6 +13,7 @@ static int use_size_cache; +static int diff_detect_rename_default = 0; static int diff_rename_limit_default = -1; static int diff_use_color_default = 0; @@ -43,12 +44,12 @@ enum color_diff { #define COLOR_WHITE "\033[37m" static const char *diff_colors[] = { - [DIFF_RESET] = COLOR_RESET, - [DIFF_PLAIN] = COLOR_NORMAL, - [DIFF_METAINFO] = COLOR_BOLD, - [DIFF_FRAGINFO] = COLOR_CYAN, - [DIFF_FILE_OLD] = COLOR_RED, - [DIFF_FILE_NEW] = COLOR_GREEN, + COLOR_RESET, + COLOR_NORMAL, + COLOR_BOLD, + COLOR_CYAN, + COLOR_RED, + COLOR_GREEN }; static int parse_diff_color_slot(const char *var, int ofs) @@ -101,7 +102,13 @@ static const char *parse_diff_color_value(const char *value, const char *var) die("bad config value '%s' for variable '%s'", value, var); } -int git_diff_config(const char *var, const char *value) +/* + * These are to give UI layer defaults. + * The core-level commands such as git-diff-files should + * never be affected by the setting of diff.renames + * the user happens to have in the configuration file. + */ +int git_diff_ui_config(const char *var, const char *value) { if (!strcmp(var, "diff.renamelimit")) { diff_rename_limit_default = git_config_int(var, value); @@ -112,7 +119,7 @@ int git_diff_config(const char *var, const char *value) diff_use_color_default = 1; /* bool */ else if (!strcasecmp(value, "auto")) { diff_use_color_default = 0; - if (isatty(1)) { + if (isatty(1) || pager_in_use) { char *term = getenv("TERM"); if (term && strcmp(term, "dumb")) diff_use_color_default = 1; @@ -126,6 +133,16 @@ int git_diff_config(const char *var, const char *value) diff_use_color_default = git_config_bool(var, value); return 0; } + if (!strcmp(var, "diff.renames")) { + if (!value) + diff_detect_rename_default = DIFF_DETECT_RENAME; + else if (!strcasecmp(value, "copies") || + !strcasecmp(value, "copy")) + diff_detect_rename_default = DIFF_DETECT_COPY; + else if (git_config_bool(var,value)) + diff_detect_rename_default = DIFF_DETECT_RENAME; + return 0; + } if (!strncmp(var, "diff.color.", 11)) { int slot = parse_diff_color_slot(var, 11); diff_colors[slot] = parse_diff_color_value(value, var); @@ -1437,6 +1454,7 @@ void diff_setup(struct diff_options *options) options->change = diff_change; options->add_remove = diff_addremove; options->color_diff = diff_use_color_default; + options->detect_rename = diff_detect_rename_default; } int diff_setup_done(struct diff_options *options) @@ -1619,10 +1637,14 @@ int diff_opt_parse(struct diff_options *options, const char **av, int ac) } else if (!strcmp(arg, "--color")) options->color_diff = 1; + else if (!strcmp(arg, "--no-color")) + options->color_diff = 0; else if (!strcmp(arg, "-w") || !strcmp(arg, "--ignore-all-space")) options->xdl_opts |= XDF_IGNORE_WHITESPACE; else if (!strcmp(arg, "-b") || !strcmp(arg, "--ignore-space-change")) options->xdl_opts |= XDF_IGNORE_WHITESPACE_CHANGE; + else if (!strcmp(arg, "--no-renames")) + options->detect_rename = 0; else return 0; return 1; @@ -123,7 +123,7 @@ extern int diff_scoreopt_parse(const char *opt); #define DIFF_SETUP_USE_CACHE 2 #define DIFF_SETUP_USE_SIZE_CACHE 4 -extern int git_diff_config(const char *var, const char *value); +extern int git_diff_ui_config(const char *var, const char *value); extern void diff_setup(struct diff_options *); extern int diff_opt_parse(struct diff_options *, const char **, int); extern int diff_setup_done(struct diff_options *); diff --git a/diffcore-rename.c b/diffcore-rename.c index d57e8656cd..1de8d32502 100644 --- a/diffcore-rename.c +++ b/diffcore-rename.c @@ -96,11 +96,15 @@ static struct diff_rename_src *register_rename_src(struct diff_filespec *one, return &(rename_src[first]); } -static int is_exact_match(struct diff_filespec *src, struct diff_filespec *dst) +static int is_exact_match(struct diff_filespec *src, + struct diff_filespec *dst, + int contents_too) { if (src->sha1_valid && dst->sha1_valid && !memcmp(src->sha1, dst->sha1, 20)) return 1; + if (!contents_too) + return 0; if (diff_populate_filespec(src, 1) || diff_populate_filespec(dst, 1)) return 0; if (src->size != dst->size) @@ -242,7 +246,7 @@ void diffcore_rename(struct diff_options *options) struct diff_queue_struct *q = &diff_queued_diff; struct diff_queue_struct outq; struct diff_score *mx; - int i, j, rename_count; + int i, j, rename_count, contents_too; int num_create, num_src, dst_cnt; if (!minimum_score) @@ -273,16 +277,23 @@ void diffcore_rename(struct diff_options *options) /* We really want to cull the candidates list early * with cheap tests in order to avoid doing deltas. + * The first round matches up the up-to-date entries, + * and then during the second round we try to match + * cache-dirty entries as well. */ - for (i = 0; i < rename_dst_nr; i++) { - struct diff_filespec *two = rename_dst[i].two; - for (j = 0; j < rename_src_nr; j++) { - struct diff_filespec *one = rename_src[j].one; - if (!is_exact_match(one, two)) - continue; - record_rename_pair(i, j, MAX_SCORE); - rename_count++; - break; /* we are done with this entry */ + for (contents_too = 0; contents_too < 2; contents_too++) { + for (i = 0; i < rename_dst_nr; i++) { + struct diff_filespec *two = rename_dst[i].two; + if (rename_dst[i].pair) + continue; /* dealt with an earlier round */ + for (j = 0; j < rename_src_nr; j++) { + struct diff_filespec *one = rename_src[j].one; + if (!is_exact_match(one, two, contents_too)) + continue; + record_rename_pair(i, j, MAX_SCORE); + rename_count++; + break; /* we are done with this entry */ + } } } @@ -336,7 +336,7 @@ static int read_directory_recursive(struct dir_struct *dir, const char *path, co if (dir->show_other_directories && (subdir || !dir->hide_empty_directories) && !dir_exists(fullname, baselen + len)) { - // Rewind the read subdirectory + /* Rewind the read subdirectory */ while (dir->nr > rewind_base) free(dir->entries[--dir->nr]); break; diff --git a/environment.c b/environment.c index 43823ff7d6..97d42b172b 100644 --- a/environment.c +++ b/environment.c @@ -21,6 +21,7 @@ char git_commit_encoding[MAX_ENCODING_LENGTH] = "utf-8"; int shared_repository = PERM_UMASK; const char *apply_default_whitespace = NULL; int zlib_compression_level = Z_DEFAULT_COMPRESSION; +int pager_in_use; static char *git_dir, *git_object_dir, *git_index_file, *git_refs_dir, *git_graft_file; diff --git a/fetch-clone.c b/fetch-clone.c index c16b0c481b..81d1371296 100644 --- a/fetch-clone.c +++ b/fetch-clone.c @@ -198,8 +198,8 @@ int receive_unpack_pack(int xd[2], const char *me, int quiet, int sideband) /* * A "binary msec" is a power-of-two-msec, aka 1/1024th of a second. - * Keeing the time in that format means that "bytes / msecs" means - * is the same as kB/s (modulo rounding). + * Keeping the time in that format means that "bytes / msecs" means + * the same as kB/s (modulo rounding). * * 1000512 is a magic number (usecs in a second, rounded up by half * of 1024, to make "rounding" come out right ;) @@ -77,7 +77,7 @@ fall_back_3way () { # This is not so wrong. Depending on which base we picked, # orig_tree may be wildly different from ours, but his_tree # has the same set of wildly different changes in parts the - # patch did not touch, so resolve ends up cancelling them, + # patch did not touch, so resolve ends up canceling them, # saying that we reverted all those changes. git-merge-resolve $orig_tree -- HEAD $his_tree || { diff --git a/git-applypatch.sh b/git-applypatch.sh index e4b09472e1..8df2aee4c2 100755 --- a/git-applypatch.sh +++ b/git-applypatch.sh @@ -182,7 +182,7 @@ git-apply --index "$PATCHFILE" || { # This is not so wrong. Depending on which base we picked, # orig_tree may be wildly different from ours, but his_tree # has the same set of wildly different changes in parts the - # patch did not touch, so resolve ends up cancelling them, + # patch did not touch, so resolve ends up canceling them, # saying that we reverted all those changes. if git-merge-resolve $orig_tree -- HEAD $his_tree diff --git a/git-archimport.perl b/git-archimport.perl index 740bc1fd52..ada60ec240 100755 --- a/git-archimport.perl +++ b/git-archimport.perl @@ -14,7 +14,7 @@ Imports a project from one or more Arch repositories. It will follow branches and repositories within the namespaces defined by the <archive/branch> -parameters suppplied. If it cannot find the remote branch a merge comes from +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. @@ -88,7 +88,7 @@ usage if $opt_h; # $arch_branches: # values associated with keys: # =1 - Arch version / git 'branch' detected via abrowse on a limit -# >1 - Arch version / git 'branch' of an auxilliary branch we've merged +# >1 - Arch version / git 'branch' of an auxiliary branch we've merged my %arch_branches = map { $_ => 1 } @ARGV; $ENV{'TMPDIR'} = $opt_t if $opt_t; # $ENV{TMPDIR} will affect tempdir() calls: @@ -667,7 +667,7 @@ sub apply_cset { if (`find $tmp/changeset/patches -type f -name '*.patch'`) { # this can be sped up considerably by doing # (find | xargs cat) | patch - # but that cna get mucked up by patches + # but that can get mucked up by patches # with missing trailing newlines or the standard # 'missing newline' flag in the patch - possibly # produced with an old/buggy diff. @@ -1026,7 +1026,7 @@ sub commitid2pset { } -# an alterative to `command` that allows input to be passed as an array +# an alternative to `command` that allows input to be passed as an array # to work around shell problems with weird characters in arguments sub safe_pipe_capture { my @output; diff --git a/git-commit.sh b/git-commit.sh index 08d786db2f..802dd7243e 100755 --- a/git-commit.sh +++ b/git-commit.sh @@ -599,7 +599,7 @@ then GIT_AUTHOR_EMAIL=`expr "z$force_author" : '.*\(<.*\)'` && test '' != "$GIT_AUTHOR_NAME" && test '' != "$GIT_AUTHOR_EMAIL" || - die "malformatted --author parameter" + die "malformed --author parameter" export GIT_AUTHOR_NAME GIT_AUTHOR_EMAIL elif test '' != "$use_commit" then @@ -635,9 +635,12 @@ fi PARENTS="-p HEAD" if test -z "$initial_commit" then + rloga='commit' if [ -f "$GIT_DIR/MERGE_HEAD" ]; then + rloga='commit (merge)' PARENTS="-p HEAD "`sed -e 's/^/-p /' "$GIT_DIR/MERGE_HEAD"` elif test -n "$amend"; then + rloga='commit (amend)' PARENTS=$(git-cat-file commit HEAD | sed -n -e '/^$/q' -e 's/^parent /-p /p') fi @@ -649,6 +652,7 @@ else fi PARENTS="" current= + rloga='commit (initial)' fi if test -z "$no_edit" @@ -724,7 +728,7 @@ then fi && commit=$(cat "$GIT_DIR"/COMMIT_MSG | git-commit-tree $tree $PARENTS) && rlogm=$(sed -e 1q "$GIT_DIR"/COMMIT_MSG) && - git-update-ref -m "commit: $rlogm" HEAD $commit $current && + git-update-ref -m "$rloga: $rlogm" HEAD $commit $current && rm -f -- "$GIT_DIR/MERGE_HEAD" && if test -f "$NEXT_INDEX" then diff --git a/git-cvsexportcommit.perl b/git-cvsexportcommit.perl index 5dcb2f9a8e..5d13a54194 100755 --- a/git-cvsexportcommit.perl +++ b/git-cvsexportcommit.perl @@ -179,7 +179,7 @@ my @bfiles = grep(m/^Binary/, safe_pipe_capture('git-diff-tree', '-p', $parent, @bfiles = map { chomp } @bfiles; foreach my $f (@bfiles) { # check that the file in cvs matches the "old" file - # extract the file to $tmpdir and comparre with cmp + # extract the file to $tmpdir and compare with cmp my $tree = safe_pipe_capture('git-rev-parse', "$parent^{tree}"); chomp $tree; my $blob = `git-ls-tree $tree "$f" | cut -f 1 | cut -d ' ' -f 3`; @@ -273,7 +273,7 @@ sub cleanupcvs { } } -# An alterative to `command` that allows input to be passed as an array +# An alternative to `command` that allows input to be passed as an array # to work around shell problems with weird characters in arguments # if the exec returns non-zero we die sub safe_pipe_capture { diff --git a/git-cvsserver.perl b/git-cvsserver.perl index 5ccca4f99f..c30ef70427 100755 --- a/git-cvsserver.perl +++ b/git-cvsserver.perl @@ -779,7 +779,7 @@ sub req_update #$log->debug("update state : " . Dumper($state)); - # foreach file specified on the commandline ... + # foreach file specified on the command line ... foreach my $filename ( @{$state->{args}} ) { $filename = filecleanup($filename); @@ -1031,7 +1031,7 @@ sub req_ci my @committedfiles = (); - # foreach file specified on the commandline ... + # foreach file specified on the command line ... foreach my $filename ( @{$state->{args}} ) { my $committedfile = $filename; @@ -1145,7 +1145,7 @@ sub req_ci $updater->update(); - # foreach file specified on the commandline ... + # foreach file specified on the command line ... foreach my $filename ( @committedfiles ) { $filename = filecleanup($filename); @@ -1190,7 +1190,7 @@ sub req_status # if no files were specified, we need to work out what files we should be providing status on ... argsfromdir($updater); - # foreach file specified on the commandline ... + # foreach file specified on the command line ... foreach my $filename ( @{$state->{args}} ) { $filename = filecleanup($filename); @@ -1291,7 +1291,7 @@ sub req_diff # if no files were specified, we need to work out what files we should be providing status on ... argsfromdir($updater); - # foreach file specified on the commandline ... + # foreach file specified on the command line ... foreach my $filename ( @{$state->{args}} ) { $filename = filecleanup($filename); @@ -1433,7 +1433,7 @@ sub req_log # if no files were specified, we need to work out what files we should be providing status on ... argsfromdir($updater); - # foreach file specified on the commandline ... + # foreach file specified on the command line ... foreach my $filename ( @{$state->{args}} ) { $filename = filecleanup($filename); @@ -1519,7 +1519,7 @@ sub req_annotate chdir $tmpdir; - # foreach file specified on the commandline ... + # foreach file specified on the command line ... foreach my $filename ( @{$state->{args}} ) { $filename = filecleanup($filename); diff --git a/git-fetch.sh b/git-fetch.sh index f80299daaa..ff1769952b 100755 --- a/git-fetch.sh +++ b/git-fetch.sh @@ -11,6 +11,7 @@ LF=' ' IFS="$LF" +rloga=fetch no_tags= tags= append= @@ -51,6 +52,9 @@ do -k|--k|--ke|--kee|--keep) keep=--keep ;; + --reflog-action=*) + rloga=`expr "z$1" : 'z-[^=]*=\(.*\)'` + ;; -*) usage ;; @@ -75,6 +79,9 @@ refs= rref= rsync_slurped_objects= +rloga="$rloga $remote_nick" +test "$remote_nick" = "$remote" || rloga="$rloga $remote" + if test "" = "$append" then : >"$GIT_DIR/FETCH_HEAD" @@ -149,11 +156,12 @@ fast_forward_local () { [ "$verbose" ] && echo >&2 "* $1: same as $3" else echo >&2 "* $1: updating with $3" + git-update-ref -m "$rloga: updating tag" "$1" "$2" fi else echo >&2 "* $1: storing $3" + git-update-ref -m "$rloga: storing tag" "$1" "$2" fi - git-update-ref "$1" "$2" ;; refs/heads/* | refs/remotes/*) @@ -174,7 +182,7 @@ fast_forward_local () { *,$local) echo >&2 "* $1: fast forward to $3" echo >&2 " from $local to $2" - git-update-ref "$1" "$2" "$local" + git-update-ref -m "$rloga: fast-forward" "$1" "$2" "$local" ;; *) false @@ -184,7 +192,7 @@ fast_forward_local () { case ",$force,$single_force," in *,t,*) echo >&2 " forcing update." - git-update-ref "$1" "$2" "$local" + git-update-ref -m "$rloga: forced-update" "$1" "$2" "$local" ;; *) echo >&2 " not updating." @@ -194,7 +202,7 @@ fast_forward_local () { } else echo >&2 "* $1: storing $3" - git-update-ref "$1" "$2" + git-update-ref -m "$rloga: storing head" "$1" "$2" fi ;; esac @@ -422,7 +430,9 @@ case ",$update_head_ok,$orig_head," in curr_head=$(git-rev-parse --verify HEAD 2>/dev/null) if test "$curr_head" != "$orig_head" then - git-update-ref HEAD "$orig_head" + git-update-ref \ + -m "$rloga: Undoing incorrectly fetched HEAD." \ + HEAD "$orig_head" die "Cannot fetch into the current branch." fi ;; diff --git a/git-instaweb.sh b/git-instaweb.sh index 69aef3c20b..63b18b99f6 100755 --- a/git-instaweb.sh +++ b/git-instaweb.sh @@ -25,7 +25,7 @@ conf=$GIT_DIR/gitweb/httpd.conf # Defaults: -# if installed, it doens't need further configuration (module_path) +# if installed, it doesn't need further configuration (module_path) test -z "$httpd" && httpd='lighttpd -f' # probably the most popular browser among gitweb users diff --git a/git-merge-one-file.sh b/git-merge-one-file.sh index 5619409f1c..fba4b0cb5f 100755 --- a/git-merge-one-file.sh +++ b/git-merge-one-file.sh @@ -8,7 +8,7 @@ # $2 - file in branch1 SHA1 (or empty) # $3 - file in branch2 SHA1 (or empty) # $4 - pathname in repository -# $5 - orignal file mode (or empty) +# $5 - original file mode (or empty) # $6 - file in branch1 mode (or empty) # $7 - file in branch2 mode (or empty) # diff --git a/git-merge-recursive.py b/git-merge-recursive.py index ce8a31fda0..4039435ce4 100755 --- a/git-merge-recursive.py +++ b/git-merge-recursive.py @@ -47,7 +47,7 @@ cacheOnly = False def merge(h1, h2, branch1Name, branch2Name, graph, callDepth=0, ancestor=None): '''Merge the commits h1 and h2, return the resulting virtual - commit object and a flag indicating the cleaness of the merge.''' + commit object and a flag indicating the cleanness of the merge.''' assert(isinstance(h1, Commit) and isinstance(h2, Commit)) global outputIndent diff --git a/git-pull.sh b/git-pull.sh index 076785c96b..d337bf4da3 100755 --- a/git-pull.sh +++ b/git-pull.sh @@ -45,7 +45,7 @@ do done orig_head=$(git-rev-parse --verify HEAD) || die "Pulling into a black hole?" -git-fetch --update-head-ok "$@" || exit 1 +git-fetch --update-head-ok --reflog-action=pull "$@" || exit 1 curr_head=$(git-rev-parse --verify HEAD) if test "$curr_head" != "$orig_head" diff --git a/git-push.sh b/git-push.sh index f10cadbf15..21775fc21a 100755 --- a/git-push.sh +++ b/git-push.sh @@ -63,7 +63,7 @@ esac shift ;# away the initial 'x' # $# is now 0 if there was no explicit refspec on the command line -# and there was no defalt refspec to push from remotes/ file. +# and there was no default refspec to push from remotes/ file. # we will let git-send-pack to do its "matching refs" thing. case "$remote" in diff --git a/git-quiltimport.sh b/git-quiltimport.sh index 86b51abd21..364baff806 100755 --- a/git-quiltimport.sh +++ b/git-quiltimport.sh @@ -49,7 +49,7 @@ if [ -n "$quilt_author" ] ; then quilt_author_email=$(expr "z$quilt_author" : '.*<\([^>]*\)') && test '' != "$quilt_author_name" && test '' != "$quilt_author_email" || - die "malformatted --author parameter" + die "malformed --author parameter" fi # Quilt patch directory diff --git a/git-send-email.perl b/git-send-email.perl index c9c1975b7f..a83c7e9094 100755 --- a/git-send-email.perl +++ b/git-send-email.perl @@ -361,7 +361,7 @@ Options: --smtp-server If set, specifies the outgoing SMTP server to use. Defaults to localhost. - --suppress-from Supress sending emails to yourself if your address + --suppress-from Suppress sending emails to yourself if your address appears in a From: line. --quiet Make git-send-email less verbose. One line per email should be @@ -435,7 +435,6 @@ sub send_message To: $to Cc: $cc Subject: $subject -Reply-To: $from Date: $date Message-Id: $message_id X-Mailer: git-send-email $gitversion diff --git a/contrib/git-svn/git-svn.perl b/git-svn.perl index 8bc4188e03..4530ffe42c 100755 --- a/contrib/git-svn/git-svn.perl +++ b/git-svn.perl @@ -8,7 +8,7 @@ use vars qw/ $AUTHOR $VERSION $GIT_SVN_INDEX $GIT_SVN $GIT_DIR $GIT_SVN_DIR $REVDB/; $AUTHOR = 'Eric Wong <normalperson@yhbt.net>'; -$VERSION = '1.1.1-broken'; +$VERSION = '@@GIT_VERSION@@'; use Cwd qw/abs_path/; $GIT_DIR = abs_path($ENV{GIT_DIR} || '.git'); @@ -760,7 +760,7 @@ sub commit_diff { exit 1; } if (defined $_file) { - $_message = file_to_s($_message); + $_message = file_to_s($_file); } else { $_message ||= get_commit_message($tb, "$GIT_DIR/.svn-commit.tmp.$$")->{msg}; @@ -1518,12 +1518,12 @@ sub get_commit_message { open my $msg, '>', $commit_msg or croak $!; chomp(my $type = `git-cat-file -t $commit`); - if ($type eq 'commit') { + if ($type eq 'commit' || $type eq 'tag') { my $pid = open my $msg_fh, '-|'; defined $pid or croak $!; if ($pid == 0) { - exec(qw(git-cat-file commit), $commit) or croak $!; + exec('git-cat-file', $type, $commit) or croak $!; } my $in_msg = 0; while (<$msg_fh>) { @@ -2429,7 +2429,7 @@ sub extract_metadata { \s([a-f\d\-]+)$/x); if (!$rev || !$uuid || !$url) { # some of the original repositories I made had - # indentifiers like this: + # identifiers like this: ($rev, $uuid) = ($id =~/^git-svn-id:\s(\d+)\@([a-f\d\-]+)/); } return ($url, $rev, $uuid); @@ -252,6 +252,11 @@ int main(int argc, const char **argv, char **envp) cmd = *++argv; argc--; + if (!strcmp(cmd, "-p") || !strcmp(cmd, "--paginate")) { + setup_pager(); + continue; + } + if (strncmp(cmd, "--", 2)) break; diff --git a/gitweb/gitweb.cgi b/gitweb/gitweb.cgi index 3e2790c5d6..2fd1e5f78e 100755 --- a/gitweb/gitweb.cgi +++ b/gitweb/gitweb.cgi @@ -22,27 +22,30 @@ our $my_url = $cgi->url(); our $my_uri = $cgi->url(-absolute => 1); our $rss_link = ""; -# location of the git-core binaries -our $gitbin = "/usr/bin"; +# core git executable to use +# this can just be "git" if your webserver has a sensible PATH +our $GIT = "/usr/bin/git"; # absolute fs-path which will be prepended to the project path #our $projectroot = "/pub/scm"; our $projectroot = "/home/kay/public_html/pub/scm"; -# version of the git-core binaries -our $git_version = qx($gitbin/git --version); -if ($git_version =~ m/git version (.*)$/) { - $git_version = $1; -} else { - $git_version = "unknown"; -} +# version of the core git binary +our $git_version = qx($GIT --version) =~ m/git version (.*)$/ ? $1 : "unknown"; # location for temporary files needed for diffs our $git_temp = "/tmp/gitweb"; +if (! -d $git_temp) { + mkdir($git_temp, 0700) || die_error("Couldn't mkdir $git_temp"); +} # target of the home link on top of all pages our $home_link = $my_uri; +# name of your site or organization to appear in page titles +# replace this with something more descriptive for clearer bookmarks +our $site_name = $ENV{'SERVER_NAME'} || "Untitled"; + # html text to include at home page our $home_text = "indextext.html"; @@ -277,7 +280,7 @@ sub git_header_html { my $status = shift || "200 OK"; my $expires = shift; - my $title = "git"; + my $title = "$site_name git"; if (defined $project) { $title .= " - $project"; if (defined $action) { @@ -290,7 +293,17 @@ sub git_header_html { } } } - print $cgi->header(-type=>'text/html', -charset => 'utf-8', -status=> $status, -expires => $expires); + my $content_type; + # require explicit support from the UA if we are to send the page as + # 'application/xhtml+xml', otherwise send it as plain old 'text/html'. + # we have to do this because MSIE sometimes globs '*/*', pretending to + # support xhtml+xml but choking when it gets what it asked for. + if ($cgi->http('HTTP_ACCEPT') =~ m/(,|;|\s|^)application\/xhtml\+xml(,|;|\s|$)/ && $cgi->Accept('application/xhtml+xml') != 0) { + $content_type = 'application/xhtml+xml'; + } else { + $content_type = 'text/html'; + } + print $cgi->header(-type=>$content_type, -charset => 'utf-8', -status=> $status, -expires => $expires); print <<EOF; <?xml version="1.0" encoding="utf-8"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> @@ -298,7 +311,7 @@ sub git_header_html { <!-- git web interface v$version, (C) 2005-2006, Kay Sievers <kay.sievers\@vrfy.org>, Christian Gierke --> <!-- git core binaries version $git_version --> <head> -<meta http-equiv="content-type" content="text/html; charset=utf-8"/> +<meta http-equiv="content-type" content="$content_type; charset=utf-8"/> <meta name="robots" content="index, nofollow"/> <title>$title</title> <link rel="stylesheet" type="text/css" href="$stylesheet"/> @@ -375,7 +388,7 @@ sub die_error { sub git_get_type { my $hash = shift; - open my $fd, "-|", "$gitbin/git-cat-file -t $hash" or return; + open my $fd, "-|", "$GIT cat-file -t $hash" or return; my $type = <$fd>; close $fd or return; chomp $type; @@ -387,7 +400,7 @@ sub git_read_head { my $oENV = $ENV{'GIT_DIR'}; my $retval = undef; $ENV{'GIT_DIR'} = "$projectroot/$project"; - if (open my $fd, "-|", "$gitbin/git-rev-parse", "--verify", "HEAD") { + if (open my $fd, "-|", $GIT, "rev-parse", "--verify", "HEAD") { my $head = <$fd>; close $fd; if (defined $head && $head =~ /^([0-9a-fA-F]{40})$/) { @@ -427,7 +440,7 @@ sub git_read_tag { my %tag; my @comment; - open my $fd, "-|", "$gitbin/git-cat-file tag $tag_id" or return; + open my $fd, "-|", "$GIT cat-file tag $tag_id" or return; $tag{'id'} = $tag_id; while (my $line = <$fd>) { chomp $line; @@ -499,7 +512,7 @@ sub git_read_commit { @commit_lines = @$commit_text; } else { $/ = "\0"; - open my $fd, "-|", "$gitbin/git-rev-list --header --parents --max-count=1 $commit_id" or return; + open my $fd, "-|", "$GIT rev-list --header --parents --max-count=1 $commit_id" or return; @commit_lines = split '\n', <$fd>; close $fd or return; $/ = "\n"; @@ -597,7 +610,7 @@ sub git_diff_print { if (defined $from) { $from_tmp = "$git_temp/gitweb_" . $$ . "_from"; open my $fd2, "> $from_tmp"; - open my $fd, "-|", "$gitbin/git-cat-file blob $from"; + open my $fd, "-|", "$GIT cat-file blob $from"; my @file = <$fd>; print $fd2 @file; close $fd2; @@ -608,7 +621,7 @@ sub git_diff_print { if (defined $to) { $to_tmp = "$git_temp/gitweb_" . $$ . "_to"; open my $fd2, "> $to_tmp"; - open my $fd, "-|", "$gitbin/git-cat-file blob $to"; + open my $fd, "-|", "$GIT cat-file blob $to"; my @file = <$fd>; print $fd2 @file; close $fd2; @@ -827,7 +840,7 @@ sub git_get_project_config { $key =~ s/^gitweb\.//; return if ($key =~ m/\W/); - my $val = qx($gitbin/git-repo-config --get gitweb.$key); + my $val = qx($GIT repo-config --get gitweb.$key); return ($val); } @@ -1049,7 +1062,7 @@ sub git_summary { "<tr><td>owner</td><td>$owner</td></tr>\n" . "<tr><td>last change</td><td>$cd{'rfc2822'}</td></tr>\n" . "</table>\n"; - open my $fd, "-|", "$gitbin/git-rev-list --max-count=17 " . git_read_head($project) or die_error(undef, "Open failed."); + open my $fd, "-|", "$GIT rev-list --max-count=17 " . git_read_head($project) or die_error(undef, "Open failed."); my (@revlist) = map { chomp; $_ } <$fd>; close $fd; print "<div>\n" . @@ -1237,7 +1250,7 @@ sub git_blame { $hash = git_get_hash_by_path($hash_base, $file_name, "blob") or die_error(undef, "Error lookup file."); } - open ($fd, "-|", "$gitbin/git-annotate", '-l', '-t', '-r', $file_name, $hash_base) + open ($fd, "-|", $GIT, "annotate", '-l', '-t', '-r', $file_name, $hash_base) or die_error(undef, "Open failed."); git_header_html(); print "<div class=\"page_nav\">\n" . @@ -1432,7 +1445,7 @@ sub git_get_hash_by_path { my $tree = $base; my @parts = split '/', $path; while (my $part = shift @parts) { - open my $fd, "-|", "$gitbin/git-ls-tree $tree" or die_error(undef, "Open git-ls-tree failed."); + open my $fd, "-|", "$GIT ls-tree $tree" or die_error(undef, "Open git-ls-tree failed."); my (@entries) = map { chomp; $_ } <$fd>; close $fd or return undef; foreach my $line (@entries) { @@ -1455,61 +1468,6 @@ sub git_get_hash_by_path { } } -sub git_blob { - if (!defined $hash && defined $file_name) { - my $base = $hash_base || git_read_head($project); - $hash = git_get_hash_by_path($base, $file_name, "blob") || die_error(undef, "Error lookup file."); - } - my $have_blame = git_get_project_config_bool ('blame'); - open my $fd, "-|", "$gitbin/git-cat-file blob $hash" or die_error(undef, "Open failed."); - git_header_html(); - if (defined $hash_base && (my %co = git_read_commit($hash_base))) { - print "<div class=\"page_nav\">\n" . - $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=summary")}, "summary") . - " | " . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=shortlog")}, "shortlog") . - " | " . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=log")}, "log") . - " | " . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=commit;h=$hash_base")}, "commit") . - " | " . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=commitdiff;h=$hash_base")}, "commitdiff") . - " | " . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=tree;h=$co{'tree'};hb=$hash_base")}, "tree") . "<br/>\n"; - if (defined $file_name) { - if ($have_blame) { - print $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=blame;h=$hash;hb=$hash_base;f=$file_name")}, "blame") . " | "; - } - print $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=blob_plain;h=$hash;f=$file_name")}, "plain") . - " | " . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=blob;hb=HEAD;f=$file_name")}, "head") . "<br/>\n"; - } else { - print $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=blob_plain;h=$hash")}, "plain") . "<br/>\n"; - } - print "</div>\n". - "<div>" . - $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=commit;h=$hash_base"), -class => "title"}, esc_html($co{'title'})) . - "</div>\n"; - } else { - print "<div class=\"page_nav\">\n" . - "<br/><br/></div>\n" . - "<div class=\"title\">$hash</div>\n"; - } - if (defined $file_name) { - print "<div class=\"page_path\"><b>" . esc_html($file_name) . "</b></div>\n"; - } - print "<div class=\"page_body\">\n"; - my $nr; - while (my $line = <$fd>) { - chomp $line; - $nr++; - while ((my $pos = index($line, "\t")) != -1) { - if (my $count = (8 - ($pos % 8))) { - my $spaces = ' ' x $count; - $line =~ s/\t/$spaces/; - } - } - printf "<div class=\"pre\"><a id=\"l%i\" href=\"#l%i\" class=\"linenr\">%4i</a> %s</div>\n", $nr, $nr, $nr, esc_html($line); - } - close $fd or print "Reading blob failed.\n"; - print "</div>"; - git_footer_html(); -} - sub mimetype_guess_file { my $filename = shift; my $mimemap = shift; @@ -1548,14 +1506,14 @@ sub git_blob_plain_mimetype { my $fd = shift; my $filename = shift; - # just in case - return $default_blob_plain_mimetype unless $fd; - if ($filename) { my $mime = mimetype_guess($filename); $mime and return $mime; } + # just in case + return $default_blob_plain_mimetype unless $fd; + if (-T $fd) { return 'text/plain' . ($default_text_plain_charset ? '; charset='.$default_text_plain_charset : ''); @@ -1573,8 +1531,10 @@ sub git_blob_plain_mimetype { } sub git_blob_plain { - open my $fd, "-|", "$gitbin/git-cat-file blob $hash" or return; - my $type = git_blob_plain_mimetype($fd, $file_name); + my $type = shift; + open my $fd, "-|", "$GIT cat-file blob $hash" or die_error("Couldn't cat $file_name, $hash"); + + $type ||= git_blob_plain_mimetype($fd, $file_name); # save as filename, even when no $file_name is given my $save_as = "$hash"; @@ -1593,6 +1553,66 @@ sub git_blob_plain { close $fd; } +sub git_blob { + if (!defined $hash && defined $file_name) { + my $base = $hash_base || git_read_head($project); + $hash = git_get_hash_by_path($base, $file_name, "blob") || die_error(undef, "Error lookup file."); + } + my $have_blame = git_get_project_config_bool ('blame'); + open my $fd, "-|", "$GIT cat-file blob $hash" or die_error(undef, "Open failed."); + my $mimetype = git_blob_plain_mimetype($fd, $file_name); + if ($mimetype !~ m/^text\//) { + close $fd; + return git_blob_plain($mimetype); + } + git_header_html(); + if (defined $hash_base && (my %co = git_read_commit($hash_base))) { + print "<div class=\"page_nav\">\n" . + $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=summary")}, "summary") . + " | " . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=shortlog")}, "shortlog") . + " | " . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=log")}, "log") . + " | " . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=commit;h=$hash_base")}, "commit") . + " | " . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=commitdiff;h=$hash_base")}, "commitdiff") . + " | " . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=tree;h=$co{'tree'};hb=$hash_base")}, "tree") . "<br/>\n"; + if (defined $file_name) { + if ($have_blame) { + print $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=blame;h=$hash;hb=$hash_base;f=$file_name")}, "blame") . " | "; + } + print $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=blob_plain;h=$hash;f=$file_name")}, "plain") . + " | " . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=blob;hb=HEAD;f=$file_name")}, "head") . "<br/>\n"; + } else { + print $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=blob_plain;h=$hash")}, "plain") . "<br/>\n"; + } + print "</div>\n". + "<div>" . + $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=commit;h=$hash_base"), -class => "title"}, esc_html($co{'title'})) . + "</div>\n"; + } else { + print "<div class=\"page_nav\">\n" . + "<br/><br/></div>\n" . + "<div class=\"title\">$hash</div>\n"; + } + if (defined $file_name) { + print "<div class=\"page_path\"><b>" . esc_html($file_name) . "</b></div>\n"; + } + print "<div class=\"page_body\">\n"; + my $nr; + while (my $line = <$fd>) { + chomp $line; + $nr++; + while ((my $pos = index($line, "\t")) != -1) { + if (my $count = (8 - ($pos % 8))) { + my $spaces = ' ' x $count; + $line =~ s/\t/$spaces/; + } + } + printf "<div class=\"pre\"><a id=\"l%i\" href=\"#l%i\" class=\"linenr\">%4i</a> %s</div>\n", $nr, $nr, $nr, esc_html($line); + } + close $fd or print "Reading blob failed.\n"; + print "</div>"; + git_footer_html(); +} + sub git_tree { if (!defined $hash) { $hash = git_read_head($project); @@ -1605,7 +1625,7 @@ sub git_tree { } } $/ = "\0"; - open my $fd, "-|", "$gitbin/git-ls-tree -z $hash" or die_error(undef, "Open git-ls-tree failed."); + open my $fd, "-|", "$GIT ls-tree -z $hash" or die_error(undef, "Open git-ls-tree failed."); chomp (my (@entries) = <$fd>); close $fd or die_error(undef, "Reading tree failed."); $/ = "\n"; @@ -1668,6 +1688,7 @@ sub git_tree { $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=blob;h=$t_hash$base_key;f=$base$t_name")}, "blob") . # " | " . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=blame;h=$t_hash$base_key;f=$base$t_name")}, "blame") . " | " . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=history;h=$hash_base;f=$base$t_name")}, "history") . + " | " . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=blob_plain;h=$t_hash;f=$base$t_name")}, "raw") . "</td>\n"; } elsif ($t_type eq "tree") { print "<td class=\"list\">" . @@ -1687,7 +1708,7 @@ sub git_tree { sub git_rss { # http://www.notestips.com/80256B3A007F2692/1/NAMO5P9UPQ - open my $fd, "-|", "$gitbin/git-rev-list --max-count=150 " . git_read_head($project) or die_error(undef, "Open failed."); + open my $fd, "-|", "$GIT rev-list --max-count=150 " . git_read_head($project) or die_error(undef, "Open failed."); my (@revlist) = map { chomp; $_ } <$fd>; close $fd or die_error(undef, "Reading rev-list failed."); print $cgi->header(-type => 'text/xml', -charset => 'utf-8'); @@ -1707,7 +1728,7 @@ sub git_rss { last; } my %cd = date_str($co{'committer_epoch'}); - open $fd, "-|", "$gitbin/git-diff-tree -r $co{'parent'} $co{'id'}" or next; + open $fd, "-|", "$GIT diff-tree -r $co{'parent'} $co{'id'}" or next; my @difftree = map { chomp; $_ } <$fd>; close $fd or next; print "<item>\n" . @@ -1749,7 +1770,7 @@ sub git_opml { print "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n". "<opml version=\"1.0\">\n". "<head>". - " <title>Git OPML Export</title>\n". + " <title>$site_name Git OPML Export</title>\n". "</head>\n". "<body>\n". "<outline text=\"git RSS feeds\">\n"; @@ -1795,7 +1816,7 @@ sub git_log { " | " . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=tree;h=$hash;hb=$hash")}, "tree") . "<br/>\n"; my $limit = sprintf("--max-count=%i", (100 * ($page+1))); - open my $fd, "-|", "$gitbin/git-rev-list $limit $hash" or die_error(undef, "Open failed."); + open my $fd, "-|", "$GIT rev-list $limit $hash" or die_error(undef, "Open failed."); my (@revlist) = map { chomp; $_ } <$fd>; close $fd; @@ -1886,7 +1907,7 @@ sub git_commit { $root = " --root"; $parent = ""; } - open my $fd, "-|", "$gitbin/git-diff-tree -r -M $root $parent $hash" or die_error(undef, "Open failed."); + open my $fd, "-|", "$GIT diff-tree -r -M $root $parent $hash" or die_error(undef, "Open failed."); @difftree = map { chomp; $_ } <$fd>; close $fd or die_error(undef, "Reading diff-tree failed."); @@ -2128,7 +2149,7 @@ sub git_commitdiff { if (!defined $hash_parent) { $hash_parent = $co{'parent'}; } - open my $fd, "-|", "$gitbin/git-diff-tree -r $hash_parent $hash" or die_error(undef, "Open failed."); + open my $fd, "-|", "$GIT diff-tree -r $hash_parent $hash" or die_error(undef, "Open failed."); my (@difftree) = map { chomp; $_ } <$fd>; close $fd or die_error(undef, "Reading diff-tree failed."); @@ -2218,14 +2239,14 @@ sub git_commitdiff { sub git_commitdiff_plain { mkdir($git_temp, 0700); - open my $fd, "-|", "$gitbin/git-diff-tree -r $hash_parent $hash" or die_error(undef, "Open failed."); + open my $fd, "-|", "$GIT diff-tree -r $hash_parent $hash" or die_error(undef, "Open failed."); my (@difftree) = map { chomp; $_ } <$fd>; close $fd or die_error(undef, "Reading diff-tree failed."); # try to figure out the next tag after this commit my $tagname; my $refs = read_info_ref("tags"); - open $fd, "-|", "$gitbin/git-rev-list HEAD"; + open $fd, "-|", "$GIT rev-list HEAD"; chomp (my (@commits) = <$fd>); close $fd; foreach my $commit (@commits) { @@ -2296,7 +2317,7 @@ sub git_history { print "<div class=\"page_path\"><b>/" . esc_html($file_name) . "</b><br/></div>\n"; open my $fd, "-|", - "$gitbin/git-rev-list --full-history $hash -- \'$file_name\'"; + "$GIT rev-list --full-history $hash -- \'$file_name\'"; print "<table cellspacing=\"0\">\n"; my $alternate = 0; while (my $line = <$fd>) { @@ -2383,7 +2404,7 @@ sub git_search { my $alternate = 0; if ($commit_search) { $/ = "\0"; - open my $fd, "-|", "$gitbin/git-rev-list --header --parents $hash" or next; + open my $fd, "-|", "$GIT rev-list --header --parents $hash" or next; while (my $commit_text = <$fd>) { if (!grep m/$searchtext/i, $commit_text) { next; @@ -2433,7 +2454,7 @@ sub git_search { if ($pickaxe_search) { $/ = "\n"; - open my $fd, "-|", "$gitbin/git-rev-list $hash | $gitbin/git-diff-tree -r --stdin -S\'$searchtext\'"; + open my $fd, "-|", "$GIT rev-list $hash | $GIT diff-tree -r --stdin -S\'$searchtext\'"; undef %co; my @files; while (my $line = <$fd>) { @@ -2504,7 +2525,7 @@ sub git_shortlog { " | " . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=tree;h=$hash;hb=$hash")}, "tree") . "<br/>\n"; my $limit = sprintf("--max-count=%i", (100 * ($page+1))); - open my $fd, "-|", "$gitbin/git-rev-list $limit $hash" or die_error(undef, "Open failed."); + open my $fd, "-|", "$GIT rev-list $limit $hash" or die_error(undef, "Open failed."); my (@revlist) = map { chomp; $_ } <$fd>; close $fd; diff --git a/http-fetch.c b/http-fetch.c index 44eba5fd0d..12493fbed2 100644 --- a/http-fetch.c +++ b/http-fetch.c @@ -490,7 +490,7 @@ static int setup_index(struct alt_base *repo, unsigned char *sha1) { struct packed_git *new_pack; if (has_pack_file(sha1)) - return 0; // don't list this as something we can get + return 0; /* don't list this as something we can get */ if (fetch_index(repo, sha1)) return -1; @@ -570,7 +570,7 @@ static void process_alternates_response(void *callback_data) base[serverlen - 1] != '/'); i += 3; } - // If the server got removed, give up. + /* If the server got removed, give up. */ okay = strchr(base, ':') - base + 3 < serverlen; } else if (alt_req->http_specific) { @@ -581,7 +581,7 @@ static void process_alternates_response(void *callback_data) okay = 1; } } - // skip 'objects' at end + /* skip 'objects' at end */ if (okay) { target = xmalloc(serverlen + posn - i - 6); strlcpy(target, base, serverlen); diff --git a/merge-file.c b/merge-file.c new file mode 100644 index 0000000000..f32c653825 --- /dev/null +++ b/merge-file.c @@ -0,0 +1,166 @@ +#include "cache.h" +#include "run-command.h" +#include "xdiff-interface.h" +#include "blob.h" + +static void rm_temp_file(const char *filename) +{ + unlink(filename); + free((void *)filename); +} + +static const char *write_temp_file(mmfile_t *f) +{ + int fd; + const char *tmp = getenv("TMPDIR"); + char *filename; + + if (!tmp) + tmp = "/tmp"; + filename = mkpath("%s/%s", tmp, "git-tmp-XXXXXX"); + fd = mkstemp(filename); + if (fd < 0) + return NULL; + filename = strdup(filename); + if (f->size != xwrite(fd, f->ptr, f->size)) { + rm_temp_file(filename); + return NULL; + } + close(fd); + return filename; +} + +static void *read_temp_file(const char *filename, unsigned long *size) +{ + struct stat st; + char *buf = NULL; + int fd = open(filename, O_RDONLY); + if (fd < 0) + return NULL; + if (!fstat(fd, &st)) { + *size = st.st_size; + buf = xmalloc(st.st_size); + if (st.st_size != xread(fd, buf, st.st_size)) { + free(buf); + buf = NULL; + } + } + close(fd); + return buf; +} + +static int fill_mmfile_blob(mmfile_t *f, struct blob *obj) +{ + void *buf; + unsigned long size; + char type[20]; + + buf = read_sha1_file(obj->object.sha1, type, &size); + if (!buf) + return -1; + if (strcmp(type, blob_type)) + return -1; + f->ptr = buf; + f->size = size; + return 0; +} + +static void free_mmfile(mmfile_t *f) +{ + free(f->ptr); +} + +static void *three_way_filemerge(mmfile_t *base, mmfile_t *our, mmfile_t *their, unsigned long *size) +{ + void *res; + const char *t1, *t2, *t3; + + t1 = write_temp_file(base); + t2 = write_temp_file(our); + t3 = write_temp_file(their); + res = NULL; + if (t1 && t2 && t3) { + int code = run_command("merge", t2, t1, t3, NULL); + if (!code || code == -1) + res = read_temp_file(t2, size); + } + rm_temp_file(t1); + rm_temp_file(t2); + rm_temp_file(t3); + return res; +} + +static int common_outf(void *priv_, mmbuffer_t *mb, int nbuf) +{ + int i; + mmfile_t *dst = priv_; + + for (i = 0; i < nbuf; i++) { + memcpy(dst->ptr + dst->size, mb[i].ptr, mb[i].size); + dst->size += mb[i].size; + } + return 0; +} + +static int generate_common_file(mmfile_t *res, mmfile_t *f1, mmfile_t *f2) +{ + unsigned long size = f1->size < f2->size ? f1->size : f2->size; + void *ptr = xmalloc(size); + xpparam_t xpp; + xdemitconf_t xecfg; + xdemitcb_t ecb; + + xpp.flags = XDF_NEED_MINIMAL; + xecfg.ctxlen = 3; + xecfg.flags = XDL_EMIT_COMMON; + ecb.outf = common_outf; + + res->ptr = ptr; + res->size = 0; + + ecb.priv = res; + return xdl_diff(f1, f2, &xpp, &xecfg, &ecb); +} + +void *merge_file(struct blob *base, struct blob *our, struct blob *their, unsigned long *size) +{ + void *res = NULL; + mmfile_t f1, f2, common; + + /* + * Removed in either branch? + * + * NOTE! This depends on the caller having done the + * proper warning about removing a file that got + * modified in the other branch! + */ + if (!our || !their) { + char type[20]; + if (base) + return NULL; + if (!our) + our = their; + return read_sha1_file(our->object.sha1, type, size); + } + + if (fill_mmfile_blob(&f1, our) < 0) + goto out_no_mmfile; + if (fill_mmfile_blob(&f2, their) < 0) + goto out_free_f1; + + if (base) { + if (fill_mmfile_blob(&common, base) < 0) + goto out_free_f2_f1; + } else { + if (generate_common_file(&common, &f1, &f2) < 0) + goto out_free_f2_f1; + } + res = three_way_filemerge(&common, &f1, &f2, size); + free_mmfile(&common); +out_free_f2_f1: + free_mmfile(&f2); +out_free_f1: + free_mmfile(&f1); +out_no_mmfile: + return res; +} diff --git a/merge-tree.c b/merge-tree.c index 9dcaab7a85..7cf00be6d5 100644 --- a/merge-tree.c +++ b/merge-tree.c @@ -1,11 +1,152 @@ #include "cache.h" #include "tree-walk.h" +#include "xdiff-interface.h" +#include "blob.h" static const char merge_tree_usage[] = "git-merge-tree <base-tree> <branch1> <branch2>"; static int resolve_directories = 1; +struct merge_list { + struct merge_list *next; + struct merge_list *link; /* other stages for this object */ + + unsigned int stage : 2, + flags : 30; + unsigned int mode; + const char *path; + struct blob *blob; +}; + +static struct merge_list *merge_result, **merge_result_end = &merge_result; + +static void add_merge_entry(struct merge_list *entry) +{ + *merge_result_end = entry; + merge_result_end = &entry->next; +} + static void merge_trees(struct tree_desc t[3], const char *base); +static const char *explanation(struct merge_list *entry) +{ + switch (entry->stage) { + case 0: + return "merged"; + case 3: + return "added in remote"; + case 2: + if (entry->link) + return "added in both"; + return "added in local"; + } + + /* Existed in base */ + entry = entry->link; + if (!entry) + return "removed in both"; + + if (entry->link) + return "changed in both"; + + if (entry->stage == 3) + return "removed in local"; + return "removed in remote"; +} + +extern void *merge_file(struct blob *, struct blob *, struct blob *, unsigned long *); + +static void *result(struct merge_list *entry, unsigned long *size) +{ + char type[20]; + struct blob *base, *our, *their; + + if (!entry->stage) + return read_sha1_file(entry->blob->object.sha1, type, size); + base = NULL; + if (entry->stage == 1) { + base = entry->blob; + entry = entry->link; + } + our = NULL; + if (entry && entry->stage == 2) { + our = entry->blob; + entry = entry->link; + } + their = NULL; + if (entry) + their = entry->blob; + return merge_file(base, our, their, size); +} + +static void *origin(struct merge_list *entry, unsigned long *size) +{ + char type[20]; + while (entry) { + if (entry->stage == 2) + return read_sha1_file(entry->blob->object.sha1, type, size); + entry = entry->link; + } + return NULL; +} + +static int show_outf(void *priv_, mmbuffer_t *mb, int nbuf) +{ + int i; + for (i = 0; i < nbuf; i++) + printf("%.*s", (int) mb[i].size, mb[i].ptr); + return 0; +} + +static void show_diff(struct merge_list *entry) +{ + unsigned long size; + mmfile_t src, dst; + xpparam_t xpp; + xdemitconf_t xecfg; + xdemitcb_t ecb; + + xpp.flags = XDF_NEED_MINIMAL; + xecfg.ctxlen = 3; + xecfg.flags = 0; + ecb.outf = show_outf; + ecb.priv = NULL; + + src.ptr = origin(entry, &size); + if (!src.ptr) + size = 0; + src.size = size; + dst.ptr = result(entry, &size); + if (!dst.ptr) + size = 0; + dst.size = size; + xdl_diff(&src, &dst, &xpp, &xecfg, &ecb); + free(src.ptr); + free(dst.ptr); +} + +static void show_result_list(struct merge_list *entry) +{ + printf("%s\n", explanation(entry)); + do { + struct merge_list *link = entry->link; + static const char *desc[4] = { "result", "base", "our", "their" }; + printf(" %-6s %o %s %s\n", desc[entry->stage], entry->mode, sha1_to_hex(entry->blob->object.sha1), entry->path); + entry = link; + } while (entry); +} + +static void show_result(void) +{ + struct merge_list *walk; + + walk = merge_result; + while (walk) { + show_result_list(walk); + show_diff(walk); + walk = walk->next; + } +} + /* An empty entry never compares same, not even to another empty entry */ static int same_entry(struct name_entry *a, struct name_entry *b) { @@ -15,24 +156,34 @@ static int same_entry(struct name_entry *a, struct name_entry *b) a->mode == b->mode; } -static const char *sha1_to_hex_zero(const unsigned char *sha1) +static struct merge_list *create_entry(unsigned stage, unsigned mode, const unsigned char *sha1, const char *path) { - if (sha1) - return sha1_to_hex(sha1); - return "0000000000000000000000000000000000000000"; + struct merge_list *res = xmalloc(sizeof(*res)); + + memset(res, 0, sizeof(*res)); + res->stage = stage; + res->path = path; + res->mode = mode; + res->blob = lookup_blob(sha1); + return res; } static void resolve(const char *base, struct name_entry *branch1, struct name_entry *result) { + struct merge_list *orig, *final; + const char *path; + /* If it's already branch1, don't bother showing it */ if (!branch1) return; - printf("0 %06o->%06o %s->%s %s%s\n", - branch1->mode, result->mode, - sha1_to_hex_zero(branch1->sha1), - sha1_to_hex_zero(result->sha1), - base, result->path); + path = strdup(mkpath("%s%s", base, result->path)); + orig = create_entry(2, branch1->mode, branch1->sha1, path); + final = create_entry(0, result->mode, result->sha1, path); + + final->link = orig; + + add_merge_entry(final); } static int unresolved_directory(const char *base, struct name_entry n[3]) @@ -71,16 +222,40 @@ static int unresolved_directory(const char *base, struct name_entry n[3]) return 1; } + +static struct merge_list *link_entry(unsigned stage, const char *base, struct name_entry *n, struct merge_list *entry) +{ + const char *path; + struct merge_list *link; + + if (!n->mode) + return entry; + if (entry) + path = entry->path; + else + path = strdup(mkpath("%s%s", base, n->path)); + link = create_entry(stage, n->mode, n->sha1, path); + link->link = entry; + return link; +} + static void unresolved(const char *base, struct name_entry n[3]) { + struct merge_list *entry = NULL; + if (unresolved_directory(base, n)) return; - if (n[0].sha1) - printf("1 %06o %s %s%s\n", n[0].mode, sha1_to_hex(n[0].sha1), base, n[0].path); - if (n[1].sha1) - printf("2 %06o %s %s%s\n", n[1].mode, sha1_to_hex(n[1].sha1), base, n[1].path); - if (n[2].sha1) - printf("3 %06o %s %s%s\n", n[2].mode, sha1_to_hex(n[2].sha1), base, n[2].path); + + /* + * Do them in reverse order so that the resulting link + * list has the stages in order - link_entry adds new + * links at the front. + */ + entry = link_entry(3, base, n + 2, entry); + entry = link_entry(2, base, n + 1, entry); + entry = link_entry(1, base, n + 0, entry); + + add_merge_entry(entry); } /* @@ -172,5 +347,7 @@ int main(int argc, char **argv) free(buf1); free(buf2); free(buf3); + + show_result(); return 0; } @@ -17,7 +17,7 @@ * in that size, you're doing something wrong. */ -// Some random size +/* Some random size */ #define MAXSIZE (8192) /* @@ -123,7 +123,8 @@ int main(int argc, char **argv) die("could not read from stdin"); } - // Verify it for some basic sanity: it needs to start with "object <sha1>\ntype\ntagger " + /* Verify it for some basic sanity: it needs to start with + "object <sha1>\ntype\ntagger " */ if (verify_tag(buffer, size) < 0) die("invalid tag signature file"); diff --git a/name-rev.c b/name-rev.c index 6a23f2d8a2..083d067e17 100644 --- a/name-rev.c +++ b/name-rev.c @@ -5,7 +5,7 @@ #include "refs.h" static const char name_rev_usage[] = - "git-name-rev [--tags] ( --all | --stdin | commitish [commitish...] )\n"; + "git-name-rev [--tags] ( --all | --stdin | committish [committish...] )\n"; typedef struct rev_name { const char *tip_name; diff --git a/pack-objects.c b/pack-objects.c index b486ea528a..04a48b925b 100644 --- a/pack-objects.c +++ b/pack-objects.c @@ -28,7 +28,7 @@ struct object_entry { struct object_entry *delta; /* delta base object */ struct packed_git *in_pack; /* already in pack */ unsigned int in_pack_offset; - struct object_entry *delta_child; /* delitified objects who bases me */ + struct object_entry *delta_child; /* deltified objects who bases me */ struct object_entry *delta_sibling; /* other deltified objects who * uses the same base as me */ @@ -39,7 +39,7 @@ struct object_entry { }; /* - * Objects we are going to pack are colected in objects array (dynamically + * Objects we are going to pack are collected in objects array (dynamically * expanded). nr_objects & nr_alloc controls this array. They are stored * in the order we see -- typically rev-list --objects order that gives us * nice "minimum seek" order. @@ -24,6 +24,8 @@ void setup_pager(void) else if (!*pager || !strcmp(pager, "cat")) return; + pager_in_use = 1; /* means we are emitting to terminal */ + if (pipe(fd) < 0) return; pid = fork(); diff --git a/ppc/sha1ppc.S b/ppc/sha1ppc.S index f591d98b3f..140cb53370 100644 --- a/ppc/sha1ppc.S +++ b/ppc/sha1ppc.S @@ -62,7 +62,7 @@ * computation of W[t+4]. * * The first 16 rounds use W values loaded directly from memory, while the - * remianing 64 use values computed from those first 16. We preload + * remaining 64 use values computed from those first 16. We preload * 4 values before starting, so there are three kinds of rounds: * - The first 12 (all f0) also load the W values from memory. * - The next 64 compute W(i+4) in parallel. 8*f0, 20*f1, 20*f2, 16*f1. diff --git a/read-cache.c b/read-cache.c index 3c32aae7e8..a50d3612c8 100644 --- a/read-cache.c +++ b/read-cache.c @@ -748,7 +748,7 @@ int read_cache(void) die("index file open failed (%s)", strerror(errno)); } - size = 0; // avoid gcc warning + size = 0; /* avoid gcc warning */ map = MAP_FAILED; if (!fstat(fd, &st)) { size = st.st_size; @@ -362,7 +362,7 @@ static int log_ref_write(struct ref_lock *lock, int logfd, written, oflags = O_APPEND | O_WRONLY; unsigned maxlen, len; char *logrec; - const char *comitter; + const char *committer; if (log_all_ref_updates) { if (safe_create_leading_directories(lock->log_file) < 0) @@ -379,24 +379,23 @@ static int log_ref_write(struct ref_lock *lock, lock->log_file, strerror(errno)); } - setup_ident(); - comitter = git_committer_info(1); + committer = git_committer_info(1); if (msg) { - maxlen = strlen(comitter) + strlen(msg) + 2*40 + 5; + maxlen = strlen(committer) + strlen(msg) + 2*40 + 5; logrec = xmalloc(maxlen); len = snprintf(logrec, maxlen, "%s %s %s\t%s\n", sha1_to_hex(lock->old_sha1), sha1_to_hex(sha1), - comitter, + committer, msg); } else { - maxlen = strlen(comitter) + 2*40 + 4; + maxlen = strlen(committer) + 2*40 + 4; logrec = xmalloc(maxlen); len = snprintf(logrec, maxlen, "%s %s %s\n", sha1_to_hex(lock->old_sha1), sha1_to_hex(sha1), - comitter); + committer); } written = len <= maxlen ? write(logfd, logrec, len) : -1; free(logrec); diff --git a/revision.c b/revision.c index a7750e626b..7df9089f53 100644 --- a/revision.c +++ b/revision.c @@ -549,6 +549,49 @@ static void add_pending_commit_list(struct rev_info *revs, } } +static void prepare_show_merge(struct rev_info *revs) +{ + struct commit_list *bases; + struct commit *head, *other; + unsigned char sha1[20]; + const char **prune = NULL; + int i, prune_num = 1; /* counting terminating NULL */ + + if (get_sha1("HEAD", sha1) || !(head = lookup_commit(sha1))) + die("--merge without HEAD?"); + if (get_sha1("MERGE_HEAD", sha1) || !(other = lookup_commit(sha1))) + die("--merge without MERGE_HEAD?"); + add_pending_object(revs, &head->object, "HEAD"); + add_pending_object(revs, &other->object, "MERGE_HEAD"); + bases = get_merge_bases(head, other, 1); + while (bases) { + struct commit *it = bases->item; + struct commit_list *n = bases->next; + free(bases); + bases = n; + it->object.flags |= UNINTERESTING; + add_pending_object(revs, &it->object, "(merge-base)"); + } + + if (!active_nr) + read_cache(); + for (i = 0; i < active_nr; i++) { + struct cache_entry *ce = active_cache[i]; + if (!ce_stage(ce)) + continue; + if (ce_path_match(ce, revs->prune_data)) { + prune_num++; + prune = xrealloc(prune, sizeof(*prune) * prune_num); + prune[prune_num-2] = ce->name; + prune[prune_num-1] = NULL; + } + while ((i+1 < active_nr) && + ce_same_name(ce, active_cache[i+1])) + i++; + } + revs->prune_data = prune; +} + /* * Parse revision information, filling in the "rev_info" structure, * and removing the used arguments from the argument list. @@ -558,7 +601,7 @@ static void add_pending_commit_list(struct rev_info *revs, */ int setup_revisions(int argc, const char **argv, struct rev_info *revs, const char *def) { - int i, flags, seen_dashdash; + int i, flags, seen_dashdash, show_merge; const char **unrecognized = argv + 1; int left = 1; @@ -575,7 +618,7 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, const ch break; } - flags = 0; + flags = show_merge = 0; for (i = 1; i < argc; i++) { struct object *object; const char *arg = argv[i]; @@ -642,6 +685,10 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, const ch def = argv[i]; continue; } + if (!strcmp(arg, "--merge")) { + show_merge = 1; + continue; + } if (!strcmp(arg, "--topo-order")) { revs->topo_order = 1; continue; @@ -863,6 +910,8 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, const ch object = get_reference(revs, arg, sha1, flags ^ local_flags); add_pending_object(revs, object, arg); } + if (show_merge) + prepare_show_merge(revs); if (def && !revs->pending.nr) { unsigned char sha1[20]; struct object *object; diff --git a/server-info.c b/server-info.c index 0eb5132cc1..fdfe05a2da 100644 --- a/server-info.c +++ b/server-info.c @@ -94,7 +94,7 @@ static int read_pack_info_file(const char *infofile) fp = fopen(infofile, "r"); if (!fp) - return 1; /* nonexisting is not an error. */ + return 1; /* nonexistent is not an error. */ while (fgets(line, sizeof(line), fp)) { int len = strlen(line); diff --git a/sha1_file.c b/sha1_file.c index bc35808440..8734d501fe 100644 --- a/sha1_file.c +++ b/sha1_file.c @@ -453,7 +453,7 @@ int use_packed_git(struct packed_git *p) { if (!p->pack_size) { struct stat st; - // We created the struct before we had the pack + /* We created the struct before we had the pack */ stat(p->pack_name, &st); if (!S_ISREG(st.st_mode)) die("packfile %s not a regular file", p->pack_name); @@ -684,7 +684,7 @@ static void *map_sha1_file_internal(const unsigned char *sha1, return map; } -int unpack_sha1_header(z_stream *stream, void *map, unsigned long mapsize, void *buffer, unsigned long size) +static int unpack_sha1_header(z_stream *stream, void *map, unsigned long mapsize, void *buffer, unsigned long size) { /* Get the data stream */ memset(stream, 0, sizeof(*stream)); @@ -720,7 +720,7 @@ static void *unpack_sha1_rest(z_stream *stream, void *buffer, unsigned long size * too permissive for what we want to check. So do an anal * object header parse by hand. */ -int parse_sha1_header(char *hdr, char *type, unsigned long *sizep) +static int parse_sha1_header(char *hdr, char *type, unsigned long *sizep) { int i; unsigned long size; @@ -1504,7 +1504,7 @@ static void *repack_object(const unsigned char *sha1, unsigned long *objsize) int hdrlen; void *buf; - // need to unpack and recompress it by itself + /* need to unpack and recompress it by itself */ unpacked = read_packed_sha1(sha1, type, &len); hdrlen = sprintf(hdr, "%s %lu", type, len) + 1; @@ -1660,7 +1660,7 @@ int has_sha1_file(const unsigned char *sha1) /* * reads from fd as long as possible into a supplied buffer of size bytes. - * If neccessary the buffer's size is increased using realloc() + * If necessary the buffer's size is increased using realloc() * * returns 0 if anything went fine and -1 otherwise * diff --git a/ssh-fetch.c b/ssh-fetch.c index 1e59cd2008..28f7fd9174 100644 --- a/ssh-fetch.c +++ b/ssh-fetch.c @@ -68,7 +68,7 @@ int fetch(unsigned char *sha1) struct object_list *temp; if (memcmp(sha1, in_transit->item->sha1, 20)) { - // we must have already fetched it to clean the queue + /* we must have already fetched it to clean the queue */ return has_sha1_file(sha1) ? 0 : -1; } prefetches--; @@ -85,7 +85,7 @@ int fetch(unsigned char *sha1) if (read(fd_in, &remote, 1) < 1) return -1; } - //fprintf(stderr, "Got %d\n", remote); + /* fprintf(stderr, "Got %d\n", remote); */ if (remote < 0) return remote; ret = write_sha1_from_fd(sha1, fd_in, conn_buf, 4096, &conn_buf_posn); diff --git a/t/Makefile b/t/Makefile index 632c55f6d5..89835093fb 100644 --- a/t/Makefile +++ b/t/Makefile @@ -11,6 +11,7 @@ TAR ?= $(TAR) SHELL_PATH_SQ = $(subst ','\'',$(SHELL_PATH)) T = $(wildcard t[0-9][0-9][0-9][0-9]-*.sh) +TSVN = $(wildcard t91[0-9][0-9]-*.sh) ifdef NO_PYTHON GIT_TEST_OPTS += --no-python @@ -24,6 +25,15 @@ $(T): clean: rm -fr trash +# we can test NO_OPTIMIZE_COMMITS independently of LC_ALL +full-svn-test: + $(MAKE) $(TSVN) GIT_SVN_NO_LIB=1 GIT_SVN_NO_OPTIMIZE_COMMITS=1 LC_ALL=C + $(MAKE) $(TSVN) GIT_SVN_NO_LIB=0 GIT_SVN_NO_OPTIMIZE_COMMITS=1 LC_ALL=C + $(MAKE) $(TSVN) GIT_SVN_NO_LIB=1 GIT_SVN_NO_OPTIMIZE_COMMITS=0 \ + LC_ALL=en_US.UTF-8 + $(MAKE) $(TSVN) GIT_SVN_NO_LIB=0 GIT_SVN_NO_OPTIMIZE_COMMITS=0 \ + LC_ALL=en_US.UTF-8 + .PHONY: $(T) clean .NOTPARALLEL: diff --git a/t/annotate-tests.sh b/t/annotate-tests.sh index 1148b0257d..b6a2edd887 100644 --- a/t/annotate-tests.sh +++ b/t/annotate-tests.sh @@ -94,7 +94,7 @@ test_expect_success \ test_expect_success \ 'merge-setup part 4' \ 'echo "evil merge." >>file && - EDITOR=: VISUAL=: git commit -a --amend' + git commit -a --amend' test_expect_success \ 'Two lines blamed on A, one on B, two on B1, one on B2, one on A U Thor' \ diff --git a/t/lib-git-svn.sh b/t/lib-git-svn.sh new file mode 100644 index 0000000000..29a1e72c61 --- /dev/null +++ b/t/lib-git-svn.sh @@ -0,0 +1,50 @@ +. ./test-lib.sh + +if test -n "$NO_SVN_TESTS" +then + test_expect_success 'skipping git-svn tests, NO_SVN_TESTS defined' : + test_done + exit +fi + +GIT_DIR=$PWD/.git +GIT_SVN_DIR=$GIT_DIR/svn/git-svn +SVN_TREE=$GIT_SVN_DIR/svn-tree + +perl -e 'use SVN::Core' >/dev/null 2>&1 +if test $? -ne 0 +then + echo 'Perl SVN libraries not found, tests requiring those will be skipped' + GIT_SVN_NO_LIB=1 +fi + +svnadmin >/dev/null 2>&1 +if test $? -ne 1 +then + test_expect_success 'skipping git-svn tests, svnadmin not found' : + test_done + exit +fi + +svn >/dev/null 2>&1 +if test $? -ne 1 +then + test_expect_success 'skipping git-svn tests, svn not found' : + test_done + exit +fi + +svnrepo=$PWD/svnrepo + +set -e + +if svnadmin create --help | grep fs-type >/dev/null +then + svnadmin create --fs-type fsfs "$svnrepo" +else + svnadmin create "$svnrepo" +fi + +svnrepo="file://$svnrepo/test-git-svn" + + diff --git a/t/t1400-update-ref.sh b/t/t1400-update-ref.sh index df3e993365..04fab26621 100755 --- a/t/t1400-update-ref.sh +++ b/t/t1400-update-ref.sh @@ -188,17 +188,29 @@ test_expect_success \ echo OTHER >F && GIT_AUTHOR_DATE="2005-05-26 23:41" \ GIT_COMMITTER_DATE="2005-05-26 23:41" git-commit -F M -a && - h_OTHER=$(git-rev-parse --verify HEAD) + h_OTHER=$(git-rev-parse --verify HEAD) && + echo FIXED >F && + GIT_AUTHOR_DATE="2005-05-26 23:44" \ + GIT_COMMITTER_DATE="2005-05-26 23:44" git-commit --amend && + h_FIXED=$(git-rev-parse --verify HEAD) && + echo TEST+FIXED >F && + echo Merged initial commit and a later commit. >M && + echo $h_TEST >.git/MERGE_HEAD && + GIT_AUTHOR_DATE="2005-05-26 23:45" \ + GIT_COMMITTER_DATE="2005-05-26 23:45" git-commit -F M && + h_MERGED=$(git-rev-parse --verify HEAD) rm -f M' cat >expect <<EOF -$Z $h_TEST $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117150200 +0000 commit: add +$Z $h_TEST $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117150200 +0000 commit (initial): add $h_TEST $h_OTHER $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117150860 +0000 commit: The other day this did not work. +$h_OTHER $h_FIXED $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117151040 +0000 commit (amend): The other day this did not work. +$h_FIXED $h_MERGED $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117151100 +0000 commit (merge): Merged initial commit and a later commit. EOF test_expect_success \ 'git-commit logged updates' \ 'diff expect .git/logs/$m' -unset h_TEST h_OTHER +unset h_TEST h_OTHER h_FIXED h_MERGED test_expect_success \ 'git-cat-file blob master:F (expect OTHER)' \ diff --git a/t/t4013-diff-various.sh b/t/t4013-diff-various.sh index 06837d1c7c..36658fb17d 100755 --- a/t/t4013-diff-various.sh +++ b/t/t4013-diff-various.sh @@ -70,7 +70,7 @@ test_expect_success setup ' for i in 1 2; do echo $i; done >>dir/sub && git update-index file0 dir/sub && - EDITOR=: VISUAL=: git commit --amend && + git commit --amend && git show-branch ' diff --git a/t/t5700-clone-reference.sh b/t/t5700-clone-reference.sh index 916ee15ba1..dd9caad1c2 100755 --- a/t/t5700-clone-reference.sh +++ b/t/t5700-clone-reference.sh @@ -31,7 +31,7 @@ test_expect_success 'cloning with reference' \ cd "$base_dir" -test_expect_success 'existance of info/alternates' \ +test_expect_success 'existence of info/alternates' \ 'test `wc -l <C/.git/objects/info/alternates` = 2' cd "$base_dir" diff --git a/t/t5710-info-alternate.sh b/t/t5710-info-alternate.sh index 097d037f5d..2e1b48a89b 100755 --- a/t/t5710-info-alternate.sh +++ b/t/t5710-info-alternate.sh @@ -81,7 +81,7 @@ test_valid_repo" cd "$base_dir" -test_expect_failure 'that info/alternates is neccessary' \ +test_expect_failure 'that info/alternates is necessary' \ 'cd C && rm .git/objects/info/alternates && test_valid_repo' diff --git a/t/t6002-rev-list-bisect.sh b/t/t6002-rev-list-bisect.sh index 693de9b32d..7831e3461c 100755 --- a/t/t6002-rev-list-bisect.sh +++ b/t/t6002-rev-list-bisect.sh @@ -154,7 +154,7 @@ test_sequence() test_bisection_diff 0 $_bisect_option u5 ^U # -# the following illustrate's Linus' binary bug blatt idea. +# the following illustrates Linus' binary bug blatt idea. # # assume the bug is actually at l3, but you don't know that - all you know is that l3 is broken # and it wasn't broken before diff --git a/t/t6021-merge-criss-cross.sh b/t/t6021-merge-criss-cross.sh index 262381379f..8f7366da8d 100755 --- a/t/t6021-merge-criss-cross.sh +++ b/t/t6021-merge-criss-cross.sh @@ -4,7 +4,7 @@ # # See http://marc.theaimsgroup.com/?l=git&m=111463358500362&w=2 for a -# nice decription of what this is about. +# nice description of what this is about. test_description='Test criss-cross merge' diff --git a/contrib/git-svn/t/t0000-contrib-git-svn.sh b/t/t9100-git-svn-basic.sh index b482bb64c0..bf1d6381d9 100644..100755 --- a/contrib/git-svn/t/t0000-contrib-git-svn.sh +++ b/t/t9100-git-svn-basic.sh @@ -3,7 +3,7 @@ # Copyright (c) 2006 Eric Wong # -test_description='git-svn tests' +test_description='git-svn basic tests' GIT_SVN_LC_ALL=$LC_ALL case "$LC_ALL" in @@ -17,6 +17,8 @@ esac . ./lib-git-svn.sh +echo 'define NO_SVN_TESTS to skip git-svn tests' + mkdir import cd import diff --git a/contrib/git-svn/t/t0001-contrib-git-svn-props.sh b/t/t9101-git-svn-props.sh index a5a235f100..a5a235f100 100644..100755 --- a/contrib/git-svn/t/t0001-contrib-git-svn-props.sh +++ b/t/t9101-git-svn-props.sh diff --git a/contrib/git-svn/t/t0002-deep-rmdir.sh b/t/t9102-git-svn-deep-rmdir.sh index d693d183c8..d693d183c8 100644..100755 --- a/contrib/git-svn/t/t0002-deep-rmdir.sh +++ b/t/t9102-git-svn-deep-rmdir.sh diff --git a/contrib/git-svn/t/t0003-graft-branches.sh b/t/t9103-git-svn-graft-branches.sh index cc62d4ece8..cc62d4ece8 100644..100755 --- a/contrib/git-svn/t/t0003-graft-branches.sh +++ b/t/t9103-git-svn-graft-branches.sh diff --git a/contrib/git-svn/t/t0004-follow-parent.sh b/t/t9104-git-svn-follow-parent.sh index 01488ff78a..01488ff78a 100644..100755 --- a/contrib/git-svn/t/t0004-follow-parent.sh +++ b/t/t9104-git-svn-follow-parent.sh diff --git a/contrib/git-svn/t/t0005-commit-diff.sh b/t/t9105-git-svn-commit-diff.sh index f994b72f80..f994b72f80 100644..100755 --- a/contrib/git-svn/t/t0005-commit-diff.sh +++ b/t/t9105-git-svn-commit-diff.sh diff --git a/t/test-lib.sh b/t/test-lib.sh index 05f6e79560..b0d7990a66 100755 --- a/t/test-lib.sh +++ b/t/test-lib.sh @@ -9,6 +9,8 @@ LC_ALL=C PAGER=cat TZ=UTC export LANG LC_ALL PAGER TZ +EDITOR=: +VISUAL=: unset AUTHOR_DATE unset AUTHOR_EMAIL unset AUTHOR_NAME @@ -30,6 +32,7 @@ unset SHA1_FILE_DIRECTORIES unset SHA1_FILE_DIRECTORY export GIT_AUTHOR_EMAIL GIT_AUTHOR_NAME export GIT_COMMITTER_EMAIL GIT_COMMITTER_NAME +export EDITOR VISUAL # Each test should start with something like this, after copyright notices: # diff --git a/templates/hooks--update b/templates/hooks--update index d7a8f0a849..76d5ac2477 100644 --- a/templates/hooks--update +++ b/templates/hooks--update @@ -60,7 +60,7 @@ then echo "Changes since $prev:" git rev-list --pretty $prev..$3 | $short echo --- - git diff $prev..$3 | diffstat -p1 + git diff --stat $prev..$3 echo --- fi ;; @@ -75,7 +75,7 @@ else base=$(git-merge-base "$2" "$3") case "$base" in "$2") - git diff "$3" "^$base" | diffstat -p1 + git diff --stat "$3" "^$base" echo echo "New commits:" ;; diff --git a/xdiff/xdiff.h b/xdiff/xdiff.h index 2ce10b4c0d..c9f817818a 100644 --- a/xdiff/xdiff.h +++ b/xdiff/xdiff.h @@ -39,6 +39,7 @@ extern "C" { #define XDL_PATCH_IGNOREBSPACE (1 << 8) #define XDL_EMIT_FUNCNAMES (1 << 0) +#define XDL_EMIT_COMMON (1 << 1) #define XDL_MMB_READONLY (1 << 0) diff --git a/xdiff/xdiffi.c b/xdiff/xdiffi.c index ed7ad2041c..d76e76a0e6 100644 --- a/xdiff/xdiffi.c +++ b/xdiff/xdiffi.c @@ -84,7 +84,7 @@ static long xdl_split(unsigned long const *ha1, long off1, long lim1, * We need to extent the diagonal "domain" by one. If the next * values exits the box boundaries we need to change it in the * opposite direction because (max - min) must be a power of two. - * Also we initialize the extenal K value to -1 so that we can + * Also we initialize the external K value to -1 so that we can * avoid extra conditions check inside the core loop. */ if (fmin > dmin) @@ -119,7 +119,7 @@ static long xdl_split(unsigned long const *ha1, long off1, long lim1, * We need to extent the diagonal "domain" by one. If the next * values exits the box boundaries we need to change it in the * opposite direction because (max - min) must be a power of two. - * Also we initialize the extenal K value to -1 so that we can + * Also we initialize the external K value to -1 so that we can * avoid extra conditions check inside the core loop. */ if (bmin > dmin) @@ -405,7 +405,7 @@ static int xdl_change_compact(xdfile_t *xdf, xdfile_t *xdfo, long flags) { /* * This is the same of what GNU diff does. Move back and forward * change groups for a consistent and pretty diff output. This also - * helps in finding joineable change groups and reduce the diff size. + * helps in finding joinable change groups and reduce the diff size. */ for (ix = ixo = 0;;) { /* diff --git a/xdiff/xemit.c b/xdiff/xemit.c index ad5bfb1910..714c563547 100644 --- a/xdiff/xemit.c +++ b/xdiff/xemit.c @@ -100,6 +100,21 @@ static void xdl_find_func(xdfile_t *xf, long i, char *buf, long sz, long *ll) { } +int xdl_emit_common(xdfenv_t *xe, xdchange_t *xscr, xdemitcb_t *ecb, + xdemitconf_t const *xecfg) { + xdfile_t *xdf = &xe->xdf1; + const char *rchg = xdf->rchg; + long ix; + + for (ix = 0; ix < xdf->nrec; ix++) { + if (rchg[ix]) + continue; + if (xdl_emit_record(xdf, ix, "", ecb)) + return -1; + } + return 0; +} + int xdl_emit_diff(xdfenv_t *xe, xdchange_t *xscr, xdemitcb_t *ecb, xdemitconf_t const *xecfg) { long s1, s2, e1, e2, lctx; @@ -107,6 +122,9 @@ int xdl_emit_diff(xdfenv_t *xe, xdchange_t *xscr, xdemitcb_t *ecb, char funcbuf[40]; long funclen = 0; + if (xecfg->flags & XDL_EMIT_COMMON) + return xdl_emit_common(xe, xscr, ecb, xecfg); + for (xch = xche = xscr; xch; xch = xche->next) { xche = xdl_get_hunk(xch, xecfg); |