diff options
113 files changed, 1759 insertions, 580 deletions
diff --git a/.gitignore b/.gitignore index 51a37b1af7..f0d2e96b88 100644 --- a/.gitignore +++ b/.gitignore @@ -168,6 +168,7 @@ git.spec *.exe *.[aos] *.py[co] +*+ config.mak autom4te.cache config.cache diff --git a/Documentation/Makefile b/Documentation/Makefile index 06b0c57b95..1c9dfcea5a 100644 --- a/Documentation/Makefile +++ b/Documentation/Makefile @@ -103,6 +103,28 @@ ifdef DOCBOOK_SUPPRESS_SP XMLTO_EXTRA += -m manpage-suppress-sp.xsl endif +# Newer DocBook stylesheet emits warning cruft in the output when +# this is not set, and if set it shows an absolute link. We can +# use MAN_BASE_URL=http://www.kernel.org/pub/software/scm/git/docs/ +# but distros may want to set it to /usr/share/doc/git-core/docs/ or +# something like that. +# +# As older stylesheets simply ignore this parameter, it ought to be +# safe to set it to empty string when the base URL is not specified, +# but unfortunately we cannot do so unconditionally because at least +# xmlto 0.0.18 is reported to lack --stringparam option. +ifdef MAN_BASE_URL +XMLTO_EXTRA += --stringparam man.base.url.for.relative.links=$(MAN_BASE_URL) +endif + +# If your target system uses GNU groff, it may try to render +# apostrophes as a "pretty" apostrophe using unicode. This breaks +# cut&paste, so you should set GNU_ROFF to force them to be ASCII +# apostrophes. Unfortunately does not work with non-GNU roff. +ifdef GNU_ROFF +XMLTO_EXTRA += -m manpage-quote-apos.xsl +endif + SHELL_PATH ?= $(SHELL) # Shell quote; SHELL_PATH_SQ = $(subst ','\'',$(SHELL_PATH)) diff --git a/Documentation/RelNotes-1.6.5.1.txt b/Documentation/RelNotes-1.6.5.1.txt new file mode 100644 index 0000000000..309ba181b2 --- /dev/null +++ b/Documentation/RelNotes-1.6.5.1.txt @@ -0,0 +1,20 @@ +GIT v1.6.5.1 Release Notes +========================== + +Fixes since v1.6.5 +------------------ + + * An corrupt pack could make codepath to read objects into an + infinite loop. + + * Download throughput display was always shown in KiB/s but on fast links + it is more appropriate to show it in MiB/s. + + * "git grep -f filename" used uninitialized variable and segfaulted. + + * "git clone -b branch" gave a wrong commit object name to post-checkout + hook. + + * "git pull" over http did not work on msys. + +Other minor documentation updates are included. diff --git a/Documentation/RelNotes-1.6.5.2.txt b/Documentation/RelNotes-1.6.5.2.txt new file mode 100644 index 0000000000..aa7ccce3a2 --- /dev/null +++ b/Documentation/RelNotes-1.6.5.2.txt @@ -0,0 +1,19 @@ +GIT v1.6.5.2 Release Notes +========================== + +Fixes since v1.6.5.1 +-------------------- + + * Installation of templates triggered a bug in busybox when using tar + implementation from it. + + * "git add -i" incorrectly ignored paths that are already in the index + if they matched .gitignore patterns. + + * "git describe --always" should have produced some output even there + were no tags in the repository, but it didn't. + + * "git ls-files" when showing tracked files incorrectly paid attention + to the exclude patterns. + +Other minor documentation updates are included. diff --git a/Documentation/RelNotes-1.6.5.3.txt b/Documentation/RelNotes-1.6.5.3.txt new file mode 100644 index 0000000000..b2fad1b22e --- /dev/null +++ b/Documentation/RelNotes-1.6.5.3.txt @@ -0,0 +1,63 @@ +Git v1.6.5.3 Release Notes +========================== + +Fixes since v1.6.5.2 +-------------------- + + * info/grafts file didn't ignore trailing CR at the end of lines. + + * Packages generated on newer FC were unreadable by older versions of + RPM as the new default is to use stronger hash. + + * output from "git blame" was unreadable when the file ended in an + incomplete line. + + * "git add -i/-p" didn't handle deletion of empty files correctly. + + * "git clone" takes up to two parameters, but did not complain when + given more arguments than necessary and silently ignored them. + + * "git cvsimport" did not read files given as command line arguments + correctly when it is run from a subdirectory. + + * "git diff --color-words -U0" didn't work correctly. + + * The handling of blank lines at the end of file by "git diff/apply + --whitespace" was inconsistent with the other kinds of errors. + They are now colored, warned against, and fixed the same way as others. + + * There was no way to allow blank lines at the end of file without + allowing extra blanks at the end of lines. You can use blank-at-eof + and blank-at-eol whitespace error class to specify them separately. + The old trailing-space error class is now a short-hand to set both. + + * "-p" option to "git format-patch" was supposed to suppress diffstat + generation, but it was broken since 1.6.1. + + * "git imap-send" did not compile cleanly with newer OpenSSL. + + * "git help -a" outside of a git repository was broken. + + * "git ls-files -i" was supposed to be inverse of "git ls-files" without -i + with respect to exclude patterns, but it was broken since 1.6.5.2. + + * "git ls-remote" outside of a git repository over http was broken. + + * "git rebase -i" gave bogus error message when the command word was + misspelled. + + * "git receive-pack" that is run in response to "git push" did not run + garbage collection nor update-server-info, but in larger hosting sites, + these almost always need to be run. To help site administrators, the + command now runs "gc --auto" and "u-s-i" by setting receive.autogc + and receive.updateserverinfo configuration variables, respectively. + + * Release notes spelled the package name with incorrect capitalization. + + * "gitweb" did not escape non-ascii characters correctly in the URL. + + * "gitweb" showed "patch" link even for merge commits. + + * "gitweb" showed incorrect links for blob line numbers in pathinfo mode. + +Other minor documentation updates are included. diff --git a/Documentation/RelNotes-1.6.5.4.txt b/Documentation/RelNotes-1.6.5.4.txt new file mode 100644 index 0000000000..e42f8b2397 --- /dev/null +++ b/Documentation/RelNotes-1.6.5.4.txt @@ -0,0 +1,32 @@ +Git v1.6.5.4 Release Notes +========================== + +Fixes since v1.6.5.3 +-------------------- + + * "git help" (without argument) used to check if you are in a directory + under git control. There was no breakage in behaviour per-se, but this + was unnecessary. + + * "git prune-packed" gave progress output even when its standard error is + not connected to a terminal; this caused cron jobs that run it to + produce crufts. + + * "git pack-objects --all-progress" is an option to ask progress output + from write-object phase _if_ progress output were to be produced, and + shouldn't have forced the progress output. + + * "git apply -p<n> --directory=<elsewhere>" did not work well for a + non-default value of n. + + * "git merge foo HEAD" was misparsed as an old-style invocation of the + command and produced a confusing error message. As it does not specify + any other branch to merge, it shouldn't be mistaken as such. We will + remove the old style "git merge <message> HEAD <commit>..." syntax in + future versions, but not in this release, + + * "git merge -m <message> <branch>..." added the standard merge message + on its own after user-supplied message, which should have overrided the + standard one. + +Other minor documentation updates are included. diff --git a/Documentation/config.txt b/Documentation/config.txt index cd1781498e..35e72e4a38 100644 --- a/Documentation/config.txt +++ b/Documentation/config.txt @@ -169,9 +169,10 @@ core.autocrlf:: writing to the filesystem. The variable can be set to 'input', in which case the conversion happens only while reading from the filesystem but files are written out with - `LF` at the end of lines. Currently, which paths to consider - "text" (i.e. be subjected to the autocrlf mechanism) is - decided purely based on the contents. + `LF` at the end of lines. A file is considered + "text" (i.e. be subjected to the autocrlf mechanism) based on + the file's `crlf` attribute, or if `crlf` is unspecified, + based on the file's contents. See linkgit:gitattributes[5]. core.safecrlf:: If true, makes git check if converting `CRLF` as controlled by @@ -380,8 +381,9 @@ Common unit suffixes of 'k', 'm', or 'g' are supported. core.excludesfile:: In addition to '.gitignore' (per-directory) and '.git/info/exclude', git looks into this file for patterns - of files which are not meant to be tracked. See - linkgit:gitignore[5]. + of files which are not meant to be tracked. "{tilde}/" is expanded + to the value of `$HOME` and "{tilde}user/" to the specified user's + home directory. See linkgit:gitignore[5]. core.editor:: Commands such as `commit` and `tag` that lets you edit @@ -416,13 +418,17 @@ core.whitespace:: consider them as errors. You can prefix `-` to disable any of them (e.g. `-trailing-space`): + -* `trailing-space` treats trailing whitespaces at the end of the line +* `blank-at-eol` treats trailing whitespaces at the end of the line as an error (enabled by default). * `space-before-tab` treats a space character that appears immediately before a tab character in the initial indent part of the line as an error (enabled by default). * `indent-with-non-tab` treats a line that is indented with 8 or more space characters as an error (not enabled by default). +* `blank-at-eof` treats blank lines added at the end of file as an error + (enabled by default). +* `trailing-space` is a short-hand to cover both `blank-at-eol` and + `blank-at-eof`. * `cr-at-eol` treats a carriage-return at the end of line as part of the line terminator, i.e. with it, `trailing-space` does not trigger if the character before such a carriage-return @@ -666,6 +672,8 @@ color.ui:: commit.template:: Specify a file to use as the template for new commit messages. + "{tilde}/" is expanded to the value of `$HOME` and "{tilde}user/" to the + specified user's home directory. diff.autorefreshindex:: When using 'git-diff' to compare with work tree @@ -1320,6 +1328,11 @@ rebase.stat:: Whether to show a diffstat of what changed upstream since the last rebase. False by default. +receive.autogc:: + By default, git-receive-pack will run "git-gc --auto" after + receiving data from git-push and updating refs. You can stop + it by setting this variable to false. + receive.fsckObjects:: If it is set to true, git-receive-pack will check all received objects. It will abort in the case of a malformed object or a @@ -1355,6 +1368,10 @@ receive.denyNonFastForwards:: even if that push is forced. This configuration variable is set when initializing a shared repository. +receive.updateserverinfo:: + If set to true, git-receive-pack will run git-update-server-info + after receiving data from git-push and updating refs. + remote.<name>.url:: The URL of a remote repository. See linkgit:git-fetch[1] or linkgit:git-push[1]. diff --git a/Documentation/fetch-options.txt b/Documentation/fetch-options.txt index 5eb2b0ee07..28868747da 100644 --- a/Documentation/fetch-options.txt +++ b/Documentation/fetch-options.txt @@ -1,25 +1,13 @@ -ifndef::git-pull[] --q:: ---quiet:: - Pass --quiet to git-fetch-pack and silence any other internally - used git commands. - --v:: ---verbose:: - Be verbose. -endif::git-pull[] - -a:: --append:: Append ref names and object names of fetched refs to the existing contents of `.git/FETCH_HEAD`. Without this option old data in `.git/FETCH_HEAD` will be overwritten. ---upload-pack <upload-pack>:: - When given, and the repository to fetch from is handled - by 'git-fetch-pack', '--exec=<upload-pack>' is passed to - the command to specify non-default path for the command - run on the other end. +--depth=<depth>:: + Deepen the history of a 'shallow' repository created by + `git clone` with `--depth=<depth>` option (see linkgit:git-clone[1]) + by the specified number of commits. -f:: --force:: @@ -29,6 +17,10 @@ endif::git-pull[] fetches is a descendant of `<lbranch>`. This option overrides that check. +-k:: +--keep:: + Keep downloaded pack. + ifdef::git-pull[] --no-tags:: endif::git-pull[] @@ -49,10 +41,6 @@ endif::git-pull[] flag lets all tags and their associated objects be downloaded. --k:: ---keep:: - Keep downloaded pack. - -u:: --update-head-ok:: By default 'git-fetch' refuses to update the head which @@ -62,7 +50,19 @@ endif::git-pull[] implementing your own Porcelain you are not supposed to use it. ---depth=<depth>:: - Deepen the history of a 'shallow' repository created by - `git clone` with `--depth=<depth>` option (see linkgit:git-clone[1]) - by the specified number of commits. +--upload-pack <upload-pack>:: + When given, and the repository to fetch from is handled + by 'git-fetch-pack', '--exec=<upload-pack>' is passed to + the command to specify non-default path for the command + run on the other end. + +ifndef::git-pull[] +-q:: +--quiet:: + Pass --quiet to git-fetch-pack and silence any other internally + used git commands. + +-v:: +--verbose:: + Be verbose. +endif::git-pull[] diff --git a/Documentation/git-add.txt b/Documentation/git-add.txt index 45ebf87ca3..e93e606f45 100644 --- a/Documentation/git-add.txt +++ b/Documentation/git-add.txt @@ -76,10 +76,10 @@ OPTIONS work tree and add them to the index. This gives the user a chance to review the difference before adding modified contents to the index. - - This effectively runs ``add --interactive``, but bypasses the - initial command menu and directly jumps to `patch` subcommand. - See ``Interactive mode'' for details. ++ +This effectively runs `add --interactive`, but bypasses the +initial command menu and directly jumps to the `patch` subcommand. +See ``Interactive mode'' for details. -e, \--edit:: Open the diff vs. the index in an editor and let the user diff --git a/Documentation/git-bundle.txt b/Documentation/git-bundle.txt index aee7e4a8c9..c3a066e60c 100644 --- a/Documentation/git-bundle.txt +++ b/Documentation/git-bundle.txt @@ -24,7 +24,7 @@ ssh, rsync, http) cannot be used. This command provides support for 'git-fetch' and 'git-pull' to operate by packaging objects and references in an archive at the originating machine, then importing those into another repository using 'git-fetch' and 'git-pull' -after moving the archive by some means (i.e., by sneakernet). As no +after moving the archive by some means (e.g., by sneakernet). As no direct connection between the repositories exists, the user must specify a basis for the bundle that is held by the destination repository: the bundle assumes that all objects in the basis are already in the diff --git a/Documentation/git-check-ref-format.txt b/Documentation/git-check-ref-format.txt index 0b7982ea76..e9b3b40af4 100644 --- a/Documentation/git-check-ref-format.txt +++ b/Documentation/git-check-ref-format.txt @@ -9,7 +9,7 @@ SYNOPSIS -------- [verse] 'git check-ref-format' <refname> -'git check-ref-format' [--branch] <branchname-shorthand> +'git check-ref-format' --branch <branchname-shorthand> DESCRIPTION ----------- @@ -63,8 +63,11 @@ reference name expressions (see linkgit:git-rev-parse[1]): . at-open-brace `@{` is used as a notation to access a reflog entry. -With the `--branch` option, it expands a branch name shorthand and -prints the name of the branch the shorthand refers to. +With the `--branch` option, it expands the ``previous branch syntax'' +`@{-n}`. For example, `@{-1}` is a way to refer the last branch you +were on. This option should be used by porcelains to accept this +syntax anywhere a branch name is expected, so they can act as if you +typed the branch name. EXAMPLE ------- diff --git a/Documentation/git-clone.txt b/Documentation/git-clone.txt index 5ebcba1c7c..7ccd742a87 100644 --- a/Documentation/git-clone.txt +++ b/Documentation/git-clone.txt @@ -11,7 +11,7 @@ SYNOPSIS [verse] 'git clone' [--template=<template_directory>] [-l] [-s] [--no-hardlinks] [-q] [-n] [--bare] [--mirror] - [-o <name>] [-u <upload-pack>] [--reference <repository>] + [-o <name>] [-b <name>] [-u <upload-pack>] [--reference <repository>] [--depth <depth>] [--recursive] [--] <repository> [<directory>] DESCRIPTION @@ -39,7 +39,7 @@ OPTIONS --local:: -l:: When the repository to clone from is on a local machine, - this flag bypasses normal "git aware" transport + this flag bypasses the normal "git aware" transport mechanism and clones the repository by making a copy of HEAD and everything under objects and refs directories. The files under `.git/objects/` directory are hardlinked @@ -60,7 +60,7 @@ OPTIONS -s:: When the repository to clone is on the local machine, instead of using hard links, automatically setup - .git/objects/info/alternates to share the objects + `.git/objects/info/alternates` to share the objects with the source repository. The resulting repository starts out without any object of its own. + @@ -69,7 +69,7 @@ it unless you understand what it does. If you clone your repository using this option and then delete branches (or use any other git command that makes any existing commit unreferenced) in the source repository, some objects may become unreferenced (or dangling). -These objects may be removed by normal git operations (such as 'git-commit') +These objects may be removed by normal git operations (such as `git commit`) which automatically call `git gc --auto`. (See linkgit:git-gc[1].) If these objects are removed and were referenced by the cloned repository, then the cloned repository will become corrupt. @@ -86,13 +86,13 @@ objects from the source repository into a pack in the cloned repository. --reference <repository>:: If the reference repository is on the local machine, - automatically setup .git/objects/info/alternates to + automatically setup `.git/objects/info/alternates` to obtain objects from the reference repository. Using an already existing repository as an alternate will require fewer objects to be copied from the repository being cloned, reducing network and local storage costs. + -*NOTE*: see NOTE to --shared option. +*NOTE*: see the NOTE for the `--shared` option. --quiet:: -q:: @@ -101,7 +101,7 @@ objects from the source repository into a pack in the cloned repository. --verbose:: -v:: - Display the progressbar, even in case the standard output is not + Display the progress bar, even in case the standard output is not a terminal. --no-checkout:: @@ -121,17 +121,17 @@ objects from the source repository into a pack in the cloned repository. configuration variables are created. --mirror:: - Set up a mirror of the remote repository. This implies --bare. + Set up a mirror of the remote repository. This implies `--bare`. --origin <name>:: -o <name>:: - Instead of using the remote name 'origin' to keep track - of the upstream repository, use <name>. + Instead of using the remote name `origin` to keep track + of the upstream repository, use `<name>`. --branch <name>:: -b <name>:: Instead of pointing the newly created HEAD to the branch pointed - to by the cloned repository's HEAD, point to <name> branch + to by the cloned repository's HEAD, point to `<name>` branch instead. In a non-bare repository, this is the branch that will be checked out. @@ -158,7 +158,7 @@ objects from the source repository into a pack in the cloned repository. --recursive:: After the clone is created, initialize all submodules within, using their default settings. This is equivalent to running - 'git submodule update --init --recursive' immediately after + `git submodule update --init --recursive` immediately after the clone is finished. This option is ignored if the cloned repository does not have a worktree/checkout (i.e. if any of `--no-checkout`/`-n`, `--bare`, or `--mirror` is given) @@ -171,8 +171,8 @@ objects from the source repository into a pack in the cloned repository. <directory>:: The name of a new directory to clone into. The "humanish" part of the source repository is used if no directory is - explicitly given ("repo" for "/path/to/repo.git" and "foo" - for "host.xz:foo/.git"). Cloning into an existing directory + explicitly given (`repo` for `/path/to/repo.git` and `foo` + for `host.xz:foo/.git`). Cloning into an existing directory is only allowed if the directory is empty. :git-clone: 1 diff --git a/Documentation/git-describe.txt b/Documentation/git-describe.txt index b231dbb947..2f97916781 100644 --- a/Documentation/git-describe.txt +++ b/Documentation/git-describe.txt @@ -44,7 +44,9 @@ OPTIONS --abbrev=<n>:: Instead of using the default 7 hexadecimal digits as the - abbreviated object name, use <n> digits. + abbreviated object name, use <n> digits, or as many digits + as needed to form a unique object name. An <n> of 0 + will suppress long format, only showing the closest tag. --candidates=<n>:: Instead of considering only the 10 most recent tags as @@ -68,8 +70,8 @@ OPTIONS This is useful when you want to see parts of the commit object name in "describe" output, even when the commit in question happens to be a tagged version. Instead of just emitting the tag name, it will - describe such a commit as v1.2-0-deadbeef (0th commit since tag v1.2 - that points at object deadbeef....). + describe such a commit as v1.2-0-gdeadbee (0th commit since tag v1.2 + that points at object deadbee....). --match <pattern>:: Only consider tags matching the given pattern (can be used to avoid @@ -108,7 +110,7 @@ the output shows the reference path as well: [torvalds@g5 git]$ git describe --all --abbrev=4 v1.0.5^2 tags/v1.0.0-21-g975b - [torvalds@g5 git]$ git describe --all HEAD^ + [torvalds@g5 git]$ git describe --all --abbrev=4 HEAD^ heads/lt/describe-7-g975b With --abbrev set to 0, the command can be used to find the @@ -117,6 +119,13 @@ closest tagname without any suffix: [torvalds@g5 git]$ git describe --abbrev=0 v1.0.5^2 tags/v1.0.0 +Note that the suffix you get if you type these commands today may be +longer than what Linus saw above when he ran these commands, as your +git repository may have new commits whose object names begin with +975b that did not exist back then, and "-g975b" suffix alone may not +be sufficient to disambiguate these commits. + + SEARCH STRATEGY --------------- diff --git a/Documentation/git-fetch.txt b/Documentation/git-fetch.txt index d3164c5c88..f2483d624e 100644 --- a/Documentation/git-fetch.txt +++ b/Documentation/git-fetch.txt @@ -37,6 +37,35 @@ include::pull-fetch-param.txt[] include::urls-remotes.txt[] + +EXAMPLES +-------- + +* Update the remote-tracking branches: ++ +------------------------------------------------ +$ git fetch origin +------------------------------------------------ ++ +The above command copies all branches from the remote refs/heads/ +namespace and stores them to the local refs/remotes/origin/ namespace, +unless the branch.<name>.fetch option is used to specify a non-default +refspec. + +* Using refspecs explicitly: ++ +------------------------------------------------ +$ git fetch origin +pu:pu maint:tmp +------------------------------------------------ ++ +This updates (or creates, as necessary) branches `pu` and `tmp` in +the local repository by fetching from the branches (respectively) +`pu` and `maint` from the remote repository. ++ +The `pu` branch will be updated even if it is does not fast-forward, +because it is prefixed with a plus sign; `tmp` will not be. + + SEE ALSO -------- linkgit:git-pull[1] diff --git a/Documentation/git-gc.txt b/Documentation/git-gc.txt index 1f6df6ad6b..4cd9cdf905 100644 --- a/Documentation/git-gc.txt +++ b/Documentation/git-gc.txt @@ -120,7 +120,7 @@ Notes particular, it will keep not only objects referenced by your current set of branches and tags, but also objects referenced by the index, remote tracking branches, refs saved by 'git-filter-branch' in -refs/original/, or reflogs (which may references commits in branches +refs/original/, or reflogs (which may reference commits in branches that were later amended or rewound). If you are expecting some objects to be collected and they aren't, check diff --git a/Documentation/git-ls-files.txt b/Documentation/git-ls-files.txt index 021066e95d..625723e41f 100644 --- a/Documentation/git-ls-files.txt +++ b/Documentation/git-ls-files.txt @@ -48,8 +48,10 @@ OPTIONS -i:: --ignored:: - Show ignored files in the output. - Note that this also reverses any exclude list present. + Show only ignored files in the output. When showing files in the + index, print only those matched by an exclude pattern. When + showing "other" files, show only those matched by an exclude + pattern. -s:: --stage:: diff --git a/Documentation/git-merge.txt b/Documentation/git-merge.txt index d05f324462..e886c2ef54 100644 --- a/Documentation/git-merge.txt +++ b/Documentation/git-merge.txt @@ -212,6 +212,39 @@ You can work through the conflict with a number of tools: common ancestor, 'git show :2:filename' shows the HEAD version and 'git show :3:filename' shows the remote version. + +EXAMPLES +-------- + +* Merge branches `fixes` and `enhancements` on top of + the current branch, making an octopus merge: ++ +------------------------------------------------ +$ git merge fixes enhancements +------------------------------------------------ + +* Merge branch `obsolete` into the current branch, using `ours` + merge strategy: ++ +------------------------------------------------ +$ git merge -s ours obsolete +------------------------------------------------ + +* Merge branch `maint` into the current branch, but do not make + a new commit automatically: ++ +------------------------------------------------ +$ git merge --no-commit maint +------------------------------------------------ ++ +This can be used when you want to include further changes to the +merge, or want to write your own merge commit message. ++ +You should refrain from abusing this option to sneak substantial +changes into a merge commit. Small fixups like bumping +release/version name would be acceptable. + + SEE ALSO -------- linkgit:git-fmt-merge-msg[1], linkgit:git-pull[1], diff --git a/Documentation/git-pack-objects.txt b/Documentation/git-pack-objects.txt index 2e4992970e..f54d433d36 100644 --- a/Documentation/git-pack-objects.txt +++ b/Documentation/git-pack-objects.txt @@ -9,8 +9,9 @@ git-pack-objects - Create a packed archive of objects SYNOPSIS -------- [verse] -'git pack-objects' [-q] [--no-reuse-delta] [--delta-base-offset] [--non-empty] - [--local] [--incremental] [--window=N] [--depth=N] [--all-progress] +'git pack-objects' [-q | --progress | --all-progress] [--all-progress-implied] + [--no-reuse-delta] [--delta-base-offset] [--non-empty] + [--local] [--incremental] [--window=N] [--depth=N] [--revs [--unpacked | --all]*] [--stdout | base-name] [--keep-true-parents] < object-list @@ -137,7 +138,7 @@ base-name:: --all-progress:: When --stdout is specified then progress report is - displayed during the object count and deltification phases + displayed during the object count and compression phases but inhibited during the write-out phase. The reason is that in some cases the output stream is directly linked to another command which may wish to display progress @@ -146,6 +147,11 @@ base-name:: report for the write-out phase as well even if --stdout is used. +--all-progress-implied:: + This is used to imply --all-progress whenever progress display + is activated. Unlike --all-progress this flag doesn't actually + force any progress display by itself. + -q:: This flag makes the command not to report its progress on the standard error stream. diff --git a/Documentation/git-pull.txt b/Documentation/git-pull.txt index 7578623edb..b93201158f 100644 --- a/Documentation/git-pull.txt +++ b/Documentation/git-pull.txt @@ -26,6 +26,10 @@ Also note that options meant for 'git-pull' itself and underlying OPTIONS ------- + +Options related to merging +~~~~~~~~~~~~~~~~~~~~~~~~~~ + include::merge-options.txt[] :git-pull: 1 @@ -47,6 +51,9 @@ unless you have read linkgit:git-rebase[1] carefully. --no-rebase:: Override earlier --rebase. +Options related to fetching +~~~~~~~~~~~~~~~~~~~~~~~~~~~ + include::fetch-options.txt[] include::pull-fetch-param.txt[] @@ -131,54 +138,13 @@ $ git pull origin next ------------------------------------------------ + This leaves a copy of `next` temporarily in FETCH_HEAD, but -does not update any remote-tracking branches. - -* Bundle local branch `fixes` and `enhancements` on top of - the current branch, making an Octopus merge: -+ ------------------------------------------------- -$ git pull . fixes enhancements ------------------------------------------------- -+ -This `git pull .` syntax is equivalent to `git merge`. - -* Merge local branch `obsolete` into the current branch, using `ours` - merge strategy: -+ ------------------------------------------------- -$ git pull -s ours . obsolete ------------------------------------------------- - -* Merge local branch `maint` into the current branch, but do not make - a commit automatically: +does not update any remote-tracking branches. Using remote-tracking +branches, the same can be done by invoking fetch and merge: + ------------------------------------------------ -$ git pull --no-commit . maint +$ git fetch origin +$ git merge origin/next ------------------------------------------------ -+ -This can be used when you want to include further changes to the -merge, or want to write your own merge commit message. -+ -You should refrain from abusing this option to sneak substantial -changes into a merge commit. Small fixups like bumping -release/version name would be acceptable. - -* Command line pull of multiple branches from one repository: -+ ------------------------------------------------- -$ git checkout master -$ git fetch origin +pu:pu maint:tmp -$ git pull . tmp ------------------------------------------------- -+ -This updates (or creates, as necessary) branches `pu` and `tmp` in -the local repository by fetching from the branches (respectively) -`pu` and `maint` from the remote repository. -+ -The `pu` branch will be updated even if it is does not fast-forward; -the others will not be. -+ -The final command then merges the newly fetched `tmp` into master. If you tried a pull which resulted in a complex conflicts and diff --git a/Documentation/git-push.txt b/Documentation/git-push.txt index ba6a8a2fb2..37c88953d1 100644 --- a/Documentation/git-push.txt +++ b/Documentation/git-push.txt @@ -138,6 +138,11 @@ useful if you write an alias or script around 'git-push'. --verbose:: Run verbosely. +-q:: +--quiet:: + Suppress all output, including the listing of updated refs, + unless an error occurs. + include::urls-remotes.txt[] OUTPUT diff --git a/Documentation/git-remote.txt b/Documentation/git-remote.txt index 82a3d29673..c272c92d4b 100644 --- a/Documentation/git-remote.txt +++ b/Documentation/git-remote.txt @@ -13,10 +13,10 @@ SYNOPSIS 'git remote add' [-t <branch>] [-m <master>] [-f] [--mirror] <name> <url> 'git remote rename' <old> <new> 'git remote rm' <name> -'git remote set-head' <name> [-a | -d | <branch>] -'git remote show' [-n] <name> +'git remote set-head' <name> (-a | -d | <branch>) +'git remote' [-v | --verbose] 'show' [-n] <name> 'git remote prune' [-n | --dry-run] <name> -'git remote update' [-p | --prune] [group | remote]... +'git remote' [-v | --verbose] 'update' [-p | --prune] [group | remote]... DESCRIPTION ----------- @@ -30,6 +30,7 @@ OPTIONS -v:: --verbose:: Be a little more verbose and show remote url after name. + NOTE: This must be placed between `remote` and `subcommand`. COMMANDS diff --git a/Documentation/git-stash.txt b/Documentation/git-stash.txt index 3f14b727b8..fafe728f89 100644 --- a/Documentation/git-stash.txt +++ b/Documentation/git-stash.txt @@ -78,7 +78,8 @@ stash@{1}: On master: 9cc0589... Add git-stash ---------------------------------------------------------------- + The command takes options applicable to the 'git-log' -command to control what is shown and how. See linkgit:git-log[1]. +command to control what is shown and how. If no options are set, the +default is `-n 10`. See linkgit:git-log[1]. show [<stash>]:: diff --git a/Documentation/git.txt b/Documentation/git.txt index d97aaf5bf8..7aa2edee58 100644 --- a/Documentation/git.txt +++ b/Documentation/git.txt @@ -43,9 +43,13 @@ unreleased) version of git, that is available from 'master' branch of the `git.git` repository. Documentation for older releases are available here: -* link:v1.6.5/git.html[documentation for release 1.6.5] +* link:v1.6.5.4/git.html[documentation for release 1.6.5.4] * release notes for + link:RelNotes-1.6.5.4.txt[1.6.5.4], + link:RelNotes-1.6.5.3.txt[1.6.5.3], + link:RelNotes-1.6.5.2.txt[1.6.5.2], + link:RelNotes-1.6.5.1.txt[1.6.5.1], link:RelNotes-1.6.5.txt[1.6.5]. * link:v1.6.4.4/git.html[documentation for release 1.6.4.4] diff --git a/Documentation/gitattributes.txt b/Documentation/gitattributes.txt index 1195e83b6e..1f472cea59 100644 --- a/Documentation/gitattributes.txt +++ b/Documentation/gitattributes.txt @@ -560,6 +560,16 @@ in the file. E.g. the string `$Format:%H$` will be replaced by the commit hash. +Packing objects +~~~~~~~~~~~~~~~ + +`delta` +^^^^^^^ + +Delta compression will not be attempted for blobs for paths with the +attribute `delta` set to false. + + Viewing files in GUI tools ~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/Documentation/gitcore-tutorial.txt b/Documentation/gitcore-tutorial.txt index b3640c4e64..0382d2c0ad 100644 --- a/Documentation/gitcore-tutorial.txt +++ b/Documentation/gitcore-tutorial.txt @@ -602,7 +602,7 @@ $ git tag -s <tagname> ---------------- which will sign the current `HEAD` (but you can also give it another -argument that specifies the thing to tag, i.e., you could have tagged the +argument that specifies the thing to tag, e.g., you could have tagged the current `mybranch` point by using `git tag <tagname> mybranch`). You normally only do signed tags for major releases or things diff --git a/Documentation/gitworkflows.txt b/Documentation/gitworkflows.txt index 2b021e3c15..91c0eea890 100644 --- a/Documentation/gitworkflows.txt +++ b/Documentation/gitworkflows.txt @@ -209,6 +209,121 @@ chance to see if their in-progress work will be compatible. `git.git` has such an official throw-away integration branch called 'pu'. +Branch management for a release +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Assuming you are using the merge approach discussed above, when you +are releasing your project you will need to do some additional branch +management work. + +A feature release is created from the 'master' branch, since 'master' +tracks the commits that should go into the next feature release. + +The 'master' branch is supposed to be a superset of 'maint'. If this +condition does not hold, then 'maint' contains some commits that +are not included on 'master'. The fixes represented by those commits +will therefore not be included in your feature release. + +To verify that 'master' is indeed a superset of 'maint', use git log: + +.Verify 'master' is a superset of 'maint' +[caption="Recipe: "] +===================================== +git log master..maint +===================================== + +This command should not list any commits. Otherwise, check out +'master' and merge 'maint' into it. + +Now you can proceed with the creation of the feature release. Apply a +tag to the tip of 'master' indicating the release version: + +.Release tagging +[caption="Recipe: "] +===================================== +`git tag -s -m "GIT X.Y.Z" vX.Y.Z master` +===================================== + +You need to push the new tag to a public git server (see +"DISTRIBUTED WORKFLOWS" below). This makes the tag available to +others tracking your project. The push could also trigger a +post-update hook to perform release-related items such as building +release tarballs and preformatted documentation pages. + +Similarly, for a maintenance release, 'maint' is tracking the commits +to be released. Therefore, in the steps above simply tag and push +'maint' rather than 'master'. + + +Maintenance branch management after a feature release +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +After a feature release, you need to manage your maintenance branches. + +First, if you wish to continue to release maintenance fixes for the +feature release made before the recent one, then you must create +another branch to track commits for that previous release. + +To do this, the current maintenance branch is copied to another branch +named with the previous release version number (e.g. maint-X.Y.(Z-1) +where X.Y.Z is the current release). + +.Copy maint +[caption="Recipe: "] +===================================== +`git branch maint-X.Y.(Z-1) maint` +===================================== + +The 'maint' branch should now be fast-forwarded to the newly released +code so that maintenance fixes can be tracked for the current release: + +.Update maint to new release +[caption="Recipe: "] +===================================== +* `git checkout maint` +* `git merge --ff-only master` +===================================== + +If the merge fails because it is not a fast-forward, then it is +possible some fixes on 'maint' were missed in the feature release. +This will not happen if the content of the branches was verified as +described in the previous section. + + +Branch management for next and pu after a feature release +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +After a feature release, the integration branch 'next' may optionally be +rewound and rebuilt from the tip of 'master' using the surviving +topics on 'next': + +.Rewind and rebuild next +[caption="Recipe: "] +===================================== +* `git checkout next` +* `git reset --hard master` +* `git merge ai/topic_in_next1` +* `git merge ai/topic_in_next2` +* ... +===================================== + +The advantage of doing this is that the history of 'next' will be +clean. For example, some topics merged into 'next' may have initially +looked promising, but were later found to be undesirable or premature. +In such a case, the topic is reverted out of 'next' but the fact +remains in the history that it was once merged and reverted. By +recreating 'next', you give another incarnation of such topics a clean +slate to retry, and a feature release is a good point in history to do +so. + +If you do this, then you should make a public announcement indicating +that 'next' was rewound and rebuilt. + +The same rewind and rebuild process may be followed for 'pu'. A public +announcement is not necessary since 'pu' is a throw-away branch, as +described above. + + DISTRIBUTED WORKFLOWS --------------------- diff --git a/Documentation/manpage-quote-apos.xsl b/Documentation/manpage-quote-apos.xsl new file mode 100644 index 0000000000..aeb8839f33 --- /dev/null +++ b/Documentation/manpage-quote-apos.xsl @@ -0,0 +1,16 @@ +<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" + version="1.0"> + +<!-- work around newer groff/man setups using a prettier apostrophe + that unfortunately does not quote anything when cut&pasting + examples to the shell --> +<xsl:template name="escape.apostrophe"> + <xsl:param name="content"/> + <xsl:call-template name="string.subst"> + <xsl:with-param name="string" select="$content"/> + <xsl:with-param name="target">'</xsl:with-param> + <xsl:with-param name="replacement">\(aq</xsl:with-param> + </xsl:call-template> +</xsl:template> + +</xsl:stylesheet> diff --git a/Documentation/merge-options.txt b/Documentation/merge-options.txt index adadf8e4bf..48d04a5d88 100644 --- a/Documentation/merge-options.txt +++ b/Documentation/merge-options.txt @@ -1,43 +1,42 @@ --q:: ---quiet:: - Operate quietly. - --v:: ---verbose:: - Be verbose. - ---stat:: - Show a diffstat at the end of the merge. The diffstat is also - controlled by the configuration option merge.stat. - --n:: ---no-stat:: - Do not show a diffstat at the end of the merge. +--commit:: +--no-commit:: + Perform the merge and commit the result. This option can + be used to override --no-commit. ++ +With --no-commit perform the merge but pretend the merge +failed and do not autocommit, to give the user a chance to +inspect and further tweak the merge result before committing. ---summary:: ---no-summary:: - Synonyms to --stat and --no-stat; these are deprecated and will be - removed in the future. +--ff:: +--no-ff:: + Do not generate a merge commit if the merge resolved as + a fast-forward, only update the branch pointer. This is + the default behavior of git-merge. ++ +With --no-ff Generate a merge commit even if the merge +resolved as a fast-forward. --log:: +--no-log:: In addition to branch names, populate the log message with one-line descriptions from the actual commits that are being merged. ++ +With --no-log do not list one-line descriptions from the +actual commits being merged. ---no-log:: - Do not list one-line descriptions from the actual commits being - merged. - ---no-commit:: - Perform the merge but pretend the merge failed and do - not autocommit, to give the user a chance to inspect and - further tweak the merge result before committing. ---commit:: - Perform the merge and commit the result. This option can - be used to override --no-commit. +--stat:: +-n:: +--no-stat:: + Show a diffstat at the end of the merge. The diffstat is also + controlled by the configuration option merge.stat. ++ +With -n or --no-stat do not show a diffstat at the end of the +merge. --squash:: +--no-squash:: Produce the working tree and index state as if a real merge happened (except for the merge information), but do not actually make a commit or @@ -46,19 +45,9 @@ commit. This allows you to create a single commit on top of the current branch whose effect is the same as merging another branch (or more in case of an octopus). - ---no-squash:: - Perform the merge and commit the result. This option can - be used to override --squash. - ---no-ff:: - Generate a merge commit even if the merge resolved as a - fast-forward. - ---ff:: - Do not generate a merge commit if the merge resolved as - a fast-forward, only update the branch pointer. This is - the default behavior of git-merge. ++ +With --no-squash perform the merge and commit the result. This +option can be used to override --squash. -s <strategy>:: --strategy=<strategy>:: @@ -67,3 +56,16 @@ If there is no `-s` option, a built-in list of strategies is used instead ('git-merge-recursive' when merging a single head, 'git-merge-octopus' otherwise). + +--summary:: +--no-summary:: + Synonyms to --stat and --no-stat; these are deprecated and will be + removed in the future. + +-q:: +--quiet:: + Operate quietly. + +-v:: +--verbose:: + Be verbose. diff --git a/Documentation/technical/api-history-graph.txt b/Documentation/technical/api-history-graph.txt index d66e61b1ec..d6fc90ac7e 100644 --- a/Documentation/technical/api-history-graph.txt +++ b/Documentation/technical/api-history-graph.txt @@ -11,9 +11,6 @@ Core functions: * `graph_init()` creates a new `struct git_graph` -* `graph_release()` destroys a `struct git_graph`, and frees the memory - associated with it. - * `graph_update()` moves the graph to a new commit. * `graph_next_line()` outputs the next line of the graph into a strbuf. It @@ -134,8 +131,6 @@ while ((commit = get_revision(opts)) != NULL) { putchar(opts->diffopt.line_termination); } } - -graph_release(graph); ------------ Sample output diff --git a/GIT-VERSION-GEN b/GIT-VERSION-GEN index 08e6073f33..6b4f708c0d 100755 --- a/GIT-VERSION-GEN +++ b/GIT-VERSION-GEN @@ -1,7 +1,7 @@ #!/bin/sh GVF=GIT-VERSION-FILE -DEF_VER=v1.6.5 +DEF_VER=v1.6.5.4 LF=' ' @@ -159,6 +159,10 @@ all:: # Define ASCIIDOC_NO_ROFF if your DocBook XSL escapes raw roff directives # (versions 1.72 and later and 1.68.1 and earlier). # +# Define GNU_ROFF if your target system uses GNU groff. This forces +# apostrophes to be ASCII so that cut&pasting examples to the shell +# will work. +# # Define NO_PERL_MAKEMAKER if you cannot use Makefiles generated by perl's # MakeMaker (e.g. using ActiveState under Cygwin). # @@ -412,6 +416,7 @@ LIB_H += builtin.h LIB_H += cache.h LIB_H += cache-tree.h LIB_H += commit.h +LIB_H += compat/bswap.h LIB_H += compat/cygwin.h LIB_H += compat/mingw.h LIB_H += csum-file.h @@ -782,6 +787,8 @@ ifeq ($(uname_O),Cygwin) NO_MMAP = YesPlease NO_IPV6 = YesPlease X = .exe + COMPAT_OBJS += compat/cygwin.o + UNRELIABLE_FSTAT = UnfortunatelyYes endif ifeq ($(uname_S),FreeBSD) NEEDS_LIBICONV = YesPlease @@ -891,10 +898,6 @@ ifeq ($(uname_S),HP-UX) NO_SYS_SELECT_H = YesPlease SNPRINTF_RETURNS_BOGUS = YesPlease endif -ifneq (,$(findstring CYGWIN,$(uname_S))) - COMPAT_OBJS += compat/cygwin.o - UNRELIABLE_FSTAT = UnfortunatelyYes -endif ifdef MSVC GIT_VERSION := $(GIT_VERSION).MSVC pathsep = ; @@ -1375,7 +1378,7 @@ SHELL = $(SHELL_PATH) all:: shell_compatibility_test $(ALL_PROGRAMS) $(BUILT_INS) $(OTHER_PROGRAMS) GIT-BUILD-OPTIONS ifneq (,$X) - $(QUIET_BUILT_IN)$(foreach p,$(patsubst %$X,%,$(filter %$X,$(ALL_PROGRAMS) $(BUILT_INS) git$X)), test '$p' -ef '$p$X' || $(RM) '$p';) + $(QUIET_BUILT_IN)$(foreach p,$(patsubst %$X,%,$(filter %$X,$(ALL_PROGRAMS) $(BUILT_INS) git$X)), test -d '$p' -o '$p' -ef '$p$X' || $(RM) '$p';) endif all:: @@ -1626,6 +1629,7 @@ GIT-CFLAGS: .FORCE-GIT-CFLAGS # and the first level quoting from the shell that runs "echo". GIT-BUILD-OPTIONS: .FORCE-GIT-BUILD-OPTIONS @echo SHELL_PATH=\''$(subst ','\'',$(SHELL_PATH_SQ))'\' >$@ + @echo PERL_PATH=\''$(subst ','\'',$(PERL_PATH_SQ))'\' >>$@ @echo TAR=\''$(subst ','\'',$(subst ','\'',$(TAR)))'\' >>$@ @echo NO_CURL=\''$(subst ','\'',$(subst ','\'',$(NO_CURL)))'\' >>$@ @echo NO_PERL=\''$(subst ','\'',$(subst ','\'',$(NO_PERL)))'\' >>$@ @@ -1799,7 +1803,10 @@ dist: git.spec git-archive$(X) configure gzip -f -9 $(GIT_TARNAME).tar rpm: dist - $(RPMBUILD) -ta $(GIT_TARNAME).tar.gz + $(RPMBUILD) \ + --define "_source_filedigest_algorithm md5" \ + --define "_binary_filedigest_algorithm md5" \ + -ta $(GIT_TARNAME).tar.gz htmldocs = git-htmldocs-$(GIT_VERSION) manpages = git-manpages-$(GIT_VERSION) @@ -1827,7 +1834,7 @@ distclean: clean $(RM) configure clean: - $(RM) *.o mozilla-sha1/*.o arm/*.o ppc/*.o compat/*.o compat/*/*.o xdiff/*.o \ + $(RM) *.o block-sha1/*.o arm/*.o ppc/*.o compat/*.o compat/*/*.o xdiff/*.o \ $(LIB_FILE) $(XDIFF_LIB) $(RM) $(ALL_PROGRAMS) $(BUILT_INS) git$X $(RM) $(TEST_PROGRAMS) @@ -1 +1 @@ -Documentation/RelNotes-1.6.5.txt
\ No newline at end of file +Documentation/RelNotes-1.6.5.4.txt
\ No newline at end of file diff --git a/builtin-apply.c b/builtin-apply.c index c8372a0a80..36e2f9dda5 100644 --- a/builtin-apply.c +++ b/builtin-apply.c @@ -153,6 +153,7 @@ struct fragment { const char *patch; int size; int rejected; + int linenr; struct fragment *next; }; @@ -822,12 +823,13 @@ static int gitdiff_unrecognized(const char *line, struct patch *patch) static const char *stop_at_slash(const char *line, int llen) { + int nslash = p_value; int i; for (i = 0; i < llen; i++) { int ch = line[i]; - if (ch == '/') - return line + i; + if (ch == '/' && --nslash <= 0) + return &line[i]; } return NULL; } @@ -1227,23 +1229,29 @@ static int find_header(char *line, unsigned long size, int *hdrsize, struct patc return -1; } -static void check_whitespace(const char *line, int len, unsigned ws_rule) +static void record_ws_error(unsigned result, const char *line, int len, int linenr) { char *err; - unsigned result = ws_check(line + 1, len - 1, ws_rule); + if (!result) return; whitespace_error++; if (squelch_whitespace_errors && squelch_whitespace_errors < whitespace_error) - ; - else { - err = whitespace_error_string(result); - fprintf(stderr, "%s:%d: %s.\n%.*s\n", - patch_input_file, linenr, err, len - 2, line + 1); - free(err); - } + return; + + err = whitespace_error_string(result); + fprintf(stderr, "%s:%d: %s.\n%.*s\n", + patch_input_file, linenr, err, len, line); + free(err); +} + +static void check_whitespace(const char *line, int len, unsigned ws_rule) +{ + unsigned result = ws_check(line + 1, len - 1, ws_rule); + + record_ws_error(result, line + 1, len - 2, linenr); } /* @@ -1359,6 +1367,7 @@ static int parse_single_patch(char *line, unsigned long size, struct patch *patc int len; fragment = xcalloc(1, sizeof(*fragment)); + fragment->linenr = linenr; len = parse_fragment(line, size, patch, fragment); if (len <= 0) die("corrupt patch at line %d", linenr); @@ -2142,6 +2151,7 @@ static int apply_one_fragment(struct image *img, struct fragment *frag, int len = linelen(patch, size); int plen, added; int added_blank_line = 0; + int is_blank_context = 0; if (!len) break; @@ -2174,8 +2184,12 @@ static int apply_one_fragment(struct image *img, struct fragment *frag, *new++ = '\n'; add_line_info(&preimage, "\n", 1, LINE_COMMON); add_line_info(&postimage, "\n", 1, LINE_COMMON); + is_blank_context = 1; break; case ' ': + if (plen && (ws_rule & WS_BLANK_AT_EOF) && + ws_blank_line(patch + 1, plen, ws_rule)) + is_blank_context = 1; case '-': memcpy(old, patch + 1, plen); add_line_info(&preimage, old, plen, @@ -2202,7 +2216,8 @@ static int apply_one_fragment(struct image *img, struct fragment *frag, (first == '+' ? 0 : LINE_COMMON)); new += added; if (first == '+' && - added == 1 && new[-1] == '\n') + (ws_rule & WS_BLANK_AT_EOF) && + ws_blank_line(patch + 1, plen, ws_rule)) added_blank_line = 1; break; case '@': case '\\': @@ -2215,6 +2230,8 @@ static int apply_one_fragment(struct image *img, struct fragment *frag, } if (added_blank_line) new_blank_lines_at_end++; + else if (is_blank_context) + ; else new_blank_lines_at_end = 0; patch += len; @@ -2296,17 +2313,24 @@ static int apply_one_fragment(struct image *img, struct fragment *frag, } if (applied_pos >= 0) { - if (ws_error_action == correct_ws_error && - new_blank_lines_at_end && - postimage.nr + applied_pos == img->nr) { + if (new_blank_lines_at_end && + preimage.nr + applied_pos == img->nr && + (ws_rule & WS_BLANK_AT_EOF) && + ws_error_action != nowarn_ws_error) { + record_ws_error(WS_BLANK_AT_EOF, "+", 1, frag->linenr); + if (ws_error_action == correct_ws_error) { + while (new_blank_lines_at_end--) + remove_last_line(&postimage); + } /* - * If the patch application adds blank lines - * at the end, and if the patch applies at the - * end of the image, remove those added blank - * lines. + * We would want to prevent write_out_results() + * from taking place in apply_patch() that follows + * the callchain led us here, which is: + * apply_patch->check_patch_list->check_patch-> + * apply_data->apply_fragments->apply_one_fragment */ - while (new_blank_lines_at_end--) - remove_last_line(&postimage); + if (ws_error_action == die_on_ws_error) + apply = 0; } /* diff --git a/builtin-blame.c b/builtin-blame.c index 7512773b40..dd16b22297 100644 --- a/builtin-blame.c +++ b/builtin-blame.c @@ -1604,6 +1604,9 @@ static void emit_porcelain(struct scoreboard *sb, struct blame_entry *ent) } while (ch != '\n' && cp < sb->final_buf + sb->final_buf_size); } + + if (sb->final_buf_size && cp[-1] != '\n') + putchar('\n'); } static void emit_other(struct scoreboard *sb, struct blame_entry *ent, int opt) @@ -1667,6 +1670,9 @@ static void emit_other(struct scoreboard *sb, struct blame_entry *ent, int opt) } while (ch != '\n' && cp < sb->final_buf + sb->final_buf_size); } + + if (sb->final_buf_size && cp[-1] != '\n') + putchar('\n'); } static void output(struct scoreboard *sb, int option) diff --git a/builtin-check-ref-format.c b/builtin-check-ref-format.c index f9381e07ea..a5ba4eae5a 100644 --- a/builtin-check-ref-format.c +++ b/builtin-check-ref-format.c @@ -7,6 +7,10 @@ #include "builtin.h" #include "strbuf.h" +static const char builtin_check_ref_format_usage[] = +"git check-ref-format <refname>\n" +" or: git check-ref-format --branch <branchname-shorthand>"; + int cmd_check_ref_format(int argc, const char **argv, const char *prefix) { if (argc == 3 && !strcmp(argv[1], "--branch")) { @@ -18,6 +22,6 @@ int cmd_check_ref_format(int argc, const char **argv, const char *prefix) exit(0); } if (argc != 2) - usage("git check-ref-format refname"); + usage(builtin_check_ref_format_usage); return !!check_ref_format(argv[1]); } diff --git a/builtin-clone.c b/builtin-clone.c index 4992c2597c..caf3025031 100644 --- a/builtin-clone.c +++ b/builtin-clone.c @@ -51,7 +51,9 @@ static struct option builtin_clone_options[] = { OPT_BOOLEAN('n', "no-checkout", &option_no_checkout, "don't create a checkout"), OPT_BOOLEAN(0, "bare", &option_bare, "create a bare repository"), - OPT_BOOLEAN(0, "naked", &option_bare, "create a bare repository"), + { OPTION_BOOLEAN, 0, "naked", &option_bare, NULL, + "create a bare repository", + PARSE_OPT_NOARG | PARSE_OPT_HIDDEN }, OPT_BOOLEAN(0, "mirror", &option_mirror, "create a mirror repository (implies bare)"), OPT_BOOLEAN('l', "local", &option_local, @@ -61,7 +63,7 @@ static struct option builtin_clone_options[] = { OPT_BOOLEAN('s', "shared", &option_shared, "setup as shared repository"), OPT_BOOLEAN(0, "recursive", &option_recursive, - "setup as shared repository"), + "initialize submodules in the clone"), OPT_STRING(0, "template", &option_template, "path", "path the template repository"), OPT_STRING(0, "reference", &option_reference, "repo", @@ -377,8 +379,13 @@ int cmd_clone(int argc, const char **argv, const char *prefix) argc = parse_options(argc, argv, prefix, builtin_clone_options, builtin_clone_usage, 0); + if (argc > 2) + usage_msg_opt("Too many arguments.", + builtin_clone_usage, builtin_clone_options); + if (argc == 0) - die("You must specify a repository to clone."); + usage_msg_opt("You must specify a repository to clone.", + builtin_clone_usage, builtin_clone_options); if (option_mirror) option_bare = 1; @@ -641,7 +648,8 @@ int cmd_clone(int argc, const char **argv, const char *prefix) die("unable to write new index file"); err |= run_hook(NULL, "post-checkout", sha1_to_hex(null_sha1), - sha1_to_hex(remote_head->old_sha1), "1", NULL); + sha1_to_hex(our_head_points_at->old_sha1), "1", + NULL); if (!err && option_recursive) err = run_command_v_opt(argv_submodule, RUN_GIT_CMD); diff --git a/builtin-commit.c b/builtin-commit.c index 200ffdaad4..2299dc75ce 100644 --- a/builtin-commit.c +++ b/builtin-commit.c @@ -954,7 +954,7 @@ static int git_commit_config(const char *k, const char *v, void *cb) struct wt_status *s = cb; if (!strcmp(k, "commit.template")) - return git_config_string(&template_file, k, v); + return git_config_pathname(&template_file, k, v); return git_status_config(k, v, s); } diff --git a/builtin-describe.c b/builtin-describe.c index df67a733ae..7542b5705c 100644 --- a/builtin-describe.c +++ b/builtin-describe.c @@ -197,7 +197,7 @@ static void describe(const char *arg, int last_one) for_each_ref(get_name, NULL); } - if (!found_names) + if (!found_names && !always) die("cannot describe '%s'", sha1_to_hex(sha1)); n = cmit->util; diff --git a/builtin-gc.c b/builtin-gc.c index 7d3e9cc7a0..093517e390 100644 --- a/builtin-gc.c +++ b/builtin-gc.c @@ -216,10 +216,13 @@ int cmd_gc(int argc, const char **argv, const char *prefix) */ if (!need_to_gc()) return 0; - fprintf(stderr, "Auto packing your repository for optimum " - "performance. You may also\n" - "run \"git gc\" manually. See " - "\"git help gc\" for more information.\n"); + fprintf(stderr, + "Auto packing the repository for optimum performance.%s\n", + quiet + ? "" + : (" You may also\n" + "run \"git gc\" manually. See " + "\"git help gc\" for more information.")); } else append_option(argv_repack, prune_expire && !strcmp(prune_expire, "now") diff --git a/builtin-grep.c b/builtin-grep.c index 761799d7d0..d79a6260a4 100644 --- a/builtin-grep.c +++ b/builtin-grep.c @@ -367,7 +367,7 @@ static int external_grep(struct grep_opt *opt, const char **paths, int cached) push_arg("-h"); if (opt->regflags & REG_EXTENDED) push_arg("-E"); - if (opt->regflags & REG_ICASE) + if (opt->ignore_case) push_arg("-i"); if (opt->binary == GREP_BINARY_NOMATCH) push_arg("-I"); @@ -631,7 +631,7 @@ static int file_callback(const struct option *opt, const char *arg, int unset) struct grep_opt *grep_opt = opt->value; FILE *patterns; int lno = 0; - struct strbuf sb; + struct strbuf sb = STRBUF_INIT; patterns = fopen(arg, "r"); if (!patterns) @@ -706,8 +706,8 @@ int cmd_grep(int argc, const char **argv, const char *prefix) OPT_GROUP(""), OPT_BOOLEAN('v', "invert-match", &opt.invert, "show non-matching lines"), - OPT_BIT('i', "ignore-case", &opt.regflags, - "case insensitive matching", REG_ICASE), + OPT_BOOLEAN('i', "ignore-case", &opt.ignore_case, + "case insensitive matching"), OPT_BOOLEAN('w', "word-regexp", &opt.word_regexp, "match patterns only at word boundaries"), OPT_SET_INT('a', "text", &opt.binary, @@ -830,6 +830,8 @@ int cmd_grep(int argc, const char **argv, const char *prefix) external_grep_allowed = 0; if (!opt.pattern_list) die("no pattern given."); + if (!opt.fixed && opt.ignore_case) + opt.regflags |= REG_ICASE; if ((opt.regflags != REG_NEWLINE) && opt.fixed) die("cannot mix --fixed-strings and regexp"); compile_grep_patterns(&opt); diff --git a/builtin-help.c b/builtin-help.c index e1eba778a5..09ad4b04f9 100644 --- a/builtin-help.c +++ b/builtin-help.c @@ -372,6 +372,7 @@ static void show_info_page(const char *git_cmd) const char *page = cmd_to_page(git_cmd); setenv("INFOPATH", system_path(GIT_INFO_PATH), 1); execlp("info", "info", "gitman", page, NULL); + die("no info viewer handled the request"); } static void get_html_page_path(struct strbuf *page_path, const char *page) @@ -416,9 +417,6 @@ int cmd_help(int argc, const char **argv, const char *prefix) const char *alias; load_command_list("git-", &main_cmds, &other_cmds); - setup_git_directory_gently(&nongit); - git_config(git_help_config, NULL); - argc = parse_options(argc, argv, prefix, builtin_help_options, builtin_help_usage, 0); @@ -436,6 +434,9 @@ int cmd_help(int argc, const char **argv, const char *prefix) return 0; } + setup_git_directory_gently(&nongit); + git_config(git_help_config, NULL); + alias = alias_lookup(argv[0]); if (alias && !is_git_command(argv[0])) { printf("`git %s' is aliased to `%s'\n", argv[0], alias); diff --git a/builtin-log.c b/builtin-log.c index 25e21ed415..7b91c91423 100644 --- a/builtin-log.c +++ b/builtin-log.c @@ -891,6 +891,7 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix) struct patch_ids ids; char *add_signoff = NULL; struct strbuf buf = STRBUF_INIT; + int use_patch_format = 0; const struct option builtin_format_patch_options[] = { { OPTION_CALLBACK, 'n', "numbered", &numbered, NULL, "use [PATCH n/m] even with a single patch", @@ -920,6 +921,8 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix) PARSE_OPT_NOARG | PARSE_OPT_NONEG, keep_callback }, OPT_BOOLEAN(0, "no-binary", &no_binary_diff, "don't output binary diffs"), + OPT_BOOLEAN('p', NULL, &use_patch_format, + "show patch format instead of default (patch + stat)"), OPT_BOOLEAN(0, "ignore-if-in-upstream", &ignore_if_in_upstream, "don't include a patch matching a commit upstream"), OPT_GROUP("Messaging"), @@ -1027,8 +1030,10 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix) if (argc > 1) die ("unrecognized argument: %s", argv[1]); - if (!rev.diffopt.output_format - || rev.diffopt.output_format == DIFF_FORMAT_PATCH) + if (use_patch_format) + rev.diffopt.output_format |= DIFF_FORMAT_PATCH; + else if (!rev.diffopt.output_format || + rev.diffopt.output_format == DIFF_FORMAT_PATCH) rev.diffopt.output_format = DIFF_FORMAT_DIFFSTAT | DIFF_FORMAT_SUMMARY | DIFF_FORMAT_PATCH; if (!DIFF_OPT_TST(&rev.diffopt, TEXT) && !no_binary_diff) diff --git a/builtin-ls-files.c b/builtin-ls-files.c index 2c95ca6105..c9a03e5427 100644 --- a/builtin-ls-files.c +++ b/builtin-ls-files.c @@ -171,8 +171,8 @@ static void show_files(struct dir_struct *dir, const char *prefix) for (i = 0; i < active_nr; i++) { struct cache_entry *ce = active_cache[i]; int dtype = ce_to_dtype(ce); - if (excluded(dir, ce->name, &dtype) != - !!(dir->flags & DIR_SHOW_IGNORED)) + if (dir->flags & DIR_SHOW_IGNORED && + !excluded(dir, ce->name, &dtype)) continue; if (show_unmerged && !ce_stage(ce)) continue; @@ -187,8 +187,8 @@ static void show_files(struct dir_struct *dir, const char *prefix) struct stat st; int err; int dtype = ce_to_dtype(ce); - if (excluded(dir, ce->name, &dtype) != - !!(dir->flags & DIR_SHOW_IGNORED)) + if (dir->flags & DIR_SHOW_IGNORED && + !excluded(dir, ce->name, &dtype)) continue; if (ce->ce_flags & CE_UPDATE) continue; diff --git a/builtin-ls-remote.c b/builtin-ls-remote.c index 78a88f7476..b5bad0c184 100644 --- a/builtin-ls-remote.c +++ b/builtin-ls-remote.c @@ -86,10 +86,10 @@ int cmd_ls_remote(int argc, const char **argv, const char *prefix) pattern[j - i] = p; } } - remote = nongit ? NULL : remote_get(dest); - if (remote && !remote->url_nr) + remote = remote_get(dest); + if (!remote->url_nr) die("remote %s has no configured URL", dest); - transport = transport_get(remote, remote ? remote->url[0] : dest); + transport = transport_get(remote, remote->url[0]); if (uploadpack != NULL) transport_set_option(transport, TRANS_OPT_UPLOADPACK, uploadpack); diff --git a/builtin-mailinfo.c b/builtin-mailinfo.c index c90cd312ac..3c4f0753fe 100644 --- a/builtin-mailinfo.c +++ b/builtin-mailinfo.c @@ -26,6 +26,7 @@ static struct strbuf charset = STRBUF_INIT; static int patch_lines; static struct strbuf **p_hdr_data, **s_hdr_data; static int use_scissors; +static int use_inbody_headers = 1; #define MAX_HDR_PARSED 10 #define MAX_BOUNDARIES 5 @@ -774,10 +775,17 @@ static int handle_commit_msg(struct strbuf *line) strbuf_ltrim(line); if (!line->len) return 0; + } + + if (use_inbody_headers && still_looking) { still_looking = check_header(line, s_hdr_data, 0); if (still_looking) return 0; - } + } else + /* Only trim the first (blank) line of the commit message + * when ignoring in-body headers. + */ + still_looking = 0; /* normalize the log message to UTF-8. */ if (metainfo_charset) @@ -1033,6 +1041,8 @@ int cmd_mailinfo(int argc, const char **argv, const char *prefix) use_scissors = 1; else if (!strcmp(argv[1], "--no-scissors")) use_scissors = 0; + else if (!strcmp(argv[1], "--no-inbody-headers")) + use_inbody_headers = 0; else usage(mailinfo_usage); argc--; argv++; diff --git a/builtin-merge.c b/builtin-merge.c index b6b84286b2..2871419143 100644 --- a/builtin-merge.c +++ b/builtin-merge.c @@ -70,7 +70,7 @@ static int option_parse_message(const struct option *opt, if (unset) strbuf_setlen(buf, 0); else if (arg) { - strbuf_addf(buf, "%s\n\n", arg); + strbuf_addf(buf, "%s%s", buf->len ? "\n\n" : "", arg); have_message = 1; } else return error("switch `m' requires a value"); @@ -792,7 +792,7 @@ static int suggest_conflicts(void) static struct commit *is_old_style_invocation(int argc, const char **argv) { struct commit *second_token = NULL; - if (argc > 1) { + if (argc > 2) { unsigned char second_sha1[20]; if (get_sha1(argv[1], second_sha1)) @@ -840,7 +840,6 @@ int cmd_merge(int argc, const char **argv, const char *prefix) const char *best_strategy = NULL, *wt_strategy = NULL; struct commit_list **remotes = &remoteheads; - setup_work_tree(); if (file_exists(git_path("MERGE_HEAD"))) die("You have not concluded your merge. (MERGE_HEAD exists)"); if (read_cache_unmerged()) @@ -928,11 +927,13 @@ int cmd_merge(int argc, const char **argv, const char *prefix) * codepath so we discard the error in this * loop. */ - for (i = 0; i < argc; i++) - merge_name(argv[i], &msg); - fmt_merge_msg(option_log, &msg, &merge_msg); - if (merge_msg.len) - strbuf_setlen(&merge_msg, merge_msg.len-1); + if (!have_message) { + for (i = 0; i < argc; i++) + merge_name(argv[i], &msg); + fmt_merge_msg(option_log, &msg, &merge_msg); + if (merge_msg.len) + strbuf_setlen(&merge_msg, merge_msg.len-1); + } } if (head_invalid || !argc) diff --git a/builtin-pack-objects.c b/builtin-pack-objects.c index 02f9246cdb..7938202170 100644 --- a/builtin-pack-objects.c +++ b/builtin-pack-objects.c @@ -24,6 +24,7 @@ static const char pack_usage[] = "git pack-objects [{ -q | --progress | --all-progress }]\n" + " [--all-progress-implied]\n" " [--max-pack-size=N] [--local] [--incremental]\n" " [--window=N] [--window-memory=N] [--depth=N]\n" " [--no-reuse-delta] [--no-reuse-object] [--delta-base-offset]\n" @@ -2122,6 +2123,7 @@ int cmd_pack_objects(int argc, const char **argv, const char *prefix) { int use_internal_rev_list = 0; int thin = 0; + int all_progress_implied = 0; uint32_t i; const char **rp_av; int rp_ac_alloc = 64; @@ -2221,6 +2223,10 @@ int cmd_pack_objects(int argc, const char **argv, const char *prefix) progress = 2; continue; } + if (!strcmp("--all-progress-implied", arg)) { + all_progress_implied = 1; + continue; + } if (!strcmp("-q", arg)) { progress = 0; continue; @@ -2329,6 +2335,9 @@ int cmd_pack_objects(int argc, const char **argv, const char *prefix) delta_search_threads = online_cpus(); #endif + if (progress && all_progress_implied) + progress = 2; + prepare_packed_git(); if (progress) diff --git a/builtin-prune-packed.c b/builtin-prune-packed.c index be99eb0ac4..f9463deec2 100644 --- a/builtin-prune-packed.c +++ b/builtin-prune-packed.c @@ -71,7 +71,7 @@ void prune_packed_objects(int opts) int cmd_prune_packed(int argc, const char **argv, const char *prefix) { - int opts = VERBOSE; + int opts = isatty(2) ? VERBOSE : 0; const struct option prune_packed_options[] = { OPT_BIT('n', "dry-run", &opts, "dry run", DRY_RUN), OPT_NEGBIT('q', "quiet", &opts, "be quiet", VERBOSE), diff --git a/builtin-push.c b/builtin-push.c index 3cb1ee46d1..752121f247 100644 --- a/builtin-push.c +++ b/builtin-push.c @@ -10,7 +10,7 @@ #include "parse-options.h" static const char * const push_usage[] = { - "git push [--all | --mirror] [-n | --dry-run] [--porcelain] [--tags] [--receive-pack=<git-receive-pack>] [--repo=<repository>] [-f | --force] [-v] [<repository> <refspec>...]", + "git push [<options>] [<repository> <refspec>...]", NULL, }; @@ -66,7 +66,6 @@ static void setup_push_tracking(void) static void setup_default_push_refspecs(void) { - git_config(git_default_config, NULL); switch (push_default) { default: case PUSH_DEFAULT_MATCHING: @@ -173,7 +172,6 @@ int cmd_push(int argc, const char **argv, const char *prefix) int tags = 0; int rc; const char *repo = NULL; /* default repository */ - struct option options[] = { OPT_BIT('q', "quiet", &flags, "be quiet", TRANSPORT_PUSH_QUIET), OPT_BIT('v', "verbose", &flags, "be verbose", TRANSPORT_PUSH_VERBOSE), @@ -181,7 +179,7 @@ int cmd_push(int argc, const char **argv, const char *prefix) OPT_BIT( 0 , "all", &flags, "push all refs", TRANSPORT_PUSH_ALL), OPT_BIT( 0 , "mirror", &flags, "mirror all refs", (TRANSPORT_PUSH_MIRROR|TRANSPORT_PUSH_FORCE)), - OPT_BOOLEAN( 0 , "tags", &tags, "push tags"), + OPT_BOOLEAN( 0 , "tags", &tags, "push tags (can't be used with --all or --mirror)"), OPT_BIT('n' , "dry-run", &flags, "dry run", TRANSPORT_PUSH_DRY_RUN), OPT_BIT( 0, "porcelain", &flags, "machine-readable output", TRANSPORT_PUSH_PORCELAIN), OPT_BIT('f', "force", &flags, "force updates", TRANSPORT_PUSH_FORCE), @@ -191,6 +189,7 @@ int cmd_push(int argc, const char **argv, const char *prefix) OPT_END() }; + git_config(git_default_config, NULL); argc = parse_options(argc, argv, prefix, options, push_usage, 0); if (tags) diff --git a/builtin-receive-pack.c b/builtin-receive-pack.c index b771fe9b20..e8bde02c27 100644 --- a/builtin-receive-pack.c +++ b/builtin-receive-pack.c @@ -28,6 +28,8 @@ static int transfer_unpack_limit = -1; static int unpack_limit = 100; static int report_status; static int prefer_ofs_delta = 1; +static int auto_update_server_info; +static int auto_gc = 1; static const char *head_name; static char *capabilities_to_send; @@ -88,6 +90,16 @@ static int receive_pack_config(const char *var, const char *value, void *cb) return 0; } + if (strcmp(var, "receive.updateserverinfo") == 0) { + auto_update_server_info = git_config_bool(var, value); + return 0; + } + + if (strcmp(var, "receive.autogc") == 0) { + auto_gc = git_config_bool(var, value); + return 0; + } + return git_default_config(var, value, cb); } @@ -672,6 +684,14 @@ int cmd_receive_pack(int argc, const char **argv, const char *prefix) report(unpack_status); run_receive_hook(post_receive_hook); run_update_post_hook(commands); + if (auto_gc) { + const char *argv_gc_auto[] = { + "gc", "--auto", "--quiet", NULL, + }; + run_command_v_opt(argv_gc_auto, RUN_GIT_CMD); + } + if (auto_update_server_info) + update_server_info(0); } return 0; } diff --git a/builtin-remote.c b/builtin-remote.c index 0777dd719b..4f4cba4976 100644 --- a/builtin-remote.c +++ b/builtin-remote.c @@ -12,13 +12,48 @@ static const char * const builtin_remote_usage[] = { "git remote add [-t <branch>] [-m <master>] [-f] [--mirror] <name> <url>", "git remote rename <old> <new>", "git remote rm <name>", - "git remote set-head <name> [-a | -d | <branch>]", - "git remote show [-n] <name>", + "git remote set-head <name> (-a | -d | <branch>)", + "git remote [-v | --verbose] show [-n] <name>", "git remote prune [-n | --dry-run] <name>", "git remote [-v | --verbose] update [-p | --prune] [group]", NULL }; +static const char * const builtin_remote_add_usage[] = { + "git remote add [<options>] <name> <url>", + NULL +}; + +static const char * const builtin_remote_rename_usage[] = { + "git remote rename <old> <new>", + NULL +}; + +static const char * const builtin_remote_rm_usage[] = { + "git remote rm <name>", + NULL +}; + +static const char * const builtin_remote_sethead_usage[] = { + "git remote set-head <name> (-a | -d | <branch>])", + NULL +}; + +static const char * const builtin_remote_show_usage[] = { + "git remote show [<options>] <name>", + NULL +}; + +static const char * const builtin_remote_prune_usage[] = { + "git remote prune [<options>] <name>", + NULL +}; + +static const char * const builtin_remote_update_usage[] = { + "git remote update [<options>] [<group> | <remote>]...", + NULL +}; + #define GET_REF_STATES (1<<0) #define GET_HEAD_NAMES (1<<1) #define GET_PUSH_REF_STATES (1<<2) @@ -70,7 +105,6 @@ static int add(int argc, const char **argv) int i; struct option options[] = { - OPT_GROUP("add specific options"), OPT_BOOLEAN('f', "fetch", &fetch, "fetch the remote branches"), OPT_CALLBACK('t', "track", &track, "branch", "branch(es) to track", opt_parse_track), @@ -79,11 +113,11 @@ static int add(int argc, const char **argv) OPT_END() }; - argc = parse_options(argc, argv, NULL, options, builtin_remote_usage, + argc = parse_options(argc, argv, NULL, options, builtin_remote_add_usage, 0); if (argc < 2) - usage_with_options(builtin_remote_usage, options); + usage_with_options(builtin_remote_add_usage, options); name = argv[0]; url = argv[1]; @@ -540,7 +574,7 @@ static int mv(int argc, const char **argv) int i; if (argc != 3) - usage_with_options(builtin_remote_usage, options); + usage_with_options(builtin_remote_rename_usage, options); rename.old = argv[1]; rename.new = argv[2]; @@ -681,7 +715,7 @@ static int rm(int argc, const char **argv) int i, result; if (argc != 2) - usage_with_options(builtin_remote_usage, options); + usage_with_options(builtin_remote_rm_usage, options); remote = remote_get(argv[1]); if (!remote) @@ -976,7 +1010,6 @@ static int show(int argc, const char **argv) { int no_query = 0, result = 0, query_flag = 0; struct option options[] = { - OPT_GROUP("show specific options"), OPT_BOOLEAN('n', NULL, &no_query, "do not query remotes"), OPT_END() }; @@ -984,7 +1017,7 @@ static int show(int argc, const char **argv) struct string_list info_list = { NULL, 0, 0, 0 }; struct show_info info; - argc = parse_options(argc, argv, NULL, options, builtin_remote_usage, + argc = parse_options(argc, argv, NULL, options, builtin_remote_show_usage, 0); if (argc < 1) @@ -1081,14 +1114,13 @@ static int set_head(int argc, const char **argv) char *head_name = NULL; struct option options[] = { - OPT_GROUP("set-head specific options"), OPT_BOOLEAN('a', "auto", &opt_a, "set refs/remotes/<name>/HEAD according to remote"), OPT_BOOLEAN('d', "delete", &opt_d, "delete refs/remotes/<name>/HEAD"), OPT_END() }; - argc = parse_options(argc, argv, NULL, options, builtin_remote_usage, + argc = parse_options(argc, argv, NULL, options, builtin_remote_sethead_usage, 0); if (argc) strbuf_addf(&buf, "refs/remotes/%s/HEAD", argv[0]); @@ -1114,7 +1146,7 @@ static int set_head(int argc, const char **argv) if (delete_ref(buf.buf, NULL, REF_NODEREF)) result |= error("Could not delete %s", buf.buf); } else - usage_with_options(builtin_remote_usage, options); + usage_with_options(builtin_remote_sethead_usage, options); if (head_name) { unsigned char sha1[20]; @@ -1138,16 +1170,15 @@ static int prune(int argc, const char **argv) { int dry_run = 0, result = 0; struct option options[] = { - OPT_GROUP("prune specific options"), OPT__DRY_RUN(&dry_run), OPT_END() }; - argc = parse_options(argc, argv, NULL, options, builtin_remote_usage, + argc = parse_options(argc, argv, NULL, options, builtin_remote_prune_usage, 0); if (argc < 1) - usage_with_options(builtin_remote_usage, options); + usage_with_options(builtin_remote_prune_usage, options); for (; argc; argc--, argv++) result |= prune_remote(*argv, dry_run); @@ -1228,13 +1259,12 @@ static int update(int argc, const char **argv) struct string_list list = { NULL, 0, 0, 0 }; static const char *default_argv[] = { NULL, "default", NULL }; struct option options[] = { - OPT_GROUP("update specific options"), OPT_BOOLEAN('p', "prune", &prune, "prune remotes after fetching"), OPT_END() }; - argc = parse_options(argc, argv, NULL, options, builtin_remote_usage, + argc = parse_options(argc, argv, NULL, options, builtin_remote_update_usage, PARSE_OPT_KEEP_ARGV0); if (argc < 2) { argc = 2; @@ -1334,7 +1364,7 @@ static int show_all(void) int cmd_remote(int argc, const char **argv, const char *prefix) { struct option options[] = { - OPT__VERBOSE(&verbose), + OPT_BOOLEAN('v', "verbose", &verbose, "be verbose; must be placed before a subcommand"), OPT_END() }; int result; diff --git a/builtin-send-pack.c b/builtin-send-pack.c index 37e528e283..2c4eaae684 100644 --- a/builtin-send-pack.c +++ b/builtin-send-pack.c @@ -38,7 +38,7 @@ static int pack_objects(int fd, struct ref *refs, struct extra_have_objects *ext */ const char *argv[] = { "pack-objects", - "--all-progress", + "--all-progress-implied", "--revs", "--stdout", NULL, diff --git a/builtin-upload-archive.c b/builtin-upload-archive.c index c4cd1e1327..29446e84cc 100644 --- a/builtin-upload-archive.c +++ b/builtin-upload-archive.c @@ -132,7 +132,6 @@ int cmd_upload_archive(int argc, const char **argv, const char *prefix) while (1) { struct pollfd pfd[2]; - ssize_t processed[2] = { 0, 0 }; int status; pfd[0].fd = fd1[0]; @@ -147,15 +146,14 @@ int cmd_upload_archive(int argc, const char **argv, const char *prefix) } continue; } - if (pfd[0].revents & POLLIN) - /* Data stream ready */ - processed[0] = process_input(pfd[0].fd, 1); if (pfd[1].revents & POLLIN) /* Status stream ready */ - processed[1] = process_input(pfd[1].fd, 2); - /* Always finish to read data when available */ - if (processed[0] || processed[1]) - continue; + if (process_input(pfd[1].fd, 2)) + continue; + if (pfd[0].revents & POLLIN) + /* Data stream ready */ + if (process_input(pfd[0].fd, 1)) + continue; if (waitpid(writer, &status, 0) < 0) error_clnt("%s", lostchild); @@ -351,7 +351,7 @@ int create_bundle(struct bundle_header *header, const char *path, /* write pack */ argv_pack[0] = "pack-objects"; - argv_pack[1] = "--all-progress"; + argv_pack[1] = "--all-progress-implied"; argv_pack[2] = "--stdout"; argv_pack[3] = "--thin"; argv_pack[4] = NULL; @@ -644,6 +644,7 @@ int set_shared_perm(const char *path, int mode); #define adjust_shared_perm(path) set_shared_perm((path), 0) int safe_create_leading_directories(char *path); int safe_create_leading_directories_const(const char *path); +extern char *expand_user_path(const char *path); char *enter_repo(char *path, int strict); static inline int is_absolute_path(const char *path) { @@ -902,6 +903,7 @@ extern unsigned long git_config_ulong(const char *, const char *); extern int git_config_bool_or_int(const char *, const char *, int *); extern int git_config_bool(const char *, const char *); extern int git_config_string(const char **, const char *, const char *); +extern int git_config_pathname(const char **, const char *, const char *); extern int git_config_set(const char *, const char *); extern int git_config_set_multivar(const char *, const char *, const char *, int); extern int git_config_rename_section(const char *, const char *); @@ -986,10 +988,12 @@ void shift_tree(const unsigned char *, const unsigned char *, unsigned char *, i * whitespace rules. * used by both diff and apply */ -#define WS_TRAILING_SPACE 01 +#define WS_BLANK_AT_EOL 01 #define WS_SPACE_BEFORE_TAB 02 #define WS_INDENT_WITH_NON_TAB 04 #define WS_CR_AT_EOL 010 +#define WS_BLANK_AT_EOF 020 +#define WS_TRAILING_SPACE (WS_BLANK_AT_EOL|WS_BLANK_AT_EOF) #define WS_DEFAULT_RULE (WS_TRAILING_SPACE|WS_SPACE_BEFORE_TAB) extern unsigned whitespace_rule_cfg; extern unsigned whitespace_rule(const char *); @@ -132,8 +132,8 @@ struct commit_graft *read_graft_line(char *buf, int len) int i; struct commit_graft *graft = NULL; - if (buf[len-1] == '\n') - buf[--len] = 0; + while (len && isspace(buf[len-1])) + buf[--len] = '\0'; if (buf[0] == '#' || buf[0] == '\0') return NULL; if ((len + 1) % 41) { @@ -351,6 +351,16 @@ int git_config_string(const char **dest, const char *var, const char *value) return 0; } +int git_config_pathname(const char **dest, const char *var, const char *value) +{ + if (!value) + return config_error_nonbool(var); + *dest = expand_user_path(value); + if (!*dest) + die("Failed to expand user dir in: '%s'", value); + return 0; +} + static int git_default_core_config(const char *var, const char *value) { /* This needs a better name */ @@ -474,7 +484,7 @@ static int git_default_core_config(const char *var, const char *value) return git_config_string(&editor_program, var, value); if (!strcmp(var, "core.excludesfile")) - return git_config_string(&excludes_file, var, value); + return git_config_pathname(&excludes_file, var, value); if (!strcmp(var, "core.whitespace")) { if (!value) @@ -174,6 +174,175 @@ static struct diff_tempfile { char tmp_path[PATH_MAX]; } diff_temp[2]; +typedef unsigned long (*sane_truncate_fn)(char *line, unsigned long len); + +struct emit_callback { + int color_diff; + unsigned ws_rule; + int blank_at_eof_in_preimage; + int blank_at_eof_in_postimage; + int lno_in_preimage; + int lno_in_postimage; + sane_truncate_fn truncate; + const char **label_path; + struct diff_words_data *diff_words; + int *found_changesp; + FILE *file; +}; + +static int count_lines(const char *data, int size) +{ + int count, ch, completely_empty = 1, nl_just_seen = 0; + count = 0; + while (0 < size--) { + ch = *data++; + if (ch == '\n') { + count++; + nl_just_seen = 1; + completely_empty = 0; + } + else { + nl_just_seen = 0; + completely_empty = 0; + } + } + if (completely_empty) + return 0; + if (!nl_just_seen) + count++; /* no trailing newline */ + return count; +} + +static int fill_mmfile(mmfile_t *mf, struct diff_filespec *one) +{ + if (!DIFF_FILE_VALID(one)) { + mf->ptr = (char *)""; /* does not matter */ + mf->size = 0; + return 0; + } + else if (diff_populate_filespec(one, 0)) + return -1; + + mf->ptr = one->data; + mf->size = one->size; + return 0; +} + +static int count_trailing_blank(mmfile_t *mf, unsigned ws_rule) +{ + char *ptr = mf->ptr; + long size = mf->size; + int cnt = 0; + + if (!size) + return cnt; + ptr += size - 1; /* pointing at the very end */ + if (*ptr != '\n') + ; /* incomplete line */ + else + ptr--; /* skip the last LF */ + while (mf->ptr < ptr) { + char *prev_eol; + for (prev_eol = ptr; mf->ptr <= prev_eol; prev_eol--) + if (*prev_eol == '\n') + break; + if (!ws_blank_line(prev_eol + 1, ptr - prev_eol, ws_rule)) + break; + cnt++; + ptr = prev_eol - 1; + } + return cnt; +} + +static void check_blank_at_eof(mmfile_t *mf1, mmfile_t *mf2, + struct emit_callback *ecbdata) +{ + int l1, l2, at; + unsigned ws_rule = ecbdata->ws_rule; + l1 = count_trailing_blank(mf1, ws_rule); + l2 = count_trailing_blank(mf2, ws_rule); + if (l2 <= l1) { + ecbdata->blank_at_eof_in_preimage = 0; + ecbdata->blank_at_eof_in_postimage = 0; + return; + } + at = count_lines(mf1->ptr, mf1->size); + ecbdata->blank_at_eof_in_preimage = (at - l1) + 1; + + at = count_lines(mf2->ptr, mf2->size); + ecbdata->blank_at_eof_in_postimage = (at - l2) + 1; +} + +static void emit_line_0(FILE *file, const char *set, const char *reset, + int first, const char *line, int len) +{ + int has_trailing_newline, has_trailing_carriage_return; + int nofirst; + + if (len == 0) { + has_trailing_newline = (first == '\n'); + has_trailing_carriage_return = (!has_trailing_newline && + (first == '\r')); + nofirst = has_trailing_newline || has_trailing_carriage_return; + } else { + has_trailing_newline = (len > 0 && line[len-1] == '\n'); + if (has_trailing_newline) + len--; + has_trailing_carriage_return = (len > 0 && line[len-1] == '\r'); + if (has_trailing_carriage_return) + len--; + nofirst = 0; + } + + fputs(set, file); + + if (!nofirst) + fputc(first, file); + fwrite(line, len, 1, file); + fputs(reset, file); + if (has_trailing_carriage_return) + fputc('\r', file); + if (has_trailing_newline) + fputc('\n', file); +} + +static void emit_line(FILE *file, const char *set, const char *reset, + const char *line, int len) +{ + emit_line_0(file, set, reset, line[0], line+1, len-1); +} + +static int new_blank_line_at_eof(struct emit_callback *ecbdata, const char *line, int len) +{ + if (!((ecbdata->ws_rule & WS_BLANK_AT_EOF) && + ecbdata->blank_at_eof_in_preimage && + ecbdata->blank_at_eof_in_postimage && + ecbdata->blank_at_eof_in_preimage <= ecbdata->lno_in_preimage && + ecbdata->blank_at_eof_in_postimage <= ecbdata->lno_in_postimage)) + return 0; + return ws_blank_line(line, len, ecbdata->ws_rule); +} + +static void emit_add_line(const char *reset, + struct emit_callback *ecbdata, + const char *line, int len) +{ + const char *ws = diff_get_color(ecbdata->color_diff, DIFF_WHITESPACE); + const char *set = diff_get_color(ecbdata->color_diff, DIFF_FILE_NEW); + + if (!*ws) + emit_line_0(ecbdata->file, set, reset, '+', line, len); + else if (new_blank_line_at_eof(ecbdata, line, len)) + /* Blank line at EOF - paint '+' as well */ + emit_line_0(ecbdata->file, ws, reset, '+', line, len); + else { + /* Emit just the prefix, then the rest. */ + emit_line_0(ecbdata->file, set, reset, '+', "", 0); + ws_check_emit(line, len, ecbdata->ws_rule, + ecbdata->file, set, reset, ws); + } +} + static struct diff_tempfile *claim_diff_tempfile(void) { int i; for (i = 0; i < ARRAY_SIZE(diff_temp); i++) @@ -201,29 +370,6 @@ static void remove_tempfile_on_signal(int signo) raise(signo); } -static int count_lines(const char *data, int size) -{ - int count, ch, completely_empty = 1, nl_just_seen = 0; - count = 0; - while (0 < size--) { - ch = *data++; - if (ch == '\n') { - count++; - nl_just_seen = 1; - completely_empty = 0; - } - else { - nl_just_seen = 0; - completely_empty = 0; - } - } - if (completely_empty) - return 0; - if (!nl_just_seen) - count++; /* no trailing newline */ - return count; -} - static void print_line_count(FILE *file, int count) { switch (count) { @@ -239,26 +385,36 @@ static void print_line_count(FILE *file, int count) } } -static void copy_file_with_prefix(FILE *file, - int prefix, const char *data, int size, - const char *set, const char *reset) +static void emit_rewrite_lines(struct emit_callback *ecb, + int prefix, const char *data, int size) { - int ch, nl_just_seen = 1; - while (0 < size--) { - ch = *data++; - if (nl_just_seen) { - fputs(set, file); - putc(prefix, file); + const char *endp = NULL; + static const char *nneof = " No newline at end of file\n"; + const char *old = diff_get_color(ecb->color_diff, DIFF_FILE_OLD); + const char *reset = diff_get_color(ecb->color_diff, DIFF_RESET); + + while (0 < size) { + int len; + + endp = memchr(data, '\n', size); + len = endp ? (endp - data + 1) : size; + if (prefix != '+') { + ecb->lno_in_preimage++; + emit_line_0(ecb->file, old, reset, '-', + data, len); + } else { + ecb->lno_in_postimage++; + emit_add_line(reset, ecb, data, len); } - if (ch == '\n') { - nl_just_seen = 1; - fputs(reset, file); - } else - nl_just_seen = 0; - putc(ch, file); + size -= len; + data += len; + } + if (!endp) { + const char *plain = diff_get_color(ecb->color_diff, + DIFF_PLAIN); + emit_line_0(ecb->file, plain, reset, '\\', + nneof, strlen(nneof)); } - if (!nl_just_seen) - fprintf(file, "%s\n\\ No newline at end of file\n", reset); } static void emit_rewrite_diff(const char *name_a, @@ -274,13 +430,12 @@ static void emit_rewrite_diff(const char *name_a, const char *name_a_tab, *name_b_tab; const char *metainfo = diff_get_color(color_diff, DIFF_METAINFO); const char *fraginfo = diff_get_color(color_diff, DIFF_FRAGINFO); - const char *old = diff_get_color(color_diff, DIFF_FILE_OLD); - const char *new = diff_get_color(color_diff, DIFF_FILE_NEW); const char *reset = diff_get_color(color_diff, DIFF_RESET); static struct strbuf a_name = STRBUF_INIT, b_name = STRBUF_INIT; const char *a_prefix, *b_prefix; const char *data_one, *data_two; size_t size_one, size_two; + struct emit_callback ecbdata; if (diff_mnemonic_prefix && DIFF_OPT_TST(o, REVERSE_DIFF)) { a_prefix = o->b_prefix; @@ -321,6 +476,22 @@ static void emit_rewrite_diff(const char *name_a, size_two = two->size; } + memset(&ecbdata, 0, sizeof(ecbdata)); + ecbdata.color_diff = color_diff; + ecbdata.found_changesp = &o->found_changes; + ecbdata.ws_rule = whitespace_rule(name_b ? name_b : name_a); + ecbdata.file = o->file; + if (ecbdata.ws_rule & WS_BLANK_AT_EOF) { + mmfile_t mf1, mf2; + mf1.ptr = (char *)data_one; + mf2.ptr = (char *)data_two; + mf1.size = size_one; + mf2.size = size_two; + check_blank_at_eof(&mf1, &mf2, &ecbdata); + } + ecbdata.lno_in_preimage = 1; + ecbdata.lno_in_postimage = 1; + lc_a = count_lines(data_one, size_one); lc_b = count_lines(data_two, size_two); fprintf(o->file, @@ -332,24 +503,9 @@ static void emit_rewrite_diff(const char *name_a, print_line_count(o->file, lc_b); fprintf(o->file, " @@%s\n", reset); if (lc_a) - copy_file_with_prefix(o->file, '-', data_one, size_one, old, reset); + emit_rewrite_lines(&ecbdata, '-', data_one, size_one); if (lc_b) - copy_file_with_prefix(o->file, '+', data_two, size_two, new, reset); -} - -static int fill_mmfile(mmfile_t *mf, struct diff_filespec *one) -{ - if (!DIFF_FILE_VALID(one)) { - mf->ptr = (char *)""; /* does not matter */ - mf->size = 0; - return 0; - } - else if (diff_populate_filespec(one, 0)) - return -1; - - mf->ptr = one->data; - mf->size = one->size; - return 0; + emit_rewrite_lines(&ecbdata, '+', data_two, size_two); } struct diff_words_buffer { @@ -529,26 +685,18 @@ static void diff_words_show(struct diff_words_data *diff_words) diff_words->minus.text.size = diff_words->plus.text.size = 0; } -typedef unsigned long (*sane_truncate_fn)(char *line, unsigned long len); - -struct emit_callback { - int nparents, color_diff; - unsigned ws_rule; - sane_truncate_fn truncate; - const char **label_path; - struct diff_words_data *diff_words; - int *found_changesp; - FILE *file; -}; +/* In "color-words" mode, show word-diff of words accumulated in the buffer */ +static void diff_words_flush(struct emit_callback *ecbdata) +{ + if (ecbdata->diff_words->minus.text.size || + ecbdata->diff_words->plus.text.size) + diff_words_show(ecbdata->diff_words); +} static void free_diff_words_data(struct emit_callback *ecbdata) { if (ecbdata->diff_words) { - /* flush buffers */ - if (ecbdata->diff_words->minus.text.size || - ecbdata->diff_words->plus.text.size) - diff_words_show(ecbdata->diff_words); - + diff_words_flush(ecbdata); free (ecbdata->diff_words->minus.text.ptr); free (ecbdata->diff_words->minus.orig); free (ecbdata->diff_words->plus.text.ptr); @@ -566,42 +714,6 @@ const char *diff_get_color(int diff_use_color, enum color_diff ix) return ""; } -static void emit_line(FILE *file, const char *set, const char *reset, const char *line, int len) -{ - int has_trailing_newline, has_trailing_carriage_return; - - has_trailing_newline = (len > 0 && line[len-1] == '\n'); - if (has_trailing_newline) - len--; - has_trailing_carriage_return = (len > 0 && line[len-1] == '\r'); - if (has_trailing_carriage_return) - len--; - - fputs(set, file); - fwrite(line, len, 1, file); - fputs(reset, file); - if (has_trailing_carriage_return) - fputc('\r', file); - if (has_trailing_newline) - fputc('\n', file); -} - -static void emit_add_line(const char *reset, struct emit_callback *ecbdata, const char *line, int len) -{ - const char *ws = diff_get_color(ecbdata->color_diff, DIFF_WHITESPACE); - const char *set = diff_get_color(ecbdata->color_diff, DIFF_FILE_NEW); - - if (!*ws) - emit_line(ecbdata->file, set, reset, line, len); - else { - /* Emit just the prefix, then the rest. */ - emit_line(ecbdata->file, set, reset, line, ecbdata->nparents); - ws_check_emit(line + ecbdata->nparents, - len - ecbdata->nparents, ecbdata->ws_rule, - ecbdata->file, set, reset, ws); - } -} - static unsigned long sane_truncate_line(struct emit_callback *ecb, char *line, unsigned long len) { const char *cp; @@ -620,10 +732,23 @@ static unsigned long sane_truncate_line(struct emit_callback *ecb, char *line, u return allot - l; } +static void find_lno(const char *line, struct emit_callback *ecbdata) +{ + const char *p; + ecbdata->lno_in_preimage = 0; + ecbdata->lno_in_postimage = 0; + p = strchr(line, '-'); + if (!p) + return; /* cannot happen */ + ecbdata->lno_in_preimage = strtol(p + 1, NULL, 10); + p = strchr(p, '+'); + if (!p) + return; /* cannot happen */ + ecbdata->lno_in_postimage = strtol(p + 1, NULL, 10); +} + static void fn_out_consume(void *priv, char *line, unsigned long len) { - int i; - int color; struct emit_callback *ecbdata = priv; const char *meta = diff_get_color(ecbdata->color_diff, DIFF_METAINFO); const char *plain = diff_get_color(ecbdata->color_diff, DIFF_PLAIN); @@ -650,14 +775,11 @@ static void fn_out_consume(void *priv, char *line, unsigned long len) len = 1; } - /* This is not really necessary for now because - * this codepath only deals with two-way diffs. - */ - for (i = 0; i < len && line[i] == '@'; i++) - ; - if (2 <= i && i < len && line[i] == ' ') { - ecbdata->nparents = i - 1; + if (line[0] == '@') { + if (ecbdata->diff_words) + diff_words_flush(ecbdata); len = sane_truncate_line(ecbdata, line, len); + find_lno(line, ecbdata); emit_line(ecbdata->file, diff_get_color(ecbdata->color_diff, DIFF_FRAGINFO), reset, line, len); @@ -666,15 +788,11 @@ static void fn_out_consume(void *priv, char *line, unsigned long len) return; } - if (len < ecbdata->nparents) { + if (len < 1) { emit_line(ecbdata->file, reset, reset, line, len); return; } - color = DIFF_PLAIN; - if (ecbdata->diff_words && ecbdata->nparents != 1) - /* fall back to normal diff */ - free_diff_words_data(ecbdata); if (ecbdata->diff_words) { if (line[0] == '-') { diff_words_append(line, len, @@ -685,28 +803,25 @@ static void fn_out_consume(void *priv, char *line, unsigned long len) &ecbdata->diff_words->plus); return; } - if (ecbdata->diff_words->minus.text.size || - ecbdata->diff_words->plus.text.size) - diff_words_show(ecbdata->diff_words); + diff_words_flush(ecbdata); line++; len--; emit_line(ecbdata->file, plain, reset, line, len); return; } - for (i = 0; i < ecbdata->nparents && len; i++) { - if (line[i] == '-') - color = DIFF_FILE_OLD; - else if (line[i] == '+') - color = DIFF_FILE_NEW; - } - if (color != DIFF_FILE_NEW) { - emit_line(ecbdata->file, - diff_get_color(ecbdata->color_diff, color), - reset, line, len); - return; + if (line[0] != '+') { + const char *color = + diff_get_color(ecbdata->color_diff, + line[0] == '-' ? DIFF_FILE_OLD : DIFF_PLAIN); + ecbdata->lno_in_preimage++; + if (line[0] == ' ') + ecbdata->lno_in_postimage++; + emit_line(ecbdata->file, color, reset, line, len); + } else { + ecbdata->lno_in_postimage++; + emit_add_line(reset, ecbdata, line + 1, len - 1); } - emit_add_line(reset, ecbdata, line, len); } static char *pprint_rename(const char *a, const char *b) @@ -1211,7 +1326,6 @@ struct checkdiff_t { struct diff_options *o; unsigned ws_rule; unsigned status; - int trailing_blanks_start; }; static int is_conflict_marker(const char *line, unsigned long len) @@ -1255,10 +1369,6 @@ static void checkdiff_consume(void *priv, char *line, unsigned long len) if (line[0] == '+') { unsigned bad; data->lineno++; - if (!ws_blank_line(line + 1, len - 1, data->ws_rule)) - data->trailing_blanks_start = 0; - else if (!data->trailing_blanks_start) - data->trailing_blanks_start = data->lineno; if (is_conflict_marker(line + 1, len - 1)) { data->status |= 1; fprintf(data->o->file, @@ -1278,14 +1388,12 @@ static void checkdiff_consume(void *priv, char *line, unsigned long len) data->o->file, set, reset, ws); } else if (line[0] == ' ') { data->lineno++; - data->trailing_blanks_start = 0; } else if (line[0] == '@') { char *plus = strchr(line, '+'); if (plus) data->lineno = strtol(plus, NULL, 10) - 1; else die("invalid diff"); - data->trailing_blanks_start = 0; } } @@ -1562,6 +1670,8 @@ static void builtin_diff(const char *name_a, ecbdata.color_diff = DIFF_OPT_TST(o, COLOR_DIFF); ecbdata.found_changesp = &o->found_changes; ecbdata.ws_rule = whitespace_rule(name_b ? name_b : name_a); + if (ecbdata.ws_rule & WS_BLANK_AT_EOF) + check_blank_at_eof(&mf1, &mf2, &ecbdata); ecbdata.file = o->file; xpp.flags = XDF_NEED_MINIMAL | o->xdl_opts; xecfg.ctxlen = o->context; @@ -1704,11 +1814,22 @@ static void builtin_checkdiff(const char *name_a, const char *name_b, xdi_diff_outf(&mf1, &mf2, checkdiff_consume, &data, &xpp, &xecfg, &ecb); - if ((data.ws_rule & WS_TRAILING_SPACE) && - data.trailing_blanks_start) { - fprintf(o->file, "%s:%d: ends with blank lines.\n", - data.filename, data.trailing_blanks_start); - data.status = 1; /* report errors */ + if (data.ws_rule & WS_BLANK_AT_EOF) { + struct emit_callback ecbdata; + int blank_at_eof; + + ecbdata.ws_rule = data.ws_rule; + check_blank_at_eof(&mf1, &mf2, &ecbdata); + blank_at_eof = ecbdata.blank_at_eof_in_preimage; + + if (blank_at_eof) { + static char *err; + if (!err) + err = whitespace_error_string(WS_BLANK_AT_EOF); + fprintf(o->file, "%s:%d: %s.\n", + data.filename, blank_at_eof, err); + data.status = 1; /* report errors */ + } } } free_and_return: diff --git a/diffcore-break.c b/diffcore-break.c index d7097bb576..3a7b60a037 100644 --- a/diffcore-break.c +++ b/diffcore-break.c @@ -69,7 +69,7 @@ static int should_break(struct diff_filespec *src, return 0; /* we do not break too small filepair */ if (diffcore_count_changes(src, dst, - NULL, NULL, + &src->cnt_data, &dst->cnt_data, 0, &src_copied, &literal_added)) return 0; @@ -204,12 +204,16 @@ void diffcore_break(int break_score) dp->score = score; dp->broken_pair = 1; + diff_free_filespec_blob(p->one); + diff_free_filespec_blob(p->two); free(p); /* not diff_free_filepair(), we are * reusing one and two here. */ continue; } } + diff_free_filespec_data(p->one); + diff_free_filespec_data(p->two); diff_q(&outq, p); } free(q->queue); diff --git a/diffcore-rename.c b/diffcore-rename.c index 63ac998bfa..d6fd3cacd6 100644 --- a/diffcore-rename.c +++ b/diffcore-rename.c @@ -523,10 +523,13 @@ void diffcore_rename(struct diff_options *options) this_src.dst = i; this_src.src = j; record_if_better(m, &this_src); + /* + * Once we run estimate_similarity, + * We do not need the text anymore. + */ diff_free_filespec_blob(one); + diff_free_filespec_blob(two); } - /* We do not need the text anymore */ - diff_free_filespec_blob(two); dst_cnt++; } diff --git a/git-add--interactive.perl b/git-add--interactive.perl index 392efb913f..8ce1ec92c2 100755 --- a/git-add--interactive.perl +++ b/git-add--interactive.perl @@ -259,7 +259,7 @@ sub list_modified { @tracked = map { chomp $_; unquote_path($_); - } run_cmd_pipe(qw(git ls-files --exclude-standard --), @ARGV); + } run_cmd_pipe(qw(git ls-files --), @ARGV); return if (!@tracked); } @@ -731,14 +731,17 @@ sub parse_diff_header { my $head = { TEXT => [], DISPLAY => [], TYPE => 'header' }; my $mode = { TEXT => [], DISPLAY => [], TYPE => 'mode' }; + my $deletion = { TEXT => [], DISPLAY => [], TYPE => 'deletion' }; for (my $i = 0; $i < @{$src->{TEXT}}; $i++) { - my $dest = $src->{TEXT}->[$i] =~ /^(old|new) mode (\d+)$/ ? - $mode : $head; + my $dest = + $src->{TEXT}->[$i] =~ /^(old|new) mode (\d+)$/ ? $mode : + $src->{TEXT}->[$i] =~ /^deleted file/ ? $deletion : + $head; push @{$dest->{TEXT}}, $src->{TEXT}->[$i]; push @{$dest->{DISPLAY}}, $src->{DISPLAY}->[$i]; } - return ($head, $mode); + return ($head, $mode, $deletion); } sub hunk_splittable { @@ -1206,7 +1209,7 @@ sub patch_update_file { my ($ix, $num); my $path = shift; my ($head, @hunk) = parse_diff($path); - ($head, my $mode) = parse_diff_header($head); + ($head, my $mode, my $deletion) = parse_diff_header($head); for (@{$head->{DISPLAY}}) { print; } @@ -1214,6 +1217,9 @@ sub patch_update_file { if (@{$mode->{TEXT}}) { unshift @hunk, $mode; } + if (@{$deletion->{TEXT}} && !@hunk) { + @hunk = ($deletion); + } $num = scalar @hunk; $ix = 0; @@ -1267,7 +1273,9 @@ sub patch_update_file { print; } print colored $prompt_color, $patch_mode_flavour{VERB}, - ($hunk[$ix]{TYPE} eq 'mode' ? ' mode change' : ' this hunk'), + ($hunk[$ix]{TYPE} eq 'mode' ? ' mode change' : + $hunk[$ix]{TYPE} eq 'deletion' ? ' deletion' : + ' this hunk'), $patch_mode_flavour{TARGET}, " [y,n,q,a,d,/$other,?]? "; my $line = prompt_single_character; @@ -289,7 +289,7 @@ split_patches () { prec=4 dotest="$GIT_DIR/rebase-apply" sign= utf8=t keep= skip= interactive= resolved= rebasing= abort= -resolvemsg= resume= scissors= +resolvemsg= resume= scissors= no_inbody_headers= git_apply_opt= committer_date_is_author_date= ignore_date= @@ -322,7 +322,7 @@ do --abort) abort=t ;; --rebasing) - rebasing=t threeway=t keep=t scissors=f ;; + rebasing=t threeway=t keep=t scissors=f no_inbody_headers=t ;; -d|--dotest) die "-d option is no longer supported. Do not use." ;; @@ -448,6 +448,7 @@ else echo "$utf8" >"$dotest/utf8" echo "$keep" >"$dotest/keep" echo "$scissors" >"$dotest/scissors" + echo "$no_inbody_headers" >"$dotest/no_inbody_headers" echo "$GIT_QUIET" >"$dotest/quiet" echo 1 >"$dotest/next" if test -n "$rebasing" @@ -495,6 +496,12 @@ t) f) scissors=--no-scissors ;; esac +if test "$(cat "$dotest/no_inbody_headers")" = t +then + no_inbody_headers=--no-inbody-headers +else + no_inbody_headers= +fi if test "$(cat "$dotest/quiet")" = t then GIT_QUIET=t @@ -549,7 +556,7 @@ do # by the user, or the user can tell us to do so by --resolved flag. case "$resume" in '') - git mailinfo $keep $scissors $utf8 "$dotest/msg" "$dotest/patch" \ + git mailinfo $keep $no_inbody_headers $scissors $utf8 "$dotest/msg" "$dotest/patch" \ <"$dotest/$msgnum" >"$dotest/info" || stop_here $this diff --git a/git-cvsimport.perl b/git-cvsimport.perl index 1ad20ac964..a7d215c8aa 100755 --- a/git-cvsimport.perl +++ b/git-cvsimport.perl @@ -579,10 +579,21 @@ sub get_headref ($) { return $r; } +my $user_filename_prepend = ''; +sub munge_user_filename { + my $name = shift; + return File::Spec->file_name_is_absolute($name) ? + $name : + $user_filename_prepend . $name; +} + -d $git_tree or mkdir($git_tree,0777) or die "Could not create $git_tree: $!"; -chdir($git_tree); +if ($git_tree ne '.') { + $user_filename_prepend = getwd() . '/'; + chdir($git_tree); +} my $last_branch = ""; my $orig_branch = ""; @@ -644,7 +655,7 @@ unless (-d $git_dir) { -f "$git_dir/cvs-authors" and read_author_info("$git_dir/cvs-authors"); if ($opt_A) { - read_author_info($opt_A); + read_author_info(munge_user_filename($opt_A)); write_author_info("$git_dir/cvs-authors"); } @@ -679,7 +690,7 @@ unless ($opt_P) { $? == 0 or die "git-cvsimport: fatal: cvsps reported error\n"; close $cvspsfh; } else { - $cvspsfile = $opt_P; + $cvspsfile = munge_user_filename($opt_P); } open(CVS, "<$cvspsfile") or die $!; diff --git a/git-instaweb.sh b/git-instaweb.sh index d96eddbe56..80a7f74fea 100755 --- a/git-instaweb.sh +++ b/git-instaweb.sh @@ -73,6 +73,11 @@ resolve_full_httpd () { } start_httpd () { + if test -f "$fqgitdir/pid"; then + say "Instance already running. Restarting..." + stop_httpd + fi + # here $httpd should have a meaningful value resolve_full_httpd diff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh index 23ded48322..9b1e899e27 100755 --- a/git-rebase--interactive.sh +++ b/git-rebase--interactive.sh @@ -408,7 +408,12 @@ do_next () { ;; *) warn "Unknown command: $command $sha1 $rest" - die_with_patch $sha1 "Please fix this in the file $TODO." + if git rev-parse --verify -q "$sha1" >/dev/null + then + die_with_patch $sha1 "Please fix this in the file $TODO." + else + die "Please fix this in the file $TODO." + fi ;; esac test -s "$TODO" && return diff --git a/git-send-email.perl b/git-send-email.perl index f5ba4e7699..a0279de687 100755 --- a/git-send-email.perl +++ b/git-send-email.perl @@ -835,7 +835,7 @@ sub send_message $gitversion = Git::version(); } - my $cc = join(", ", unique_email_list(@cc)); + my $cc = join(",\n\t", unique_email_list(@cc)); my $ccline = ""; if ($cc ne '') { $ccline = "\nCc: $cc"; @@ -976,7 +976,9 @@ X-Mailer: git-send-email $gitversion if ($smtp_server !~ m#^/#) { print "Server: $smtp_server\n"; print "MAIL FROM:<$raw_from>\n"; - print "RCPT TO:".join(',',(map { "<$_>" } @recipients))."\n"; + foreach my $entry (@recipients) { + print "RCPT TO:<$entry>\n"; + } } else { print "Sendmail: $smtp_server ".join(' ',@sendmail_parameters)."\n"; } diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl index 24b219310a..c77cd0341d 100755 --- a/gitweb/gitweb.perl +++ b/gitweb/gitweb.perl @@ -1083,8 +1083,7 @@ sub to_utf8 { # correct, but quoted slashes look too horrible in bookmarks sub esc_param { my $str = shift; - $str =~ s/([^A-Za-z0-9\-_.~()\/:@])/sprintf("%%%02X", ord($1))/eg; - $str =~ s/\+/%2B/g; + $str =~ s/([^A-Za-z0-9\-_.~()\/:@ ]+)/CGI::escape($1)/eg; $str =~ s/ /\+/g; return $str; } @@ -5065,7 +5064,8 @@ sub git_blob { chomp $line; $nr++; $line = untabify($line); - printf "<div class=\"pre\"><a id=\"l%i\" href=\"#l%i\" class=\"linenr\">%4i</a> %s</div>\n", + printf "<div class=\"pre\"><a id=\"l%i\" href=\"" . href(-replay => 1) + . "#l%i\" class=\"linenr\">%4i</a> %s</div>\n", $nr, $nr, $nr, esc_html($line, -nbsp=>1); } } @@ -5328,7 +5328,7 @@ sub git_commit { } @$parents ) . ')'; } - if (gitweb_check_feature('patches')) { + if (gitweb_check_feature('patches') && @$parents <= 1) { $formats_nav .= " | " . $cgi->a({-href => href(action=>"patch", -replay=>1)}, "patch"); @@ -5616,7 +5616,7 @@ sub git_commitdiff { $formats_nav = $cgi->a({-href => href(action=>"commitdiff_plain", -replay=>1)}, "raw"); - if ($patch_max) { + if ($patch_max && @{$co{'parents'}} <= 1) { $formats_nav .= " | " . $cgi->a({-href => href(action=>"patch", -replay=>1)}, "patch"); @@ -5824,7 +5824,7 @@ sub git_commitdiff_plain { # format-patch-style patches sub git_patch { - git_commitdiff(-format => 'patch', -single=> 1); + git_commitdiff(-format => 'patch', -single => 1); } sub git_patches { @@ -6,7 +6,6 @@ struct git_graph; /* * Create a new struct git_graph. - * The graph should be freed with graph_release() when no longer needed. */ struct git_graph *graph_init(struct rev_info *opt); @@ -41,6 +41,7 @@ static void compile_regexp(struct grep_pat *p, struct grep_opt *opt) int err; p->word_regexp = opt->word_regexp; + p->ignore_case = opt->ignore_case; if (opt->fixed || is_fixed(p->pattern)) p->fixed = 1; @@ -262,9 +263,15 @@ static void show_name(struct grep_opt *opt, const char *name) printf("%s%c", name, opt->null_following_name ? '\0' : '\n'); } -static int fixmatch(const char *pattern, char *line, regmatch_t *match) + +static int fixmatch(const char *pattern, char *line, int ignore_case, regmatch_t *match) { - char *hit = strstr(line, pattern); + char *hit; + if (ignore_case) + hit = strcasestr(line, pattern); + else + hit = strstr(line, pattern); + if (!hit) { match->rm_so = match->rm_eo = -1; return REG_NOMATCH; @@ -326,7 +333,7 @@ static int match_one_pattern(struct grep_pat *p, char *bol, char *eol, again: if (p->fixed) - hit = !fixmatch(p->pattern, bol, pmatch); + hit = !fixmatch(p->pattern, bol, p->ignore_case, pmatch); else hit = !regexec(&p->regexp, bol, 1, pmatch, eflags); @@ -32,6 +32,7 @@ struct grep_pat { enum grep_header_field field; regex_t regexp; unsigned fixed:1; + unsigned ignore_case:1; unsigned word_regexp:1; }; @@ -64,6 +65,7 @@ struct grep_opt { regex_t regexp; int linenum; int invert; + int ignore_case; int status_only; int name_only; int unmatch_name_only; diff --git a/imap-send.c b/imap-send.c index 3847fd151d..f805c6ed81 100644 --- a/imap-send.c +++ b/imap-send.c @@ -273,7 +273,11 @@ static int ssl_socket_connect(struct imap_socket *sock, int use_tls_only, int ve fprintf(stderr, "SSL requested but SSL support not compiled in\n"); return -1; #else +#if (OPENSSL_VERSION_NUMBER >= 0x10000000L) + const SSL_METHOD *meth; +#else SSL_METHOD *meth; +#endif SSL_CTX *ctx; int ret; @@ -11,6 +11,7 @@ * which is what it's designed for. */ #include "cache.h" +#include "strbuf.h" static char bad_path[] = "/bad-path/"; @@ -207,43 +208,49 @@ int validate_headref(const char *path) return -1; } -static char *user_path(char *buf, char *path, int sz) +static struct passwd *getpw_str(const char *username, size_t len) { struct passwd *pw; - char *slash; - int len, baselen; + char *username_z = xmalloc(len + 1); + memcpy(username_z, username, len); + username_z[len] = '\0'; + pw = getpwnam(username_z); + free(username_z); + return pw; +} - if (!path || path[0] != '~') - return NULL; - path++; - slash = strchr(path, '/'); - if (path[0] == '/' || !path[0]) { - pw = getpwuid(getuid()); - } - else { - if (slash) { - *slash = 0; - pw = getpwnam(path); - *slash = '/'; +/* + * Return a string with ~ and ~user expanded via getpw*. If buf != NULL, + * then it is a newly allocated string. Returns NULL on getpw failure or + * if path is NULL. + */ +char *expand_user_path(const char *path) +{ + struct strbuf user_path = STRBUF_INIT; + const char *first_slash = strchrnul(path, '/'); + const char *to_copy = path; + + if (path == NULL) + goto return_null; + if (path[0] == '~') { + const char *username = path + 1; + size_t username_len = first_slash - username; + if (username_len == 0) { + const char *home = getenv("HOME"); + strbuf_add(&user_path, home, strlen(home)); + } else { + struct passwd *pw = getpw_str(username, username_len); + if (!pw) + goto return_null; + strbuf_add(&user_path, pw->pw_dir, strlen(pw->pw_dir)); } - else - pw = getpwnam(path); + to_copy = first_slash; } - if (!pw || !pw->pw_dir || sz <= strlen(pw->pw_dir)) - return NULL; - baselen = strlen(pw->pw_dir); - memcpy(buf, pw->pw_dir, baselen); - while ((1 < baselen) && (buf[baselen-1] == '/')) { - buf[baselen-1] = 0; - baselen--; - } - if (slash && slash[1]) { - len = strlen(slash); - if (sz <= baselen + len) - return NULL; - memcpy(buf + baselen, slash, len + 1); - } - return buf; + strbuf_add(&user_path, to_copy, strlen(to_copy)); + return strbuf_detach(&user_path, NULL); +return_null: + strbuf_release(&user_path); + return NULL; } /* @@ -291,8 +298,18 @@ char *enter_repo(char *path, int strict) if (PATH_MAX <= len) return NULL; if (path[0] == '~') { - if (!user_path(used_path, path, PATH_MAX)) + char *newpath = expand_user_path(path); + if (!newpath || (PATH_MAX - 10 < strlen(newpath))) { + free(newpath); return NULL; + } + /* + * Copy back into the static buffer. A pity + * since newpath was not bounded, but other + * branches of the if are limited by PATH_MAX + * anyway. + */ + strcpy(used_path, newpath); free(newpath); strcpy(validated_path, path); path = used_path; } diff --git a/progress.c b/progress.c index 132ed95a3d..3971f49f4d 100644 --- a/progress.c +++ b/progress.c @@ -131,7 +131,13 @@ static void throughput_string(struct throughput *tp, off_t total, } else { l -= snprintf(tp->display, l, ", %u bytes", (int)total); } - if (rate) + + if (rate > 1 << 10) { + int x = rate + 5; /* for rounding */ + snprintf(tp->display + sizeof(tp->display) - l, l, + " | %u.%2.2u MiB/s", + x >> 10, ((x & ((1 << 10) - 1)) * 100) >> 10); + } else if (rate) snprintf(tp->display + sizeof(tp->display) - l, l, " | %u KiB/s", rate); } diff --git a/remote-curl.c b/remote-curl.c index ad6a1637b5..ebdab3603e 100644 --- a/remote-curl.c +++ b/remote-curl.c @@ -3,6 +3,7 @@ #include "strbuf.h" #include "walker.h" #include "http.h" +#include "exec_cmd.h" static struct ref *get_refs(struct walker *walker, const char *url) { @@ -81,8 +82,10 @@ int main(int argc, const char **argv) struct strbuf buf = STRBUF_INIT; const char *url; struct walker *walker = NULL; + int nongit; - setup_git_directory(); + git_extract_argv0_path(argv[0]); + setup_git_directory_gently(&nongit); if (argc < 2) { fprintf(stderr, "Remote needed\n"); return 1; @@ -101,6 +104,8 @@ int main(int argc, const char **argv) break; if (!prefixcmp(buf.buf, "fetch ")) { char *obj = buf.buf + strlen("fetch "); + if (nongit) + die("Fetch attempted without a local repo"); if (!walker) walker = get_http_walker(url, remote); walker->get_all = 1; diff --git a/sha1_file.c b/sha1_file.c index 4ea0b18d0a..63981fb3fd 100644 --- a/sha1_file.c +++ b/sha1_file.c @@ -1587,13 +1587,15 @@ static void *unpack_compressed_entry(struct packed_git *p, buffer[size] = 0; memset(&stream, 0, sizeof(stream)); stream.next_out = buffer; - stream.avail_out = size; + stream.avail_out = size + 1; git_inflate_init(&stream); do { in = use_pack(p, w_curs, curpos, &stream.avail_in); stream.next_in = in; st = git_inflate(&stream, Z_FINISH); + if (!stream.avail_out) + break; /* the payload is larger than it should be */ curpos += stream.next_in - in; } while (st == Z_OK || st == Z_BUF_ERROR); git_inflate_end(&stream); diff --git a/t/t3003-ls-files-exclude.sh b/t/t3003-ls-files-exclude.sh new file mode 100755 index 0000000000..d5ec333131 --- /dev/null +++ b/t/t3003-ls-files-exclude.sh @@ -0,0 +1,40 @@ +#!/bin/sh + +test_description='ls-files --exclude does not affect index files' +. ./test-lib.sh + +test_expect_success 'create repo with file' ' + echo content >file && + git add file && + git commit -m file && + echo modification >file +' + +check_output() { +test_expect_success "ls-files output contains file ($1)" " + echo '$2' >expect && + git ls-files --exclude-standard --$1 >output && + test_cmp expect output +" +} + +check_all_output() { + check_output 'cached' 'file' + check_output 'modified' 'file' +} + +check_all_output +test_expect_success 'add file to gitignore' ' + echo file >.gitignore +' +check_all_output + +test_expect_success 'ls-files -i lists only tracked-but-ignored files' ' + echo content >other-file && + git add other-file && + echo file >expect && + git ls-files -i --exclude-standard >output && + test_cmp expect output +' + +test_done diff --git a/t/t3701-add-interactive.sh b/t/t3701-add-interactive.sh index 62fd65e18d..d86bc81abf 100755 --- a/t/t3701-add-interactive.sh +++ b/t/t3701-add-interactive.sh @@ -138,6 +138,20 @@ test_expect_success 'real edit works' ' test_cmp expected output ' +test_expect_success 'skip files similarly as commit -a' ' + git reset && + echo file >.gitignore && + echo changed >file && + echo y | git add -p file && + git diff >output && + git reset && + git commit -am commit && + git diff >expected && + test_cmp expected output && + git reset --hard HEAD^ +' +rm -f .gitignore + if test "$(git config --bool core.filemode)" = false then say 'skipping filemode tests (filesystem does not properly support modes)' @@ -214,4 +228,21 @@ test_expect_success 'add first line works' ' test_cmp expected diff ' +cat >expected <<EOF +diff --git a/empty b/empty +deleted file mode 100644 +index e69de29..0000000 +EOF + +test_expect_success 'deleting an empty file' ' + git reset --hard && + > empty && + git add empty && + git commit -m empty && + rm empty && + echo y | git add -p empty && + git diff --cached >diff && + test_cmp expected diff +' + test_done diff --git a/t/t4014-format-patch.sh b/t/t4014-format-patch.sh index 531f5b795c..cab6ce2e97 100755 --- a/t/t4014-format-patch.sh +++ b/t/t4014-format-patch.sh @@ -455,6 +455,27 @@ test_expect_success 'format-patch respects -U' ' ' +cat > expect << EOF + +diff --git a/file b/file +index 40f36c6..2dc5c23 100644 +--- a/file ++++ b/file +@@ -14,3 +14,19 @@ C + D + E + F ++5 +EOF + +test_expect_success 'format-patch -p suppresses stat' ' + + git format-patch -p -2 && + sed -e "1,/^$/d" -e "/^+5/q" < 0001-This-is-an-excessively-long-subject-line-for-a-messa.patch > output && + test_cmp expect output + +' + test_expect_success 'format-patch from a subdirectory (1)' ' filename=$( rm -rf sub && diff --git a/t/t4015-diff-whitespace.sh b/t/t4015-diff-whitespace.sh index 6d13da30da..8dd147d78f 100755 --- a/t/t4015-diff-whitespace.sh +++ b/t/t4015-diff-whitespace.sh @@ -362,10 +362,17 @@ test_expect_success 'line numbers in --check output are correct' ' ' -test_expect_success 'checkdiff detects trailing blank lines' ' +test_expect_success 'checkdiff detects new trailing blank lines (1)' ' echo "foo();" >x && echo "" >>x && - git diff --check | grep "ends with blank" + git diff --check | grep "new blank line" +' + +test_expect_success 'checkdiff detects new trailing blank lines (2)' ' + { echo a; echo b; echo; echo; } >x && + git add x && + { echo a; echo; echo; echo; echo; } >x && + git diff --check | grep "new blank line" ' test_expect_success 'checkdiff allows new blank lines' ' diff --git a/t/t4019-diff-wserror.sh b/t/t4019-diff-wserror.sh index 84a1fe3115..3a3663fbcb 100755 --- a/t/t4019-diff-wserror.sh +++ b/t/t4019-diff-wserror.sh @@ -165,7 +165,7 @@ test_expect_success 'trailing empty lines (1)' ' rm -f .gitattributes && test_must_fail git diff --check >output && - grep "ends with blank lines." output && + grep "new blank line at" output && grep "trailing whitespace" output ' @@ -190,4 +190,13 @@ test_expect_success 'do not color trailing cr in context' ' ' +test_expect_success 'color new trailing blank lines' ' + { echo a; echo b; echo; echo; } >x && + git add x && + { echo a; echo; echo; echo; echo c; echo; echo; echo; echo; } >x && + git diff --color x >output && + cnt=$(grep "${blue_grep}" output | wc -l) && + test $cnt = 2 +' + test_done diff --git a/t/t4034-diff-words.sh b/t/t4034-diff-words.sh index 4508effcaa..21db6e95c4 100755 --- a/t/t4034-diff-words.sh +++ b/t/t4034-diff-words.sh @@ -68,6 +68,26 @@ cat > expect <<\EOF <WHITE>index 330b04f..5ed8eff 100644<RESET> <WHITE>--- a/pre<RESET> <WHITE>+++ b/post<RESET> +<BROWN>@@ -1 +1 @@<RESET> +<RED>h(4)<RESET><GREEN>h(4),hh[44]<RESET> +<BROWN>@@ -3,0 +4,4 @@ a = b + c<RESET> + +<GREEN>aa = a<RESET> + +<GREEN>aeff = aeff * ( aaa )<RESET> +EOF + +test_expect_success 'word diff without context' ' + + word_diff --color-words --unified=0 + +' + +cat > expect <<\EOF +<WHITE>diff --git a/pre b/post<RESET> +<WHITE>index 330b04f..5ed8eff 100644<RESET> +<WHITE>--- a/pre<RESET> +<WHITE>+++ b/post<RESET> <BROWN>@@ -1,3 +1,7 @@<RESET> h(4),<GREEN>hh<RESET>[44] <RESET> diff --git a/t/t4124-apply-ws-rule.sh b/t/t4124-apply-ws-rule.sh index fac2093d7f..ca26397590 100755 --- a/t/t4124-apply-ws-rule.sh +++ b/t/t4124-apply-ws-rule.sh @@ -170,4 +170,95 @@ test_expect_success 'trailing whitespace & no newline at the end of file' ' grep "^$" target ' +test_expect_success 'blank at EOF with --whitespace=fix (1)' ' + : these can fail depending on what we did before + git config --unset core.whitespace + rm -f .gitattributes + + { echo a; echo b; echo c; } >one && + git add one && + { echo a; echo b; echo c; } >expect && + { cat expect; echo; } >one && + git diff -- one >patch && + + git checkout one && + git apply --whitespace=fix patch && + test_cmp expect one +' + +test_expect_success 'blank at EOF with --whitespace=fix (2)' ' + { echo a; echo b; echo c; } >one && + git add one && + { echo a; echo c; } >expect && + { cat expect; echo; echo; } >one && + git diff -- one >patch && + + git checkout one && + git apply --whitespace=fix patch && + test_cmp expect one +' + +test_expect_success 'blank at EOF with --whitespace=fix (3)' ' + { echo a; echo b; echo; } >one && + git add one && + { echo a; echo c; echo; } >expect && + { cat expect; echo; echo; } >one && + git diff -- one >patch && + + git checkout one && + git apply --whitespace=fix patch && + test_cmp expect one +' + +test_expect_success 'blank at end of hunk, not at EOF with --whitespace=fix' ' + { echo a; echo b; echo; echo; echo; echo; echo; echo d; } >one && + git add one && + { echo a; echo c; echo; echo; echo; echo; echo; echo; echo d; } >expect && + cp expect one && + git diff -- one >patch && + + git checkout one && + git apply --whitespace=fix patch && + test_cmp expect one +' + +test_expect_success 'blank at EOF with --whitespace=warn' ' + { echo a; echo b; echo c; } >one && + git add one && + echo >>one && + cat one >expect && + git diff -- one >patch && + + git checkout one && + git apply --whitespace=warn patch 2>error && + test_cmp expect one && + grep "new blank line at EOF" error +' + +test_expect_success 'blank at EOF with --whitespace=error' ' + { echo a; echo b; echo c; } >one && + git add one && + cat one >expect && + echo >>one && + git diff -- one >patch && + + git checkout one && + test_must_fail git apply --whitespace=error patch 2>error && + test_cmp expect one && + grep "new blank line at EOF" error +' + +test_expect_success 'blank but not empty at EOF' ' + { echo a; echo b; echo c; } >one && + git add one && + echo " " >>one && + cat one >expect && + git diff -- one >patch && + + git checkout one && + git apply --whitespace=warn patch 2>error && + test_cmp expect one && + grep "new blank line at EOF" error +' + test_done diff --git a/t/t4128-apply-root.sh b/t/t4128-apply-root.sh index 8f6aea48d8..6cc741a634 100755 --- a/t/t4128-apply-root.sh +++ b/t/t4128-apply-root.sh @@ -58,6 +58,23 @@ test_expect_success 'apply --directory (new file)' ' ' cat > patch << EOF +diff --git a/c/newfile2 b/c/newfile2 +new file mode 100644 +index 0000000..d95f3ad +--- /dev/null ++++ b/c/newfile2 +@@ -0,0 +1 @@ ++content +EOF + +test_expect_success 'apply --directory -p (new file)' ' + git reset --hard initial && + git apply -p2 --directory=some/sub/dir/ --index patch && + test content = $(git show :some/sub/dir/newfile2) && + test content = $(cat some/sub/dir/newfile2) +' + +cat > patch << EOF diff --git a/delfile b/delfile deleted file mode 100644 index d95f3ad..0000000 diff --git a/t/t5100-mailinfo.sh b/t/t5100-mailinfo.sh index 0279d07c83..ebc36c1758 100755 --- a/t/t5100-mailinfo.sh +++ b/t/t5100-mailinfo.sh @@ -11,7 +11,7 @@ test_expect_success 'split sample box' \ 'git mailsplit -o. "$TEST_DIRECTORY"/t5100/sample.mbox >last && last=`cat last` && echo total is $last && - test `cat last` = 14' + test `cat last` = 16' check_mailinfo () { mail=$1 opt=$2 @@ -30,6 +30,10 @@ do if test -f "$TEST_DIRECTORY"/t5100/msg$mail--scissors then check_mailinfo $mail --scissors + fi && + if test -f "$TEST_DIRECTORY"/t5100/msg$mail--no-inbody-headers + then + check_mailinfo $mail --no-inbody-headers fi ' done diff --git a/t/t5100/.gitattributes b/t/t5100/.gitattributes new file mode 100644 index 0000000000..c93f5142fa --- /dev/null +++ b/t/t5100/.gitattributes @@ -0,0 +1,4 @@ +msg* encoding=UTF-8 +info* encoding=UTF-8 +rfc2047-info-* encoding=UTF-8 +sample.mbox encoding=UTF-8 diff --git a/t/t5100/0010 b/t/t5100/0010 deleted file mode 100644 index f5892c9da7..0000000000 --- a/t/t5100/0010 +++ /dev/null @@ -1,35 +0,0 @@ -From b9704a518e21158433baa2cc2d591fea687967f6 Mon Sep 17 00:00:00 2001 -From: =?UTF-8?q?Lukas=20Sandstr=C3=B6m?= <lukass@etek.chalmers.se> -Date: Thu, 10 Jul 2008 23:41:33 +0200 -Subject: Re: discussion that lead to this patch -MIME-Version: 1.0 -Content-Type: text/plain; charset=UTF-8 -Content-Transfer-Encoding: 8bit - -[PATCH] git-mailinfo: Fix getting the subject from the body - -"Subject: " isn't in the static array "header", and thus -memcmp("Subject: ", header[i], 7) will never match. - -Signed-off-by: Lukas Sandström <lukass@etek.chalmers.se> -Signed-off-by: Junio C Hamano <gitster@pobox.com> ---- - builtin-mailinfo.c | 2 +- - 1 files changed, 1 insertions(+), 1 deletions(-) - -diff --git a/builtin-mailinfo.c b/builtin-mailinfo.c -index 962aa34..2d1520f 100644 ---- a/builtin-mailinfo.c -+++ b/builtin-mailinfo.c -@@ -334,7 +334,7 @@ static int check_header(char *line, unsigned linesize, char **hdr_data, int over - return 1; - if (!memcmp("[PATCH]", line, 7) && isspace(line[7])) { - for (i = 0; header[i]; i++) { -- if (!memcmp("Subject: ", header[i], 9)) { -+ if (!memcmp("Subject", header[i], 7)) { - if (! handle_header(line, hdr_data[i], 0)) { - return 1; - } --- -1.5.6.2.455.g1efb2 - diff --git a/t/t5100/info0015 b/t/t5100/info0015 new file mode 100644 index 0000000000..0114f106c5 --- /dev/null +++ b/t/t5100/info0015 @@ -0,0 +1,5 @@ +Author: +Email: +Subject: check bogus body header (from) +Date: Fri, 9 Jun 2006 00:44:16 -0700 + diff --git a/t/t5100/info0015--no-inbody-headers b/t/t5100/info0015--no-inbody-headers new file mode 100644 index 0000000000..c4d8d7720e --- /dev/null +++ b/t/t5100/info0015--no-inbody-headers @@ -0,0 +1,5 @@ +Author: A U Thor +Email: a.u.thor@example.com +Subject: check bogus body header (from) +Date: Fri, 9 Jun 2006 00:44:16 -0700 + diff --git a/t/t5100/info0016 b/t/t5100/info0016 new file mode 100644 index 0000000000..38ccd0dcf2 --- /dev/null +++ b/t/t5100/info0016 @@ -0,0 +1,5 @@ +Author: A U Thor +Email: a.u.thor@example.com +Subject: check bogus body header (date) +Date: bogus + diff --git a/t/t5100/info0016--no-inbody-headers b/t/t5100/info0016--no-inbody-headers new file mode 100644 index 0000000000..f4857d45df --- /dev/null +++ b/t/t5100/info0016--no-inbody-headers @@ -0,0 +1,5 @@ +Author: A U Thor +Email: a.u.thor@example.com +Subject: check bogus body header (date) +Date: Fri, 9 Jun 2006 00:44:16 -0700 + diff --git a/t/t5100/msg0015 b/t/t5100/msg0015 new file mode 100644 index 0000000000..9577238685 --- /dev/null +++ b/t/t5100/msg0015 @@ -0,0 +1,2 @@ +- a list + - of stuff diff --git a/t/t5100/msg0015--no-inbody-headers b/t/t5100/msg0015--no-inbody-headers new file mode 100644 index 0000000000..be5115b1c1 --- /dev/null +++ b/t/t5100/msg0015--no-inbody-headers @@ -0,0 +1,3 @@ +From: bogosity + - a list + - of stuff diff --git a/t/t5100/msg0016 b/t/t5100/msg0016 new file mode 100644 index 0000000000..0d9adada96 --- /dev/null +++ b/t/t5100/msg0016 @@ -0,0 +1,2 @@ +and some content + diff --git a/t/t5100/msg0016--no-inbody-headers b/t/t5100/msg0016--no-inbody-headers new file mode 100644 index 0000000000..1063f51178 --- /dev/null +++ b/t/t5100/msg0016--no-inbody-headers @@ -0,0 +1,4 @@ +Date: bogus + +and some content + diff --git a/t/t5100/patch0015 b/t/t5100/patch0015 new file mode 100644 index 0000000000..ad64848873 --- /dev/null +++ b/t/t5100/patch0015 @@ -0,0 +1,8 @@ +--- +diff --git a/foo b/foo +index e69de29..d95f3ad 100644 +--- a/foo ++++ b/foo +@@ -0,0 +1 @@ ++content + diff --git a/t/t5100/patch0015--no-inbody-headers b/t/t5100/patch0015--no-inbody-headers new file mode 100644 index 0000000000..ad64848873 --- /dev/null +++ b/t/t5100/patch0015--no-inbody-headers @@ -0,0 +1,8 @@ +--- +diff --git a/foo b/foo +index e69de29..d95f3ad 100644 +--- a/foo ++++ b/foo +@@ -0,0 +1 @@ ++content + diff --git a/t/t5100/patch0016 b/t/t5100/patch0016 new file mode 100644 index 0000000000..ad64848873 --- /dev/null +++ b/t/t5100/patch0016 @@ -0,0 +1,8 @@ +--- +diff --git a/foo b/foo +index e69de29..d95f3ad 100644 +--- a/foo ++++ b/foo +@@ -0,0 +1 @@ ++content + diff --git a/t/t5100/patch0016--no-inbody-headers b/t/t5100/patch0016--no-inbody-headers new file mode 100644 index 0000000000..ad64848873 --- /dev/null +++ b/t/t5100/patch0016--no-inbody-headers @@ -0,0 +1,8 @@ +--- +diff --git a/foo b/foo +index e69de29..d95f3ad 100644 +--- a/foo ++++ b/foo +@@ -0,0 +1 @@ ++content + diff --git a/t/t5100/sample.mbox b/t/t5100/sample.mbox index 13fa4ae03b..de1031241d 100644 --- a/t/t5100/sample.mbox +++ b/t/t5100/sample.mbox @@ -650,3 +650,36 @@ index b0b5d8f..461c47e 100644 convert_to_utf8(line, charset.buf); -- 1.6.4.1 +From nobody Mon Sep 17 00:00:00 2001 +From: A U Thor <a.u.thor@example.com> +Subject: check bogus body header (from) +Date: Fri, 9 Jun 2006 00:44:16 -0700 + +From: bogosity + - a list + - of stuff +--- +diff --git a/foo b/foo +index e69de29..d95f3ad 100644 +--- a/foo ++++ b/foo +@@ -0,0 +1 @@ ++content + +From nobody Mon Sep 17 00:00:00 2001 +From: A U Thor <a.u.thor@example.com> +Subject: check bogus body header (date) +Date: Fri, 9 Jun 2006 00:44:16 -0700 + +Date: bogus + +and some content + +--- +diff --git a/foo b/foo +index e69de29..d95f3ad 100644 +--- a/foo ++++ b/foo +@@ -0,0 +1 @@ ++content + diff --git a/t/t5303-pack-corruption-resilience.sh b/t/t5303-pack-corruption-resilience.sh index 5132d41309..5f6cd4f333 100755 --- a/t/t5303-pack-corruption-resilience.sh +++ b/t/t5303-pack-corruption-resilience.sh @@ -275,4 +275,13 @@ test_expect_success \ git cat-file blob $blob_2 > /dev/null && git cat-file blob $blob_3 > /dev/null' +test_expect_success \ + 'corrupting header to have too small output buffer fails unpack' \ + 'create_new_pack && + git prune-packed && + printf "\262\001" | do_corrupt_object $blob_1 0 && + test_must_fail git cat-file blob $blob_1 > /dev/null && + test_must_fail git cat-file blob $blob_2 > /dev/null && + test_must_fail git cat-file blob $blob_3 > /dev/null' + test_done diff --git a/t/t6120-describe.sh b/t/t6120-describe.sh index 8c7e081c53..f5a1b615f6 100755 --- a/t/t6120-describe.sh +++ b/t/t6120-describe.sh @@ -34,6 +34,8 @@ test_expect_success setup ' echo one >file && git add file && git commit -m initial && one=$(git rev-parse HEAD) && + git describe --always HEAD && + test_tick && echo two >file && git add file && git commit -m second && two=$(git rev-parse HEAD) && diff --git a/t/t7002-grep.sh b/t/t7002-grep.sh index ae56a36eac..3a103fec96 100755 --- a/t/t7002-grep.sh +++ b/t/t7002-grep.sh @@ -14,6 +14,7 @@ int main(int argc, const char **argv) { printf("Hello world.\n"); return 0; + /* char ?? */ } EOF @@ -213,6 +214,72 @@ test_expect_success 'grep -e A --and --not -e B' ' test_cmp expected actual ' +test_expect_success 'grep -f, non-existent file' ' + test_must_fail git grep -f patterns +' + +cat >expected <<EOF +file:foo mmap bar +file:foo_mmap bar +file:foo_mmap bar mmap +file:foo mmap bar_mmap +file:foo_mmap bar mmap baz +EOF + +cat >pattern <<EOF +mmap +EOF + +test_expect_success 'grep -f, one pattern' ' + git grep -f pattern >actual && + test_cmp expected actual +' + +cat >expected <<EOF +file:foo mmap bar +file:foo_mmap bar +file:foo_mmap bar mmap +file:foo mmap bar_mmap +file:foo_mmap bar mmap baz +t/a/v:vvv +t/v:vvv +v:vvv +EOF + +cat >patterns <<EOF +mmap +vvv +EOF + +test_expect_success 'grep -f, multiple patterns' ' + git grep -f patterns >actual && + test_cmp expected actual +' + +cat >expected <<EOF +file:foo mmap bar +file:foo_mmap bar +file:foo_mmap bar mmap +file:foo mmap bar_mmap +file:foo_mmap bar mmap baz +t/a/v:vvv +t/v:vvv +v:vvv +EOF + +cat >patterns <<EOF + +mmap + +vvv + +EOF + +test_expect_success 'grep -f, ignore empty lines' ' + git grep -f patterns >actual && + test_cmp expected actual +' + cat >expected <<EOF y:y yy -- @@ -345,4 +412,13 @@ test_expect_success 'grep from a subdirectory to search wider area (2)' ' ) ' +cat >expected <<EOF +hello.c:int main(int argc, const char **argv) +EOF + +test_expect_success 'grep -Fi' ' + git grep -Fi "CHAR *" >actual && + test_cmp expected actual +' + test_done diff --git a/t/t7604-merge-custom-message.sh b/t/t7604-merge-custom-message.sh index de977c5e2f..269cfdf267 100755 --- a/t/t7604-merge-custom-message.sh +++ b/t/t7604-merge-custom-message.sh @@ -22,15 +22,12 @@ test_expect_success 'setup' ' git tag c2 ' -cat >expected <<\EOF -custom message -Merge commit 'c2' -EOF test_expect_success 'merge c2 with a custom message' ' git reset --hard c1 && + echo >expected "custom message" && git merge -m "custom message" c2 && - git cat-file commit HEAD | sed -e "1,/^$/d" > actual && + git cat-file commit HEAD | sed -e "1,/^$/d" >actual && test_cmp expected actual ' diff --git a/t/t7800-difftool.sh b/t/t7800-difftool.sh index ebdccf9a1e..fff6a6d0ea 100755 --- a/t/t7800-difftool.sh +++ b/t/t7800-difftool.sh @@ -136,7 +136,7 @@ test_expect_success 'GIT_DIFFTOOL_PROMPT variable' ' GIT_DIFFTOOL_PROMPT=true && export GIT_DIFFTOOL_PROMPT && - prompt=$(echo | git difftool --prompt branch | tail -1) && + prompt=$(echo | git difftool branch | tail -1) && prompt_given "$prompt" && restore_test_defaults diff --git a/t/t9001-send-email.sh b/t/t9001-send-email.sh index fb606a9f05..84a7f03d46 100755 --- a/t/t9001-send-email.sh +++ b/t/t9001-send-email.sh @@ -103,10 +103,18 @@ cat >expected-show-all-headers <<\EOF Dry-OK. Log says: Server: relay.example.com MAIL FROM:<from@example.com> -RCPT TO:<to@example.com>,<cc@example.com>,<author@example.com>,<one@example.com>,<two@example.com>,<bcc@example.com> +RCPT TO:<to@example.com> +RCPT TO:<cc@example.com> +RCPT TO:<author@example.com> +RCPT TO:<one@example.com> +RCPT TO:<two@example.com> +RCPT TO:<bcc@example.com> From: Example <from@example.com> To: to@example.com -Cc: cc@example.com, A <author@example.com>, One <one@example.com>, two@example.com +Cc: cc@example.com, + A <author@example.com>, + One <one@example.com>, + two@example.com Subject: [PATCH 1/1] Second. Date: DATE-STRING Message-Id: MESSAGE-ID-STRING @@ -164,7 +172,7 @@ test_expect_success 'cccmd works' ' --smtp-server="$(pwd)/fake.sendmail" \ cccmd.patch \ && - grep ^Cc:.*cccmd@example.com msgtxt1 + grep "^ cccmd@example.com" msgtxt1 ' z8=zzzzzzzz @@ -278,10 +286,17 @@ cat >expected-suppress-sob <<\EOF Dry-OK. Log says: Server: relay.example.com MAIL FROM:<from@example.com> -RCPT TO:<to@example.com>,<cc@example.com>,<author@example.com>,<one@example.com>,<two@example.com> +RCPT TO:<to@example.com> +RCPT TO:<cc@example.com> +RCPT TO:<author@example.com> +RCPT TO:<one@example.com> +RCPT TO:<two@example.com> From: Example <from@example.com> To: to@example.com -Cc: cc@example.com, A <author@example.com>, One <one@example.com>, two@example.com +Cc: cc@example.com, + A <author@example.com>, + One <one@example.com>, + two@example.com Subject: [PATCH 1/1] Second. Date: DATE-STRING Message-Id: MESSAGE-ID-STRING @@ -318,10 +333,15 @@ cat >expected-suppress-sob <<\EOF Dry-OK. Log says: Server: relay.example.com MAIL FROM:<from@example.com> -RCPT TO:<to@example.com>,<author@example.com>,<one@example.com>,<two@example.com> +RCPT TO:<to@example.com> +RCPT TO:<author@example.com> +RCPT TO:<one@example.com> +RCPT TO:<two@example.com> From: Example <from@example.com> To: to@example.com -Cc: A <author@example.com>, One <one@example.com>, two@example.com +Cc: A <author@example.com>, + One <one@example.com>, + two@example.com Subject: [PATCH 1/1] Second. Date: DATE-STRING Message-Id: MESSAGE-ID-STRING @@ -344,10 +364,17 @@ cat >expected-suppress-cccmd <<\EOF Dry-OK. Log says: Server: relay.example.com MAIL FROM:<from@example.com> -RCPT TO:<to@example.com>,<author@example.com>,<one@example.com>,<two@example.com>,<committer@example.com> +RCPT TO:<to@example.com> +RCPT TO:<author@example.com> +RCPT TO:<one@example.com> +RCPT TO:<two@example.com> +RCPT TO:<committer@example.com> From: Example <from@example.com> To: to@example.com -Cc: A <author@example.com>, One <one@example.com>, two@example.com, C O Mitter <committer@example.com> +Cc: A <author@example.com>, + One <one@example.com>, + two@example.com, + C O Mitter <committer@example.com> Subject: [PATCH 1/1] Second. Date: DATE-STRING Message-Id: MESSAGE-ID-STRING @@ -392,10 +419,17 @@ cat >expected-suppress-body <<\EOF Dry-OK. Log says: Server: relay.example.com MAIL FROM:<from@example.com> -RCPT TO:<to@example.com>,<author@example.com>,<one@example.com>,<two@example.com>,<cc-cmd@example.com> +RCPT TO:<to@example.com> +RCPT TO:<author@example.com> +RCPT TO:<one@example.com> +RCPT TO:<two@example.com> +RCPT TO:<cc-cmd@example.com> From: Example <from@example.com> To: to@example.com -Cc: A <author@example.com>, One <one@example.com>, two@example.com, cc-cmd@example.com +Cc: A <author@example.com>, + One <one@example.com>, + two@example.com, + cc-cmd@example.com Subject: [PATCH 1/1] Second. Date: DATE-STRING Message-Id: MESSAGE-ID-STRING @@ -416,10 +450,15 @@ cat >expected-suppress-body-cccmd <<\EOF Dry-OK. Log says: Server: relay.example.com MAIL FROM:<from@example.com> -RCPT TO:<to@example.com>,<author@example.com>,<one@example.com>,<two@example.com> +RCPT TO:<to@example.com> +RCPT TO:<author@example.com> +RCPT TO:<one@example.com> +RCPT TO:<two@example.com> From: Example <from@example.com> To: to@example.com -Cc: A <author@example.com>, One <one@example.com>, two@example.com +Cc: A <author@example.com>, + One <one@example.com>, + two@example.com Subject: [PATCH 1/1] Second. Date: DATE-STRING Message-Id: MESSAGE-ID-STRING @@ -440,10 +479,15 @@ cat >expected-suppress-sob <<\EOF Dry-OK. Log says: Server: relay.example.com MAIL FROM:<from@example.com> -RCPT TO:<to@example.com>,<author@example.com>,<one@example.com>,<two@example.com> +RCPT TO:<to@example.com> +RCPT TO:<author@example.com> +RCPT TO:<one@example.com> +RCPT TO:<two@example.com> From: Example <from@example.com> To: to@example.com -Cc: A <author@example.com>, One <one@example.com>, two@example.com +Cc: A <author@example.com>, + One <one@example.com>, + two@example.com Subject: [PATCH 1/1] Second. Date: DATE-STRING Message-Id: MESSAGE-ID-STRING @@ -466,10 +510,17 @@ cat >expected-suppress-bodycc <<\EOF Dry-OK. Log says: Server: relay.example.com MAIL FROM:<from@example.com> -RCPT TO:<to@example.com>,<author@example.com>,<one@example.com>,<two@example.com>,<committer@example.com> +RCPT TO:<to@example.com> +RCPT TO:<author@example.com> +RCPT TO:<one@example.com> +RCPT TO:<two@example.com> +RCPT TO:<committer@example.com> From: Example <from@example.com> To: to@example.com -Cc: A <author@example.com>, One <one@example.com>, two@example.com, C O Mitter <committer@example.com> +Cc: A <author@example.com>, + One <one@example.com>, + two@example.com, + C O Mitter <committer@example.com> Subject: [PATCH 1/1] Second. Date: DATE-STRING Message-Id: MESSAGE-ID-STRING @@ -489,10 +540,13 @@ cat >expected-suppress-cc <<\EOF Dry-OK. Log says: Server: relay.example.com MAIL FROM:<from@example.com> -RCPT TO:<to@example.com>,<author@example.com>,<committer@example.com> +RCPT TO:<to@example.com> +RCPT TO:<author@example.com> +RCPT TO:<committer@example.com> From: Example <from@example.com> To: to@example.com -Cc: A <author@example.com>, C O Mitter <committer@example.com> +Cc: A <author@example.com>, + C O Mitter <committer@example.com> Subject: [PATCH 1/1] Second. Date: DATE-STRING Message-Id: MESSAGE-ID-STRING @@ -605,7 +659,7 @@ test_expect_success 'utf8 Cc is rfc2047 encoded' ' --to=nobody@example.com \ --smtp-server="$(pwd)/fake.sendmail" \ outdir/*.patch && - grep "^Cc:" msgtxt1 | + grep "^ " msgtxt1 | grep "=?UTF-8?q?=C3=A0=C3=A9=C3=AC=C3=B6=C3=BA?= <utf8@example.com>" ' diff --git a/t/t9400-git-cvsserver-server.sh b/t/t9400-git-cvsserver-server.sh index 64f947d75b..c2ec3cb4bd 100755 --- a/t/t9400-git-cvsserver-server.sh +++ b/t/t9400-git-cvsserver-server.sh @@ -20,7 +20,7 @@ then say 'skipping git-cvsserver tests, cvs not found' test_done fi -perl -e 'use DBI; use DBD::SQLite' >/dev/null 2>&1 || { +"$PERL_PATH" -e 'use DBI; use DBD::SQLite' >/dev/null 2>&1 || { say 'skipping git-cvsserver tests, Perl SQLite interface unavailable' test_done } diff --git a/t/t9401-git-cvsserver-crlf.sh b/t/t9401-git-cvsserver-crlf.sh index aca40c1b1f..40637d6782 100755 --- a/t/t9401-git-cvsserver-crlf.sh +++ b/t/t9401-git-cvsserver-crlf.sh @@ -57,7 +57,7 @@ then say 'skipping git-cvsserver tests, perl not available' test_done fi -perl -e 'use DBI; use DBD::SQLite' >/dev/null 2>&1 || { +"$PERL_PATH" -e 'use DBI; use DBD::SQLite' >/dev/null 2>&1 || { say 'skipping git-cvsserver tests, Perl SQLite interface unavailable' test_done } diff --git a/t/t9700-perl-git.sh b/t/t9700-perl-git.sh index 4eb7d3f7f0..8686086dde 100755 --- a/t/t9700-perl-git.sh +++ b/t/t9700-perl-git.sh @@ -11,7 +11,7 @@ if ! test_have_prereq PERL; then test_done fi -perl -MTest::More -e 0 2>/dev/null || { +"$PERL_PATH" -MTest::More -e 0 2>/dev/null || { say "Perl Test::More unavailable, skipping test" test_done } @@ -48,6 +48,6 @@ test_expect_success \ test_external_without_stderr \ 'Perl API' \ - perl "$TEST_DIRECTORY"/t9700/test.pl + "$PERL_PATH" "$TEST_DIRECTORY"/t9700/test.pl test_done diff --git a/templates/Makefile b/templates/Makefile index a12c6e214e..408f0137a8 100644 --- a/templates/Makefile +++ b/templates/Makefile @@ -50,4 +50,4 @@ clean: install: all $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(template_instdir_SQ)' (cd blt && $(TAR) cf - .) | \ - (cd '$(DESTDIR_SQ)$(template_instdir_SQ)' && umask 022 && $(TAR) xfo -) + (cd '$(DESTDIR_SQ)$(template_instdir_SQ)' && umask 022 && $(TAR) xof -) diff --git a/templates/hooks--pre-commit.sample b/templates/hooks--pre-commit.sample index 043970a751..439eefda51 100755 --- a/templates/hooks--pre-commit.sample +++ b/templates/hooks--pre-commit.sample @@ -7,6 +7,14 @@ # # To enable this hook, rename this file to "pre-commit". +if git-rev-parse --verify HEAD >/dev/null 2>&1 +then + against=HEAD +else + # Initial commit: diff against an empty tree object + against=4b825dc642cb6eb9a060e54bf8d69288fbee4904 +fi + # If you want to allow non-ascii filenames set this variable to true. allownonascii=$(git config hooks.allownonascii) @@ -17,7 +25,7 @@ if [ "$allownonascii" != "true" ] && # Note that the use of brackets around a tr range is ok here, (it's # even required, for portability to Solaris 10's /usr/bin/tr), since # the square bracket bytes happen to fall in the designated range. - test "$(git diff --cached --name-only --diff-filter=A -z | + test "$(git diff --cached --name-only --diff-filter=A -z $against | LC_ALL=C tr -d '[ -~]\0')" then echo "Error: Attempt to add a non-ascii file name." @@ -35,12 +43,4 @@ then exit 1 fi -if git-rev-parse --verify HEAD >/dev/null 2>&1 -then - against=HEAD -else - # Initial commit: diff against an empty tree object - against=4b825dc642cb6eb9a060e54bf8d69288fbee4904 -fi - exec git diff-index --check --cached $against -- diff --git a/transport.c b/transport.c index 644a30a0b2..298dc46ec5 100644 --- a/transport.c +++ b/transport.c @@ -812,6 +812,9 @@ struct transport *transport_get(struct remote *remote, const char *url) { struct transport *ret = xcalloc(1, sizeof(*ret)); + if (!remote) + die("No remote provided to transport_get()"); + ret->remote = remote; ret->url = url; @@ -849,10 +852,10 @@ struct transport *transport_get(struct remote *remote, const char *url) data->thin = 1; data->conn = NULL; data->uploadpack = "git-upload-pack"; - if (remote && remote->uploadpack) + if (remote->uploadpack) data->uploadpack = remote->uploadpack; data->receivepack = "git-receive-pack"; - if (remote && remote->receivepack) + if (remote->receivepack) data->receivepack = remote->receivepack; } diff --git a/upload-pack.c b/upload-pack.c index 38ddac2e86..953ebe1a60 100644 --- a/upload-pack.c +++ b/upload-pack.c @@ -308,6 +308,23 @@ static void create_pack_file(void) } continue; } + if (0 <= pe && (pfd[pe].revents & (POLLIN|POLLHUP))) { + /* Status ready; we ship that in the side-band + * or dump to the standard error. + */ + sz = xread(pack_objects.err, progress, + sizeof(progress)); + if (0 < sz) + send_client_data(2, progress, sz); + else if (sz == 0) { + close(pack_objects.err); + pack_objects.err = -1; + } + else + goto fail; + /* give priority to status messages */ + continue; + } if (0 <= pu && (pfd[pu].revents & (POLLIN|POLLHUP))) { /* Data ready; we keep the last byte to ourselves * in case we detect broken rev-list, so that we @@ -345,21 +362,6 @@ static void create_pack_file(void) if (sz < 0) goto fail; } - if (0 <= pe && (pfd[pe].revents & (POLLIN|POLLHUP))) { - /* Status ready; we ship that in the side-band - * or dump to the standard error. - */ - sz = xread(pack_objects.err, progress, - sizeof(progress)); - if (0 < sz) - send_client_data(2, progress, sz); - else if (sz == 0) { - close(pack_objects.err); - pack_objects.err = -1; - } - else - goto fail; - } } if (finish_command(&pack_objects)) { @@ -16,6 +16,8 @@ static struct whitespace_rule { { "space-before-tab", WS_SPACE_BEFORE_TAB, 0 }, { "indent-with-non-tab", WS_INDENT_WITH_NON_TAB, 0 }, { "cr-at-eol", WS_CR_AT_EOL, 1 }, + { "blank-at-eol", WS_BLANK_AT_EOL, 0 }, + { "blank-at-eof", WS_BLANK_AT_EOF, 0 }, }; unsigned parse_whitespace_rule(const char *string) @@ -102,8 +104,17 @@ unsigned whitespace_rule(const char *pathname) char *whitespace_error_string(unsigned ws) { struct strbuf err = STRBUF_INIT; - if (ws & WS_TRAILING_SPACE) + if ((ws & WS_TRAILING_SPACE) == WS_TRAILING_SPACE) strbuf_addstr(&err, "trailing whitespace"); + else { + if (ws & WS_BLANK_AT_EOL) + strbuf_addstr(&err, "trailing whitespace"); + if (ws & WS_BLANK_AT_EOF) { + if (err.len) + strbuf_addstr(&err, ", "); + strbuf_addstr(&err, "new blank line at EOF"); + } + } if (ws & WS_SPACE_BEFORE_TAB) { if (err.len) strbuf_addstr(&err, ", "); @@ -141,11 +152,11 @@ static unsigned ws_check_emit_1(const char *line, int len, unsigned ws_rule, } /* Check for trailing whitespace. */ - if (ws_rule & WS_TRAILING_SPACE) { + if (ws_rule & WS_BLANK_AT_EOL) { for (i = len - 1; i >= 0; i--) { if (isspace(line[i])) { trailing_whitespace = i; - result |= WS_TRAILING_SPACE; + result |= WS_BLANK_AT_EOL; } else break; @@ -261,7 +272,7 @@ int ws_fix_copy(char *dst, const char *src, int len, unsigned ws_rule, int *erro /* * Strip trailing whitespace */ - if (ws_rule & WS_TRAILING_SPACE) { + if (ws_rule & WS_BLANK_AT_EOL) { if (0 < len && src[len - 1] == '\n') { add_nl_to_tail = 1; len--; |