Code

Merge branch 'fc/apply-p2-get-header-name' into maint
authorJunio C Hamano <gitster@pobox.com>
Thu, 9 Dec 2010 18:36:36 +0000 (10:36 -0800)
committerJunio C Hamano <gitster@pobox.com>
Thu, 9 Dec 2010 18:36:36 +0000 (10:36 -0800)
* fc/apply-p2-get-header-name:
  test: git-apply -p2 rename/chmod only
  Fix git-apply with -p greater than 1

97 files changed:
Documentation/CodingGuidelines
Documentation/RelNotes/1.7.0.8.txt [new file with mode: 0644]
Documentation/RelNotes/1.7.1.3.txt [new file with mode: 0644]
Documentation/RelNotes/1.7.2.4.txt [new file with mode: 0644]
Documentation/RelNotes/1.7.3.3.txt [new file with mode: 0644]
Documentation/config.txt
Documentation/diff-options.txt
Documentation/fetch-options.txt
Documentation/git-add.txt
Documentation/git-cherry-pick.txt
Documentation/git-commit.txt
Documentation/git-merge.txt
Documentation/git-pull.txt
Documentation/git-repack.txt
Documentation/git-reset.txt
Documentation/git-revert.txt
Documentation/git-rm.txt
Documentation/git-show.txt
Documentation/gitattributes.txt
Documentation/rev-list-options.txt
Documentation/technical/api-sigchain.txt [new file with mode: 0644]
GIT-VERSION-GEN
INSTALL
Makefile
RelNotes
builtin.h
builtin/add.c
builtin/apply.c
builtin/blame.c
builtin/cat-file.c
builtin/clean.c
builtin/merge-file.c
builtin/merge.c
builtin/pack-objects.c
builtin/rev-list.c
builtin/revert.c
builtin/send-pack.c
compat/mingw.c
contrib/completion/git-completion.bash
contrib/emacs/git-blame.el
contrib/examples/git-svnimport.perl
contrib/fast-import/git-p4
contrib/fast-import/import-directories.perl
contrib/hooks/post-receive-email
diff.c
dir.c
git-add--interactive.perl
git-archimport.perl
git-cvsexportcommit.perl
git-cvsimport.perl
git-cvsserver.perl
git-difftool.perl
git-rebase.sh
git-relink.perl
git-repack.sh
git-send-email.perl
git-sh-setup.sh
git-submodule.sh
git-svn.perl
gitweb/gitweb.perl
http.c
mailmap.c
perl/Git.pm
setup.c
sha1_name.c
t/gitweb-lib.sh
t/lib-httpd/apache.conf
t/t1011-read-tree-sparse-checkout.sh
t/t3402-rebase-merge.sh
t/t3419-rebase-patch-id.sh [new file with mode: 0755]
t/t3506-cherry-pick-ff.sh
t/t4011-diff-symlink.sh
t/t4012-diff-binary.sh
t/t4015-diff-whitespace.sh
t/t4018-diff-funcname.sh
t/t4019-diff-wserror.sh
t/t4034-diff-words.sh
t/t4103-apply-binary.sh
t/t4132-apply-removal.sh
t/t4135-apply-weird-filenames.sh
t/t4135/damaged-tz.diff [new file with mode: 0644]
t/t4135/funny-tz.diff [new file with mode: 0644]
t/t4203-mailmap.sh
t/t5551-http-fetch.sh
t/t6006-rev-list-format.sh
t/t6023-merge-file.sh
t/t7006/test-terminal.perl
t/t7403-submodule-sync.sh
t/t7607-merge-overwrite.sh
t/t8006-blame-textconv.sh
t/t8007-cat-file-textconv.sh
t/t9001-send-email.sh
t/t9700/test.pl
t/test-lib.sh
userdiff.c
ws.c
xdiff/xemit.c

index 09ffc46563cba1057b37ba4a5701858fb95c5dda..46f8a3fab13f71623ef6dbc4239067e8daa9dc59 100644 (file)
@@ -31,6 +31,10 @@ But if you must have a list of rules, here they are.
 
 For shell scripts specifically (not exhaustive):
 
+ - We use tabs for indentation.
+
+ - Case arms are indented at the same depth as case and esac lines.
+
  - We prefer $( ... ) for command substitution; unlike ``, it
    properly nests.  It should have been the way Bourne spelled
    it from day one, but unfortunately isn't.
diff --git a/Documentation/RelNotes/1.7.0.8.txt b/Documentation/RelNotes/1.7.0.8.txt
new file mode 100644 (file)
index 0000000..7f05b48
--- /dev/null
@@ -0,0 +1,10 @@
+Git v1.7.0.8 Release Notes
+==========================
+
+This is primarily to backport support for the new "add.ignoreErrors"
+name given to the existing "add.ignore-errors" configuration variable.
+
+The next version, Git 1.7.4, and future versions, will support both
+old and incorrect name and the new corrected name, but without this
+backport, users who want to use the new name "add.ignoreErrors" in
+their repositories cannot use older versions of Git.
diff --git a/Documentation/RelNotes/1.7.1.3.txt b/Documentation/RelNotes/1.7.1.3.txt
new file mode 100644 (file)
index 0000000..5b18518
--- /dev/null
@@ -0,0 +1,10 @@
+Git v1.7.1.3 Release Notes
+==========================
+
+This is primarily to backport support for the new "add.ignoreErrors"
+name given to the existing "add.ignore-errors" configuration variable.
+
+The next version, Git 1.7.4, and future versions, will support both
+old and incorrect name and the new corrected name, but without this
+backport, users who want to use the new name "add.ignoreErrors" in
+their repositories cannot use older versions of Git.
diff --git a/Documentation/RelNotes/1.7.2.4.txt b/Documentation/RelNotes/1.7.2.4.txt
new file mode 100644 (file)
index 0000000..f7950a4
--- /dev/null
@@ -0,0 +1,10 @@
+Git v1.7.2.4 Release Notes
+==========================
+
+This is primarily to backport support for the new "add.ignoreErrors"
+name given to the existing "add.ignore-errors" configuration variable.
+
+The next version, Git 1.7.4, and future versions, will support both
+old and incorrect name and the new corrected name, but without this
+backport, users who want to use the new name "add.ignoreErrors" in
+their repositories cannot use older versions of Git.
diff --git a/Documentation/RelNotes/1.7.3.3.txt b/Documentation/RelNotes/1.7.3.3.txt
new file mode 100644 (file)
index 0000000..9b2b244
--- /dev/null
@@ -0,0 +1,54 @@
+Git v1.7.3.3 Release Notes
+==========================
+
+In addition to the usual fixes, this release also includes support for
+the new "add.ignoreErrors" name given to the existing "add.ignore-errors"
+configuration variable.
+
+The next version, Git 1.7.4, and future versions, will support both
+old and incorrect name and the new corrected name, but without this
+backport, users who want to use the new name "add.ignoreErrors" in
+their repositories cannot use older versions of Git.
+
+Fixes since v1.7.3.2
+--------------------
+
+ * "git apply" segfaulted when a bogus input is fed to it.
+
+ * Running "git cherry-pick --ff" on a root commit segfaulted.
+
+ * "diff", "blame" and friends incorrectly applied textconv filters to
+   symlinks.
+
+ * Highlighting of whitespace breakage in "diff" output was showing
+   incorrect amount of whitespaces when blank-at-eol is set and the line
+   consisted only of whitespaces and a TAB.
+
+ * "diff" was overly inefficient when trying to find the line to use for
+   the function header (i.e. equivalent to --show-c-function of GNU diff).
+
+ * "git imap-send" depends on libcrypto but our build rule relied on the
+   linker to implicitly link it via libssl, which was wrong.
+
+ * "git merge-file" can be called from within a subdirectory now.
+
+ * "git repack -f" expanded and recompressed non-delta objects in the
+   existing pack, which was wasteful.  Use new "-F" option if you really
+   want to (e.g. when changing the pack.compression level).
+
+ * "git rev-list --format="...%x00..." incorrectly chopped its output
+   at NUL.
+
+ * "git send-email" did not correctly remove duplicate mail addresses from
+   the Cc: header that appear on the To: header.
+
+ * The completion script (in contrib/completion) ignored lightweight tags
+   in __git_ps1().
+
+ * "git-blame" mode (in contrib/emacs) didn't say (require 'format-spec)
+   even though it depends on it; it didn't work with Emacs 22 or older
+   unless Gnus is used.
+
+ * "git-p4" (in contrib/) did not correctly handle deleted files.
+
+Other minor fixes and documentation updates are also included.
index 7f6b2109bd83a55b7dddd8a8bc36c6fc1006a134..3fd4b626fa84deb317709f11782534f36df36033 100644 (file)
@@ -548,9 +548,13 @@ core.sparseCheckout::
        linkgit:git-read-tree[1] for more information.
 
 add.ignore-errors::
+add.ignoreErrors::
        Tells 'git add' to continue adding files when some files cannot be
        added due to indexing errors. Equivalent to the '--ignore-errors'
-       option of linkgit:git-add[1].
+       option of linkgit:git-add[1].  Older versions of git accept only
+       `add.ignore-errors`, which does not follow the usual naming
+       convention for configuration variables.  Newer versions of git
+       honor `add.ignoreErrors` as well.
 
 alias.*::
        Command aliases for the linkgit:git[1] command wrapper - e.g.
@@ -1466,6 +1470,10 @@ pack.compression::
        not set,  defaults to -1, the zlib default, which is "a default
        compromise between speed and compression (currently equivalent
        to level 6)."
++
+Note that changing the compression level will not automatically recompress
+all existing objects. You can force recompression by passing the -F option
+to linkgit:git-repack[1].
 
 pack.deltaCacheSize::
        The maximum memory in bytes used for caching deltas in
index d723e992321490e64041caa5021e82bb75eefa02..5495344e612dece0eb6cb6311864463c004f1181 100644 (file)
@@ -247,20 +247,6 @@ endif::git-log[]
        Detect copies as well as renames.  See also `--find-copies-harder`.
        If `n` is specified, it has the same meaning as for `-M<n>`.
 
-ifndef::git-format-patch[]
---diff-filter=[(A|C|D|M|R|T|U|X|B)...[*]]::
-       Select only files that are Added (`A`), Copied (`C`),
-       Deleted (`D`), Modified (`M`), Renamed (`R`), have their
-       type (i.e. regular file, symlink, submodule, ...) changed (`T`),
-       are Unmerged (`U`), are
-       Unknown (`X`), or have had their pairing Broken (`B`).
-       Any combination of the filter characters (including none) can be used.
-       When `*` (All-or-none) is added to the combination, all
-       paths are selected if there is any file that matches
-       other criteria in the comparison; if there is no file
-       that matches other criteria, nothing is selected.
-endif::git-format-patch[]
-
 --find-copies-harder::
        For performance reasons, by default, `-C` option finds copies only
        if the original file of the copy was modified in the same
@@ -278,6 +264,18 @@ endif::git-format-patch[]
        number.
 
 ifndef::git-format-patch[]
+--diff-filter=[(A|C|D|M|R|T|U|X|B)...[*]]::
+       Select only files that are Added (`A`), Copied (`C`),
+       Deleted (`D`), Modified (`M`), Renamed (`R`), have their
+       type (i.e. regular file, symlink, submodule, ...) changed (`T`),
+       are Unmerged (`U`), are
+       Unknown (`X`), or have had their pairing Broken (`B`).
+       Any combination of the filter characters (including none) can be used.
+       When `*` (All-or-none) is added to the combination, all
+       paths are selected if there is any file that matches
+       other criteria in the comparison; if there is no file
+       that matches other criteria, nothing is selected.
+
 -S<string>::
        Look for differences that introduce or remove an instance of
        <string>. Note that this is different than the string simply
index 470ac31396606a18298f69329b050a86943c580c..5ce1e727458bfa5e73ad98c7a852bd7c0f034c6b 100644 (file)
@@ -53,6 +53,7 @@ endif::git-pull[]
        behavior for a remote may be specified with the remote.<name>.tagopt
        setting. See linkgit:git-config[1].
 
+ifndef::git-pull[]
 -t::
 --tags::
        Most of the tags are fetched automatically as branch
@@ -63,6 +64,7 @@ endif::git-pull[]
        downloaded. The default behavior for a remote may be
        specified with the remote.<name>.tagopt setting. See
        linkgit:git-config[1].
+endif::git-pull[]
 
 -u::
 --update-head-ok::
index 73378b2bef8405f54c661e8c9745057b5b243f4d..54aaaeb41b969be4c79a2a8072bc6daca469ca8d 100644 (file)
@@ -92,9 +92,11 @@ See ``Interactive mode'' for details.
        edit it.  After the editor was closed, adjust the hunk headers
        and apply the patch to the index.
 +
-*NOTE*: Obviously, if you change anything else than the first character
-on lines beginning with a space or a minus, the patch will no longer
-apply.
+The intent of this option is to pick and choose lines of the patch to
+apply, or even to modify the contents of lines to be staged. This can be
+quicker and more flexible than using the interactive hunk selector.
+However, it is easy to confuse oneself and create a patch that does not
+apply to the index. See EDITING PATCHES below.
 
 -u::
 --update::
@@ -295,6 +297,78 @@ diff::
   This lets you review what will be committed (i.e. between
   HEAD and index).
 
+
+EDITING PATCHES
+---------------
+
+Invoking `git add -e` or selecting `e` from the interactive hunk
+selector will open a patch in your editor; after the editor exits, the
+result is applied to the index. You are free to make arbitrary changes
+to the patch, but note that some changes may have confusing results, or
+even result in a patch that cannot be applied.  If you want to abort the
+operation entirely (i.e., stage nothing new in the index), simply delete
+all lines of the patch. The list below describes some common things you
+may see in a patch, and which editing operations make sense on them.
+
+--
+added content::
+
+Added content is represented by lines beginning with "{plus}". You can
+prevent staging any addition lines by deleting them.
+
+removed content::
+
+Removed content is represented by lines beginning with "-". You can
+prevent staging their removal by converting the "-" to a " " (space).
+
+modified content::
+
+Modified content is represented by "-" lines (removing the old content)
+followed by "{plus}" lines (adding the replacement content). You can
+prevent staging the modification by converting "-" lines to " ", and
+removing "{plus}" lines. Beware that modifying only half of the pair is
+likely to introduce confusing changes to the index.
+--
+
+There are also more complex operations that can be performed. But beware
+that because the patch is applied only to the index and not the working
+tree, the working tree will appear to "undo" the change in the index.
+For example, introducing a a new line into the index that is in neither
+the HEAD nor the working tree will stage the new line for commit, but
+the line will appear to be reverted in the working tree.
+
+Avoid using these constructs, or do so with extreme caution.
+
+--
+removing untouched content::
+
+Content which does not differ between the index and working tree may be
+shown on context lines, beginning with a " " (space).  You can stage
+context lines for removal by converting the space to a "-". The
+resulting working tree file will appear to re-add the content.
+
+modifying existing content::
+
+One can also modify context lines by staging them for removal (by
+converting " " to "-") and adding a "{plus}" line with the new content.
+Similarly, one can modify "{plus}" lines for existing additions or
+modifications. In all cases, the new modification will appear reverted
+in the working tree.
+
+new content::
+
+You may also add new content that does not exist in the patch; simply
+add new lines, each starting with "{plus}". The addition will appear
+reverted in the working tree.
+--
+
+There are also several operations which should be avoided entirely, as
+they will make the patch impossible to apply:
+
+* adding context (" ") or removal ("-") lines
+* deleting context or removal lines
+* modifying the contents of context or removal lines
+
 SEE ALSO
 --------
 linkgit:git-status[1]
index 3c96fa8c86c34df2dced6cd9ec8a391ee3b7208e..73008705ebe304c8d2a2d089e9328be369c50fc6 100644 (file)
@@ -92,7 +92,7 @@ git cherry-pick ^HEAD master::
        Apply the changes introduced by all commits that are ancestors
        of master but not of HEAD to produce new commits.
 
-git cherry-pick master\~4 master~2::
+git cherry-pick master{tilde}4 master{tilde}2::
 
        Apply the changes introduced by the fifth and third last
        commits pointed to by master and create 2 new commits with
index 42fb1f57b21d7c355d3df6be07329c478786a9a7..ec7b577b85ae5a320b1006380f5abd03946ba44b 100644 (file)
@@ -11,8 +11,8 @@ SYNOPSIS
 'git commit' [-a | --interactive] [-s] [-v] [-u<mode>] [--amend] [--dry-run]
           [(-c | -C) <commit>] [-F <file> | -m <msg>] [--reset-author]
           [--allow-empty] [--allow-empty-message] [--no-verify] [-e] [--author=<author>]
-          [--date=<date>] [--cleanup=<mode>] [--status | --no-status] [--]
-          [[-i | -o ]<file>...]
+          [--date=<date>] [--cleanup=<mode>] [--status | --no-status]
+          [-i | -o] [--] [<file>...]
 
 DESCRIPTION
 -----------
index 84043cc5b26db7d34c93a70ec005df913c345d85..d43416d299a7c028a88e8ddce89536c2c64e65c9 100644 (file)
@@ -59,13 +59,13 @@ include::merge-options.txt[]
 -m <msg>::
        Set the commit message to be used for the merge commit (in
        case one is created).
-
-       If `--log` is specified, a shortlog of the commits being merged
-       will be appended to the specified message.
-
-       The 'git fmt-merge-msg' command can be
-       used to give a good default for automated 'git merge'
-       invocations.
++
+If `--log` is specified, a shortlog of the commits being merged
+will be appended to the specified message.
++
+The 'git fmt-merge-msg' command can be
+used to give a good default for automated 'git merge'
+invocations.
 
 --rerere-autoupdate::
 --no-rerere-autoupdate::
index c50f7dcb890139d829bae51c30b513d54fd7761e..abbc3eb3e0ee208a13237cde5ae3d00d962ad62e 100644 (file)
@@ -27,8 +27,8 @@ With `--rebase`, it runs 'git rebase' instead of 'git merge'.
 passed to linkgit:git-fetch[1].  <refspec> can name an
 arbitrary remote ref (for example, the name of a tag) or even
 a collection of refs with corresponding remote tracking branches
-(e.g., refs/heads/*:refs/remotes/origin/*), but usually it is
-the name of a branch in the remote repository.
+(e.g., refs/heads/{asterisk}:refs/remotes/origin/{asterisk}),
+but usually it is the name of a branch in the remote repository.
 
 Default values for <repository> and <branch> are read from the
 "remote" and "merge" configuration for the current branch
@@ -92,12 +92,14 @@ include::merge-options.txt[]
 :git-pull: 1
 
 --rebase::
-       Instead of a merge, perform a rebase after fetching.  If
-       there is a remote ref for the upstream branch, and this branch
-       was rebased since last fetched, the rebase uses that information
-       to avoid rebasing non-local changes. To make this the default
-       for branch `<name>`, set configuration `branch.<name>.rebase`
-       to `true`.
+       Rebase the current branch on top of the upstream branch after
+       fetching.  If there is a remote-tracking branch corresponding to
+       the upstream branch and the upstream branch was rebased since last
+       fetched, the rebase uses that information to avoid rebasing
+       non-local changes.
++
+See `branch.<name>.rebase` in linkgit:git-config[1] if you want to make
+`git pull` always use `{litdd}rebase` instead of merging.
 +
 [NOTE]
 This is a potentially _dangerous_ mode of operation.
index af79b86516764617163b020ec3c4d9bbeda9fe9b..27f7865b061cc96398f7aa052d162723e1f9255e 100644 (file)
@@ -8,7 +8,7 @@ git-repack - Pack unpacked objects in a repository
 
 SYNOPSIS
 --------
-'git repack' [-a] [-A] [-d] [-f] [-l] [-n] [-q] [--window=<n>] [--depth=<n>]
+'git repack' [-a] [-A] [-d] [-f] [-F] [-l] [-n] [-q] [--window=<n>] [--depth=<n>]
 
 DESCRIPTION
 -----------
@@ -62,6 +62,10 @@ other objects in that pack they already have locally.
        linkgit:git-pack-objects[1].
 
 -f::
+       Pass the `--no-reuse-delta` option to `git-pack-objects`, see
+       linkgit:git-pack-objects[1].
+
+-F::
        Pass the `--no-reuse-object` option to `git-pack-objects`, see
        linkgit:git-pack-objects[1].
 
index 9cf31485feec4b03850edb1f2f3a4b765245f4cc..fd72976371cee0fcd25e3419138eb13382dc6ab8 100644 (file)
@@ -15,17 +15,24 @@ SYNOPSIS
 DESCRIPTION
 -----------
 In the first and second form, copy entries from <commit> to the index.
-In the third form, set the current branch to <commit>, optionally
-modifying index and worktree to match.  The <commit> defaults to HEAD
+In the third form, set the current branch head (HEAD) to <commit>, optionally
+modifying index and working tree to match.  The <commit> defaults to HEAD
 in all forms.
 
 'git reset' [-q] [<commit>] [--] <paths>...::
        This form resets the index entries for all <paths> to their
-       state at the <commit>.  (It does not affect the worktree, nor
+       state at <commit>.  (It does not affect the working tree, nor
        the current branch.)
 +
 This means that `git reset <paths>` is the opposite of `git add
 <paths>`.
++
+After running `git reset <paths>` to update the index entry, you can
+use linkgit:git-checkout[1] to check the contents out of the index to
+the working tree.
+Alternatively, using linkgit:git-checkout[1] and specifying a commit, you
+can copy the contents of a path out of a commit to the index and to the
+working tree in one go.
 
 'git reset' --patch|-p [<commit>] [--] [<paths>...]::
        Interactively select hunks in the difference between the index
@@ -36,16 +43,17 @@ This means that `git reset -p` is the opposite of `git add -p` (see
 linkgit:git-add[1]).
 
 'git reset' [--<mode>] [<commit>]::
-       This form points the current branch to <commit> and then
-       updates index and working tree according to <mode>, which must
-       be one of the following:
+       This form resets the current branch head to <commit> and
+       possibly updates the index (resetting it to the tree of <commit>) and
+       the working tree depending on <mode>, which
+       must be one of the following:
 +
 --
 --soft::
-       Does not touch the index file nor the working tree at allbut
-       requires them to be in a good order. This leaves all your changed
-       files "Changes to be committed", as 'git status' would
-       put it.
+       Does not touch the index file nor the working tree at all (but
+       resets the head to <commit>, just like all modes do). This leaves
+       all your changed files "Changes to be committed", as 'git status'
+       would put it.
 
 --mixed::
        Resets the index but not the working tree (i.e., the changed files
@@ -53,22 +61,30 @@ linkgit:git-add[1]).
        been updated. This is the default action.
 
 --hard::
-       Matches the working tree and index to that of the tree being
-       switched to. Any changes to tracked files in the working tree
-       since <commit> are lost.
+       Resets the index and working tree. Any changes to tracked files in the
+       working tree since <commit> are discarded.
 
 --merge::
-       Resets the index to match the tree recorded by the named commit,
-       and updates the files that are different between the named commit
-       and the current commit in the working tree.
+       Resets the index and updates the files in the working tree that are
+       different between <commit> and HEAD, but keeps those which are
+       different between the index and working tree (i.e. which have changes
+       which have not been added).
+       If a file that is different between <commit> and the index has unstaged
+       changes, reset is aborted.
++
+In other words, --merge does something like a 'git read-tree -u -m <commit>',
+but carries forward unmerged index entries.
 
 --keep::
-       Reset the index to the given commit, keeping local changes in
-       the working tree since the current commit, while updating
-       working tree files without local changes to what appears in
-       the given commit.  If a file that is different between the
-       current commit and the given commit has local changes, reset
-       is aborted.
+       Resets the index, updates files in the working tree that are
+       different between <commit> and HEAD, but keeps those
+       which are different between HEAD and the working tree (i.e.
+       which have local changes).
+       If a file that is different between <commit> and HEAD has local changes,
+       reset is aborted.
++
+In other words, --keep does a 2-way merge between <commit> and HEAD followed by
+'git reset --mixed <commit>'.
 --
 
 If you want to undo a commit other than the latest on a branch,
@@ -184,7 +200,7 @@ tip of the current branch in ORIG_HEAD, so resetting hard to it
 brings your index file and the working tree back to that state,
 and resets the tip of the branch to that commit.
 
-Undo a merge or pull inside a dirty work tree::
+Undo a merge or pull inside a dirty working tree::
 +
 ------------
 $ git pull                         <1>
@@ -257,7 +273,7 @@ Suppose you are working on something and you commit it, and then you
 continue working a bit more, but now you think that what you have in
 your working tree should be in another branch that has nothing to do
 with what you committed previously. You can start a new branch and
-reset it while keeping the changes in your work tree.
+reset it while keeping the changes in your working tree.
 +
 ------------
 $ git tag start
@@ -294,8 +310,10 @@ In these tables, A, B, C and D are some different states of a
 file. For example, the first line of the first table means that if a
 file is in state A in the working tree, in state B in the index, in
 state C in HEAD and in state D in the target, then "git reset --soft
-target" will put the file in state A in the working tree, in state B
-in the index and in state D in HEAD.
+target" will leave the file in the working tree in state A and in the
+index in state B.  It resets (i.e. moves) the HEAD (i.e. the tip of
+the current branch, if you are on one) to "target" (which has the file
+in state D).
 
       working index HEAD target         working index HEAD
       ----------------------------------------------------
@@ -346,11 +364,11 @@ in the index and in state D in HEAD.
                                --keep   B       C     C
 
 "reset --merge" is meant to be used when resetting out of a conflicted
-merge. Any mergy operation guarantees that the work tree file that is
+merge. Any mergy operation guarantees that the working tree file that is
 involved in the merge does not have local change wrt the index before
-it starts, and that it writes the result out to the work tree. So if
+it starts, and that it writes the result out to the working tree. So if
 we see some difference between the index and the target and also
-between the index and the work tree, then it means that we are not
+between the index and the working tree, then it means that we are not
 resetting out from a state that a mergy operation left after failing
 with a conflict. That is why we disallow --merge option in this case.
 
index f40984d144e4ca276f84fc81a74c4ae726dcf497..752fc88e768e4b8e1afddad4bdd7833cf20978c7 100644 (file)
@@ -87,7 +87,7 @@ git revert HEAD~3::
        Revert the changes specified by the fourth last commit in HEAD
        and create a new commit with the reverted changes.
 
-git revert -n master\~5..master~2::
+git revert -n master{tilde}5..master{tilde}2::
 
        Revert the changes done by commits from the fifth last commit
        in master (included) to the third last commit in master
index 71e3d9fc23ab6f1c181c47ebb7c9483950a9e9a6..0adbe8b1f8e6e992a1f991fbdba4deffbd6e15b0 100644 (file)
@@ -89,8 +89,8 @@ the paths that have disappeared from the filesystem. However,
 depending on the use case, there are several ways that can be
 done.
 
-Using "git commit -a"
-~~~~~~~~~~~~~~~~~~~~~
+Using ``git commit -a''
+~~~~~~~~~~~~~~~~~~~~~~~
 If you intend that your next commit should record all modifications
 of tracked files in the working tree and record all removals of
 files that have been removed from the working tree with `rm`
@@ -98,8 +98,8 @@ files that have been removed from the working tree with `rm`
 automatically notice and record all removals.  You can also have a
 similar effect without committing by using `git add -u`.
 
-Using "git add -A"
-~~~~~~~~~~~~~~~~~~
+Using ``git add -A''
+~~~~~~~~~~~~~~~~~~~~
 When accepting a new code drop for a vendor branch, you probably
 want to record both the removal of paths and additions of new paths
 as well as modifications of existing paths.
@@ -111,8 +111,8 @@ tree using this command:
 git ls-files -z | xargs -0 rm -f
 ----------------
 
-and then "untar" the new code in the working tree. Alternately
-you could "rsync" the changes into the working tree.
+and then untar the new code in the working tree. Alternately
+you could 'rsync' the changes into the working tree.
 
 After that, the easiest way to record all removals, additions, and
 modifications in the working tree is:
index 2049c60f75aeb5ae325a49e3eb3c7e7132fec193..f0a8a1aff3694cf00587d8670a8fe9962fe98af3 100644 (file)
@@ -54,6 +54,10 @@ git show v1.0.0::
 git show v1.0.0^\{tree\}::
        Shows the tree pointed to by the tag `v1.0.0`.
 
+git show -s --format=%s v1.0.0^\{commit\}::
+       Shows the subject of the commit pointed to by the
+       tag `v1.0.0`.
+
 git show next~10:Documentation/README::
        Shows the contents of the file `Documentation/README` as
        they were current in the 10th last commit of the branch
index e5a27d875eb63dbfeccbf5357983f5c94668ffeb..fbf507a7ee3694f99fb236347fc0c7f352b7e50e 100644 (file)
@@ -477,6 +477,8 @@ patterns are available:
 
 - `csharp` suitable for source code in the C# language.
 
+- `fortran` suitable for source code in the Fortran language.
+
 - `html` suitable for HTML/XHTML documents.
 
 - `java` suitable for source code in the Java language.
index 7a42567060bc4c79e5eef00e4cc01a90c9ab39a4..42ca059908b6af5726d958d92912705c96235d29 100644 (file)
@@ -95,6 +95,8 @@ you would get an output like this:
        to be printed in between commits, in order for the graph history
        to be drawn properly.
 +
+This enables parent rewriting, see 'History Simplification' below.
++
 This implies the '--topo-order' option by default, but the
 '--date-order' option may also be specified.
 
@@ -146,6 +148,9 @@ options may be given. See linkgit:git-diff-files[1] for more options.
 -t::
 
        Show the tree objects in the diff output. This implies '-r'.
+
+-s::
+       Suppress diff output.
 endif::git-rev-list[]
 
 Commit Limiting
diff --git a/Documentation/technical/api-sigchain.txt b/Documentation/technical/api-sigchain.txt
new file mode 100644 (file)
index 0000000..535cdff
--- /dev/null
@@ -0,0 +1,41 @@
+sigchain API
+============
+
+Code often wants to set a signal handler to clean up temporary files or
+other work-in-progress when we die unexpectedly. For multiple pieces of
+code to do this without conflicting, each piece of code must remember
+the old value of the handler and restore it either when:
+
+  1. The work-in-progress is finished, and the handler is no longer
+     necessary. The handler should revert to the original behavior
+     (either another handler, SIG_DFL, or SIG_IGN).
+
+  2. The signal is received. We should then do our cleanup, then chain
+     to the next handler (or die if it is SIG_DFL).
+
+Sigchain is a tiny library for keeping a stack of handlers. Your handler
+and installation code should look something like:
+
+------------------------------------------
+  void clean_foo_on_signal(int sig)
+  {
+         clean_foo();
+         sigchain_pop(sig);
+         raise(sig);
+  }
+
+  void other_func()
+  {
+         sigchain_push_common(clean_foo_on_signal);
+         mess_up_foo();
+         clean_foo();
+  }
+------------------------------------------
+
+Handlers are given the typdef of sigchain_fun. This is the same type
+that is given to signal() or sigaction(). It is perfectly reasonable to
+push SIG_DFL or SIG_IGN onto the stack.
+
+You can sigchain_push and sigchain_pop individual signals. For
+convenience, sigchain_push_common will push the handler onto the stack
+for many common signals.
index 9ff9e51205ca14aef2f0e2c5936d14f715f1ea61..702306acd2c10d1cbe04c26bf3b89bafadb256f7 100755 (executable)
@@ -1,7 +1,7 @@
 #!/bin/sh
 
 GVF=GIT-VERSION-FILE
-DEF_VER=v1.7.3.2
+DEF_VER=v1.7.3.3
 
 LF='
 '
diff --git a/INSTALL b/INSTALL
index 59200b730ec00a63f981691f7fd37f2eacb11653..10a1cba643cc9e6cc9a441708b1d43f468fb8383 100644 (file)
--- a/INSTALL
+++ b/INSTALL
@@ -67,10 +67,10 @@ Issues of note:
        - A POSIX-compliant shell is required to run many scripts needed
          for everyday use (e.g. "bisect", "pull").
 
-       - "Perl" is needed to use some of the features (e.g. preparing a
-         partial commit using "git add -i/-p", interacting with svn
-         repositories with "git svn").  If you can live without these, use
-         NO_PERL.
+       - "Perl" version 5.8 or later is needed to use some of the
+         features (e.g. preparing a partial commit using "git add -i/-p",
+         interacting with svn repositories with "git svn").  If you can
+         live without these, use NO_PERL.
 
        - "openssl" library is used by git-imap-send to use IMAP over SSL.
          If you don't need it, use NO_OPENSSL.
index d3dcfb18a7a4dffddb8e8cc742b7c151e639549e..cd0f6481721f9ec47bdc2c0da93936fdfe806a2c 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -1921,7 +1921,7 @@ git-%$X: %.o $(GITLIBS)
 
 git-imap-send$X: imap-send.o $(GITLIBS)
        $(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) \
-               $(LIBS) $(OPENSSL_LINK) $(OPENSSL_LIBSSL)
+               $(LIBS) $(OPENSSL_LINK) $(OPENSSL_LIBSSL) $(LIB_4_CRYPTO)
 
 git-http-fetch$X: revision.o http.o http-walker.o http-fetch.o $(GITLIBS)
        $(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) \
@@ -1977,7 +1977,7 @@ cscope:
        $(FIND) . -name '*.[hcS]' -print | xargs cscope -b
 
 ### Detect prefix changes
-TRACK_CFLAGS = $(subst ','\'',$(ALL_CFLAGS)):\
+TRACK_CFLAGS = $(CC):$(subst ','\'',$(ALL_CFLAGS)):\
              $(bindir_SQ):$(gitexecdir_SQ):$(template_dir_SQ):$(prefix_SQ)
 
 GIT-CFLAGS: FORCE
index c2b0d4d1266e8f3b104133da35cfcc2ec4ad97a6..9653ffeb826c5ff72a8eafc9cc541fe094882fb2 120000 (symlink)
--- a/RelNotes
+++ b/RelNotes
@@ -1 +1 @@
-Documentation/RelNotes/1.7.3.2.txt
\ No newline at end of file
+Documentation/RelNotes/1.7.3.3.txt
\ No newline at end of file
index 0398d247400e55f2a2ededc054902374c7516d5b..9bf69eee0cb99fd4a8c66ee2f2bdecafe02b3b0b 100644 (file)
--- a/builtin.h
+++ b/builtin.h
@@ -35,7 +35,7 @@ void finish_copy_notes_for_rewrite(struct notes_rewrite_cfg *c);
 
 extern int check_pager_config(const char *cmd);
 
-extern int textconv_object(const char *path, const unsigned char *sha1, char **buf, unsigned long *buf_size);
+extern int textconv_object(const char *path, unsigned mode, const unsigned char *sha1, char **buf, unsigned long *buf_size);
 
 extern int cmd_add(int argc, const char **argv, const char *prefix);
 extern int cmd_annotate(int argc, const char **argv, const char *prefix);
index 56a4e0af6b35ea9f6d86accad27a1c87bc5ad0d9..3a5fca51590db53747f8712f733aa01e5840d8fb 100644 (file)
@@ -331,7 +331,8 @@ static struct option builtin_add_options[] = {
 
 static int add_config(const char *var, const char *value, void *cb)
 {
-       if (!strcasecmp(var, "add.ignore-errors")) {
+       if (!strcasecmp(var, "add.ignoreerrors") ||
+           !strcasecmp(var, "add.ignore-errors")) {
                ignore_add_errors = git_config_bool(var, value);
                return 0;
        }
index 108828d48ad0cb09b88dff7caab14f3e8a3690b0..b719f41482ee3be39d91a30f93eeabaf9d96be55 100644 (file)
@@ -449,7 +449,7 @@ static char *find_name_gnu(const char *line, char *def, int p_value)
        return squash_slash(strbuf_detach(&name, NULL));
 }
 
-static size_t tz_len(const char *line, size_t len)
+static size_t sane_tz_len(const char *line, size_t len)
 {
        const char *tz, *p;
 
@@ -467,6 +467,24 @@ static size_t tz_len(const char *line, size_t len)
        return line + len - tz;
 }
 
+static size_t tz_with_colon_len(const char *line, size_t len)
+{
+       const char *tz, *p;
+
+       if (len < strlen(" +08:00") || line[len - strlen(":00")] != ':')
+               return 0;
+       tz = line + len - strlen(" +08:00");
+
+       if (tz[0] != ' ' || (tz[1] != '+' && tz[1] != '-'))
+               return 0;
+       p = tz + 2;
+       if (!isdigit(*p++) || !isdigit(*p++) || *p++ != ':' ||
+           !isdigit(*p++) || !isdigit(*p++))
+               return 0;
+
+       return line + len - tz;
+}
+
 static size_t date_len(const char *line, size_t len)
 {
        const char *date, *p;
@@ -561,7 +579,9 @@ static size_t diff_timestamp_len(const char *line, size_t len)
        if (!isdigit(end[-1]))
                return 0;
 
-       n = tz_len(line, end - line);
+       n = sane_tz_len(line, end - line);
+       if (!n)
+               n = tz_with_colon_len(line, end - line);
        end -= n;
 
        n = short_time_len(line, end - line);
@@ -733,8 +753,8 @@ static int has_epoch_timestamp(const char *nameline)
                " "
                "[0-2][0-9]:[0-5][0-9]:00(\\.0+)?"
                " "
-               "([-+][0-2][0-9][0-5][0-9])\n";
-       const char *timestamp = NULL, *cp;
+               "([-+][0-2][0-9]:?[0-5][0-9])\n";
+       const char *timestamp = NULL, *cp, *colon;
        static regex_t *stamp;
        regmatch_t m[10];
        int zoneoffset;
@@ -764,8 +784,11 @@ static int has_epoch_timestamp(const char *nameline)
                return 0;
        }
 
-       zoneoffset = strtol(timestamp + m[3].rm_so + 1, NULL, 10);
-       zoneoffset = (zoneoffset / 100) * 60 + (zoneoffset % 100);
+       zoneoffset = strtol(timestamp + m[3].rm_so + 1, (char **) &colon, 10);
+       if (*colon == ':')
+               zoneoffset = zoneoffset * 60 + strtol(colon + 1, NULL, 10);
+       else
+               zoneoffset = (zoneoffset / 100) * 60 + (zoneoffset % 100);
        if (timestamp[m[3].rm_so] == '-')
                zoneoffset = -zoneoffset;
 
@@ -2645,6 +2668,12 @@ static int apply_binary_fragment(struct image *img, struct patch *patch)
        unsigned long len;
        void *dst;
 
+       if (!fragment)
+               return error("missing binary patch data for '%s'",
+                            patch->new_name ?
+                            patch->new_name :
+                            patch->old_name);
+
        /* Binary patch is irreversible without the optional second hunk */
        if (apply_in_reverse) {
                if (!fragment->next)
index 101535448f2b0405c280387b63f7ce82fb7dd350..f5fccc1f6767d7386e37f7273c560d0d4491ee91 100644 (file)
@@ -83,6 +83,7 @@ struct origin {
        struct commit *commit;
        mmfile_t file;
        unsigned char blob_sha1[20];
+       unsigned mode;
        char path[FLEX_ARRAY];
 };
 
@@ -92,6 +93,7 @@ struct origin {
  * Return 1 if the conversion succeeds, 0 otherwise.
  */
 int textconv_object(const char *path,
+                   unsigned mode,
                    const unsigned char *sha1,
                    char **buf,
                    unsigned long *buf_size)
@@ -100,7 +102,7 @@ int textconv_object(const char *path,
        struct userdiff_driver *textconv;
 
        df = alloc_filespec(path);
-       fill_filespec(df, sha1, S_IFREG | 0664);
+       fill_filespec(df, sha1, mode);
        textconv = get_textconv(df);
        if (!textconv) {
                free_filespec(df);
@@ -125,7 +127,7 @@ static void fill_origin_blob(struct diff_options *opt,
 
                num_read_blob++;
                if (DIFF_OPT_TST(opt, ALLOW_TEXTCONV) &&
-                   textconv_object(o->path, o->blob_sha1, &file->ptr, &file_size))
+                   textconv_object(o->path, o->mode, o->blob_sha1, &file->ptr, &file_size))
                        ;
                else
                        file->ptr = read_sha1_file(o->blob_sha1, &type, &file_size);
@@ -313,21 +315,23 @@ static struct origin *get_origin(struct scoreboard *sb,
  * for an origin is also used to pass the blame for the entire file to
  * the parent to detect the case where a child's blob is identical to
  * that of its parent's.
+ *
+ * This also fills origin->mode for corresponding tree path.
  */
-static int fill_blob_sha1(struct origin *origin)
+static int fill_blob_sha1_and_mode(struct origin *origin)
 {
-       unsigned mode;
        if (!is_null_sha1(origin->blob_sha1))
                return 0;
        if (get_tree_entry(origin->commit->object.sha1,
                           origin->path,
-                          origin->blob_sha1, &mode))
+                          origin->blob_sha1, &origin->mode))
                goto error_out;
        if (sha1_object_info(origin->blob_sha1, NULL) != OBJ_BLOB)
                goto error_out;
        return 0;
  error_out:
        hashclr(origin->blob_sha1);
+       origin->mode = S_IFINVALID;
        return -1;
 }
 
@@ -360,12 +364,14 @@ static struct origin *find_origin(struct scoreboard *sb,
                        /*
                         * If the origin was newly created (i.e. get_origin
                         * would call make_origin if none is found in the
-                        * scoreboard), it does not know the blob_sha1,
+                        * scoreboard), it does not know the blob_sha1/mode,
                         * so copy it.  Otherwise porigin was in the
-                        * scoreboard and already knows blob_sha1.
+                        * scoreboard and already knows blob_sha1/mode.
                         */
-                       if (porigin->refcnt == 1)
+                       if (porigin->refcnt == 1) {
                                hashcpy(porigin->blob_sha1, cached->blob_sha1);
+                               porigin->mode = cached->mode;
+                       }
                        return porigin;
                }
                /* otherwise it was not very useful; free it */
@@ -400,6 +406,7 @@ static struct origin *find_origin(struct scoreboard *sb,
                /* The path is the same as parent */
                porigin = get_origin(sb, parent, origin->path);
                hashcpy(porigin->blob_sha1, origin->blob_sha1);
+               porigin->mode = origin->mode;
        } else {
                /*
                 * Since origin->path is a pathspec, if the parent
@@ -425,6 +432,7 @@ static struct origin *find_origin(struct scoreboard *sb,
                case 'M':
                        porigin = get_origin(sb, parent, origin->path);
                        hashcpy(porigin->blob_sha1, p->one->sha1);
+                       porigin->mode = p->one->mode;
                        break;
                case 'A':
                case 'T':
@@ -444,6 +452,7 @@ static struct origin *find_origin(struct scoreboard *sb,
 
                cached = make_origin(porigin->commit, porigin->path);
                hashcpy(cached->blob_sha1, porigin->blob_sha1);
+               cached->mode = porigin->mode;
                parent->util = cached;
        }
        return porigin;
@@ -486,6 +495,7 @@ static struct origin *find_rename(struct scoreboard *sb,
                    !strcmp(p->two->path, origin->path)) {
                        porigin = get_origin(sb, parent, p->one->path);
                        hashcpy(porigin->blob_sha1, p->one->sha1);
+                       porigin->mode = p->one->mode;
                        break;
                }
        }
@@ -1099,6 +1109,7 @@ static int find_copy_in_parent(struct scoreboard *sb,
 
                        norigin = get_origin(sb, parent, p->one->path);
                        hashcpy(norigin->blob_sha1, p->one->sha1);
+                       norigin->mode = p->one->mode;
                        fill_origin_blob(&sb->revs->diffopt, norigin, &file_p);
                        if (!file_p.ptr)
                                continue;
@@ -2075,7 +2086,7 @@ static struct commit *fake_working_tree_commit(struct diff_options *opt,
                switch (st.st_mode & S_IFMT) {
                case S_IFREG:
                        if (DIFF_OPT_TST(opt, ALLOW_TEXTCONV) &&
-                           textconv_object(read_from, null_sha1, &buf.buf, &buf_len))
+                           textconv_object(read_from, mode, null_sha1, &buf.buf, &buf_len))
                                buf.len = buf_len;
                        else if (strbuf_read_file(&buf, read_from, st.st_size) != st.st_size)
                                die_errno("cannot open or read '%s'", read_from);
@@ -2455,11 +2466,11 @@ parse_done:
        }
        else {
                o = get_origin(&sb, sb.final, path);
-               if (fill_blob_sha1(o))
+               if (fill_blob_sha1_and_mode(o))
                        die("no such path %s in %s", path, final_commit_name);
 
                if (DIFF_OPT_TST(&sb.revs->diffopt, ALLOW_TEXTCONV) &&
-                   textconv_object(path, o->blob_sha1, (char **) &sb.final_buf,
+                   textconv_object(path, o->mode, o->blob_sha1, (char **) &sb.final_buf,
                                    &sb.final_buf_size))
                        ;
                else
index 76ec3fec9279f38520fa4b5b525ce2c03cc9cbb0..94632dbdb400f9a2986d10f06dd16119ce1b4e54 100644 (file)
@@ -143,7 +143,7 @@ static int cat_one_file(int opt, const char *exp_type, const char *obj_name)
                        die("git cat-file --textconv %s: <object> must be <sha1:path>",
                            obj_name);
 
-               if (!textconv_object(obj_context.path, sha1, &buf, &size))
+               if (!textconv_object(obj_context.path, obj_context.mode, sha1, &buf, &size))
                        die("git cat-file --textconv: unable to run textconv on %s",
                            obj_name);
                break;
index c8798f549ed12192a098ab90b35c0437b8059351..fb24030751ec5e755009a97439ffa08ff55f67d5 100644 (file)
@@ -38,7 +38,7 @@ int cmd_clean(int argc, const char **argv, const char *prefix)
 {
        int i;
        int show_only = 0, remove_directories = 0, quiet = 0, ignored = 0;
-       int ignored_only = 0, baselen = 0, config_set = 0, errors = 0;
+       int ignored_only = 0, config_set = 0, errors = 0;
        int rm_flags = REMOVE_DIR_KEEP_NESTED_GIT;
        struct strbuf directory = STRBUF_INIT;
        struct dir_struct dir;
@@ -138,7 +138,7 @@ int cmd_clean(int argc, const char **argv, const char *prefix)
                if (pathspec) {
                        memset(seen, 0, argc > 0 ? argc : 1);
                        matches = match_pathspec(pathspec, ent->name, len,
-                                                baselen, seen);
+                                                0, seen);
                }
 
                if (S_ISDIR(st.st_mode)) {
@@ -153,7 +153,7 @@ int cmd_clean(int argc, const char **argv, const char *prefix)
                                        printf("Removing %s\n", qname);
                                if (remove_dir_recursively(&directory,
                                                           rm_flags) != 0) {
-                                       warning("failed to remove '%s'", qname);
+                                       warning("failed to remove %s", qname);
                                        errors++;
                                }
                        } else if (show_only) {
@@ -173,7 +173,7 @@ int cmd_clean(int argc, const char **argv, const char *prefix)
                                printf("Removing %s\n", qname);
                        }
                        if (unlink(ent->name) != 0) {
-                               warning("failed to remove '%s'", qname);
+                               warning("failed to remove %s", qname);
                                errors++;
                        }
                }
index b6664d49be9454b703615af4e71f92231e053e07..6c4afb5a38bc954be836c441b9b09b22ef82b132 100644 (file)
@@ -28,6 +28,7 @@ int cmd_merge_file(int argc, const char **argv, const char *prefix)
        xmparam_t xmp = {{0}};
        int ret = 0, i = 0, to_stdout = 0;
        int quiet = 0;
+       int prefixlen = 0;
        struct option options[] = {
                OPT_BOOLEAN('p', "stdout", &to_stdout, "send results to standard output"),
                OPT_SET_INT(0, "diff3", &xmp.style, "use a diff3 based merge", XDL_MERGE_DIFF3),
@@ -65,10 +66,14 @@ int cmd_merge_file(int argc, const char **argv, const char *prefix)
                                     "%s\n", strerror(errno));
        }
 
+       if (prefix)
+               prefixlen = strlen(prefix);
+
        for (i = 0; i < 3; i++) {
+               const char *fname = prefix_filename(prefix, prefixlen, argv[i]);
                if (!names[i])
                        names[i] = argv[i];
-               if (read_mmfile(mmfs + i, argv[i]))
+               if (read_mmfile(mmfs + i, fname))
                        return -1;
                if (buffer_is_binary(mmfs[i].ptr, mmfs[i].size))
                        return error("Cannot merge binary files: %s\n",
index 5f65c0c8a6eacd4c6d05602ad9de2821ec62a034..d0bd651725648c01e2c4250f2533aed2c8174164 100644 (file)
@@ -233,6 +233,24 @@ static void save_state(void)
                die("not a valid object: %s", buffer.buf);
 }
 
+static void read_empty(unsigned const char *sha1, int verbose)
+{
+       int i = 0;
+       const char *args[7];
+
+       args[i++] = "read-tree";
+       if (verbose)
+               args[i++] = "-v";
+       args[i++] = "-m";
+       args[i++] = "-u";
+       args[i++] = EMPTY_TREE_SHA1_HEX;
+       args[i++] = sha1_to_hex(sha1);
+       args[i] = NULL;
+
+       if (run_command_v_opt(args, RUN_GIT_CMD))
+               die("read-tree failed");
+}
+
 static void reset_hard(unsigned const char *sha1, int verbose)
 {
        int i = 0;
@@ -993,7 +1011,7 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
                        die("%s - not something we can merge", argv[0]);
                update_ref("initial pull", "HEAD", remote_head->sha1, NULL, 0,
                                DIE_ON_ERR);
-               reset_hard(remote_head->sha1, 0);
+               read_empty(remote_head->sha1, 0);
                return 0;
        } else {
                struct strbuf merge_names = STRBUF_INIT;
index f8eba53c82242d0c435524ab9ffab70ba2e2d5ad..3cbeb299d172c51b8ab6940a836efdf8a1a8e4ce 100644 (file)
@@ -1298,9 +1298,23 @@ static int try_delta(struct unpacked *trg, struct unpacked *src,
                read_lock();
                src->data = read_sha1_file(src_entry->idx.sha1, &type, &sz);
                read_unlock();
-               if (!src->data)
+               if (!src->data) {
+                       if (src_entry->preferred_base) {
+                               static int warned = 0;
+                               if (!warned++)
+                                       warning("object %s cannot be read",
+                                               sha1_to_hex(src_entry->idx.sha1));
+                               /*
+                                * Those objects are not included in the
+                                * resulting pack.  Be resilient and ignore
+                                * them if they can't be read, in case the
+                                * pack could be created nevertheless.
+                                */
+                               return 0;
+                       }
                        die("object %s cannot be read",
                            sha1_to_hex(src_entry->idx.sha1));
+               }
                if (sz != src_size)
                        die("object %s inconsistent object length (%lu vs %lu)",
                            sha1_to_hex(src_entry->idx.sha1), sz, src_size);
index 158ce1111af12db1445d82cfa5728bc19837570d..ba27d39f977f2807cddb6e18364837b9fd50e970 100644 (file)
@@ -147,8 +147,10 @@ static void show_commit(struct commit *commit, void *data)
                        }
                } else {
                        if (revs->commit_format != CMIT_FMT_USERFORMAT ||
-                           buf.len)
-                               printf("%s%c", buf.buf, info->hdr_termination);
+                           buf.len) {
+                               fwrite(buf.buf, 1, buf.len, stdout);
+                               putchar(info->hdr_termination);
+                       }
                }
                strbuf_release(&buf);
        } else {
index 4b47ace36b51566acb5b748f679070f02cbbf568..57b51e4a0e148062e1945d640b81559d65e4c2ba 100644 (file)
@@ -442,7 +442,7 @@ static int do_pick_commit(void)
        else
                parent = commit->parents->item;
 
-       if (allow_ff && !hashcmp(parent->object.sha1, head))
+       if (allow_ff && parent && !hashcmp(parent->object.sha1, head))
                return fast_forward_to(commit->object.sha1, head);
 
        if (parent && parse_commit(parent) < 0)
index 481602d8ae73612226bcc758f2aedea7f964779c..8aa303158b2461c9272c8ca5b094149a54cc35d2 100644 (file)
@@ -101,7 +101,7 @@ static int pack_objects(int fd, struct ref *refs, struct extra_have_objects *ext
        }
 
        if (finish_command(&po))
-               return error("pack-objects died with strange error");
+               return -1;
        return 0;
 }
 
index f2d9e1fd974b7271366da09370e10fafd2c50f08..b98e6000062134f01a0611fb17a3fd43250f7989 100644 (file)
@@ -195,9 +195,10 @@ static inline time_t filetime_to_time_t(const FILETIME *ft)
  */
 static int do_lstat(const char *file_name, struct stat *buf)
 {
+       int err;
        WIN32_FILE_ATTRIBUTE_DATA fdata;
 
-       if (!(errno = get_file_attr(file_name, &fdata))) {
+       if (!(err = get_file_attr(file_name, &fdata))) {
                buf->st_ino = 0;
                buf->st_gid = 0;
                buf->st_uid = 0;
@@ -211,6 +212,7 @@ static int do_lstat(const char *file_name, struct stat *buf)
                buf->st_ctime = filetime_to_time_t(&(fdata.ftCreationTime));
                return 0;
        }
+       errno = err;
        return -1;
 }
 
index f83f019ca91a2611f5bd3474ccf6d10081320c4c..d3037fc94eb027e5067b0371da2b33081fd89da5 100755 (executable)
@@ -255,7 +255,7 @@ __git_ps1 ()
                                (describe)
                                        git describe HEAD ;;
                                (* | default)
-                                       git describe --exact-match HEAD ;;
+                                       git describe --tags --exact-match HEAD ;;
                                esac 2>/dev/null)" ||
 
                                b="$(cut -c1-7 "$g/HEAD" 2>/dev/null)..." ||
index 7f4c7929784f8e2d8b24b0eaf9f05a2f10c1c6eb..d351cfb6e7e818f5f760e83889586c6dbf6e3a11 100644 (file)
@@ -79,6 +79,7 @@
 ;;; Code:
 
 (eval-when-compile (require 'cl))                            ; to use `push', `pop'
+(require 'format-spec)
 
 (defface git-blame-prefix-face
   '((((background dark)) (:foreground "gray"
index 4576c4a862c8ea0565a67eccdae6ef1ac4d9af9a..ead4c04d3f7ca64ed55ff605d7ee8087189a2226 100755 (executable)
@@ -1,4 +1,4 @@
-#!/usr/bin/perl -w
+#!/usr/bin/perl
 
 # This tool is copyright (c) 2005, Matthias Urlichs.
 # It is released under the Gnu Public License, version 2.
index c1ea643ace920e83a5577948553d4c9d1046abec..04ce7e3b020f489d59fe103970fc989d7b351127 100755 (executable)
@@ -706,7 +706,9 @@ class P4Submit(Command):
             submitTemplate = self.prepareLogMessage(template, logMessage)
             if os.environ.has_key("P4DIFF"):
                 del(os.environ["P4DIFF"])
-            diff = p4_read_pipe("diff -du ...")
+            diff = ""
+            for editedFile in editedFiles:
+                diff += p4_read_pipe("diff -du %r" % editedFile)
 
             newdiff = ""
             for newFile in filesToAdd:
index 3a5da4ab00f2e29c3244611f40d776293e796e7d..7f3afa5ac4a4ca979a4e5dd63ebc59344f20857b 100755 (executable)
@@ -1,4 +1,4 @@
-#!/usr/bin/perl -w
+#!/usr/bin/perl
 #
 # Copyright 2008-2009 Peter Krefting <peter@softwolves.pp.se>
 #
@@ -140,6 +140,7 @@ by whitespace or other characters.
 
 # Globals
 use strict;
+use warnings;
 use integer;
 my $crlfmode = 0;
 my @revs;
index 00850864371e16d1fa572b0d0e5832b8a88d8666..f99ea9585014face001849aeeefa5f20e79bc1e2 100755 (executable)
 # ---------------------------- Functions
 
 #
-# Top level email generation function.  This decides what type of update
-# this is and calls the appropriate body-generation routine after outputting
-# the common header
+# Function to prepare for email generation. This decides what type
+# of update this is and whether an email should even be generated.
 #
-# Note this function doesn't actually generate any email output, that is
-# taken care of by the functions it calls:
-#  - generate_email_header
-#  - generate_create_XXXX_email
-#  - generate_update_XXXX_email
-#  - generate_delete_XXXX_email
-#  - generate_email_footer
-#
-generate_email()
+prep_for_email()
 {
        # --- Arguments
        oldrev=$(git rev-parse $1)
@@ -153,13 +144,13 @@ generate_email()
                        short_refname=${refname##refs/remotes/}
                        echo >&2 "*** Push-update of tracking branch, $refname"
                        echo >&2 "***  - no email generated."
-                       exit 0
+                       return 1
                        ;;
                *)
                        # Anything else (is there anything else?)
                        echo >&2 "*** Unknown type of update to $refname ($rev_type)"
                        echo >&2 "***  - no email generated"
-                       exit 1
+                       return 1
                        ;;
        esac
 
@@ -175,9 +166,32 @@ generate_email()
                esac
                echo >&2 "*** $config_name is not set so no email will be sent"
                echo >&2 "*** for $refname update $oldrev->$newrev"
-               exit 0
+               return 1
        fi
 
+       return 0
+}
+
+#
+# Top level email generation function.  This calls the appropriate
+# body-generation routine after outputting the common header.
+#
+# Note this function doesn't actually generate any email output, that is
+# taken care of by the functions it calls:
+#  - generate_email_header
+#  - generate_create_XXXX_email
+#  - generate_update_XXXX_email
+#  - generate_delete_XXXX_email
+#  - generate_email_footer
+#
+# Note also that this function cannot 'exit' from the script; when this
+# function is running (in hook script mode), the send_mail() function
+# is already executing in another process, connected via a pipe, and
+# if this function exits without, whatever has been generated to that
+# point will be sent as an email... even if nothing has been generated.
+#
+generate_email()
+{
        # Email parameters
        # The email subject will contain the best description of the ref
        # that we can build from the parameters
@@ -717,10 +731,11 @@ if [ -n "$1" -a -n "$2" -a -n "$3" ]; then
        # Output to the terminal in command line mode - if someone wanted to
        # resend an email; they could redirect the output to sendmail
        # themselves
-       PAGER= generate_email $2 $3 $1
+       prep_for_email $2 $3 $1 && PAGER= generate_email
 else
        while read oldrev newrev refname
        do
-               generate_email $oldrev $newrev $refname $maxlines | send_mail
+               prep_for_email $oldrev $newrev $refname || continue
+               generate_email $maxlines | send_mail
        done
 fi
diff --git a/diff.c b/diff.c
index 0e2e872e0bb6b82d08e4dc6415afe875ccccc367..c8a7ceea02ff732f85df19d894cc5ab56ea6648e 100644 (file)
--- a/diff.c
+++ b/diff.c
@@ -1771,8 +1771,14 @@ static void emit_binary_diff(FILE *file, mmfile_t *one, mmfile_t *two, char *pre
 
 static void diff_filespec_load_driver(struct diff_filespec *one)
 {
-       if (!one->driver)
+       /* Use already-loaded driver */
+       if (one->driver)
+               return;
+
+       if (S_ISREG(one->mode))
                one->driver = userdiff_find_by_path(one->path);
+
+       /* Fallback to default settings */
        if (!one->driver)
                one->driver = userdiff_find_by_name("default");
 }
@@ -1820,8 +1826,7 @@ struct userdiff_driver *get_textconv(struct diff_filespec *one)
 {
        if (!DIFF_FILE_VALID(one))
                return NULL;
-       if (!S_ISREG(one->mode))
-               return NULL;
+
        diff_filespec_load_driver(one);
        if (!one->driver->textconv)
                return NULL;
@@ -2153,7 +2158,7 @@ static void builtin_checkdiff(const char *name_a, const char *name_b,
 
                        ecbdata.ws_rule = data.ws_rule;
                        check_blank_at_eof(&mf1, &mf2, &ecbdata);
-                       blank_at_eof = ecbdata.blank_at_eof_in_preimage;
+                       blank_at_eof = ecbdata.blank_at_eof_in_postimage;
 
                        if (blank_at_eof) {
                                static char *err;
@@ -3527,7 +3532,7 @@ static void diff_flush_stat(struct diff_filepair *p, struct diff_options *o,
 
        if ((DIFF_FILE_VALID(p->one) && S_ISDIR(p->one->mode)) ||
            (DIFF_FILE_VALID(p->two) && S_ISDIR(p->two->mode)))
-               return; /* no tree diffs in patch format */
+               return; /* no useful stat for tree diffs */
 
        run_diffstat(p, o, diffstat);
 }
@@ -3540,7 +3545,7 @@ static void diff_flush_checkdiff(struct diff_filepair *p,
 
        if ((DIFF_FILE_VALID(p->one) && S_ISDIR(p->one->mode)) ||
            (DIFF_FILE_VALID(p->two) && S_ISDIR(p->two->mode)))
-               return; /* no tree diffs in patch format */
+               return; /* nothing to check in tree diffs */
 
        run_checkdiff(p, o);
 }
@@ -3865,7 +3870,7 @@ static int diff_get_patch_id(struct diff_options *options, unsigned char *sha1)
 
                xpp.flags = 0;
                xecfg.ctxlen = 3;
-               xecfg.flags = XDL_EMIT_FUNCNAMES;
+               xecfg.flags = 0;
                xdi_diff_outf(&mf1, &mf2, patch_id_consume, &data,
                              &xpp, &xecfg);
        }
diff --git a/dir.c b/dir.c
index d1e5e5e5bfaea81cb46fc3e3f57df31c6ef1eb2a..b2dfb69eb5606a7538cc5e1876a91f703ec4969c 100644 (file)
--- a/dir.c
+++ b/dir.c
@@ -360,7 +360,8 @@ int excluded_from_list(const char *pathname,
 
                        if (x->flags & EXC_FLAG_MUSTBEDIR) {
                                if (!dtype) {
-                                       if (!prefixcmp(pathname, exclude))
+                                       if (!prefixcmp(pathname, exclude) &&
+                                           pathname[x->patternlen] == '/')
                                                return to_exclude;
                                        else
                                                continue;
index 27fc79347af428dd39daa5b550814cc6cf980510..77f60fa3960323e412f8d09968e63865cc639298 100755 (executable)
@@ -1,6 +1,8 @@
-#!/usr/bin/perl -w
+#!/usr/bin/perl
 
+use 5.008;
 use strict;
+use warnings;
 use Git;
 
 binmode(STDOUT, ":raw");
index 98f3ede566a6cb0c902ce84795f7de8f8afbe633..bc32f18d6d9cbf915eb7797817390adbbc111506 100755 (executable)
@@ -1,4 +1,4 @@
-#!/usr/bin/perl -w
+#!/usr/bin/perl
 #
 # This tool is copyright (c) 2005, Martin Langhoff.
 # It is released under the Gnu Public License, version 2.
@@ -54,6 +54,7 @@ and can contain multiple, unrelated branches.
 
 =cut
 
+use 5.008;
 use strict;
 use warnings;
 use Getopt::Std;
index 59b672213bfc36f95db089f0e13bafc1c2f2ed71..39a426e067c76e01d3f2a0d63243ec494436da46 100755 (executable)
@@ -1,6 +1,8 @@
-#!/usr/bin/perl -w
+#!/usr/bin/perl
 
+use 5.008;
 use strict;
+use warnings;
 use Getopt::Std;
 use File::Temp qw(tempdir);
 use Data::Dumper;
index 9e03eee4586ca3b7476b56f66e9dcf6ffe3088cf..249aeaf17557c4b8f05fdd5f1df5c16d65f0f84c 100755 (executable)
@@ -1,4 +1,4 @@
-#!/usr/bin/perl -w
+#!/usr/bin/perl
 
 # This tool is copyright (c) 2005, Matthias Urlichs.
 # It is released under the Gnu Public License, version 2.
@@ -13,6 +13,7 @@
 # The head revision is on branch "origin" by default.
 # You can change that with the '-o' option.
 
+use 5.008;
 use strict;
 use warnings;
 use Getopt::Long;
index e9f3037df351ceed0262a8995f19903464163af8..2822bed1fdf6977cd415461bc48630a4996f7084 100755 (executable)
@@ -15,6 +15,7 @@
 ####
 ####
 
+use 5.008;
 use strict;
 use warnings;
 use bytes;
index adc42de8752fd395707f1e395c61991b3146cebb..e95e4ad973f21dd104950dc6ebb28485844b36f4 100755 (executable)
@@ -10,6 +10,7 @@
 #
 # Any arguments that are unknown to this script are forwarded to 'git diff'.
 
+use 5.008;
 use strict;
 use warnings;
 use Cwd qw(abs_path);
index e5df23bb8350d6d155bdf1ac9a5be4c9fdc29326..10a238ae3cc942bc021db18195b7098e2866c266 100755 (executable)
@@ -311,10 +311,6 @@ do
                esac
                strategy_opts="$strategy_opts $(git rev-parse --sq-quote "--$newopt")"
                do_merge=t
-               if test -n "$strategy"
-               then
-                       strategy=recursive
-               fi
                ;;
        -s=*|--s=*|--st=*|--str=*|--stra=*|--strat=*|--strate=*|\
                --strateg=*|--strategy=*|\
index c2a0ef8d5a2794a45908cbcfff1b419ebfc17f8e..e136732cea80c1594ac02c93cf246e8c77ff89b8 100755 (executable)
@@ -6,7 +6,7 @@
 #
 # Scan two git object-trees, and hardlink any common objects between them.
 
-use 5.006;
+use 5.008;
 use strict;
 use warnings;
 use Getopt::Long;
index 1eb3bca352f38ec3807383cc5fff7f7e62731b2b..624feec26f66b15926ffa11767c146222bc9a185 100755 (executable)
@@ -10,7 +10,8 @@ git repack [options]
 a               pack everything in a single pack
 A               same as -a, and turn unreachable objects loose
 d               remove redundant packs, and run git-prune-packed
-f               pass --no-reuse-object to git-pack-objects
+f               pass --no-reuse-delta to git-pack-objects
+F               pass --no-reuse-object to git-pack-objects
 n               do not run git-update-server-info
 q,quiet         be quiet
 l               pass --local to git-pack-objects
@@ -34,7 +35,8 @@ do
                unpack_unreachable=--unpack-unreachable ;;
        -d)     remove_redundant=t ;;
        -q)     GIT_QUIET=t ;;
-       -f)     no_reuse=--no-reuse-object ;;
+       -f)     no_reuse=--no-reuse-delta ;;
+       -F)     no_reuse=--no-reuse-object ;;
        -l)     local=--local ;;
        --max-pack-size|--window|--window-memory|--depth)
                extra="$extra $1=$2"; shift ;;
@@ -50,7 +52,7 @@ true)
 esac
 
 PACKDIR="$GIT_OBJECT_DIRECTORY/pack"
-PACKTMP="$GIT_OBJECT_DIRECTORY/.tmp-$$-pack"
+PACKTMP="$PACKDIR/.tmp-$$-pack"
 rm -f "$PACKTMP"-*
 trap 'rm -f "$PACKTMP"-*' 0 1 2 3 15
 
@@ -80,6 +82,8 @@ case ",$all_into_one," in
        ;;
 esac
 
+mkdir -p "$PACKDIR" || exit
+
 args="$args $local ${GIT_QUIET:+-q} $no_reuse$extra"
 names=$(git pack-objects --keep-true-parents --honor-pack-keep --non-empty --all --reflog $args </dev/null "$PACKTMP") ||
        exit 1
@@ -88,7 +92,6 @@ if [ -z "$names" ]; then
 fi
 
 # Ok we have prepared all new packfiles.
-mkdir -p "$PACKDIR" || exit
 
 # First see if there are packs of the same name and if so
 # if we can move them out of the way (this can happen if we
index e1f29a72a10ff68c972b439749535d251bfd311c..c1d8edbdd324fc1eca7bc475cbf31bd913036682 100755 (executable)
@@ -1,4 +1,4 @@
-#!/usr/bin/perl -w
+#!/usr/bin/perl
 #
 # Copyright 2002,2005 Greg Kroah-Hartman <greg@kroah.com>
 # Copyright 2005 Ryan Anderson <ryan@michonline.com>
@@ -16,6 +16,7 @@
 #    and second line is the subject of the message.
 #
 
+use 5.008;
 use strict;
 use warnings;
 use Term::ReadLine;
@@ -85,6 +86,7 @@ git send-email [options] <file | directory | rev-list options >
     --[no-]validate                * Perform patch sanity checks. Default on.
     --[no-]format-patch            * understand any non optional arguments as
                                      `git format-patch` ones.
+    --force                        * Send even if safety checks would prevent it.
 
 EOT
        exit(1);
@@ -162,6 +164,7 @@ if ($@) {
 my ($quiet, $dry_run) = (0, 0);
 my $format_patch;
 my $compose_filename;
+my $force = 0;
 
 # Handle interactive edition of files.
 my $multiedit;
@@ -301,6 +304,7 @@ my $rc = GetOptions("sender|from=s" => \$sender,
                    "validate!" => \$validate,
                    "format-patch!" => \$format_patch,
                    "8bit-encoding=s" => \$auto_8bit_encoding,
+                   "force" => \$force,
         );
 
 unless ($rc) {
@@ -702,6 +706,16 @@ if (!defined $auto_8bit_encoding && scalar %broken_encoding) {
                                  default => "UTF-8");
 }
 
+if (!$force) {
+       for my $f (@files) {
+               if (get_patch_subject($f) =~ /\*\*\* SUBJECT HERE \*\*\*/) {
+                       die "Refusing to send because the patch\n\t$f\n"
+                               . "has the template subject '*** SUBJECT HERE ***'. "
+                               . "Pass --force if you really want to send.\n";
+               }
+       }
+}
+
 my $prompting = 0;
 if (!defined $sender) {
        $sender = $repoauthor || $repocommitter || '';
@@ -940,7 +954,7 @@ sub maildomain {
 sub send_message {
        my @recipients = unique_email_list(@to);
        @cc = (grep { my $cc = extract_valid_address($_);
-                     not grep { $cc eq $_ } @recipients
+                     not grep { $cc eq $_ || $_ =~ /<\Q${cc}\E>$/ } @recipients
                    }
               map { sanitize_address($_) }
               @cc);
index 6131670860514c215a6b9b7417dd05c3124e81b4..8d54b73d3208064829613499580bad541586c725 100644 (file)
@@ -151,17 +151,14 @@ get_author_ident_from_commit () {
                s/'\''/'\''\\'\'\''/g
                h
                s/^author \([^<]*\) <[^>]*> .*$/\1/
-               s/'\''/'\''\'\'\''/g
                s/.*/GIT_AUTHOR_NAME='\''&'\''/p
 
                g
                s/^author [^<]* <\([^>]*\)> .*$/\1/
-               s/'\''/'\''\'\'\''/g
                s/.*/GIT_AUTHOR_EMAIL='\''&'\''/p
 
                g
                s/^author [^<]* <[^>]*> \(.*\)$/\1/
-               s/'\''/'\''\'\'\''/g
                s/.*/GIT_AUTHOR_DATE='\''&'\''/p
 
                q
index 9ebbab798d21147fc019b6183cad0c462c9dafca..c291eed59cca35d4b08285133acaca29bd80d372 100755 (executable)
@@ -836,11 +836,12 @@ cmd_sync()
                        ;;
                esac
 
+               say "Synchronizing submodule url for '$name'"
+               git config submodule."$name".url "$url"
+
                if test -e "$path"/.git
                then
                (
-                       say "Synchronizing submodule url for '$name'"
-                       git config submodule."$name".url "$url"
                        clear_local_git_env
                        cd "$path"
                        remote=$(get_default_remote)
index 18cfb2466d11aa28a795e3dabac70e236061fbe9..757de82161e05b9d12c489efeff05c7fec341fe4 100755 (executable)
@@ -1,6 +1,7 @@
 #!/usr/bin/env perl
 # Copyright (C) 2006, Eric Wong <normalperson@yhbt.net>
 # License: GPL v2 or later
+use 5.008;
 use warnings;
 use strict;
 use vars qw/   $AUTHOR $VERSION
index a85e2f63197649bff4842ea2970448205618c104..e645d4a821f7eab28911f508923abd3e9a9dc53b 100755 (executable)
@@ -7,6 +7,7 @@
 #
 # This program is licensed under the GPLv2
 
+use 5.008;
 use strict;
 use warnings;
 use CGI qw(:standard :escapeHTML -nosticky);
diff --git a/http.c b/http.c
index 0a5011f615bdfade0b69682b177dc97471ac20a3..17bcf19c5001d309bdbf524e7d3817cf3482a3c3 100644 (file)
--- a/http.c
+++ b/http.c
@@ -279,6 +279,11 @@ static CURL *get_curl_handle(void)
        }
 
        curl_easy_setopt(result, CURLOPT_FOLLOWLOCATION, 1);
+#if LIBCURL_VERSION_NUM >= 0x071301
+       curl_easy_setopt(result, CURLOPT_POSTREDIR, CURL_REDIR_POST_ALL);
+#elif LIBCURL_VERSION_NUM >= 0x071101
+       curl_easy_setopt(result, CURLOPT_POST301, 1);
+#endif
 
        if (getenv("GIT_CURL_VERBOSE"))
                curl_easy_setopt(result, CURLOPT_VERBOSE, 1);
index f80b701292f0d852950735ab20a63dac13e92362..02fcfde0b0b786af5229559586cf8ff5758429bc 100644 (file)
--- a/mailmap.c
+++ b/mailmap.c
@@ -79,12 +79,14 @@ static void add_mapping(struct string_list *map,
        if (old_name == NULL) {
                debug_mm("mailmap: adding (simple) entry for %s at index %d\n", old_email, index);
                /* Replace current name and new email for simple entry */
-               free(me->name);
-               free(me->email);
-               if (new_name)
+               if (new_name) {
+                       free(me->name);
                        me->name = xstrdup(new_name);
-               if (new_email)
+               }
+               if (new_email) {
+                       free(me->email);
                        me->email = xstrdup(new_email);
+               }
        } else {
                struct mailmap_info *mi = xmalloc(sizeof(struct mailmap_info));
                debug_mm("mailmap: adding (complex) entry for %s at index %d\n", old_email, index);
index 6cb0dd19344ba1169b23b7e4949033f8a9088a00..205e48aa3a7b912005565ac9c296205a897a1476 100644 (file)
@@ -7,6 +7,7 @@ Git - Perl interface to the Git version control system
 
 package Git;
 
+use 5.008;
 use strict;
 
 
diff --git a/setup.c b/setup.c
index a3b76de2bb1c18e2f3b8cdf5799c3c650b16d027..346ef2eb2d678b742280c0816a09b8ca174ca799 100644 (file)
--- a/setup.c
+++ b/setup.c
@@ -46,7 +46,7 @@ const char *prefix_filename(const char *pfx, int pfx_len, const char *arg)
 {
        static char path[PATH_MAX];
 #ifndef WIN32
-       if (!pfx || !*pfx || is_absolute_path(arg))
+       if (!pfx_len || is_absolute_path(arg))
                return arg;
        memcpy(path, pfx, pfx_len);
        strcpy(path + pfx_len, arg);
@@ -55,7 +55,7 @@ const char *prefix_filename(const char *pfx, int pfx_len, const char *arg)
        /* don't add prefix to absolute paths, but still replace '\' by '/' */
        if (is_absolute_path(arg))
                pfx_len = 0;
-       else
+       else if (pfx_len)
                memcpy(path, pfx, pfx_len);
        strcpy(path + pfx_len, arg);
        for (p = path + pfx_len; *p; p++)
index 484081de82928108a23a714a76ea88693e56bdd1..3e856b80369c289a3d9399d60ec3be22bbbc6788 100644 (file)
@@ -1069,6 +1069,7 @@ int get_sha1_with_context_1(const char *name, unsigned char *sha1,
                struct cache_entry *ce;
                int pos;
                if (namelen > 2 && name[1] == '/')
+                       /* don't need mode for commit */
                        return get_sha1_oneline(name + 2, sha1);
                if (namelen < 3 ||
                    name[2] != ':' ||
@@ -1096,6 +1097,7 @@ int get_sha1_with_context_1(const char *name, unsigned char *sha1,
                                break;
                        if (ce_stage(ce) == stage) {
                                hashcpy(sha1, ce->sha1);
+                               oc->mode = ce->ce_mode;
                                return 0;
                        }
                        pos++;
index 81ef2a0969d98f05ce22cd8a06fcb55a7af9aee8..1b9523d02f3a8e785b0823a1d58dfaa22837ba39 100644 (file)
@@ -80,7 +80,7 @@ if ! test_have_prereq PERL; then
        test_done
 fi
 
-perl -MEncode -e 'decode_utf8("", Encode::FB_CROAK)' >/dev/null 2>&1 || {
+perl -MEncode -e '$e="";decode_utf8($e, Encode::FB_CROAK)' >/dev/null 2>&1 || {
     skip_all='skipping gitweb tests, perl version is too old'
     test_done
 }
index 4961505d1dd99da529b43abd42522e6a005961b1..f41c7c674c497825d714a0fe9be3c9bc0a0f30c6 100644 (file)
@@ -17,6 +17,9 @@ ErrorLog error.log
 <IfModule !mod_env.c>
        LoadModule env_module modules/mod_env.so
 </IfModule>
+<IfModule !mod_rewrite.c>
+       LoadModule rewrite_module modules/mod_rewrite.so
+</IFModule>
 
 Alias /dumb/ www/
 
@@ -36,6 +39,10 @@ ScriptAlias /smart_noexport/ ${GIT_EXEC_PATH}/git-http-backend/
        Options ExecCGI
 </Files>
 
+RewriteEngine on
+RewriteRule ^/smart-redir-perm/(.*)$ /smart/$1 [R=301]
+RewriteRule ^/smart-redir-temp/(.*)$ /smart/$1 [R=302]
+
 <IfDefine SSL>
 LoadModule ssl_module modules/mod_ssl.so
 
index 9a07de1a5b6d3a98c0db0b24cdd9c3a68cef79b5..8008fa2d894baf76a19168a020ed4f4640619ce7 100755 (executable)
@@ -17,17 +17,19 @@ test_expect_success 'setup' '
        cat >expected <<-\EOF &&
        100644 77f0ba1734ed79d12881f81b36ee134de6a3327b 0       init.t
        100644 e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 0       sub/added
+       100644 e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 0       subsub/added
        EOF
        cat >expected.swt <<-\EOF &&
        H init.t
        H sub/added
+       H subsub/added
        EOF
 
        test_commit init &&
        echo modified >>init.t &&
-       mkdir sub &&
-       touch sub/added &&
-       git add init.t sub/added &&
+       mkdir sub subsub &&
+       touch sub/added subsub/added &&
+       git add init.t sub/added subsub/added &&
        git commit -m "modified and added" &&
        git tag top &&
        git rm sub/added &&
@@ -81,6 +83,7 @@ test_expect_success 'match directories with trailing slash' '
        cat >expected.swt-noinit <<-\EOF &&
        S init.t
        H sub/added
+       S subsub/added
        EOF
 
        echo sub/ > .git/info/sparse-checkout &&
@@ -105,6 +108,7 @@ test_expect_success 'checkout area changes' '
        cat >expected.swt-nosub <<-\EOF &&
        H init.t
        S sub/added
+       S subsub/added
        EOF
 
        echo init.t >.git/info/sparse-checkout &&
index 2bea65634a1790ceecf824309c1fbb66250f58d5..be8c1d5ef9fd650c128a9fe7126cbcd8db6c5a95 100755 (executable)
@@ -117,4 +117,25 @@ test_expect_success 'picking rebase' '
        esac
 '
 
+test_expect_success 'rebase -s funny -Xopt' '
+       test_when_finished "rm -fr test-bin funny.was.run" &&
+       mkdir test-bin &&
+       cat >test-bin/git-merge-funny <<-EOF &&
+       #!$SHELL_PATH
+       case "\$1" in --opt) ;; *) exit 2 ;; esac
+       shift &&
+       >funny.was.run &&
+       exec git merge-recursive "\$@"
+       EOF
+       chmod +x test-bin/git-merge-funny &&
+       git reset --hard &&
+       git checkout -b test-funny master^ &&
+       test_commit funny &&
+       (
+               PATH=./test-bin:$PATH
+               git rebase -s funny -Xopt master
+       ) &&
+       test -f funny.was.run
+'
+
 test_done
diff --git a/t/t3419-rebase-patch-id.sh b/t/t3419-rebase-patch-id.sh
new file mode 100755 (executable)
index 0000000..1aee483
--- /dev/null
@@ -0,0 +1,109 @@
+#!/bin/bash
+
+test_description='git rebase - test patch id computation'
+
+. ./test-lib.sh
+
+test_set_prereq NOT_EXPENSIVE
+test -n "$GIT_PATCHID_TIMING_TESTS" && test_set_prereq EXPENSIVE
+test -x /usr/bin/time && test_set_prereq USR_BIN_TIME
+
+count()
+{
+       i=0
+       while test $i -lt $1
+       do
+               echo "$i"
+               i=$(($i+1))
+       done
+}
+
+scramble()
+{
+       i=0
+       while read x
+       do
+               if test $i -ne 0
+               then
+                       echo "$x"
+               fi
+               i=$(((i+1) % 10))
+       done < "$1" > "$1.new"
+       mv -f "$1.new" "$1"
+}
+
+run()
+{
+       echo \$ "$@"
+       /usr/bin/time "$@" >/dev/null
+}
+
+test_expect_success 'setup' '
+       git commit --allow-empty -m initial
+       git tag root
+'
+
+do_tests()
+{
+       pr=$1
+       nlines=$2
+
+       test_expect_success $pr "setup: $nlines lines" "
+               rm -f .gitattributes &&
+               git checkout -q -f master &&
+               git reset --hard root &&
+               count $nlines >file &&
+               git add file &&
+               git commit -q -m initial &&
+               git branch -f other &&
+
+               scramble file &&
+               git add file &&
+               git commit -q -m 'change big file' &&
+
+               git checkout -q other &&
+               : >newfile &&
+               git add newfile &&
+               git commit -q -m 'add small file' &&
+
+               git cherry-pick master >/dev/null 2>&1
+       "
+
+       test_debug "
+               run git diff master^\!
+       "
+
+       test_expect_success $pr 'setup attributes' "
+               echo 'file binary' >.gitattributes
+       "
+
+       test_debug "
+               run git format-patch --stdout master &&
+               run git format-patch --stdout --ignore-if-in-upstream master
+       "
+
+       test_expect_success $pr 'detect upstream patch' "
+               git checkout -q master &&
+               scramble file &&
+               git add file &&
+               git commit -q -m 'change big file again' &&
+               git checkout -q other^{} &&
+               git rebase master &&
+               test_must_fail test -n \"\$(git rev-list master...HEAD~)\"
+       "
+
+       test_expect_success $pr 'do not drop patch' "
+               git branch -f squashed master &&
+               git checkout -q -f squashed &&
+               git reset -q --soft HEAD~2 &&
+               git commit -q -m squashed &&
+               git checkout -q other^{} &&
+               test_must_fail git rebase squashed &&
+               rm -rf .git/rebase-apply
+       "
+}
+
+do_tests NOT_EXPENSIVE 500
+do_tests EXPENSIVE 50000
+
+test_done
index e17ae712b1078333fa191b97764177016bc01b84..51ca391e472441d2d503e721795d609bfaad1100 100755 (executable)
@@ -95,4 +95,14 @@ test_expect_success 'cherry pick a merge relative to nonexistent parent with --f
        test_must_fail git cherry-pick --ff -m 3 C
 '
 
+test_expect_success 'cherry pick a root commit with --ff' '
+       git reset --hard first -- &&
+       git rm file1 &&
+       echo first >file2 &&
+       git add file2 &&
+       git commit --amend -m "file2" &&
+       git cherry-pick --ff first &&
+       test "$(git rev-parse --verify HEAD)" = "1df192cd8bc58a2b275d842cede4d221ad9000d1"
+'
+
 test_done
index 6f6948925fed1b99f37ec94dd7e4aa2075eb6bb7..408a19c4c258da9b7860edffea314b181e273edf 100755 (executable)
@@ -88,4 +88,30 @@ test_expect_success SYMLINKS \
     test_must_fail git diff --no-index pinky brain > output 2> output.err &&
     grep narf output &&
     ! grep error output.err'
+
+test_expect_success SYMLINKS 'setup symlinks with attributes' '
+       echo "*.bin diff=bin" >>.gitattributes &&
+       echo content >file.bin &&
+       ln -s file.bin link.bin &&
+       git add -N file.bin link.bin
+'
+
+cat >expect <<'EOF'
+diff --git a/file.bin b/file.bin
+index e69de29..d95f3ad 100644
+Binary files a/file.bin and b/file.bin differ
+diff --git a/link.bin b/link.bin
+index e69de29..dce41ec 120000
+--- a/link.bin
++++ b/link.bin
+@@ -0,0 +1 @@
++file.bin
+\ No newline at end of file
+EOF
+test_expect_success SYMLINKS 'symlinks do not respect userdiff config by path' '
+       git config diff.bin.binary true &&
+       git diff file.bin link.bin >actual &&
+       test_cmp expect actual
+'
+
 test_done
index bc46563afc607e6fba9acbd2773d88207c878981..05ec0628322ccc103343515feb70d27a9a0e6c76 100755 (executable)
@@ -77,10 +77,6 @@ test_expect_success 'apply binary patch' \
         tree1=`git write-tree` &&
         test "$tree1" = "$tree0"'
 
-nul_to_q() {
-       perl -pe 'y/\000/Q/'
-}
-
 test_expect_success 'diff --no-index with binary creation' '
        echo Q | q_to_nul >binary &&
        (: hide error code from diff, which just indicates differences
index 935d101fe8d880ff426452ca6f611ce8d30b8bc1..a8736f7cbeef65b3454847bb4b4df508c0079652 100755 (executable)
@@ -491,4 +491,41 @@ test_expect_success 'combined diff with autocrlf conversion' '
 
 '
 
+# Start testing the colored format for whitespace checks
+
+test_expect_success 'setup diff colors' '
+       git config color.diff always &&
+       git config color.diff.plain normal &&
+       git config color.diff.meta bold &&
+       git config color.diff.frag cyan &&
+       git config color.diff.func normal &&
+       git config color.diff.old red &&
+       git config color.diff.new green &&
+       git config color.diff.commit yellow &&
+       git config color.diff.whitespace "normal red" &&
+
+       git config core.autocrlf false
+'
+cat >expected <<\EOF
+<BOLD>diff --git a/x b/x<RESET>
+<BOLD>index 9daeafb..2874b91 100644<RESET>
+<BOLD>--- a/x<RESET>
+<BOLD>+++ b/x<RESET>
+<CYAN>@@ -1 +1,4 @@<RESET>
+ test<RESET>
+<GREEN>+<RESET><GREEN>{<RESET>
+<GREEN>+<RESET><BRED>  <RESET>
+<GREEN>+<RESET><GREEN>}<RESET>
+EOF
+
+test_expect_success 'diff that introduces a line with only tabs' '
+       git config core.whitespace blank-at-eol &&
+       git reset --hard &&
+       echo "test" > x &&
+       git commit -m "initial" x &&
+       echo "{NTN}" | tr "NT" "\n\t" >> x &&
+       git -c color.diff=always diff | test_decode_color >current &&
+       test_cmp expected current
+'
+
 test_done
index c8e19372b00f128646b809e1f5723d88b58a3f30..0a61b57b5f6f00ae4c0734a34ce45c0ba1fcf098 100755 (executable)
@@ -32,7 +32,7 @@ EOF
 
 sed 's/beer\\/beer,\\/' < Beer.java > Beer-correct.java
 
-builtin_patterns="bibtex cpp csharp html java objc pascal php python ruby tex"
+builtin_patterns="bibtex cpp csharp fortran html java objc pascal php python ruby tex"
 for p in $builtin_patterns
 do
        test_expect_success "builtin $p pattern compiles" '
index f6d1f1ebab406fcd4f405178ec151149754500b0..87df0aeb59ecb22f07454ce08172f8cfa4940591 100755 (executable)
@@ -178,6 +178,15 @@ test_expect_success 'trailing empty lines (2)' '
 
 '
 
+test_expect_success 'checkdiff shows correct line number for trailing blank lines' '
+
+       printf "a\nb\n" > G &&
+       git add G &&
+       printf "x\nx\nx\na\nb\nc\n\n" > G &&
+       [ "$(git diff --check -- G)" = "G:7: new blank line at EOF." ]
+
+'
+
 test_expect_success 'do not color trailing cr in context' '
        git config --unset core.whitespace
        rm -f .gitattributes &&
index 6f7548c3a144ecada6642eccee6b0f687baafb2d..3f3c7577ca85c92e5ff986044e0c4afa95bf608d 100755 (executable)
@@ -35,10 +35,10 @@ aeff = aeff * ( aaa )
 EOF
 
 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>
+<BOLD>diff --git a/pre b/post<RESET>
+<BOLD>index 330b04f..5ed8eff 100644<RESET>
+<BOLD>--- a/pre<RESET>
+<BOLD>+++ b/post<RESET>
 <CYAN>@@ -1,3 +1,7 @@<RESET>
 <RED>h(4)<RESET><GREEN>h(4),hh[44]<RESET>
 
@@ -122,10 +122,10 @@ test_expect_success '--word-diff=plain --no-color' '
 '
 
 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>
+<BOLD>diff --git a/pre b/post<RESET>
+<BOLD>index 330b04f..5ed8eff 100644<RESET>
+<BOLD>--- a/pre<RESET>
+<BOLD>+++ b/post<RESET>
 <CYAN>@@ -1,3 +1,7 @@<RESET>
 <RED>[-h(4)-]<RESET><GREEN>{+h(4),hh[44]+}<RESET>
 
@@ -143,10 +143,10 @@ test_expect_success '--word-diff=plain --color' '
 '
 
 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>
+<BOLD>diff --git a/pre b/post<RESET>
+<BOLD>index 330b04f..5ed8eff 100644<RESET>
+<BOLD>--- a/pre<RESET>
+<BOLD>+++ b/post<RESET>
 <CYAN>@@ -1 +1 @@<RESET>
 <RED>h(4)<RESET><GREEN>h(4),hh[44]<RESET>
 <CYAN>@@ -3,0 +4,4 @@<RESET> <RESET><MAGENTA>a = b + c<RESET>
@@ -163,10 +163,10 @@ test_expect_success 'word diff without context' '
 '
 
 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>
+<BOLD>diff --git a/pre b/post<RESET>
+<BOLD>index 330b04f..5ed8eff 100644<RESET>
+<BOLD>--- a/pre<RESET>
+<BOLD>+++ b/post<RESET>
 <CYAN>@@ -1,3 +1,7 @@<RESET>
 h(4),<GREEN>hh<RESET>[44]
 
@@ -199,10 +199,10 @@ test_expect_success 'option overrides .gitattributes' '
 '
 
 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>
+<BOLD>diff --git a/pre b/post<RESET>
+<BOLD>index 330b04f..5ed8eff 100644<RESET>
+<BOLD>--- a/pre<RESET>
+<BOLD>+++ b/post<RESET>
 <CYAN>@@ -1,3 +1,7 @@<RESET>
 h(4)<GREEN>,hh[44]<RESET>
 
@@ -231,10 +231,10 @@ test_expect_success 'command-line overrides config' '
 '
 
 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>
+<BOLD>diff --git a/pre b/post<RESET>
+<BOLD>index 330b04f..5ed8eff 100644<RESET>
+<BOLD>--- a/pre<RESET>
+<BOLD>+++ b/post<RESET>
 <CYAN>@@ -1,3 +1,7 @@<RESET>
 h(4),<GREEN>{+hh+}<RESET>[44]
 
@@ -260,10 +260,10 @@ test_expect_success 'remove diff driver regex' '
 '
 
 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>
+<BOLD>diff --git a/pre b/post<RESET>
+<BOLD>index 330b04f..5ed8eff 100644<RESET>
+<BOLD>--- a/pre<RESET>
+<BOLD>+++ b/post<RESET>
 <CYAN>@@ -1,3 +1,7 @@<RESET>
 h(4),<GREEN>hh[44<RESET>]
 
@@ -282,10 +282,10 @@ echo 'aaa (aaa)' > pre
 echo 'aaa (aaa) aaa' > post
 
 cat > expect <<\EOF
-<WHITE>diff --git a/pre b/post<RESET>
-<WHITE>index c29453b..be22f37 100644<RESET>
-<WHITE>--- a/pre<RESET>
-<WHITE>+++ b/post<RESET>
+<BOLD>diff --git a/pre b/post<RESET>
+<BOLD>index c29453b..be22f37 100644<RESET>
+<BOLD>--- a/pre<RESET>
+<BOLD>+++ b/post<RESET>
 <CYAN>@@ -1 +1 @@<RESET>
 aaa (aaa) <GREEN>aaa<RESET>
 EOF
@@ -301,10 +301,10 @@ echo '(:' > pre
 echo '(' > post
 
 cat > expect <<\EOF
-<WHITE>diff --git a/pre b/post<RESET>
-<WHITE>index 289cb9d..2d06f37 100644<RESET>
-<WHITE>--- a/pre<RESET>
-<WHITE>+++ b/post<RESET>
+<BOLD>diff --git a/pre b/post<RESET>
+<BOLD>index 289cb9d..2d06f37 100644<RESET>
+<BOLD>--- a/pre<RESET>
+<BOLD>+++ b/post<RESET>
 <CYAN>@@ -1 +1 @@<RESET>
 (<RED>:<RESET>
 EOF
index 9692f16f3581f261c4c10a29f03751990adb7897..08ad6d8b9e6b2869bfd2b574779380895709972d 100755 (executable)
@@ -37,7 +37,16 @@ test_expect_success 'setup' "
        git diff-tree -p -C master binary >C.diff &&
 
        git diff-tree -p --binary master binary >BF.diff &&
-       git diff-tree -p --binary -C master binary >CF.diff
+       git diff-tree -p --binary -C master binary >CF.diff &&
+
+       git diff-tree -p --full-index master binary >B-index.diff &&
+       git diff-tree -p -C --full-index master binary >C-index.diff &&
+
+       git init other-repo &&
+       (cd other-repo &&
+        git fetch .. master &&
+        git reset --hard FETCH_HEAD
+       )
 "
 
 test_expect_success 'stat binary diff -- should not fail.' \
@@ -100,6 +109,22 @@ test_expect_success 'apply binary diff (copy) -- should fail.' \
        'do_reset &&
         test_must_fail git apply --index C.diff'
 
+test_expect_success 'apply binary diff with full-index' '
+       do_reset &&
+       git apply B-index.diff
+'
+
+test_expect_success 'apply binary diff with full-index (copy)' '
+       do_reset &&
+       git apply C-index.diff
+'
+
+test_expect_success 'apply full-index binary diff in new repo' '
+       (cd other-repo &&
+        do_reset &&
+        test_must_fail git apply ../B-index.diff)
+'
+
 test_expect_success 'apply binary diff without replacement.' \
        'do_reset &&
         git apply BF.diff'
index bb1ffe3b6cfe491137b34993fe2e3bed99908dff..a2bc1cd37d852a9cab79c946bf88ee9dc958b460 100755 (executable)
@@ -30,6 +30,7 @@ test_expect_success setup '
        epocWest="1969-12-31 16:00:00.000000000 -0800" &&
         epocGMT="1970-01-01 00:00:00.000000000 +0000" &&
        epocEast="1970-01-01 09:00:00.000000000 +0900" &&
+       epocWest2="1969-12-31 16:00:00 -08:00" &&
 
        sed -e "s/TS0/$epocWest/" -e "s/TS1/$timeWest/" <c >createWest.patch &&
        sed -e "s/TS0/$epocEast/" -e "s/TS1/$timeEast/" <c >createEast.patch &&
@@ -46,6 +47,7 @@ test_expect_success setup '
        sed -e "s/TS0/$timeWest/" -e "s/TS1/$epocWest/" <d >removeWest.patch &&
        sed -e "s/TS0/$timeEast/" -e "s/TS1/$epocEast/" <d >removeEast.patch &&
        sed -e "s/TS0/$timeGMT/" -e "s/TS1/$epocGMT/" <d >removeGMT.patch &&
+       sed -e "s/TS0/$timeWest/" -e "s/TS1/$epocWest2/" <d >removeWest2.patch &&
 
        echo something >something &&
        >empty
index 1e5aad57ab799819c6f319eaf813149d8bdda136..bf5dc57286493b0b94caf927304e92db11e54f2c 100755 (executable)
@@ -72,4 +72,20 @@ test_expect_success 'whitespace-damaged traditional patch' '
        test_cmp expected postimage.txt
 '
 
+test_expect_success 'traditional patch with colon in timezone' '
+       echo postimage >expected &&
+       reset_preimage &&
+       rm -f "post image.txt" &&
+       git apply "$vector/funny-tz.diff" &&
+       test_cmp expected "post image.txt"
+'
+
+test_expect_success 'traditional, whitespace-damaged, colon in timezone' '
+       echo postimage >expected &&
+       reset_preimage &&
+       rm -f "post image.txt" &&
+       git apply "$vector/damaged-tz.diff" &&
+       test_cmp expected "post image.txt"
+'
+
 test_done
diff --git a/t/t4135/damaged-tz.diff b/t/t4135/damaged-tz.diff
new file mode 100644 (file)
index 0000000..07aaf08
--- /dev/null
@@ -0,0 +1,5 @@
+diff -urN -X /usr/people/jes/exclude-linux linux-2.6.12-rc2-mm3-vanilla/post image.txt linux-2.6.12-rc2-mm3/post image.txt
+--- linux-2.6.12-rc2-mm3-vanilla/post image.txt 1969-12-31 16:00:00 -08:00
++++ linux-2.6.12-rc2-mm3/post image.txt 2005-04-12 02:14:06 -07:00
+@@ -0,0 +1 @@
++postimage
diff --git a/t/t4135/funny-tz.diff b/t/t4135/funny-tz.diff
new file mode 100644 (file)
index 0000000..998e3a8
--- /dev/null
@@ -0,0 +1,5 @@
+diff -urN -X /usr/people/jes/exclude-linux linux-2.6.12-rc2-mm3-vanilla/post image.txt linux-2.6.12-rc2-mm3/post image.txt
+--- linux-2.6.12-rc2-mm3-vanilla/post image.txt        1969-12-31 16:00:00 -08:00
++++ linux-2.6.12-rc2-mm3/post image.txt        2005-04-12 02:14:06 -07:00
+@@ -0,0 +1 @@
++postimage
index 9a7d1b446634382d91286a6c062cc9bcda0bd33f..e818de6ddd904378265cb11f2d48075cda474f5f 100755 (executable)
@@ -4,6 +4,14 @@ test_description='.mailmap configurations'
 
 . ./test-lib.sh
 
+fuzz_blame () {
+       sed "
+               s/$_x05[0-9a-f][0-9a-f][0-9a-f]/OBJID/g
+               s/$_x05[0-9a-f][0-9a-f]/OBJI/g
+               s/[-0-9]\{10\} [:0-9]\{8\} [-+][0-9]\{4\}/DATE/g
+       " "$@"
+}
+
 test_expect_success setup '
        echo one >one &&
        git add one &&
@@ -11,6 +19,7 @@ test_expect_success setup '
        git commit -m initial &&
        echo two >>one &&
        git add one &&
+       test_tick &&
        git commit --author "nick1 <bugs@company.xx>" -m second
 '
 
@@ -54,7 +63,7 @@ Repo Guy (1):
 
 EOF
 test_expect_success 'mailmap.file set' '
-       mkdir internal_mailmap &&
+       mkdir -p internal_mailmap &&
        echo "Internal Guy <bugs@company.xx>" > internal_mailmap/.mailmap &&
        git config mailmap.file internal_mailmap/.mailmap &&
        git shortlog HEAD >actual &&
@@ -92,6 +101,40 @@ test_expect_success 'mailmap.file non-existant' '
        test_cmp expect actual
 '
 
+cat >expect <<\EOF
+Internal Guy (1):
+      second
+
+Repo Guy (1):
+      initial
+
+EOF
+
+test_expect_success 'name entry after email entry' '
+       mkdir -p internal_mailmap &&
+       echo "<bugs@company.xy> <bugs@company.xx>" >internal_mailmap/.mailmap &&
+       echo "Internal Guy <bugs@company.xx>" >>internal_mailmap/.mailmap &&
+       git shortlog HEAD >actual &&
+       test_cmp expect actual
+'
+
+cat >expect <<\EOF
+Internal Guy (1):
+      second
+
+Repo Guy (1):
+      initial
+
+EOF
+
+test_expect_success 'name entry after email entry, case-insensitive' '
+       mkdir -p internal_mailmap &&
+       echo "<bugs@company.xy> <bugs@company.xx>" >internal_mailmap/.mailmap &&
+       echo "Internal Guy <BUGS@Company.xx>" >>internal_mailmap/.mailmap &&
+       git shortlog HEAD >actual &&
+       test_cmp expect actual
+'
+
 cat >expect <<\EOF
 A U Thor (1):
       initial
@@ -101,7 +144,7 @@ nick1 (1):
 
 EOF
 test_expect_success 'No mailmap files, but configured' '
-       rm .mailmap &&
+       rm -f .mailmap internal_mailmap/.mailmap &&
        git shortlog HEAD >actual &&
        test_cmp expect actual
 '
@@ -153,7 +196,7 @@ test_expect_success 'Shortlog output (complex mapping)' '
        test_tick &&
        git commit --author "CTO <cto@coompany.xx>" -m seventh &&
 
-       mkdir internal_mailmap &&
+       mkdir -p internal_mailmap &&
        echo "Committed <committer@example.com>" > internal_mailmap/.mailmap &&
        echo "<cto@company.xx>                       <cto@coompany.xx>" >> internal_mailmap/.mailmap &&
        echo "Some Dude <some@dude.xx>         nick1 <bugs@company.xx>" >> internal_mailmap/.mailmap &&
@@ -198,18 +241,18 @@ test_expect_success 'Log output (complex mapping)' '
 
 # git blame
 cat >expect <<\EOF
-^3a2fdcb (A U Thor     2005-04-07 15:13:13 -0700 1) one
-7de6f99b (Some Dude    2005-04-07 15:13:13 -0700 2) two
-5815879d (Other Author 2005-04-07 15:14:13 -0700 3) three
-ff859d96 (Other Author 2005-04-07 15:15:13 -0700 4) four
-5ab6d4fa (Santa Claus  2005-04-07 15:16:13 -0700 5) five
-38a42d8b (Santa Claus  2005-04-07 15:17:13 -0700 6) six
-8ddc0386 (CTO          2005-04-07 15:18:13 -0700 7) seven
+^OBJI (A U Thor     DATE 1) one
+OBJID (Some Dude    DATE 2) two
+OBJID (Other Author DATE 3) three
+OBJID (Other Author DATE 4) four
+OBJID (Santa Claus  DATE 5) five
+OBJID (Santa Claus  DATE 6) six
+OBJID (CTO          DATE 7) seven
 EOF
-
 test_expect_success 'Blame output (complex mapping)' '
        git blame one >actual &&
-       test_cmp expect actual
+       fuzz_blame actual >actual.fuzz &&
+       test_cmp expect actual.fuzz
 '
 
 test_done
index fd19121372aecc0806e17e62d639855f391045d3..26d355725f5e8d317c71cb466ea091ec8f741d63 100755 (executable)
@@ -101,5 +101,13 @@ test_expect_success 'used upload-pack service' '
        test_cmp exp act
 '
 
+test_expect_success 'follow redirects (301)' '
+       git clone $HTTPD_URL/smart-redir-perm/repo.git --quiet repo-p
+'
+
+test_expect_success 'follow redirects (302)' '
+       git clone $HTTPD_URL/smart-redir-temp/repo.git --quiet repo-t
+'
+
 stop_httpd
 test_done
index cccacd4add48524abd4a3021f8048a6c45c245ea..d918cc02d090157485d404d34d49005e50cd9f1a 100755 (executable)
@@ -162,6 +162,14 @@ commit 131a310eb913d107dd3c09a65d1651175898735d
 commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873
 EOF
 
+test_expect_success '%x00 shows NUL' '
+       echo  >expect commit f58db70b055c5718631e5c61528b28b12090cdea &&
+       echo >>expect fooQbar &&
+       git rev-list -1 --format=foo%x00bar HEAD >actual.nul &&
+       nul_to_q <actual.nul >actual &&
+       test_cmp expect actual
+'
+
 test_expect_success '%ad respects --date=' '
        echo 2005-04-07 >expect.ad-short &&
        git log -1 --date=short --pretty=tformat:%ad >output.ad-short master &&
index d486d73994cf563063b578ec5e212331e87bf67f..d9f343942c7eb9d1e80e98db2252cb29135544fa 100755 (executable)
@@ -64,6 +64,14 @@ cp new1.txt test.txt
 test_expect_success "merge without conflict" \
        "git merge-file test.txt orig.txt new2.txt"
 
+test_expect_success 'works in subdirectory' '
+       mkdir dir &&
+       cp new1.txt dir/a.txt &&
+       cp orig.txt dir/o.txt &&
+       cp new2.txt dir/b.txt &&
+       ( cd dir && git merge-file a.txt o.txt b.txt )
+'
+
 cp new1.txt test.txt
 test_expect_success "merge without conflict (--quiet)" \
        "git merge-file --quiet test.txt orig.txt new2.txt"
index 73ff80937195f3ee8d4bf647a6c06bef23bb8891..6b5f22ae4a3ca96a22fa0a7d77bac1b59e747b00 100755 (executable)
@@ -1,4 +1,5 @@
 #!/usr/bin/perl
+use 5.008;
 use strict;
 use warnings;
 use IO::Pty;
index 02522f9627eea8166b2d4709ef3519b23c8dd3d5..e5b19538b0192e5ab5f9081b0c10ac0dc8497cb6 100755 (executable)
@@ -23,7 +23,9 @@ test_expect_success setup '
         git commit -m "submodule"
        ) &&
        git clone super super-clone &&
-       (cd super-clone && git submodule update --init)
+       (cd super-clone && git submodule update --init) &&
+       git clone super empty-clone &&
+       (cd empty-clone && git submodule init)
 '
 
 test_expect_success 'change submodule' '
@@ -64,4 +66,12 @@ test_expect_success '"git submodule sync" should update submodule URLs' '
        )
 '
 
+test_expect_success '"git submodule sync" should update submodule URLs if not yet cloned' '
+       (cd empty-clone &&
+        git pull &&
+        git submodule sync &&
+        test -d "$(git config submodule.submodule.url)"
+       )
+'
+
 test_done
index d82349a6a8d6c12c3ca4398a18bd6c1dd42efdc9..3988900fc33f0f5f9cdd416096df619aec2d577e 100755 (executable)
@@ -84,4 +84,20 @@ test_expect_success 'will not overwrite removed file with staged changes' '
        test_cmp important c1.c
 '
 
+cat >expect <<\EOF
+error: Untracked working tree file 'c0.c' would be overwritten by merge.
+fatal: read-tree failed
+EOF
+
+test_expect_success 'will not overwrite untracked file on unborn branch' '
+       git reset --hard c0 &&
+       git rm -fr . &&
+       git checkout --orphan new &&
+       cp important c0.c &&
+       test_must_fail git merge c0 2>out &&
+       test_cmp out expect &&
+       test_path_is_missing .git/MERGE_HEAD &&
+       test_cmp important c0.c
+'
+
 test_done
index 9ad96d4d32390081ba97c336d80b2294cf69dc44..dbf623bce5598860800fa463c26ec8145d6e2400 100755 (executable)
@@ -9,22 +9,29 @@ find_blame() {
 
 cat >helper <<'EOF'
 #!/bin/sh
-sed 's/^/converted: /' "$@"
+grep -q '^bin: ' "$1" || { echo "E: $1 is not \"binary\" file" 1>&2; exit 1; }
+sed 's/^bin: /converted: /' "$1"
 EOF
 chmod +x helper
 
 test_expect_success 'setup ' '
-       echo test 1 >one.bin &&
-       echo test number 2 >two.bin &&
+       echo "bin: test 1" >one.bin &&
+       echo "bin: test number 2" >two.bin &&
+       if test_have_prereq SYMLINKS; then
+               ln -s one.bin symlink.bin
+       fi &&
        git add . &&
        GIT_AUTHOR_NAME=Number1 git commit -a -m First --date="2010-01-01 18:00:00" &&
-       echo test 1 version 2 >one.bin &&
-       echo test number 2 version 2 >>two.bin &&
+       echo "bin: test 1 version 2" >one.bin &&
+       echo "bin: test number 2 version 2" >>two.bin &&
+       if test_have_prereq SYMLINKS; then
+               ln -sf two.bin symlink.bin
+       fi &&
        GIT_AUTHOR_NAME=Number2 git commit -a -m Second --date="2010-01-01 20:00:00"
 '
 
 cat >expected <<EOF
-(Number2 2010-01-01 20:00:00 +0000 1) test 1 version 2
+(Number2 2010-01-01 20:00:00 +0000 1) bin: test 1 version 2
 EOF
 
 test_expect_success 'no filter specified' '
@@ -67,7 +74,7 @@ test_expect_success 'blame --textconv going through revisions' '
 '
 
 test_expect_success 'make a new commit' '
-       echo "test number 2 version 3" >>two.bin &&
+       echo "bin: test number 2 version 3" >>two.bin &&
        GIT_AUTHOR_NAME=Number3 git commit -a -m Third --date="2010-01-01 22:00:00"
 '
 
@@ -77,4 +84,45 @@ test_expect_success 'blame from previous revision' '
        test_cmp expected result
 '
 
+cat >expected <<EOF
+(Number2 2010-01-01 20:00:00 +0000 1) two.bin
+EOF
+
+test_expect_success SYMLINKS 'blame with --no-textconv (on symlink)' '
+       git blame --no-textconv symlink.bin >blame &&
+       find_blame <blame >result &&
+       test_cmp expected result
+'
+
+test_expect_success SYMLINKS 'blame --textconv (on symlink)' '
+       git blame --textconv symlink.bin >blame &&
+       find_blame <blame >result &&
+       test_cmp expected result
+'
+
+# cp two.bin three.bin  and make small tweak
+# (this will direct blame -C -C three.bin to consider two.bin and symlink.bin)
+test_expect_success SYMLINKS 'make another new commit' '
+       cat >three.bin <<\EOF &&
+bin: test number 2
+bin: test number 2 version 2
+bin: test number 2 version 3
+bin: test number 3
+EOF
+       git add three.bin &&
+       GIT_AUTHOR_NAME=Number4 git commit -a -m Fourth --date="2010-01-01 23:00:00"
+'
+
+test_expect_success SYMLINKS 'blame on last commit (-C -C, symlink)' '
+       git blame -C -C three.bin >blame &&
+       find_blame <blame >result &&
+       cat >expected <<\EOF &&
+(Number1 2010-01-01 18:00:00 +0000 1) converted: test number 2
+(Number2 2010-01-01 20:00:00 +0000 2) converted: test number 2 version 2
+(Number3 2010-01-01 22:00:00 +0000 3) converted: test number 2 version 3
+(Number4 2010-01-01 23:00:00 +0000 4) converted: test number 3
+EOF
+       test_cmp expected result
+'
+
 test_done
index 38ac05e4a0b62e9105a400b4583d5504b42b3e7d..78a0085e648b8fa6773b47e86959853cf29ccdf9 100755 (executable)
@@ -5,15 +5,19 @@ test_description='git cat-file textconv support'
 
 cat >helper <<'EOF'
 #!/bin/sh
-sed 's/^/converted: /' "$@"
+grep -q '^bin: ' "$1" || { echo "E: $1 is not \"binary\" file" 1>&2; exit 1; }
+sed 's/^bin: /converted: /' "$1"
 EOF
 chmod +x helper
 
 test_expect_success 'setup ' '
-       echo test >one.bin &&
+       echo "bin: test" >one.bin &&
+       if test_have_prereq SYMLINKS; then
+               ln -s one.bin symlink.bin
+       fi &&
        git add . &&
        GIT_AUTHOR_NAME=Number1 git commit -a -m First --date="2010-01-01 18:00:00" &&
-       echo test version 2 >one.bin &&
+       echo "bin: test version 2" >one.bin &&
        GIT_AUTHOR_NAME=Number2 git commit -a -m Second --date="2010-01-01 20:00:00"
 '
 
@@ -33,7 +37,7 @@ test_expect_success 'setup textconv filters' '
 '
 
 cat >expected <<EOF
-test version 2
+bin: test version 2
 EOF
 
 test_expect_success 'cat-file without --textconv' '
@@ -42,7 +46,7 @@ test_expect_success 'cat-file without --textconv' '
 '
 
 cat >expected <<EOF
-test
+bin: test
 EOF
 
 test_expect_success 'cat-file without --textconv on previous commit' '
@@ -67,4 +71,28 @@ test_expect_success 'cat-file --textconv on previous commit' '
        git cat-file --textconv HEAD^:one.bin >result &&
        test_cmp expected result
 '
+
+test_expect_success SYMLINKS 'cat-file without --textconv (symlink)' '
+       git cat-file blob :symlink.bin >result &&
+       printf "%s" "one.bin" >expected
+       test_cmp expected result
+'
+
+
+test_expect_success SYMLINKS 'cat-file --textconv on index (symlink)' '
+       ! git cat-file --textconv :symlink.bin 2>result &&
+       cat >expected <<\EOF &&
+fatal: git cat-file --textconv: unable to run textconv on :symlink.bin
+EOF
+       test_cmp expected result
+'
+
+test_expect_success SYMLINKS 'cat-file --textconv on HEAD (symlink)' '
+       ! git cat-file --textconv HEAD:symlink.bin 2>result &&
+       cat >expected <<EOF &&
+fatal: git cat-file --textconv: unable to run textconv on HEAD:symlink.bin
+EOF
+       test_cmp expected result
+'
+
 test_done
index 07c50c764c5ed465b78d2e61ac0b0f9bf58efb64..a298eb04373f622473e3d33c9a46c6734f8a8fc8 100755 (executable)
@@ -1032,4 +1032,40 @@ test_expect_success $PREREQ '--8bit-encoding also treats subject' '
        test_cmp expected actual
 '
 
+# Note that the patches in this test are deliberately out of order; we
+# want to make sure it works even if the cover-letter is not in the
+# first mail.
+test_expect_success 'refusing to send cover letter template' '
+       clean_fake_sendmail &&
+       rm -fr outdir &&
+       git format-patch --cover-letter -2 -o outdir &&
+       test_must_fail git send-email \
+         --from="Example <nobody@example.com>" \
+         --to=nobody@example.com \
+         --smtp-server="$(pwd)/fake.sendmail" \
+         outdir/0002-*.patch \
+         outdir/0000-*.patch \
+         outdir/0001-*.patch \
+         2>errors >out &&
+       grep "SUBJECT HERE" errors &&
+       test -z "$(ls msgtxt*)"
+'
+
+test_expect_success '--force sends cover letter template anyway' '
+       clean_fake_sendmail &&
+       rm -fr outdir &&
+       git format-patch --cover-letter -2 -o outdir &&
+       git send-email \
+         --force \
+         --from="Example <nobody@example.com>" \
+         --to=nobody@example.com \
+         --smtp-server="$(pwd)/fake.sendmail" \
+         outdir/0002-*.patch \
+         outdir/0000-*.patch \
+         outdir/0001-*.patch \
+         2>errors >out &&
+       ! grep "SUBJECT HERE" errors &&
+       test -n "$(ls msgtxt*)"
+'
+
 test_done
index 671f38db2bb78c076b281602ca5b87f10fdf4d00..c15ca2d6479a814d7649a38a671a554b6ed8b68f 100755 (executable)
@@ -1,7 +1,7 @@
 #!/usr/bin/perl
 use lib (split(/:/, $ENV{GITPERLLIB}));
 
-use 5.006002;
+use 5.008;
 use warnings;
 use strict;
 
index 830e5e7360350a424a2fe6016a03c913209f7557..c6afebb00d02808f2a990347c8b0479d825cce5b 100644 (file)
@@ -238,14 +238,51 @@ test_set_editor () {
 }
 
 test_decode_color () {
-       sed     -e 's/.\[1m/<WHITE>/g' \
-               -e 's/.\[31m/<RED>/g' \
-               -e 's/.\[32m/<GREEN>/g' \
-               -e 's/.\[33m/<YELLOW>/g' \
-               -e 's/.\[34m/<BLUE>/g' \
-               -e 's/.\[35m/<MAGENTA>/g' \
-               -e 's/.\[36m/<CYAN>/g' \
-               -e 's/.\[m/<RESET>/g'
+       awk '
+               function name(n) {
+                       if (n == 0) return "RESET";
+                       if (n == 1) return "BOLD";
+                       if (n == 30) return "BLACK";
+                       if (n == 31) return "RED";
+                       if (n == 32) return "GREEN";
+                       if (n == 33) return "YELLOW";
+                       if (n == 34) return "BLUE";
+                       if (n == 35) return "MAGENTA";
+                       if (n == 36) return "CYAN";
+                       if (n == 37) return "WHITE";
+                       if (n == 40) return "BLACK";
+                       if (n == 41) return "BRED";
+                       if (n == 42) return "BGREEN";
+                       if (n == 43) return "BYELLOW";
+                       if (n == 44) return "BBLUE";
+                       if (n == 45) return "BMAGENTA";
+                       if (n == 46) return "BCYAN";
+                       if (n == 47) return "BWHITE";
+               }
+               {
+                       while (match($0, /\x1b\[[0-9;]*m/) != 0) {
+                               printf "%s<", substr($0, 1, RSTART-1);
+                               codes = substr($0, RSTART+2, RLENGTH-3);
+                               if (length(codes) == 0)
+                                       printf "%s", name(0)
+                               else {
+                                       n = split(codes, ary, ";");
+                                       sep = "";
+                                       for (i = 1; i <= n; i++) {
+                                               printf "%s%s", sep, name(ary[i]);
+                                               sep = ";"
+                                       }
+                               }
+                               printf ">";
+                               $0 = substr($0, RSTART + RLENGTH, length($0) - RSTART - RLENGTH + 1);
+                       }
+                       print
+               }
+       '
+}
+
+nul_to_q () {
+       perl -pe 'y/\000/Q/'
 }
 
 q_to_nul () {
index e5522159b362811346b4306246391e960a4e7041..f9e05b548c2fdbc349a1d47d81619e266ec9fb83 100644 (file)
@@ -9,7 +9,23 @@ static int drivers_alloc;
 
 #define PATTERNS(name, pattern, word_regex)                    \
        { name, NULL, -1, { pattern, REG_EXTENDED }, word_regex }
+#define IPATTERN(name, pattern, word_regex)                    \
+       { name, NULL, -1, { pattern, REG_EXTENDED | REG_ICASE }, word_regex }
 static struct userdiff_driver builtin_drivers[] = {
+IPATTERN("fortran",
+        "!^([C*]|[ \t]*!)\n"
+        "!^[ \t]*MODULE[ \t]+PROCEDURE[ \t]\n"
+        "^[ \t]*((END[ \t]+)?(PROGRAM|MODULE|BLOCK[ \t]+DATA"
+               "|([^'\" \t]+[ \t]+)*(SUBROUTINE|FUNCTION))[ \t]+[A-Z].*)$",
+        /* -- */
+        "[a-zA-Z][a-zA-Z0-9_]*"
+        "|\\.([Ee][Qq]|[Nn][Ee]|[Gg][TtEe]|[Ll][TtEe]|[Tt][Rr][Uu][Ee]|[Ff][Aa][Ll][Ss][Ee]|[Aa][Nn][Dd]|[Oo][Rr]|[Nn]?[Ee][Qq][Vv]|[Nn][Oo][Tt])\\."
+        /* numbers and format statements like 2E14.4, or ES12.6, 9X.
+         * Don't worry about format statements without leading digits since
+         * they would have been matched above as a variable anyway. */
+        "|[-+]?[0-9.]+([AaIiDdEeFfLlTtXx][Ss]?[-+]?[0-9.]*)?(_[a-zA-Z0-9][a-zA-Z0-9_]*)?"
+        "|//|\\*\\*|::|[/<>=]="
+        "|[^[:space:]]|[\x80-\xff]+"),
 PATTERNS("html", "^[ \t]*(<[Hh][1-6][ \t].*>.*)$",
         "[^<>= \t]+|[^[:space:]]|[\x80-\xff]+"),
 PATTERNS("java",
@@ -101,6 +117,7 @@ PATTERNS("csharp",
 { "default", NULL, -1, { NULL, 0 } },
 };
 #undef PATTERNS
+#undef IPATTERN
 
 static struct userdiff_driver driver_true = {
        "diff=true",
diff --git a/ws.c b/ws.c
index d7b8c33f14195ba7ebe86bdbca2fea8f1b22ad37..7302f8f5a2cd450771aefcba0a385a90121ba0cf 100644 (file)
--- a/ws.c
+++ b/ws.c
@@ -174,8 +174,11 @@ static unsigned ws_check_emit_1(const char *line, int len, unsigned ws_rule,
                }
        }
 
+       if (trailing_whitespace == -1)
+               trailing_whitespace = len;
+
        /* Check indentation */
-       for (i = 0; i < len; i++) {
+       for (i = 0; i < trailing_whitespace; i++) {
                if (line[i] == ' ')
                        continue;
                if (line[i] != '\t')
@@ -218,8 +221,6 @@ static unsigned ws_check_emit_1(const char *line, int len, unsigned ws_rule,
                 * Now the rest of the line starts at "written".
                 * The non-highlighted part ends at "trailing_whitespace".
                 */
-               if (trailing_whitespace == -1)
-                       trailing_whitespace = len;
 
                /* Emit non-highlighted (middle) segment. */
                if (trailing_whitespace - written > 0) {
index c4bedf0d1ce1252563d7f36da7d846f5943343b0..277e2eec5b4cced5882f37ac42af7f22efe92902 100644 (file)
@@ -85,27 +85,6 @@ static long def_ff(const char *rec, long len, char *buf, long sz, void *priv)
        return -1;
 }
 
-static void xdl_find_func(xdfile_t *xf, long i, char *buf, long sz, long *ll,
-               find_func_t ff, void *ff_priv) {
-
-       /*
-        * Be quite stupid about this for now.  Find a line in the old file
-        * before the start of the hunk (and context) which starts with a
-        * plausible character.
-        */
-
-       const char *rec;
-       long len;
-
-       while (i-- > 0) {
-               len = xdl_get_rec(xf, i, &rec);
-               if ((*ll = ff(rec, len, buf, sz, ff_priv)) >= 0)
-                       return;
-       }
-       *ll = 0;
-}
-
-
 static int xdl_emit_common(xdfenv_t *xe, xdchange_t *xscr, xdemitcb_t *ecb,
                            xdemitconf_t const *xecfg) {
        xdfile_t *xdf = &xe->xdf1;
@@ -127,6 +106,7 @@ int xdl_emit_diff(xdfenv_t *xe, xdchange_t *xscr, xdemitcb_t *ecb,
        xdchange_t *xch, *xche;
        char funcbuf[80];
        long funclen = 0;
+       long funclineprev = -1;
        find_func_t ff = xecfg->find_func ?  xecfg->find_func : def_ff;
 
        if (xecfg->flags & XDL_EMIT_COMMON)
@@ -150,9 +130,19 @@ int xdl_emit_diff(xdfenv_t *xe, xdchange_t *xscr, xdemitcb_t *ecb,
                 */
 
                if (xecfg->flags & XDL_EMIT_FUNCNAMES) {
-                       xdl_find_func(&xe->xdf1, s1, funcbuf,
-                                     sizeof(funcbuf), &funclen,
-                                     ff, xecfg->find_func_priv);
+                       long l;
+                       for (l = s1 - 1; l >= 0 && l > funclineprev; l--) {
+                               const char *rec;
+                               long reclen = xdl_get_rec(&xe->xdf1, l, &rec);
+                               long newfunclen = ff(rec, reclen, funcbuf,
+                                                    sizeof(funcbuf),
+                                                    xecfg->find_func_priv);
+                               if (newfunclen >= 0) {
+                                       funclen = newfunclen;
+                                       break;
+                               }
+                       }
+                       funclineprev = s1 - 1;
                }
                if (xdl_emit_hunk_hdr(s1 + 1, e1 - s1, s2 + 1, e2 - s2,
                                      funcbuf, funclen, ecb) < 0)