summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Documentation/RelNotes/1.8.5.6.txt34
-rw-r--r--Documentation/RelNotes/1.9.5.txt34
-rw-r--r--Documentation/RelNotes/2.0.5.txt34
-rw-r--r--Documentation/RelNotes/2.1.4.txt34
-rw-r--r--Documentation/RelNotes/2.2.0.txt126
-rw-r--r--Documentation/RelNotes/2.2.1.txt34
-rw-r--r--Documentation/RelNotes/2.3.0.txt74
-rw-r--r--Documentation/config.txt15
-rw-r--r--Documentation/git-notes.txt12
-rw-r--r--Documentation/git-push.txt2
-rw-r--r--Documentation/git.txt44
-rwxr-xr-xGIT-VERSION-GEN2
-rw-r--r--Makefile14
l---------RelNotes2
-rw-r--r--builtin/apply.c2
-rw-r--r--builtin/checkout.c18
-rw-r--r--builtin/commit.c28
-rw-r--r--builtin/config.c34
-rw-r--r--builtin/init-db.c3
-rw-r--r--builtin/merge.c22
-rw-r--r--builtin/notes.c258
-rw-r--r--builtin/push.c10
-rw-r--r--builtin/receive-pack.c2
-rw-r--r--builtin/repack.c47
-rw-r--r--cache.h3
-rw-r--r--commit.c46
-rw-r--r--commit.h3
-rw-r--r--compat/mingw.c2
-rw-r--r--config.c14
-rw-r--r--config.mak.uname3
-rw-r--r--connect.c15
-rw-r--r--csum-file.h11
-rw-r--r--environment.c10
-rw-r--r--fsck.c5
-rwxr-xr-xgit-difftool--helper.sh2
-rw-r--r--git-mergetool--lib.sh20
-rwxr-xr-xgit-mergetool.sh16
-rw-r--r--git.c27
-rwxr-xr-xgitweb/gitweb.perl6
-rw-r--r--mergetools/diffmerge1
-rw-r--r--mergetools/emerge1
-rw-r--r--mergetools/kdiff31
-rw-r--r--notes.c3
-rw-r--r--pack-bitmap-write.c8
-rw-r--r--pack-bitmap.c22
-rw-r--r--pack-bitmap.h6
-rw-r--r--path.c33
-rw-r--r--po/de.po18
-rw-r--r--read-cache.c10
-rw-r--r--refs.c10
-rw-r--r--sequencer.c34
-rw-r--r--sequencer.h1
-rwxr-xr-xt/t0001-init.sh7
-rwxr-xr-xt/t0090-cache-tree.sh2
-rwxr-xr-xt/t1014-read-tree-confusing.sh62
-rwxr-xr-xt/t1450-fsck.sh65
-rwxr-xr-xt/t2022-checkout-paths.sh17
-rwxr-xr-xt/t3301-notes.sh1341
-rwxr-xr-xt/t3507-cherry-pick-conflict.sh42
-rwxr-xr-xt/t4026-color.sh8
-rwxr-xr-xt/t5528-push-default.sh32
-rwxr-xr-xt/t7513-interpret-trailers.sh34
-rwxr-xr-xt/t9603-cvsimport-patchsets.sh2
-rwxr-xr-xt/t9604-cvsimport-timestamps.sh4
-rw-r--r--t/test-lib.sh6
-rw-r--r--trailer.c32
-rw-r--r--unpack-trees.c12
-rw-r--r--utf8.c64
-rw-r--r--utf8.h8
-rw-r--r--wt-status.c17
70 files changed, 1809 insertions, 1162 deletions
diff --git a/Documentation/RelNotes/1.8.5.6.txt b/Documentation/RelNotes/1.8.5.6.txt
new file mode 100644
index 0000000..92ff92b
--- /dev/null
+++ b/Documentation/RelNotes/1.8.5.6.txt
@@ -0,0 +1,34 @@
+Git v1.8.5.6 Release Notes
+==========================
+
+Fixes since v1.8.5.5
+--------------------
+
+ * We used to allow committing a path ".Git/config" with Git that is
+ running on a case sensitive filesystem, but an attempt to check out
+ such a path with Git that runs on a case insensitive filesystem
+ would have clobbered ".git/config", which is definitely not what
+ the user would have expected. Git now prevents you from tracking
+ a path with ".Git" (in any case combination) as a path component.
+
+ * On Windows, certain path components that are different from ".git"
+ are mapped to ".git", e.g. "git~1/config" is treated as if it were
+ ".git/config". HFS+ has a similar issue, where certain unicode
+ codepoints are ignored, e.g. ".g\u200cit/config" is treated as if
+ it were ".git/config". Pathnames with these potential issues are
+ rejected on the affected systems. Git on systems that are not
+ affected by this issue (e.g. Linux) can also be configured to
+ reject them to ensure cross platform interoperability of the hosted
+ projects.
+
+ * "git fsck" notices a tree object that records such a path that can
+ be confused with ".git", and with receive.fsckObjects configuration
+ set to true, an attempt to "git push" such a tree object will be
+ rejected. Such a path may not be a problem on a well behaving
+ filesystem but in order to protect those on HFS+ and on case
+ insensitive filesystems, this check is enabled on all platforms.
+
+A big "thanks!" for bringing this issue to us goes to our friends in
+the Mercurial land, namely, Matt Mackall and Augie Fackler.
+
+Also contains typofixes, documentation updates and trivial code clean-ups.
diff --git a/Documentation/RelNotes/1.9.5.txt b/Documentation/RelNotes/1.9.5.txt
new file mode 100644
index 0000000..8d6ac0c
--- /dev/null
+++ b/Documentation/RelNotes/1.9.5.txt
@@ -0,0 +1,34 @@
+Git v1.9.5 Release Notes
+========================
+
+Fixes since v1.9.4
+------------------
+
+ * We used to allow committing a path ".Git/config" with Git that is
+ running on a case sensitive filesystem, but an attempt to check out
+ such a path with Git that runs on a case insensitive filesystem
+ would have clobbered ".git/config", which is definitely not what
+ the user would have expected. Git now prevents you from tracking
+ a path with ".Git" (in any case combination) as a path component.
+
+ * On Windows, certain path components that are different from ".git"
+ are mapped to ".git", e.g. "git~1/config" is treated as if it were
+ ".git/config". HFS+ has a similar issue, where certain unicode
+ codepoints are ignored, e.g. ".g\u200cit/config" is treated as if
+ it were ".git/config". Pathnames with these potential issues are
+ rejected on the affected systems. Git on systems that are not
+ affected by this issue (e.g. Linux) can also be configured to
+ reject them to ensure cross platform interoperability of the hosted
+ projects.
+
+ * "git fsck" notices a tree object that records such a path that can
+ be confused with ".git", and with receive.fsckObjects configuration
+ set to true, an attempt to "git push" such a tree object will be
+ rejected. Such a path may not be a problem on a well behaving
+ filesystem but in order to protect those on HFS+ and on case
+ insensitive filesystems, this check is enabled on all platforms.
+
+A big "thanks!" for bringing this issue to us goes to our friends in
+the Mercurial land, namely, Matt Mackall and Augie Fackler.
+
+Also contains typofixes, documentation updates and trivial code clean-ups.
diff --git a/Documentation/RelNotes/2.0.5.txt b/Documentation/RelNotes/2.0.5.txt
new file mode 100644
index 0000000..3a16f69
--- /dev/null
+++ b/Documentation/RelNotes/2.0.5.txt
@@ -0,0 +1,34 @@
+Git v2.0.5 Release Notes
+========================
+
+Fixes since v2.0.4
+------------------
+
+ * We used to allow committing a path ".Git/config" with Git that is
+ running on a case sensitive filesystem, but an attempt to check out
+ such a path with Git that runs on a case insensitive filesystem
+ would have clobbered ".git/config", which is definitely not what
+ the user would have expected. Git now prevents you from tracking
+ a path with ".Git" (in any case combination) as a path component.
+
+ * On Windows, certain path components that are different from ".git"
+ are mapped to ".git", e.g. "git~1/config" is treated as if it were
+ ".git/config". HFS+ has a similar issue, where certain unicode
+ codepoints are ignored, e.g. ".g\u200cit/config" is treated as if
+ it were ".git/config". Pathnames with these potential issues are
+ rejected on the affected systems. Git on systems that are not
+ affected by this issue (e.g. Linux) can also be configured to
+ reject them to ensure cross platform interoperability of the hosted
+ projects.
+
+ * "git fsck" notices a tree object that records such a path that can
+ be confused with ".git", and with receive.fsckObjects configuration
+ set to true, an attempt to "git push" such a tree object will be
+ rejected. Such a path may not be a problem on a well behaving
+ filesystem but in order to protect those on HFS+ and on case
+ insensitive filesystems, this check is enabled on all platforms.
+
+A big "thanks!" for bringing this issue to us goes to our friends in
+the Mercurial land, namely, Matt Mackall and Augie Fackler.
+
+Also contains typofixes, documentation updates and trivial code clean-ups.
diff --git a/Documentation/RelNotes/2.1.4.txt b/Documentation/RelNotes/2.1.4.txt
new file mode 100644
index 0000000..d16e5f0
--- /dev/null
+++ b/Documentation/RelNotes/2.1.4.txt
@@ -0,0 +1,34 @@
+Git v2.1.4 Release Notes
+========================
+
+Fixes since v2.1.3
+------------------
+
+ * We used to allow committing a path ".Git/config" with Git that is
+ running on a case sensitive filesystem, but an attempt to check out
+ such a path with Git that runs on a case insensitive filesystem
+ would have clobbered ".git/config", which is definitely not what
+ the user would have expected. Git now prevents you from tracking
+ a path with ".Git" (in any case combination) as a path component.
+
+ * On Windows, certain path components that are different from ".git"
+ are mapped to ".git", e.g. "git~1/config" is treated as if it were
+ ".git/config". HFS+ has a similar issue, where certain unicode
+ codepoints are ignored, e.g. ".g\u200cit/config" is treated as if
+ it were ".git/config". Pathnames with these potential issues are
+ rejected on the affected systems. Git on systems that are not
+ affected by this issue (e.g. Linux) can also be configured to
+ reject them to ensure cross platform interoperability of the hosted
+ projects.
+
+ * "git fsck" notices a tree object that records such a path that can
+ be confused with ".git", and with receive.fsckObjects configuration
+ set to true, an attempt to "git push" such a tree object will be
+ rejected. Such a path may not be a problem on a well behaving
+ filesystem but in order to protect those on HFS+ and on case
+ insensitive filesystems, this check is enabled on all platforms.
+
+A big "thanks!" for bringing this issue to us goes to our friends in
+the Mercurial land, namely, Matt Mackall and Augie Fackler.
+
+Also contains typofixes, documentation updates and trivial code clean-ups.
diff --git a/Documentation/RelNotes/2.2.0.txt b/Documentation/RelNotes/2.2.0.txt
index d4001c5..e98ecbc 100644
--- a/Documentation/RelNotes/2.2.0.txt
+++ b/Documentation/RelNotes/2.2.0.txt
@@ -9,71 +9,72 @@ Ports
* Building on older MacOS X systems automatically sets
the necessary NO_APPLE_COMMON_CRYPTO build-time option.
- * The support to build with NO_PTHREADS has been resurrected.
+ * Building with NO_PTHREADS has been resurrected.
- * Compilation options has been updated a bit to support z/OS port
- better.
+ * Compilation options have been updated a bit to better support the
+ z/OS port.
UI, Workflows & Features
- * "git archive" learned to filter what gets archived with pathspec.
+ * "git archive" learned to filter what gets archived with a pathspec.
* "git config --edit --global" starts from a skeletal per-user
configuration file contents, instead of a total blank, when the
- user does not already have any. This immediately reduces the
- need for a later "Have you forgotten setting core.user?" and we
- can add more to the template as we gain more experience.
+ user does not already have any global config. This immediately
+ reduces the need to later ask "Have you forgotten to set
+ core.user?", and we can add more to the template as we gain
+ more experience.
* "git stash list -p" used to be almost always a no-op because each
stash entry is represented as a merge commit. It learned to show
the difference between the base commit version and the working tree
- version, which is in line with what "git show" gives.
+ version, which is in line with what "git stash show" gives.
* Sometimes users want to report a bug they experience on their
repository, but they are not at liberty to share the contents of
the repository. "fast-export" was taught an "--anonymize" option
- to replace blob contents, names of people and paths and log
+ to replace blob contents, names of people, paths and log
messages with bland and simple strings to help them.
* "git difftool" learned an option to stop feeding paths to the
diff backend when it exits with a non-zero status.
- * "git grep" allows to paint (or not paint) partial matches on
+ * "git grep" learned to paint (or not paint) partial matches on
context lines when showing "grep -C<num>" output in color.
- * "log --date=iso" uses a slight variant of ISO 8601 format that is
- made more human readable. A new "--date=iso-strict" option gives
- datetime output that is more strictly conformant.
+ * "log --date=iso" uses a slight variant of the ISO 8601 format that is
+ more human readable. A new "--date=iso-strict" option gives
+ datetime output that conforms more strictly.
* The logic "git prune" uses is more resilient against various corner
cases.
* A broken reimplementation of Git could write an invalid index that
- records both stage #0 and higher stage entries for the same path.
+ records both stage #0 and higher-stage entries for the same path.
We now notice and reject such an index, as there is no sensible
fallback (we do not know if the broken tool wanted to resolve and
- forgot to remove higher stage entries, or if it wanted to unresolve
- and forgot to remove the stage#0 entry).
+ forgot to remove the higher-stage entries, or if it wanted to unresolve
+ and forgot to remove the stage #0 entry).
- * The temporary files "git mergetool" uses are named to avoid too
+ * The temporary files "git mergetool" uses are renamed to avoid too
many dots in them (e.g. a temporary file for "hello.c" used to be
named e.g. "hello.BASE.4321.c" but now uses underscore instead,
- e.g. "hello_BASE_4321.c").
+ e.g. "hello_BASE_4321.c", to allow us to have multiple variants).
- * The temporary files "git mergetools" uses can be placed in a newly
+ * The temporary files "git mergetool" uses can be placed in a newly
created temporary directory, instead of the current directory, by
setting the mergetool.writeToTemp configuration variable.
* "git mergetool" understands "--tool bc" now, as version 4 of
BeyondCompare can be driven the same way as its version 3 and it
- feels awkward to say "--tool bc3".
+ feels awkward to say "--tool bc3" to run version 4.
* The "pre-receive" and "post-receive" hooks are no longer required
to consume their input fully (not following this requirement used
to result in intermittent errors in "git push").
- * The pretty-format specifier "%d", which expanded to " (tagname)"
+ * The pretty-format specifier "%d", which expands to " (tagname)"
for a tagged commit, gained a cousin "%D" that just gives the
"tagname" without frills.
@@ -86,17 +87,17 @@ UI, Workflows & Features
without having to "trust" the server.
* "git interpret-trailers" is a new filter to programmatically edit
- the tail end of the commit log messages.
+ the tail end of the commit log messages, e.g. "Signed-off-by:".
* "git help everyday" shows the "Everyday Git in 20 commands or so"
- document, whose contents have been updated to more modern Git
- practice.
+ document, whose contents have been updated to match more modern
+ Git practice.
- * On the "git svn" front, work to reduce memory consumption and
- to improve handling of mergeinfo progresses.
+ * On the "git svn" front, work progresses to reduce memory consumption and
+ to improve handling of mergeinfo.
-Performance, Internal Implementation, etc.
+Performance, Internal Implementation, Development Support etc.
* The API to manipulate the "refs" has been restructured to make it
more transactional, with the eventual goal to allow all-or-none
@@ -106,34 +107,34 @@ Performance, Internal Implementation, etc.
* The lockfile API and its users have been cleaned up.
* We no longer attempt to keep track of individual dependencies to
- the header files in the build procedure, relying on automated
+ the header files in the build procedure, relying instead on automated
dependency generation support from modern compilers.
* In tests, we have been using NOT_{MINGW,CYGWIN} test prerequisites
long before negated prerequisites e.g. !MINGW were invented.
The former has been converted to the latter to avoid confusion.
- * Looking up remotes configuration in a repository with very many
- remotes defined has been optimized.
+ * Optimized looking up a remote's configuration in a repository with very many
+ remotes defined.
* There are cases where you lock and open to write a file, close it
- to show the updated contents to external processes, and then have
- to update the file again while still holding the lock, but the
- lockfile API lacked support for such an access pattern.
+ to show the updated contents to an external processes, and then have
+ to update the file again while still holding the lock; now the
+ lockfile API has support for such an access pattern.
* The API to allocate the structure to keep track of commit
decoration has been updated to make it less cumbersome to use.
* An in-core caching layer to let us avoid reading the same
- configuration files number of times has been added. A few commands
+ configuration files several times has been added. A few commands
have been converted to use this subsystem.
* Various code paths have been cleaned up and simplified by using
- "strbuf", "starts_with()", and "skip_prefix()" APIs more.
+ the "strbuf", "starts_with()", and "skip_prefix()" APIs more.
* A few codepaths that died when large blobs that would not fit in
core are involved in their operation have been taught to punt
- instead, by e.g. marking too large a blob as not to be diffed.
+ instead, by e.g. marking a too-large blob as not to be diffed.
* A few more code paths in "commit" and "checkout" have been taught
to repopulate the cache-tree in the index, to help speed up later
@@ -141,7 +142,7 @@ Performance, Internal Implementation, etc.
"status").
* A common programming mistake to assign the same short option name
- to two separate options is detected by parse_options() API to help
+ to two separate options is detected by the parse_options() API to help
developers.
* The code path to write out the packed-refs file has been optimized,
@@ -153,7 +154,7 @@ Performance, Internal Implementation, etc.
especially matters in a repository with a large number of existing
refs.
- * "git fsck" was taught to check contents of tag objects a bit more.
+ * "git fsck" was taught to check the contents of tag objects a bit more.
* "git hash-object" was taught a "--literally" option to help
debugging.
@@ -162,16 +163,17 @@ Performance, Internal Implementation, etc.
original before feeding the filter. Instead, stream the file
contents directly to the filter and process its output.
- * The scripts in the test suite can be run with "-x" option to show
- a shell-trace of each command run in them.
+ * The scripts in the test suite can be run with the "-x" option to show
+ a shell-trace of each command they run.
* The "run-command" API learned to manage the argv and environment
- array for child process, alleviating the need for the callers to
+ arrays for child process, alleviating the need for the callers to
allocate and deallocate them.
* Some people use AsciiDoctor, instead of AsciiDoc, to format our
- documentation set; the documentation has been adjusted, as
- AsciiDoctor is pickier than AsciiDoc in its input mark-up.
+ documentation set; the documentation has been adjusted to be usable
+ by both, as AsciiDoctor is pickier than AsciiDoc about its input
+ mark-up.
Also contains various documentation updates and code clean-ups.
@@ -189,21 +191,21 @@ notes for details).
format", which was counterintuitive.
* "git -c section.var command" and "git -c section.var= command"
- should pass the configuration differently (the former should be a
+ should pass the configuration value differently (the former should be a
boolean true, the latter should be an empty string).
* Applying a patch not generated by Git in a subdirectory used to
- check the whitespace breakage using the attributes for incorrect
+ check for whitespace breakage using the attributes of incorrect
paths. Also whitespace checks were performed even for paths
- excluded via "git apply --exclude=<path>" mechanism.
+ excluded via the "git apply --exclude=<path>" mechanism.
- * "git bundle create" with date-range specification were meant to
+ * "git bundle create" with a date-range specification was meant to
exclude tags outside the range, but it didn't.
- * "git add x" where x that used to be a directory has become a
+ * "git add x" where x used to be a directory and is now a
symbolic link to a directory misbehaved.
- * The prompt script checked $GIT_DIR/ref/stash file to see if there
+ * The prompt script checked the $GIT_DIR/ref/stash file to see if there
is a stash, which was a no-no.
* Pack-protocol documentation had a minor typo.
@@ -217,7 +219,7 @@ notes for details).
(merge 107efbe rs/daemon-fixes later to maint).
* With sufficiently long refnames, "git fast-import" could have
- overflown an on-stack buffer.
+ overflowed an on-stack buffer.
* After "pack-refs --prune" packed refs at the top-level, it failed
to prune them.
@@ -232,8 +234,8 @@ notes for details).
to first check out <branch>.
(merge 95c6826 so/rebase-doc later to maint).
- * "git push" over HTTP transport had an artificial limit on number of
- refs that can be pushed imposed by the command line length.
+ * "git push" over HTTP transport had an artificial limit on the number of
+ refs that can be pushed, imposed by the command line length.
(merge 26be19b jk/send-pack-many-refspecs later to maint).
* When receiving an invalid pack stream that records the same object
@@ -248,19 +250,19 @@ notes for details).
detached HEAD as a starting point to traverse objects still in use.
(merge c40fdd0 mk/reachable-protect-detached-head later to maint).
- * "git config --add section.var val" used to lose existing
- section.var whose value was an empty string.
+ * "git config --add section.var val" when section.var already has an
+ empty-string value used to lose the empty-string value.
(merge c1063be ta/config-add-to-empty-or-true-fix later to maint).
* "git fsck" failed to report that it found corrupt objects via its
exit status in some cases.
(merge 30d1038 jk/fsck-exit-code-fix later to maint).
- * Use of "--verbose" option used to break "git branch --merged".
+ * Use of the "--verbose" option used to break "git branch --merged".
(merge 12994dd jk/maint-branch-verbose-merged later to maint).
- * Some MUAs mangled a line in a message that begins with "From " to
- ">From " when writing to a mailbox file and feeding such an input
+ * Some MUAs mangle a line in a message that begins with "From " to
+ ">From " when writing to a mailbox file, and feeding such an input
to "git am" used to lose such a line.
(merge 85de86a jk/mbox-from-line later to maint).
@@ -273,8 +275,8 @@ notes for details).
coding guidelines.
(merge 1c4b660 da/include-compat-util-first-in-c later to maint).
- * t7004 test, which tried to run Git with small stack space, has been
- updated to give a bit larger stack to avoid false breakage on some
+ * The t7004 test, which tried to run Git with small stack space, has been
+ updated to use a bit larger stack to avoid false breakage on some
platforms.
(merge b9a1907 sk/tag-contains-wo-recursion later to maint).
@@ -287,11 +289,11 @@ notes for details).
CGI.pm as of 4.04; use CGI::start_from instead.
(merge 4750f4b rm/gitweb-start-form later to maint).
- * Newer versions of 'meld' breaks the auto-detection we use to see if
+ * Newer versions of 'meld' break the auto-detection we use to see if
they are new enough to support the `--output` option.
(merge b12d045 da/mergetool-meld later to maint).
- * "git pack-objects" forgot to disable the codepath to generate
+ * "git pack-objects" forgot to disable the codepath to generate the
object reachability bitmap when it needs to split the resulting
pack.
(merge 2113471 jk/pack-objects-no-bitmap-when-splitting later to maint).
@@ -301,7 +303,7 @@ notes for details).
index file.
(merge 729dbbd jk/cache-tree-protect-from-broken-libgit2 later to maint).
- * "git fetch" into a repository where branch B was deleted earlier
+ * "git fetch" into a repository where branch B was deleted earlier,
back when it had reflog enabled, and then branch B/C is fetched
into it without reflog enabled, which is arguably an unlikely
corner case, unnecessarily failed.
diff --git a/Documentation/RelNotes/2.2.1.txt b/Documentation/RelNotes/2.2.1.txt
new file mode 100644
index 0000000..d5a3cd9
--- /dev/null
+++ b/Documentation/RelNotes/2.2.1.txt
@@ -0,0 +1,34 @@
+Git v2.2.1 Release Notes
+========================
+
+Fixes since v2.2
+----------------
+
+ * We used to allow committing a path ".Git/config" with Git that is
+ running on a case sensitive filesystem, but an attempt to check out
+ such a path with Git that runs on a case insensitive filesystem
+ would have clobbered ".git/config", which is definitely not what
+ the user would have expected. Git now prevents you from tracking
+ a path with ".Git" (in any case combination) as a path component.
+
+ * On Windows, certain path components that are different from ".git"
+ are mapped to ".git", e.g. "git~1/config" is treated as if it were
+ ".git/config". HFS+ has a similar issue, where certain unicode
+ codepoints are ignored, e.g. ".g\u200cit/config" is treated as if
+ it were ".git/config". Pathnames with these potential issues are
+ rejected on the affected systems. Git on systems that are not
+ affected by this issue (e.g. Linux) can also be configured to
+ reject them to ensure cross platform interoperability of the hosted
+ projects.
+
+ * "git fsck" notices a tree object that records such a path that can
+ be confused with ".git", and with receive.fsckObjects configuration
+ set to true, an attempt to "git push" such a tree object will be
+ rejected. Such a path may not be a problem on a well behaving
+ filesystem but in order to protect those on HFS+ and on case
+ insensitive filesystems, this check is enabled on all platforms.
+
+A big "thanks!" for bringing this issue to us goes to our friends in
+the Mercurial land, namely, Matt Mackall and Augie Fackler.
+
+Also contains typofixes, documentation updates and trivial code clean-ups.
diff --git a/Documentation/RelNotes/2.3.0.txt b/Documentation/RelNotes/2.3.0.txt
new file mode 100644
index 0000000..880c062
--- /dev/null
+++ b/Documentation/RelNotes/2.3.0.txt
@@ -0,0 +1,74 @@
+Git v2.3 Release Notes
+======================
+
+Updates since v2.2
+------------------
+
+Ports
+
+ *
+
+UI, Workflows & Features
+
+ * It was cumbersome to use "GIT_SSH" mechanism when the user wanted
+ to pass an extra set of arguments to the underlying ssh. A new
+ environment variable GIT_SSH_COMMAND can be used for this.
+
+ * A request to store an empty note via "git notes" meant to remove
+ note from the object but with --allow-empty we will store a
+ (surprise!) note that is empty.
+
+
+Performance, Internal Implementation, Development Support etc.
+
+ *
+
+
+Also contains various documentation updates and code clean-ups.
+
+
+Fixes since v2.2
+----------------
+
+Unless otherwise noted, all the fixes since v2.2 in the maintenance
+track are contained in this release (see the maintenance releases'
+notes for details).
+
+ * "git checkout $treeish $path", when $path in the index and the
+ working tree already matched what is in $treeish at the $path,
+ still overwrote the $path unnecessarily.
+ (merge c5326bd jk/checkout-from-tree later to maint).
+
+ * "git config --get-color" did not parse its command line arguments
+ carefully.
+ (merge cb35722 jk/colors-fix later to maint).
+
+ * open() emulated on Windows platforms did not give EISDIR upon
+ an attempt to open a directory for writing.
+ (merge ba6fad0 js/windows-open-eisdir-error later to maint).
+
+ * A few code paths used abs() when they should have used labs() on
+ long integers.
+ (merge 83915ba rs/maint-config-use-labs later to maint).
+ (merge 31a8aa1 rs/receive-pack-use-labs later to maint).
+
+ * "gitweb" used to depend on a behaviour recent CGI.pm deprecated.
+ (merge 13dbf46 jk/gitweb-with-newer-cgi-multi-param later to maint).
+
+ * "git init" (hence "git clone") initialized the per-repository
+ configuration file .git/config with x-bit by mistake.
+ (merge 1f32ecf mh/config-flip-xbit-back-after-checking later to maint).
+
+ * Git 2.0 was supposed to make the "simple" mode for the default of
+ "git push", but it didn't.
+ (merge 00a6fa0 jk/push-simple later to maint).
+
+ * "Everyday" document had a broken link.
+ (merge 366c8d4 po/everyday-doc later to maint).
+
+ * A few test fixes.
+ (merge 880ef58 jk/no-perl-tests later to maint).
+
+ * The build procedure did not bother fixing perl and python scripts
+ when NO_PERL and NO_PYTHON build-time configuration changed.
+ (merge ca2051d jk/rebuild-perl-scripts-with-no-perl-seting-change later to maint).
diff --git a/Documentation/config.txt b/Documentation/config.txt
index 9220725..9335ff2 100644
--- a/Documentation/config.txt
+++ b/Documentation/config.txt
@@ -246,6 +246,17 @@ core.precomposeunicode::
When false, file names are handled fully transparent by Git,
which is backward compatible with older versions of Git.
+core.protectHFS::
+ If set to true, do not allow checkout of paths that would
+ be considered equivalent to `.git` on an HFS+ filesystem.
+ Defaults to `true` on Mac OS, and `false` elsewhere.
+
+core.protectNTFS::
+ If set to true, do not allow checkout of paths that would
+ cause problems with the NTFS filesystem, e.g. conflict with
+ 8.3 "short" names.
+ Defaults to `true` on Windows, and `false` elsewhere.
+
core.trustctime::
If false, the ctime differences between the index and the
working tree are ignored; useful when the inode change time
@@ -839,6 +850,10 @@ accepted are `normal`, `black`, `red`, `green`, `yellow`, `blue`,
`blink` and `reverse`. The first color given is the foreground; the
second is the background. The position of the attribute, if any,
doesn't matter.
++
+Colors (foreground and background) may also be given as numbers between
+0 and 255; these use ANSI 256-color mode (but note that not all
+terminals may support this).
color.diff::
Whether to use ANSI escape sequences to add color to patches.
diff --git a/Documentation/git-notes.txt b/Documentation/git-notes.txt
index 310f0a5..851518d 100644
--- a/Documentation/git-notes.txt
+++ b/Documentation/git-notes.txt
@@ -9,10 +9,10 @@ SYNOPSIS
--------
[verse]
'git notes' [list [<object>]]
-'git notes' add [-f] [-F <file> | -m <msg> | (-c | -C) <object>] [<object>]
+'git notes' add [-f] [--allow-empty] [-F <file> | -m <msg> | (-c | -C) <object>] [<object>]
'git notes' copy [-f] ( --stdin | <from-object> <to-object> )
-'git notes' append [-F <file> | -m <msg> | (-c | -C) <object>] [<object>]
-'git notes' edit [<object>]
+'git notes' append [--allow-empty] [-F <file> | -m <msg> | (-c | -C) <object>] [<object>]
+'git notes' edit [--allow-empty] [<object>]
'git notes' show [<object>]
'git notes' merge [-v | -q] [-s <strategy> ] <notes-ref>
'git notes' merge --commit [-v | -q]
@@ -155,6 +155,10 @@ OPTIONS
Like '-C', but with '-c' the editor is invoked, so that
the user can further edit the note message.
+--allow-empty::
+ Allow an empty note object to be stored. The default behavior is
+ to automatically remove empty notes.
+
--ref <ref>::
Manipulate the notes tree in <ref>. This overrides
'GIT_NOTES_REF' and the "core.notesRef" configuration. The ref
@@ -287,7 +291,7 @@ arbitrary files using 'git hash-object':
------------
$ cc *.c
$ blob=$(git hash-object -w a.out)
-$ git notes --ref=built add -C "$blob" HEAD
+$ git notes --ref=built add --allow-empty -C "$blob" HEAD
------------
(You cannot simply use `git notes --ref=built add -F a.out HEAD`
diff --git a/Documentation/git-push.txt b/Documentation/git-push.txt
index 21b3f29..b17283a 100644
--- a/Documentation/git-push.txt
+++ b/Documentation/git-push.txt
@@ -34,7 +34,7 @@ When the command line does not specify what to push with `<refspec>...`
arguments or `--all`, `--mirror`, `--tags` options, the command finds
the default `<refspec>` by consulting `remote.*.push` configuration,
and if it is not found, honors `push.default` configuration to decide
-what to push (See gitlink:git-config[1] for the meaning of `push.default`).
+what to push (See linkgit:git-config[1] for the meaning of `push.default`).
OPTIONS[[OPTIONS]]
diff --git a/Documentation/git.txt b/Documentation/git.txt
index 9202010..73dc0ad 100644
--- a/Documentation/git.txt
+++ b/Documentation/git.txt
@@ -43,35 +43,45 @@ unreleased) version of Git, that is available from the 'master'
branch of the `git.git` repository.
Documentation for older releases are available here:
-* link:v2.1.3/git.html[documentation for release 2.1.3]
+* link:v2.2.1/git.html[documentation for release 2.2.1]
* release notes for
+ link:RelNotes/2.2.1.txt[2.2.1],
+ link:RelNotes/2.2.0.txt[2.2].
+
+* link:v2.1.4/git.html[documentation for release 2.1.4]
+
+* release notes for
+ link:RelNotes/2.1.4.txt[2.1.4],
link:RelNotes/2.1.3.txt[2.1.3],
link:RelNotes/2.1.2.txt[2.1.2],
link:RelNotes/2.1.1.txt[2.1.1],
link:RelNotes/2.1.0.txt[2.1].
-* link:v2.0.4/git.html[documentation for release 2.0.4]
+* link:v2.0.5/git.html[documentation for release 2.0.5]
* release notes for
+ link:RelNotes/2.0.5.txt[2.0.5],
link:RelNotes/2.0.4.txt[2.0.4],
link:RelNotes/2.0.3.txt[2.0.3],
link:RelNotes/2.0.2.txt[2.0.2],
link:RelNotes/2.0.1.txt[2.0.1],
link:RelNotes/2.0.0.txt[2.0.0].
-* link:v1.9.4/git.html[documentation for release 1.9.4]
+* link:v1.9.5/git.html[documentation for release 1.9.5]
* release notes for
+ link:RelNotes/1.9.5.txt[1.9.5],
link:RelNotes/1.9.4.txt[1.9.4],
link:RelNotes/1.9.3.txt[1.9.3],
link:RelNotes/1.9.2.txt[1.9.2],
link:RelNotes/1.9.1.txt[1.9.1],
link:RelNotes/1.9.0.txt[1.9.0].
-* link:v1.8.5.5/git.html[documentation for release 1.8.5.5]
+* link:v1.8.5.6/git.html[documentation for release 1.8.5.6]
* release notes for
+ link:RelNotes/1.8.5.6.txt[1.8.5.6],
link:RelNotes/1.8.5.5.txt[1.8.5.5],
link:RelNotes/1.8.5.4.txt[1.8.5.4],
link:RelNotes/1.8.5.3.txt[1.8.5.3],
@@ -876,19 +886,21 @@ other
and the `core.editor` option in linkgit:git-config[1].
'GIT_SSH'::
- If this environment variable is set then 'git fetch'
- and 'git push' will use this command instead
- of 'ssh' when they need to connect to a remote system.
- The '$GIT_SSH' command will be given exactly two or
- four arguments: the 'username@host' (or just 'host')
- from the URL and the shell command to execute on that
- remote system, optionally preceded by '-p' (literally) and
- the 'port' from the URL when it specifies something other
- than the default SSH port.
+'GIT_SSH_COMMAND'::
+ If either of these environment variables is set then 'git fetch'
+ and 'git push' will use the specified command instead of 'ssh'
+ when they need to connect to a remote system.
+ The command will be given exactly two or four arguments: the
+ 'username@host' (or just 'host') from the URL and the shell
+ command to execute on that remote system, optionally preceded by
+ '-p' (literally) and the 'port' from the URL when it specifies
+ something other than the default SSH port.
+
-To pass options to the program that you want to list in GIT_SSH
-you will need to wrap the program and options into a shell script,
-then set GIT_SSH to refer to the shell script.
+`$GIT_SSH_COMMAND` takes precedence over `$GIT_SSH`, and is interpreted
+by the shell, which allows additional arguments to be included.
+`$GIT_SSH` on the other hand must be just the path to a program
+(which can be a wrapper shell script, if additional arguments are
+needed).
+
Usually it is easier to configure any desired options through your
personal `.ssh/config` file. Please consult your ssh documentation
diff --git a/GIT-VERSION-GEN b/GIT-VERSION-GEN
index 27285f0..53dd6b3 100755
--- a/GIT-VERSION-GEN
+++ b/GIT-VERSION-GEN
@@ -1,7 +1,7 @@
#!/bin/sh
GVF=GIT-VERSION-FILE
-DEF_VER=v2.2.0-rc2
+DEF_VER=v2.2.0.GIT
LF='
'
diff --git a/Makefile b/Makefile
index 827006b..7482a4d 100644
--- a/Makefile
+++ b/Makefile
@@ -1662,7 +1662,7 @@ GIT-SCRIPT-DEFINES: FORCE
fi
-$(patsubst %.sh,%,$(SCRIPT_SH)) : % : %.sh GIT-SCRIPT-DEFINES
+$(SCRIPT_SH_GEN) : % : %.sh GIT-SCRIPT-DEFINES
$(QUIET_GEN)$(cmd_munge_script) && \
chmod +x $@+ && \
mv $@+ $@
@@ -1676,8 +1676,11 @@ git.res: git.rc GIT-VERSION-FILE
$(join -DMAJOR= -DMINOR=, $(wordlist 1,2,$(subst -, ,$(subst ., ,$(GIT_VERSION))))) \
-DGIT_VERSION="\\\"$(GIT_VERSION)\\\"" $< -o $@
+# This makes sure we depend on the NO_PERL setting itself.
+$(SCRIPT_PERL_GEN): GIT-BUILD-OPTIONS
+
ifndef NO_PERL
-$(patsubst %.perl,%,$(SCRIPT_PERL)): perl/perl.mak
+$(SCRIPT_PERL_GEN): perl/perl.mak
perl/perl.mak: perl/PM.stamp
@@ -1690,7 +1693,7 @@ perl/perl.mak: GIT-CFLAGS GIT-PREFIX perl/Makefile perl/Makefile.PL
$(QUIET_SUBDIR0)perl $(QUIET_SUBDIR1) PERL_PATH='$(PERL_PATH_SQ)' prefix='$(prefix_SQ)' $(@F)
PERL_DEFINES = $(PERL_PATH_SQ):$(PERLLIB_EXTRA_SQ)
-$(patsubst %.perl,%,$(SCRIPT_PERL)): % : %.perl perl/perl.mak GIT-PERL-DEFINES GIT-VERSION-FILE
+$(SCRIPT_PERL_GEN): % : %.perl perl/perl.mak GIT-PERL-DEFINES GIT-VERSION-FILE
$(QUIET_GEN)$(RM) $@ $@+ && \
INSTLIBDIR=`MAKEFLAGS= $(MAKE) -C perl -s --no-print-directory instlibdir` && \
INSTLIBDIR_EXTRA='$(PERLLIB_EXTRA_SQ)' && \
@@ -1724,7 +1727,7 @@ git-instaweb: git-instaweb.sh gitweb GIT-SCRIPT-DEFINES
chmod +x $@+ && \
mv $@+ $@
else # NO_PERL
-$(patsubst %.perl,%,$(SCRIPT_PERL)) git-instaweb: % : unimplemented.sh
+$(SCRIPT_PERL_GEN) git-instaweb: % : unimplemented.sh
$(QUIET_GEN)$(RM) $@ $@+ && \
sed -e '1s|#!.*/sh|#!$(SHELL_PATH_SQ)|' \
-e 's|@@REASON@@|NO_PERL=$(NO_PERL)|g' \
@@ -1733,6 +1736,9 @@ $(patsubst %.perl,%,$(SCRIPT_PERL)) git-instaweb: % : unimplemented.sh
mv $@+ $@
endif # NO_PERL
+# This makes sure we depend on the NO_PYTHON setting itself.
+$(SCRIPT_PYTHON_GEN): GIT-BUILD-OPTIONS
+
ifndef NO_PYTHON
$(SCRIPT_PYTHON_GEN): GIT-CFLAGS GIT-PREFIX GIT-PYTHON-VARS
$(SCRIPT_PYTHON_GEN): % : %.py
diff --git a/RelNotes b/RelNotes
index c473b35..9257c74 120000
--- a/RelNotes
+++ b/RelNotes
@@ -1 +1 @@
-Documentation/RelNotes/2.2.0.txt \ No newline at end of file
+Documentation/RelNotes/2.3.0.txt \ No newline at end of file
diff --git a/builtin/apply.c b/builtin/apply.c
index 6696ea4..28d24f8 100644
--- a/builtin/apply.c
+++ b/builtin/apply.c
@@ -3728,7 +3728,7 @@ static void build_fake_ancestor(struct patch *list, const char *filename)
if (!preimage_sha1_in_gitlink_patch(patch, sha1))
; /* ok, the textual part looks sane */
else
- die("sha1 information is lacking or useless for submoule %s",
+ die("sha1 information is lacking or useless for submodule %s",
name);
} else if (!get_sha1_blob(patch->old_sha1_prefix, sha1)) {
; /* ok */
diff --git a/builtin/checkout.c b/builtin/checkout.c
index 5410dac..5a78758 100644
--- a/builtin/checkout.c
+++ b/builtin/checkout.c
@@ -67,6 +67,7 @@ static int update_some(const unsigned char *sha1, const char *base, int baselen,
{
int len;
struct cache_entry *ce;
+ int pos;
if (S_ISDIR(mode))
return READ_TREE_RECURSIVE;
@@ -79,6 +80,23 @@ static int update_some(const unsigned char *sha1, const char *base, int baselen,
ce->ce_flags = create_ce_flags(0) | CE_UPDATE;
ce->ce_namelen = len;
ce->ce_mode = create_ce_mode(mode);
+
+ /*
+ * If the entry is the same as the current index, we can leave the old
+ * entry in place. Whether it is UPTODATE or not, checkout_entry will
+ * do the right thing.
+ */
+ pos = cache_name_pos(ce->name, ce->ce_namelen);
+ if (pos >= 0) {
+ struct cache_entry *old = active_cache[pos];
+ if (ce->ce_mode == old->ce_mode &&
+ !hashcmp(ce->sha1, old->sha1)) {
+ old->ce_flags |= CE_UPDATE;
+ free(ce);
+ return 0;
+ }
+ }
+
add_cache_entry(ce, ADD_CACHE_OK_TO_ADD | ADD_CACHE_OK_TO_REPLACE);
return 0;
}
diff --git a/builtin/commit.c b/builtin/commit.c
index e108c53..cda74e9 100644
--- a/builtin/commit.c
+++ b/builtin/commit.c
@@ -800,32 +800,8 @@ static int prepare_to_commit(const char *index_file, const char *prefix,
if (clean_message_contents)
stripspace(&sb, 0);
- if (signoff) {
- /*
- * See if we have a Conflicts: block at the end. If yes, count
- * its size, so we can ignore it.
- */
- int ignore_footer = 0;
- int i, eol, previous = 0;
- const char *nl;
-
- for (i = 0; i < sb.len; i++) {
- nl = memchr(sb.buf + i, '\n', sb.len - i);
- if (nl)
- eol = nl - sb.buf;
- else
- eol = sb.len;
- if (starts_with(sb.buf + previous, "\nConflicts:\n")) {
- ignore_footer = sb.len - previous;
- break;
- }
- while (i < eol)
- i++;
- previous = eol;
- }
-
- append_signoff(&sb, ignore_footer, 0);
- }
+ if (signoff)
+ append_signoff(&sb, ignore_non_trailer(&sb), 0);
if (fwrite(sb.buf, 1, sb.len, s->fp) < sb.len)
die_errno(_("could not write commit template"));
diff --git a/builtin/config.c b/builtin/config.c
index 8cc2604..15a7bea 100644
--- a/builtin/config.c
+++ b/builtin/config.c
@@ -69,8 +69,8 @@ static struct option builtin_config_options[] = {
OPT_BIT(0, "remove-section", &actions, N_("remove a section: name"), ACTION_REMOVE_SECTION),
OPT_BIT('l', "list", &actions, N_("list all"), ACTION_LIST),
OPT_BIT('e', "edit", &actions, N_("open an editor"), ACTION_EDIT),
- OPT_STRING(0, "get-color", &get_color_slot, N_("slot"), N_("find the color configured: [default]")),
- OPT_STRING(0, "get-colorbool", &get_colorbool_slot, N_("slot"), N_("find the color setting: [stdout-is-tty]")),
+ OPT_BIT(0, "get-color", &actions, N_("find the color configured: slot [default]"), ACTION_GET_COLOR),
+ OPT_BIT(0, "get-colorbool", &actions, N_("find the color setting: slot [stdout-is-tty]"), ACTION_GET_COLORBOOL),
OPT_GROUP(N_("Type")),
OPT_BIT(0, "bool", &types, N_("value is \"true\" or \"false\""), TYPE_BOOL),
OPT_BIT(0, "int", &types, N_("value is decimal number"), TYPE_INT),
@@ -303,8 +303,9 @@ static int git_get_color_config(const char *var, const char *value, void *cb)
return 0;
}
-static void get_color(const char *def_color)
+static void get_color(const char *var, const char *def_color)
{
+ get_color_slot = var;
get_color_found = 0;
parsed_color[0] = '\0';
git_config_with_options(git_get_color_config, NULL,
@@ -333,8 +334,9 @@ static int git_get_colorbool_config(const char *var, const char *value,
return 0;
}
-static int get_colorbool(int print)
+static int get_colorbool(const char *var, int print)
{
+ get_colorbool_slot = var;
get_colorbool_found = -1;
get_diff_color_found = -1;
get_color_ui_found = -1;
@@ -532,12 +534,7 @@ int cmd_config(int argc, const char **argv, const char *prefix)
usage_with_options(builtin_config_usage, builtin_config_options);
}
- if (get_color_slot)
- actions |= ACTION_GET_COLOR;
- if (get_colorbool_slot)
- actions |= ACTION_GET_COLORBOOL;
-
- if ((get_color_slot || get_colorbool_slot) && types) {
+ if ((actions & (ACTION_GET_COLOR|ACTION_GET_COLORBOOL)) && types) {
error("--get-color and variable type are incoherent");
usage_with_options(builtin_config_usage, builtin_config_options);
}
@@ -568,8 +565,8 @@ int cmd_config(int argc, const char **argv, const char *prefix)
}
}
else if (actions == ACTION_EDIT) {
- const char *config_file = given_config_source.file ?
- given_config_source.file : git_path("config");
+ char *config_file;
+
check_argc(argc, 0, 0);
if (!given_config_source.file && nongit)
die("not in a git directory");
@@ -578,6 +575,8 @@ int cmd_config(int argc, const char **argv, const char *prefix)
if (given_config_source.blob)
die("editing blobs is not supported");
git_config(git_default_config, NULL);
+ config_file = xstrdup(given_config_source.file ?
+ given_config_source.file : git_path("config"));
if (use_global_config) {
int fd = open(config_file, O_CREAT | O_EXCL | O_WRONLY, 0666);
if (fd) {
@@ -590,6 +589,7 @@ int cmd_config(int argc, const char **argv, const char *prefix)
die_errno(_("cannot create configuration file %s"), config_file);
}
launch_editor(config_file, NULL, NULL);
+ free(config_file);
}
else if (actions == ACTION_SET) {
int ret;
@@ -683,12 +683,14 @@ int cmd_config(int argc, const char **argv, const char *prefix)
die("No such section!");
}
else if (actions == ACTION_GET_COLOR) {
- get_color(argv[0]);
+ check_argc(argc, 1, 2);
+ get_color(argv[0], argv[1]);
}
else if (actions == ACTION_GET_COLORBOOL) {
- if (argc == 1)
- color_stdout_is_tty = git_config_bool("command line", argv[0]);
- return get_colorbool(argc != 0);
+ check_argc(argc, 1, 2);
+ if (argc == 2)
+ color_stdout_is_tty = git_config_bool("command line", argv[1]);
+ return get_colorbool(argv[0], argc == 2);
}
return 0;
diff --git a/builtin/init-db.c b/builtin/init-db.c
index 587a505..aab44d2 100644
--- a/builtin/init-db.c
+++ b/builtin/init-db.c
@@ -254,7 +254,8 @@ static int create_default_files(const char *template_path)
struct stat st2;
filemode = (!chmod(path, st1.st_mode ^ S_IXUSR) &&
!lstat(path, &st2) &&
- st1.st_mode != st2.st_mode);
+ st1.st_mode != st2.st_mode &&
+ !chmod(path, st1.st_mode));
}
git_config_set("core.filemode", filemode ? "true" : "false");
diff --git a/builtin/merge.c b/builtin/merge.c
index bebbe5b..215d485 100644
--- a/builtin/merge.c
+++ b/builtin/merge.c
@@ -29,6 +29,7 @@
#include "remote.h"
#include "fmt-merge-msg.h"
#include "gpg-interface.h"
+#include "sequencer.h"
#define DEFAULT_TWOHEAD (1<<0)
#define DEFAULT_OCTOPUS (1<<1)
@@ -880,28 +881,19 @@ static int finish_automerge(struct commit *head,
return 0;
}
-static int suggest_conflicts(int renormalizing)
+static int suggest_conflicts(void)
{
const char *filename;
FILE *fp;
- int pos;
+ struct strbuf msgbuf = STRBUF_INIT;
filename = git_path("MERGE_MSG");
fp = fopen(filename, "a");
if (!fp)
die_errno(_("Could not open '%s' for writing"), filename);
- fprintf(fp, "\nConflicts:\n");
- for (pos = 0; pos < active_nr; pos++) {
- const struct cache_entry *ce = active_cache[pos];
-
- if (ce_stage(ce)) {
- fprintf(fp, "\t%s\n", ce->name);
- while (pos + 1 < active_nr &&
- !strcmp(ce->name,
- active_cache[pos + 1]->name))
- pos++;
- }
- }
+
+ append_conflicts_hint(&msgbuf);
+ fputs(msgbuf.buf, fp);
fclose(fp);
rerere(allow_rerere_auto);
printf(_("Automatic merge failed; "
@@ -1550,7 +1542,7 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
fprintf(stderr, _("Automatic merge went well; "
"stopped before committing as requested\n"));
else
- ret = suggest_conflicts(option_renormalize);
+ ret = suggest_conflicts();
done:
free(branch_to_free);
diff --git a/builtin/notes.c b/builtin/notes.c
index 68b6cd8..a9f37d0 100644
--- a/builtin/notes.c
+++ b/builtin/notes.c
@@ -22,10 +22,10 @@
static const char * const git_notes_usage[] = {
N_("git notes [--ref <notes_ref>] [list [<object>]]"),
- N_("git notes [--ref <notes_ref>] add [-f] [-m <msg> | -F <file> | (-c | -C) <object>] [<object>]"),
+ N_("git notes [--ref <notes_ref>] add [-f] [--allow-empty] [-m <msg> | -F <file> | (-c | -C) <object>] [<object>]"),
N_("git notes [--ref <notes_ref>] copy [-f] <from-object> <to-object>"),
- N_("git notes [--ref <notes_ref>] append [-m <msg> | -F <file> | (-c | -C) <object>] [<object>]"),
- N_("git notes [--ref <notes_ref>] edit [<object>]"),
+ N_("git notes [--ref <notes_ref>] append [--allow-empty] [-m <msg> | -F <file> | (-c | -C) <object>] [<object>]"),
+ N_("git notes [--ref <notes_ref>] edit [--allow-empty] [<object>]"),
N_("git notes [--ref <notes_ref>] show [<object>]"),
N_("git notes [--ref <notes_ref>] merge [-v | -q] [-s <strategy> ] <notes_ref>"),
N_("git notes merge --commit [-v | -q]"),
@@ -92,12 +92,22 @@ static const char * const git_notes_get_ref_usage[] = {
static const char note_template[] =
"\nWrite/edit the notes for the following object:\n";
-struct msg_arg {
+struct note_data {
int given;
int use_editor;
+ char *edit_path;
struct strbuf buf;
};
+static void free_note_data(struct note_data *d)
+{
+ if (d->edit_path) {
+ unlink_or_warn(d->edit_path);
+ free(d->edit_path);
+ }
+ strbuf_release(&d->buf);
+}
+
static int list_each_note(const unsigned char *object_sha1,
const unsigned char *note_sha1, char *note_path,
void *cb_data)
@@ -106,7 +116,7 @@ static int list_each_note(const unsigned char *object_sha1,
return 0;
}
-static void write_note_data(int fd, const unsigned char *sha1)
+static void copy_obj_to_fd(int fd, const unsigned char *sha1)
{
unsigned long size;
enum object_type type;
@@ -149,26 +159,23 @@ static void write_commented_object(int fd, const unsigned char *object)
sha1_to_hex(object));
}
-static void create_note(const unsigned char *object, struct msg_arg *msg,
- int append_only, const unsigned char *prev,
- unsigned char *result)
+static void prepare_note_data(const unsigned char *object, struct note_data *d,
+ const unsigned char *old_note)
{
- char *path = NULL;
-
- if (msg->use_editor || !msg->given) {
+ if (d->use_editor || !d->given) {
int fd;
struct strbuf buf = STRBUF_INIT;
/* write the template message before editing: */
- path = git_pathdup("NOTES_EDITMSG");
- fd = open(path, O_CREAT | O_TRUNC | O_WRONLY, 0600);
+ d->edit_path = git_pathdup("NOTES_EDITMSG");
+ fd = open(d->edit_path, O_CREAT | O_TRUNC | O_WRONLY, 0600);
if (fd < 0)
- die_errno(_("could not create file '%s'"), path);
+ die_errno(_("could not create file '%s'"), d->edit_path);
- if (msg->given)
- write_or_die(fd, msg->buf.buf, msg->buf.len);
- else if (prev && !append_only)
- write_note_data(fd, prev);
+ if (d->given)
+ write_or_die(fd, d->buf.buf, d->buf.len);
+ else if (old_note)
+ copy_obj_to_fd(fd, old_note);
strbuf_addch(&buf, '\n');
strbuf_add_commented_lines(&buf, note_template, strlen(note_template));
@@ -179,94 +186,71 @@ static void create_note(const unsigned char *object, struct msg_arg *msg,
close(fd);
strbuf_release(&buf);
- strbuf_reset(&(msg->buf));
-
- if (launch_editor(path, &(msg->buf), NULL)) {
- die(_("Please supply the note contents using either -m" \
- " or -F option"));
- }
- stripspace(&(msg->buf), 1);
- }
-
- if (prev && append_only) {
- /* Append buf to previous note contents */
- unsigned long size;
- enum object_type type;
- char *prev_buf = read_sha1_file(prev, &type, &size);
+ strbuf_reset(&d->buf);
- strbuf_grow(&(msg->buf), size + 1);
- if (msg->buf.len && prev_buf && size)
- strbuf_insert(&(msg->buf), 0, "\n", 1);
- if (prev_buf && size)
- strbuf_insert(&(msg->buf), 0, prev_buf, size);
- free(prev_buf);
- }
-
- if (!msg->buf.len) {
- fprintf(stderr, _("Removing note for object %s\n"),
- sha1_to_hex(object));
- hashclr(result);
- } else {
- if (write_sha1_file(msg->buf.buf, msg->buf.len, blob_type, result)) {
- error(_("unable to write note object"));
- if (path)
- error(_("The note contents have been left in %s"),
- path);
- exit(128);
+ if (launch_editor(d->edit_path, &d->buf, NULL)) {
+ die(_("Please supply the note contents using either -m or -F option"));
}
+ stripspace(&d->buf, 1);
}
+}
- if (path) {
- unlink_or_warn(path);
- free(path);
+static void write_note_data(struct note_data *d, unsigned char *sha1)
+{
+ if (write_sha1_file(d->buf.buf, d->buf.len, blob_type, sha1)) {
+ error(_("unable to write note object"));
+ if (d->edit_path)
+ error(_("The note contents have been left in %s"),
+ d->edit_path);
+ exit(128);
}
}
static int parse_msg_arg(const struct option *opt, const char *arg, int unset)
{
- struct msg_arg *msg = opt->value;
+ struct note_data *d = opt->value;
- strbuf_grow(&(msg->buf), strlen(arg) + 2);
- if (msg->buf.len)
- strbuf_addch(&(msg->buf), '\n');
- strbuf_addstr(&(msg->buf), arg);
- stripspace(&(msg->buf), 0);
+ strbuf_grow(&d->buf, strlen(arg) + 2);
+ if (d->buf.len)
+ strbuf_addch(&d->buf, '\n');
+ strbuf_addstr(&d->buf, arg);
+ stripspace(&d->buf, 0);
- msg->given = 1;
+ d->given = 1;
return 0;
}
static int parse_file_arg(const struct option *opt, const char *arg, int unset)
{
- struct msg_arg *msg = opt->value;
+ struct note_data *d = opt->value;
- if (msg->buf.len)
- strbuf_addch(&(msg->buf), '\n');
+ if (d->buf.len)
+ strbuf_addch(&d->buf, '\n');
if (!strcmp(arg, "-")) {
- if (strbuf_read(&(msg->buf), 0, 1024) < 0)
+ if (strbuf_read(&d->buf, 0, 1024) < 0)
die_errno(_("cannot read '%s'"), arg);
- } else if (strbuf_read_file(&(msg->buf), arg, 1024) < 0)
+ } else if (strbuf_read_file(&d->buf, arg, 1024) < 0)
die_errno(_("could not open or read '%s'"), arg);
- stripspace(&(msg->buf), 0);
+ stripspace(&d->buf, 0);
- msg->given = 1;
+ d->given = 1;
return 0;
}
static int parse_reuse_arg(const struct option *opt, const char *arg, int unset)
{
- struct msg_arg *msg = opt->value;
+ struct note_data *d = opt->value;
char *buf;
unsigned char object[20];
enum object_type type;
unsigned long len;
- if (msg->buf.len)
- strbuf_addch(&(msg->buf), '\n');
+ if (d->buf.len)
+ strbuf_addch(&d->buf, '\n');
if (get_sha1(arg, object))
die(_("Failed to resolve '%s' as a valid ref."), arg);
- if (!(buf = read_sha1_file(object, &type, &len)) || !len) {
+ if (!(buf = read_sha1_file(object, &type, &len))) {
free(buf);
die(_("Failed to read object '%s'."), arg);
}
@@ -274,17 +258,17 @@ static int parse_reuse_arg(const struct option *opt, const char *arg, int unset)
free(buf);
die(_("Cannot read note data from non-blob object '%s'."), arg);
}
- strbuf_add(&(msg->buf), buf, len);
+ strbuf_add(&d->buf, buf, len);
free(buf);
- msg->given = 1;
+ d->given = 1;
return 0;
}
static int parse_reedit_arg(const struct option *opt, const char *arg, int unset)
{
- struct msg_arg *msg = opt->value;
- msg->use_editor = 1;
+ struct note_data *d = opt->value;
+ d->use_editor = 1;
return parse_reuse_arg(opt, arg, unset);
}
@@ -397,26 +381,27 @@ static int append_edit(int argc, const char **argv, const char *prefix);
static int add(int argc, const char **argv, const char *prefix)
{
- int retval = 0, force = 0;
+ int force = 0, allow_empty = 0;
const char *object_ref;
struct notes_tree *t;
unsigned char object[20], new_note[20];
- char logmsg[100];
const unsigned char *note;
- struct msg_arg msg = { 0, 0, STRBUF_INIT };
+ struct note_data d = { 0, 0, NULL, STRBUF_INIT };
struct option options[] = {
- { OPTION_CALLBACK, 'm', "message", &msg, N_("message"),
+ { OPTION_CALLBACK, 'm', "message", &d, N_("message"),
N_("note contents as a string"), PARSE_OPT_NONEG,
parse_msg_arg},
- { OPTION_CALLBACK, 'F', "file", &msg, N_("file"),
+ { OPTION_CALLBACK, 'F', "file", &d, N_("file"),
N_("note contents in a file"), PARSE_OPT_NONEG,
parse_file_arg},
- { OPTION_CALLBACK, 'c', "reedit-message", &msg, N_("object"),
+ { OPTION_CALLBACK, 'c', "reedit-message", &d, N_("object"),
N_("reuse and edit specified note object"), PARSE_OPT_NONEG,
parse_reedit_arg},
- { OPTION_CALLBACK, 'C', "reuse-message", &msg, N_("object"),
+ { OPTION_CALLBACK, 'C', "reuse-message", &d, N_("object"),
N_("reuse specified note object"), PARSE_OPT_NONEG,
parse_reuse_arg},
+ OPT_BOOL(0, "allow-empty", &allow_empty,
+ N_("allow storing empty note")),
OPT__FORCE(&force, N_("replace existing notes")),
OPT_END()
};
@@ -439,41 +424,44 @@ static int add(int argc, const char **argv, const char *prefix)
if (note) {
if (!force) {
- if (!msg.given) {
- /*
- * Redirect to "edit" subcommand.
- *
- * We only end up here if none of -m/-F/-c/-C
- * or -f are given. The original args are
- * therefore still in argv[0-1].
- */
- argv[0] = "edit";
- free_notes(t);
- return append_edit(argc, argv, prefix);
+ free_notes(t);
+ if (d.given) {
+ free_note_data(&d);
+ return error(_("Cannot add notes. "
+ "Found existing notes for object %s. "
+ "Use '-f' to overwrite existing notes"),
+ sha1_to_hex(object));
}
- retval = error(_("Cannot add notes. Found existing notes "
- "for object %s. Use '-f' to overwrite "
- "existing notes"), sha1_to_hex(object));
- goto out;
+ /*
+ * Redirect to "edit" subcommand.
+ *
+ * We only end up here if none of -m/-F/-c/-C or -f are
+ * given. The original args are therefore still in
+ * argv[0-1].
+ */
+ argv[0] = "edit";
+ return append_edit(argc, argv, prefix);
}
fprintf(stderr, _("Overwriting existing notes for object %s\n"),
sha1_to_hex(object));
}
- create_note(object, &msg, 0, note, new_note);
-
- if (is_null_sha1(new_note))
+ prepare_note_data(object, &d, note);
+ if (d.buf.len || allow_empty) {
+ write_note_data(&d, new_note);
+ if (add_note(t, object, new_note, combine_notes_overwrite))
+ die("BUG: combine_notes_overwrite failed");
+ commit_notes(t, "Notes added by 'git notes add'");
+ } else {
+ fprintf(stderr, _("Removing note for object %s\n"),
+ sha1_to_hex(object));
remove_note(t, object);
- else if (add_note(t, object, new_note, combine_notes_overwrite))
- die("BUG: combine_notes_overwrite failed");
+ commit_notes(t, "Notes removed by 'git notes add'");
+ }
- snprintf(logmsg, sizeof(logmsg), "Notes %s by 'git notes %s'",
- is_null_sha1(new_note) ? "removed" : "added", "add");
- commit_notes(t, logmsg);
-out:
+ free_note_data(&d);
free_notes(t);
- strbuf_release(&(msg.buf));
- return retval;
+ return 0;
}
static int copy(int argc, const char **argv, const char *prefix)
@@ -554,26 +542,29 @@ out:
static int append_edit(int argc, const char **argv, const char *prefix)
{
+ int allow_empty = 0;
const char *object_ref;
struct notes_tree *t;
unsigned char object[20], new_note[20];
const unsigned char *note;
char logmsg[100];
const char * const *usage;
- struct msg_arg msg = { 0, 0, STRBUF_INIT };
+ struct note_data d = { 0, 0, NULL, STRBUF_INIT };
struct option options[] = {
- { OPTION_CALLBACK, 'm', "message", &msg, N_("message"),
+ { OPTION_CALLBACK, 'm', "message", &d, N_("message"),
N_("note contents as a string"), PARSE_OPT_NONEG,
parse_msg_arg},
- { OPTION_CALLBACK, 'F', "file", &msg, N_("file"),
+ { OPTION_CALLBACK, 'F', "file", &d, N_("file"),
N_("note contents in a file"), PARSE_OPT_NONEG,
parse_file_arg},
- { OPTION_CALLBACK, 'c', "reedit-message", &msg, N_("object"),
+ { OPTION_CALLBACK, 'c', "reedit-message", &d, N_("object"),
N_("reuse and edit specified note object"), PARSE_OPT_NONEG,
parse_reedit_arg},
- { OPTION_CALLBACK, 'C', "reuse-message", &msg, N_("object"),
+ { OPTION_CALLBACK, 'C', "reuse-message", &d, N_("object"),
N_("reuse specified note object"), PARSE_OPT_NONEG,
parse_reuse_arg},
+ OPT_BOOL(0, "allow-empty", &allow_empty,
+ N_("allow storing empty note")),
OPT_END()
};
int edit = !strcmp(argv[0], "edit");
@@ -587,7 +578,7 @@ static int append_edit(int argc, const char **argv, const char *prefix)
usage_with_options(usage, options);
}
- if (msg.given && edit)
+ if (d.given && edit)
fprintf(stderr, _("The -m/-F/-c/-C options have been deprecated "
"for the 'edit' subcommand.\n"
"Please use 'git notes add -f -m/-F/-c/-C' instead.\n"));
@@ -600,18 +591,39 @@ static int append_edit(int argc, const char **argv, const char *prefix)
t = init_notes_check(argv[0]);
note = get_note(t, object);
- create_note(object, &msg, !edit, note, new_note);
+ prepare_note_data(object, &d, edit ? note : NULL);
- if (is_null_sha1(new_note))
- remove_note(t, object);
- else if (add_note(t, object, new_note, combine_notes_overwrite))
- die("BUG: combine_notes_overwrite failed");
+ if (note && !edit) {
+ /* Append buf to previous note contents */
+ unsigned long size;
+ enum object_type type;
+ char *prev_buf = read_sha1_file(note, &type, &size);
+
+ strbuf_grow(&d.buf, size + 1);
+ if (d.buf.len && prev_buf && size)
+ strbuf_insert(&d.buf, 0, "\n", 1);
+ if (prev_buf && size)
+ strbuf_insert(&d.buf, 0, prev_buf, size);
+ free(prev_buf);
+ }
- snprintf(logmsg, sizeof(logmsg), "Notes %s by 'git notes %s'",
- is_null_sha1(new_note) ? "removed" : "added", argv[0]);
+ if (d.buf.len || allow_empty) {
+ write_note_data(&d, new_note);
+ if (add_note(t, object, new_note, combine_notes_overwrite))
+ die("BUG: combine_notes_overwrite failed");
+ snprintf(logmsg, sizeof(logmsg), "Notes added by 'git notes %s'",
+ argv[0]);
+ } else {
+ fprintf(stderr, _("Removing note for object %s\n"),
+ sha1_to_hex(object));
+ remove_note(t, object);
+ snprintf(logmsg, sizeof(logmsg), "Notes removed by 'git notes %s'",
+ argv[0]);
+ }
commit_notes(t, logmsg);
+
+ free_note_data(&d);
free_notes(t);
- strbuf_release(&(msg.buf));
return 0;
}
diff --git a/builtin/push.c b/builtin/push.c
index a076b19..12f5e69 100644
--- a/builtin/push.c
+++ b/builtin/push.c
@@ -161,7 +161,7 @@ static const char message_detached_head_die[] =
" git push %s HEAD:<name-of-remote-branch>\n");
static void setup_push_upstream(struct remote *remote, struct branch *branch,
- int triangular)
+ int triangular, int simple)
{
struct strbuf refspec = STRBUF_INIT;
@@ -184,7 +184,7 @@ static void setup_push_upstream(struct remote *remote, struct branch *branch,
"to update which remote branch."),
remote->name, branch->name);
- if (push_default == PUSH_DEFAULT_SIMPLE) {
+ if (simple) {
/* Additional safety */
if (strcmp(branch->refname, branch->merge[0]->src))
die_push_simple(branch, remote);
@@ -257,11 +257,11 @@ static void setup_default_push_refspecs(struct remote *remote)
if (triangular)
setup_push_current(remote, branch);
else
- setup_push_upstream(remote, branch, triangular);
+ setup_push_upstream(remote, branch, triangular, 1);
break;
case PUSH_DEFAULT_UPSTREAM:
- setup_push_upstream(remote, branch, triangular);
+ setup_push_upstream(remote, branch, triangular, 0);
break;
case PUSH_DEFAULT_CURRENT:
@@ -503,7 +503,7 @@ int cmd_push(int argc, const char **argv, const char *prefix)
0, CAS_OPT_NAME, &cas, N_("refname>:<expect"),
N_("require old value of ref to be at this value"),
PARSE_OPT_OPTARG, parseopt_push_cas_option },
- { OPTION_CALLBACK, 0, "recurse-submodules", &flags, N_("check"),
+ { OPTION_CALLBACK, 0, "recurse-submodules", &flags, "check|on-demand",
N_("control recursive pushing of submodules"),
PARSE_OPT_OPTARG, option_parse_recurse_submodules },
OPT_BOOL( 0 , "thin", &thin, N_("use thin pack")),
diff --git a/builtin/receive-pack.c b/builtin/receive-pack.c
index 32fc540..e908d07 100644
--- a/builtin/receive-pack.c
+++ b/builtin/receive-pack.c
@@ -431,7 +431,7 @@ static const char *check_nonce(const char *buf, size_t len)
nonce_stamp_slop = (long)ostamp - (long)stamp;
if (nonce_stamp_slop_limit &&
- abs(nonce_stamp_slop) <= nonce_stamp_slop_limit) {
+ labs(nonce_stamp_slop) <= nonce_stamp_slop_limit) {
/*
* Pretend as if the received nonce (which passes the
* HMAC check, so it is not a forged by third-party)
diff --git a/builtin/repack.c b/builtin/repack.c
index 2845620..83e91c7 100644
--- a/builtin/repack.c
+++ b/builtin/repack.c
@@ -135,7 +135,6 @@ int cmd_repack(int argc, const char **argv, const char *prefix)
};
struct child_process cmd = CHILD_PROCESS_INIT;
struct string_list_item *item;
- struct argv_array cmd_args = ARGV_ARRAY_INIT;
struct string_list names = STRING_LIST_INIT_DUP;
struct string_list rollback = STRING_LIST_INIT_NODUP;
struct string_list existing_packs = STRING_LIST_INIT_DUP;
@@ -202,56 +201,55 @@ int cmd_repack(int argc, const char **argv, const char *prefix)
sigchain_push_common(remove_pack_on_signal);
- argv_array_push(&cmd_args, "pack-objects");
- argv_array_push(&cmd_args, "--keep-true-parents");
+ argv_array_push(&cmd.args, "pack-objects");
+ argv_array_push(&cmd.args, "--keep-true-parents");
if (!pack_kept_objects)
- argv_array_push(&cmd_args, "--honor-pack-keep");
- argv_array_push(&cmd_args, "--non-empty");
- argv_array_push(&cmd_args, "--all");
- argv_array_push(&cmd_args, "--reflog");
- argv_array_push(&cmd_args, "--indexed-objects");
+ argv_array_push(&cmd.args, "--honor-pack-keep");
+ argv_array_push(&cmd.args, "--non-empty");
+ argv_array_push(&cmd.args, "--all");
+ argv_array_push(&cmd.args, "--reflog");
+ argv_array_push(&cmd.args, "--indexed-objects");
if (window)
- argv_array_pushf(&cmd_args, "--window=%s", window);
+ argv_array_pushf(&cmd.args, "--window=%s", window);
if (window_memory)
- argv_array_pushf(&cmd_args, "--window-memory=%s", window_memory);
+ argv_array_pushf(&cmd.args, "--window-memory=%s", window_memory);
if (depth)
- argv_array_pushf(&cmd_args, "--depth=%s", depth);
+ argv_array_pushf(&cmd.args, "--depth=%s", depth);
if (max_pack_size)
- argv_array_pushf(&cmd_args, "--max-pack-size=%s", max_pack_size);
+ argv_array_pushf(&cmd.args, "--max-pack-size=%s", max_pack_size);
if (no_reuse_delta)
- argv_array_pushf(&cmd_args, "--no-reuse-delta");
+ argv_array_pushf(&cmd.args, "--no-reuse-delta");
if (no_reuse_object)
- argv_array_pushf(&cmd_args, "--no-reuse-object");
+ argv_array_pushf(&cmd.args, "--no-reuse-object");
if (write_bitmaps)
- argv_array_push(&cmd_args, "--write-bitmap-index");
+ argv_array_push(&cmd.args, "--write-bitmap-index");
if (pack_everything & ALL_INTO_ONE) {
get_non_kept_pack_filenames(&existing_packs);
if (existing_packs.nr && delete_redundant) {
if (unpack_unreachable)
- argv_array_pushf(&cmd_args,
+ argv_array_pushf(&cmd.args,
"--unpack-unreachable=%s",
unpack_unreachable);
else if (pack_everything & LOOSEN_UNREACHABLE)
- argv_array_push(&cmd_args,
+ argv_array_push(&cmd.args,
"--unpack-unreachable");
}
} else {
- argv_array_push(&cmd_args, "--unpacked");
- argv_array_push(&cmd_args, "--incremental");
+ argv_array_push(&cmd.args, "--unpacked");
+ argv_array_push(&cmd.args, "--incremental");
}
if (local)
- argv_array_push(&cmd_args, "--local");
+ argv_array_push(&cmd.args, "--local");
if (quiet)
- argv_array_push(&cmd_args, "--quiet");
+ argv_array_push(&cmd.args, "--quiet");
if (delta_base_offset)
- argv_array_push(&cmd_args, "--delta-base-offset");
+ argv_array_push(&cmd.args, "--delta-base-offset");
- argv_array_push(&cmd_args, packtmp);
+ argv_array_push(&cmd.args, packtmp);
- cmd.argv = cmd_args.argv;
cmd.git_cmd = 1;
cmd.out = -1;
cmd.no_stdin = 1;
@@ -270,7 +268,6 @@ int cmd_repack(int argc, const char **argv, const char *prefix)
ret = finish_command(&cmd);
if (ret)
return ret;
- argv_array_clear(&cmd_args);
if (!names.nr && !quiet)
printf("Nothing new to pack.\n");
diff --git a/cache.h b/cache.h
index 99ed096..22b7b81 100644
--- a/cache.h
+++ b/cache.h
@@ -617,6 +617,8 @@ extern int fsync_object_files;
extern int core_preload_index;
extern int core_apply_sparse_checkout;
extern int precomposed_unicode;
+extern int protect_hfs;
+extern int protect_ntfs;
/*
* The character that begins a commented line in user-editable file
@@ -831,6 +833,7 @@ int normalize_path_copy(char *dst, const char *src);
int longest_ancestor_length(const char *path, struct string_list *prefixes);
char *strip_path_suffix(const char *path, const char *suffix);
int daemon_avoid_alias(const char *path);
+extern int is_ntfs_dotgit(const char *name);
/* object replacement */
#define LOOKUP_REPLACE_OBJECT 1
diff --git a/commit.c b/commit.c
index 19cf8f9..a54cb9a 100644
--- a/commit.c
+++ b/commit.c
@@ -1640,3 +1640,49 @@ const char *find_commit_header(const char *msg, const char *key, size_t *out_len
}
return NULL;
}
+
+/*
+ * Inspect sb and determine the true "end" of the log message, in
+ * order to find where to put a new Signed-off-by: line. Ignored are
+ * trailing comment lines and blank lines, and also the traditional
+ * "Conflicts:" block that is not commented out, so that we can use
+ * "git commit -s --amend" on an existing commit that forgot to remove
+ * it.
+ *
+ * Returns the number of bytes from the tail to ignore, to be fed as
+ * the second parameter to append_signoff().
+ */
+int ignore_non_trailer(struct strbuf *sb)
+{
+ int boc = 0;
+ int bol = 0;
+ int in_old_conflicts_block = 0;
+
+ while (bol < sb->len) {
+ char *next_line;
+
+ if (!(next_line = memchr(sb->buf + bol, '\n', sb->len - bol)))
+ next_line = sb->buf + sb->len;
+ else
+ next_line++;
+
+ if (sb->buf[bol] == comment_line_char || sb->buf[bol] == '\n') {
+ /* is this the first of the run of comments? */
+ if (!boc)
+ boc = bol;
+ /* otherwise, it is just continuing */
+ } else if (starts_with(sb->buf + bol, "Conflicts:\n")) {
+ in_old_conflicts_block = 1;
+ if (!boc)
+ boc = bol;
+ } else if (in_old_conflicts_block && sb->buf[bol] == '\t') {
+ ; /* a pathname in the conflicts block */
+ } else if (boc) {
+ /* the previous was not trailing comment */
+ boc = 0;
+ in_old_conflicts_block = 0;
+ }
+ bol = next_line - sb->buf;
+ }
+ return boc ? sb->len - boc : 0;
+}
diff --git a/commit.h b/commit.h
index bc68ccb..cd35ac1 100644
--- a/commit.h
+++ b/commit.h
@@ -337,6 +337,9 @@ extern void free_commit_extra_headers(struct commit_extra_header *extra);
extern const char *find_commit_header(const char *msg, const char *key,
size_t *out_len);
+/* Find the end of the log message, the right place for a new trailer. */
+extern int ignore_non_trailer(struct strbuf *sb);
+
typedef void (*each_mergetag_fn)(struct commit *commit, struct commit_extra_header *extra,
void *cb_data);
diff --git a/compat/mingw.c b/compat/mingw.c
index c5c37e5..70f3191 100644
--- a/compat/mingw.c
+++ b/compat/mingw.c
@@ -312,7 +312,7 @@ int mingw_open (const char *filename, int oflags, ...)
return -1;
fd = _wopen(wfilename, oflags, mode);
- if (fd < 0 && (oflags & O_CREAT) && errno == EACCES) {
+ if (fd < 0 && (oflags & O_ACCMODE) != O_RDONLY && errno == EACCES) {
DWORD attrs = GetFileAttributesW(wfilename);
if (attrs != INVALID_FILE_ATTRIBUTES && (attrs & FILE_ATTRIBUTE_DIRECTORY))
errno = EISDIR;
diff --git a/config.c b/config.c
index 15a2983..752e2e2 100644
--- a/config.c
+++ b/config.c
@@ -506,9 +506,9 @@ static int git_parse_signed(const char *value, intmax_t *ret, intmax_t max)
errno = EINVAL;
return 0;
}
- uval = abs(val);
+ uval = labs(val);
uval *= factor;
- if (uval > max || abs(val) > uval) {
+ if (uval > max || labs(val) > uval) {
errno = ERANGE;
return 0;
}
@@ -896,6 +896,16 @@ static int git_default_core_config(const char *var, const char *value)
return 0;
}
+ if (!strcmp(var, "core.protecthfs")) {
+ protect_hfs = git_config_bool(var, value);
+ return 0;
+ }
+
+ if (!strcmp(var, "core.protectntfs")) {
+ protect_ntfs = git_config_bool(var, value);
+ return 0;
+ }
+
/* Add other config variables here and to Documentation/config.txt. */
return 0;
}
diff --git a/config.mak.uname b/config.mak.uname
index a2f380f..f3c93f2 100644
--- a/config.mak.uname
+++ b/config.mak.uname
@@ -105,6 +105,7 @@ ifeq ($(uname_S),Darwin)
HAVE_DEV_TTY = YesPlease
COMPAT_OBJS += compat/precompose_utf8.o
BASIC_CFLAGS += -DPRECOMPOSE_UNICODE
+ BASIC_CFLAGS += -DPROTECT_HFS_DEFAULT=1
endif
ifeq ($(uname_S),SunOS)
NEEDS_SOCKET = YesPlease
@@ -373,6 +374,7 @@ ifeq ($(uname_S),Windows)
EXTLIBS = user32.lib advapi32.lib shell32.lib wininet.lib ws2_32.lib invalidcontinue.obj
PTHREAD_LIBS =
lib =
+ BASIC_CFLAGS += -DPROTECT_NTFS_DEFAULT=1
ifndef DEBUG
BASIC_CFLAGS += -GL -Os -MD
BASIC_LDFLAGS += -LTCG
@@ -514,6 +516,7 @@ ifneq (,$(findstring MINGW,$(uname_S)))
COMPAT_OBJS += compat/mingw.o compat/winansi.o \
compat/win32/pthread.o compat/win32/syslog.o \
compat/win32/dirent.o
+ BASIC_CFLAGS += -DPROTECT_NTFS_DEFAULT=1
BASIC_LDFLAGS += -Wl,--large-address-aware
EXTLIBS += -lws2_32
GITLIBS += git.res
diff --git a/connect.c b/connect.c
index d47d0ec..cb23bbc 100644
--- a/connect.c
+++ b/connect.c
@@ -700,14 +700,23 @@ struct child_process *git_connect(int fd[2], const char *url,
conn->in = conn->out = -1;
if (protocol == PROTO_SSH) {
- const char *ssh = getenv("GIT_SSH");
- int putty = ssh && strcasestr(ssh, "plink");
+ const char *ssh;
+ int putty;
char *ssh_host = hostandport;
const char *port = NULL;
get_host_and_port(&ssh_host, &port);
port = get_port_numeric(port);
- if (!ssh) ssh = "ssh";
+ ssh = getenv("GIT_SSH_COMMAND");
+ if (ssh) {
+ conn->use_shell = 1;
+ putty = 0;
+ } else {
+ ssh = getenv("GIT_SSH");
+ if (!ssh)
+ ssh = "ssh";
+ putty = !!strcasestr(ssh, "plink");
+ }
argv_array_push(&conn->args, ssh);
if (putty && !strcasestr(ssh, "tortoiseplink"))
diff --git a/csum-file.h b/csum-file.h
index bb543d5..7530927 100644
--- a/csum-file.h
+++ b/csum-file.h
@@ -39,4 +39,15 @@ extern void sha1flush(struct sha1file *f);
extern void crc32_begin(struct sha1file *);
extern uint32_t crc32_end(struct sha1file *);
+static inline void sha1write_u8(struct sha1file *f, uint8_t data)
+{
+ sha1write(f, &data, sizeof(data));
+}
+
+static inline void sha1write_be32(struct sha1file *f, uint32_t data)
+{
+ data = htonl(data);
+ sha1write(f, &data, sizeof(data));
+}
+
#endif
diff --git a/environment.c b/environment.c
index 565f652..1ade5c9 100644
--- a/environment.c
+++ b/environment.c
@@ -64,6 +64,16 @@ int precomposed_unicode = -1; /* see probe_utf8_pathname_composition() */
struct startup_info *startup_info;
unsigned long pack_size_limit_cfg;
+#ifndef PROTECT_HFS_DEFAULT
+#define PROTECT_HFS_DEFAULT 0
+#endif
+int protect_hfs = PROTECT_HFS_DEFAULT;
+
+#ifndef PROTECT_NTFS_DEFAULT
+#define PROTECT_NTFS_DEFAULT 0
+#endif
+int protect_ntfs = PROTECT_NTFS_DEFAULT;
+
/*
* The character that begins a commented line in user-editable file
* that is subject to stripspace.
diff --git a/fsck.c b/fsck.c
index 2fffa43..0324194 100644
--- a/fsck.c
+++ b/fsck.c
@@ -7,6 +7,7 @@
#include "tag.h"
#include "fsck.h"
#include "refs.h"
+#include "utf8.h"
static int fsck_walk_tree(struct tree *tree, fsck_walk_func walk, void *data)
{
@@ -171,7 +172,9 @@ static int fsck_tree(struct tree *item, int strict, fsck_error error_func)
has_empty_name |= !*name;
has_dot |= !strcmp(name, ".");
has_dotdot |= !strcmp(name, "..");
- has_dotgit |= !strcmp(name, ".git");
+ has_dotgit |= (!strcmp(name, ".git") ||
+ is_hfs_dotgit(name) ||
+ is_ntfs_dotgit(name));
has_zero_pad |= *(char *)desc.buffer == '0';
update_tree_entry(&desc);
diff --git a/git-difftool--helper.sh b/git-difftool--helper.sh
index d4fb6df..2b11b1d 100755
--- a/git-difftool--helper.sh
+++ b/git-difftool--helper.sh
@@ -94,3 +94,5 @@ else
shift 7
done
fi
+
+exit 0
diff --git a/git-mergetool--lib.sh b/git-mergetool--lib.sh
index 2b66351..fe61e89 100644
--- a/git-mergetool--lib.sh
+++ b/git-mergetool--lib.sh
@@ -92,7 +92,7 @@ translate_merge_tool_path () {
check_unchanged () {
if test "$MERGED" -nt "$BACKUP"
then
- status=0
+ return 0
else
while true
do
@@ -100,8 +100,8 @@ check_unchanged () {
printf "Was the merge successful? [y/n] "
read answer || return 1
case "$answer" in
- y*|Y*) status=0; break ;;
- n*|N*) status=1; break ;;
+ y*|Y*) return 0 ;;
+ n*|N*) return 1 ;;
esac
done
fi
@@ -119,8 +119,6 @@ setup_user_tool () {
diff_cmd () {
( eval $merge_tool_cmd )
- status=$?
- return $status
}
merge_cmd () {
@@ -130,13 +128,10 @@ setup_user_tool () {
then
touch "$BACKUP"
( eval $merge_tool_cmd )
- status=$?
check_unchanged
else
( eval $merge_tool_cmd )
- status=$?
fi
- return $status
}
}
@@ -153,13 +148,11 @@ setup_tool () {
}
diff_cmd () {
- status=1
- return $status
+ return 1
}
merge_cmd () {
- status=1
- return $status
+ return 1
}
translate_merge_tool_path () {
@@ -210,7 +203,6 @@ run_merge_tool () {
merge_tool_path=$(get_merge_tool_path "$1") || exit
base_present="$2"
- status=0
# Bring tool-specific functions into scope
setup_tool "$1" || return 1
@@ -221,8 +213,6 @@ run_merge_tool () {
else
run_diff_cmd "$1"
fi
- status=$?
- return $status
}
# Run a either a configured or built-in diff tool
diff --git a/git-mergetool.sh b/git-mergetool.sh
index ff050e5..d20581c 100755
--- a/git-mergetool.sh
+++ b/git-mergetool.sh
@@ -426,8 +426,6 @@ fi
merge_keep_backup="$(git config --bool mergetool.keepBackup || echo true)"
merge_keep_temporaries="$(git config --bool mergetool.keepTemporaries || echo false)"
-last_status=0
-rollup_status=0
files=
if test $# -eq 0
@@ -455,19 +453,15 @@ printf "%s\n" "$files"
IFS='
'
+rc=0
for i in $files
do
- if test $last_status -ne 0
- then
- prompt_after_failed_merge || exit 1
- fi
printf "\n"
- merge_file "$i"
- last_status=$?
- if test $last_status -ne 0
+ if ! merge_file "$i"
then
- rollup_status=1
+ rc=1
+ prompt_after_failed_merge || exit 1
fi
done
-exit $rollup_status
+exit $rc
diff --git a/git.c b/git.c
index 18fbf79..82d7a1c 100644
--- a/git.c
+++ b/git.c
@@ -487,15 +487,20 @@ static struct cmd_struct commands[] = {
{ "write-tree", cmd_write_tree, RUN_SETUP },
};
-int is_builtin(const char *s)
+static struct cmd_struct *get_builtin(const char *s)
{
int i;
for (i = 0; i < ARRAY_SIZE(commands); i++) {
- struct cmd_struct *p = commands+i;
+ struct cmd_struct *p = commands + i;
if (!strcmp(s, p->cmd))
- return 1;
+ return p;
}
- return 0;
+ return NULL;
+}
+
+int is_builtin(const char *s)
+{
+ return !!get_builtin(s);
}
static void handle_builtin(int argc, const char **argv)
@@ -503,6 +508,7 @@ static void handle_builtin(int argc, const char **argv)
const char *cmd = argv[0];
int i;
static const char ext[] = STRIP_EXTENSION;
+ struct cmd_struct *builtin;
if (sizeof(ext) > 1) {
i = strlen(argv[0]) - strlen(ext);
@@ -519,15 +525,12 @@ static void handle_builtin(int argc, const char **argv)
argv[0] = cmd = "help";
}
- for (i = 0; i < ARRAY_SIZE(commands); i++) {
- struct cmd_struct *p = commands+i;
- if (strcmp(p->cmd, cmd))
- continue;
- if (saved_environment && (p->option & NO_SETUP)) {
+ builtin = get_builtin(cmd);
+ if (builtin) {
+ if (saved_environment && (builtin->option & NO_SETUP))
restore_env();
- break;
- }
- exit(run_builtin(p, argc, argv));
+ else
+ exit(run_builtin(builtin, argc, argv));
}
}
diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index ccf7516..7a5b23a 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -20,6 +20,10 @@ use File::Basename qw(basename);
use Time::HiRes qw(gettimeofday tv_interval);
binmode STDOUT, ':utf8';
+if (!defined($CGI::VERSION) || $CGI::VERSION < 4.08) {
+ eval 'sub CGI::multi_param { CGI::param(@_) }'
+}
+
our $t0 = [ gettimeofday() ];
our $number_of_git_cmds = 0;
@@ -871,7 +875,7 @@ sub evaluate_query_params {
while (my ($name, $symbol) = each %cgi_param_mapping) {
if ($symbol eq 'opt') {
- $input_params{$name} = [ map { decode_utf8($_) } $cgi->param($symbol) ];
+ $input_params{$name} = [ map { decode_utf8($_) } $cgi->multi_param($symbol) ];
} else {
$input_params{$name} = decode_utf8($cgi->param($symbol));
}
diff --git a/mergetools/diffmerge b/mergetools/diffmerge
index 85ac720..f138cb4 100644
--- a/mergetools/diffmerge
+++ b/mergetools/diffmerge
@@ -11,5 +11,4 @@ merge_cmd () {
"$merge_tool_path" --merge \
--result="$MERGED" "$LOCAL" "$REMOTE"
fi
- status=$?
}
diff --git a/mergetools/emerge b/mergetools/emerge
index f96d9e5..7b895fd 100644
--- a/mergetools/emerge
+++ b/mergetools/emerge
@@ -15,7 +15,6 @@ merge_cmd () {
"$LOCAL" "$REMOTE" \
"$(basename "$MERGED")"
fi
- status=$?
}
translate_merge_tool_path() {
diff --git a/mergetools/kdiff3 b/mergetools/kdiff3
index a30034f..793d129 100644
--- a/mergetools/kdiff3
+++ b/mergetools/kdiff3
@@ -20,5 +20,4 @@ merge_cmd () {
-o "$MERGED" "$LOCAL" "$REMOTE" \
>/dev/null 2>&1
fi
- status=$?
}
diff --git a/notes.c b/notes.c
index 5fe691d..62bc6e1 100644
--- a/notes.c
+++ b/notes.c
@@ -1218,8 +1218,7 @@ static void format_note(struct notes_tree *t, const unsigned char *object_sha1,
if (!sha1)
return;
- if (!(msg = read_sha1_file(sha1, &type, &msglen)) || !msglen ||
- type != OBJ_BLOB) {
+ if (!(msg = read_sha1_file(sha1, &type, &msglen)) || type != OBJ_BLOB) {
free(msg);
return;
}
diff --git a/pack-bitmap-write.c b/pack-bitmap-write.c
index 8029ae3..c05d138 100644
--- a/pack-bitmap-write.c
+++ b/pack-bitmap-write.c
@@ -472,7 +472,6 @@ static void write_selected_commits_v1(struct sha1file *f,
for (i = 0; i < writer.selected_nr; ++i) {
struct bitmapped_commit *stored = &writer.selected[i];
- struct bitmap_disk_entry on_disk;
int commit_pos =
sha1_pos(stored->commit->object.sha1, index, index_nr, sha1_access);
@@ -480,11 +479,10 @@ static void write_selected_commits_v1(struct sha1file *f,
if (commit_pos < 0)
die("BUG: trying to write commit not in index");
- on_disk.object_pos = htonl(commit_pos);
- on_disk.xor_offset = stored->xor_offset;
- on_disk.flags = stored->flags;
+ sha1write_be32(f, commit_pos);
+ sha1write_u8(f, stored->xor_offset);
+ sha1write_u8(f, stored->flags);
- sha1write(f, &on_disk, sizeof(on_disk));
dump_bitmap(f, stored->write_as);
}
}
diff --git a/pack-bitmap.c b/pack-bitmap.c
index a1f3c0d..6a81841 100644
--- a/pack-bitmap.c
+++ b/pack-bitmap.c
@@ -197,13 +197,24 @@ static struct stored_bitmap *store_bitmap(struct bitmap_index *index,
return stored;
}
+static inline uint32_t read_be32(const unsigned char *buffer, size_t *pos)
+{
+ uint32_t result = get_be32(buffer + *pos);
+ (*pos) += sizeof(result);
+ return result;
+}
+
+static inline uint8_t read_u8(const unsigned char *buffer, size_t *pos)
+{
+ return buffer[(*pos)++];
+}
+
static int load_bitmap_entries_v1(struct bitmap_index *index)
{
static const size_t MAX_XOR_OFFSET = 160;
uint32_t i;
struct stored_bitmap **recent_bitmaps;
- struct bitmap_disk_entry *entry;
recent_bitmaps = xcalloc(MAX_XOR_OFFSET, sizeof(struct stored_bitmap));
@@ -214,15 +225,12 @@ static int load_bitmap_entries_v1(struct bitmap_index *index)
uint32_t commit_idx_pos;
const unsigned char *sha1;
- entry = (struct bitmap_disk_entry *)(index->map + index->map_pos);
- index->map_pos += sizeof(struct bitmap_disk_entry);
+ commit_idx_pos = read_be32(index->map, &index->map_pos);
+ xor_offset = read_u8(index->map, &index->map_pos);
+ flags = read_u8(index->map, &index->map_pos);
- commit_idx_pos = ntohl(entry->object_pos);
sha1 = nth_packed_object_sha1(index->pack, commit_idx_pos);
- xor_offset = (int)entry->xor_offset;
- flags = (int)entry->flags;
-
bitmap = read_bitmap_1(index);
if (!bitmap)
return -1;
diff --git a/pack-bitmap.h b/pack-bitmap.h
index 8b7f4e9..487600b 100644
--- a/pack-bitmap.h
+++ b/pack-bitmap.h
@@ -5,12 +5,6 @@
#include "khash.h"
#include "pack-objects.h"
-struct bitmap_disk_entry {
- uint32_t object_pos;
- uint8_t xor_offset;
- uint8_t flags;
-} __attribute__((packed));
-
struct bitmap_disk_header {
char magic[4];
uint16_t version;
diff --git a/path.c b/path.c
index f68df0c..e608993 100644
--- a/path.c
+++ b/path.c
@@ -823,3 +823,36 @@ int daemon_avoid_alias(const char *p)
}
}
}
+
+static int only_spaces_and_periods(const char *path, size_t len, size_t skip)
+{
+ if (len < skip)
+ return 0;
+ len -= skip;
+ path += skip;
+ while (len-- > 0) {
+ char c = *(path++);
+ if (c != ' ' && c != '.')
+ return 0;
+ }
+ return 1;
+}
+
+int is_ntfs_dotgit(const char *name)
+{
+ int len;
+
+ for (len = 0; ; len++)
+ if (!name[len] || name[len] == '\\' || is_dir_sep(name[len])) {
+ if (only_spaces_and_periods(name, len, 4) &&
+ !strncasecmp(name, ".git", 4))
+ return 1;
+ if (only_spaces_and_periods(name, len, 5) &&
+ !strncasecmp(name, "git~1", 5))
+ return 1;
+ if (name[len] != '\\')
+ return 0;
+ name += len + 1;
+ len = -1;
+ }
+}
diff --git a/po/de.po b/po/de.po
index 56263b4..5a93ea8 100644
--- a/po/de.po
+++ b/po/de.po
@@ -644,11 +644,11 @@ msgstr "%s: %s - %s"
#: lockfile.c:275
msgid "BUG: reopen a lockfile that is still open"
-msgstr "FEHLER: Wiedereröffnen einer bereits geöffneten Lock-Datei"
+msgstr "FEHLER: Wiederöffnen einer bereits geöffneten Lock-Datei"
#: lockfile.c:277
msgid "BUG: reopen a lockfile that has been committed"
-msgstr "FEHLER: Wiedereröffnen einer bereits committeten Lock-Datei"
+msgstr "FEHLER: Wiederöffnen einer bereits committeten Lock-Datei"
#: merge.c:41
msgid "failed to read the cache"
@@ -1956,7 +1956,7 @@ msgstr "Unbeobachtete Dateien nicht aufgelistet%s"
#: wt-status.c:1370
msgid " (use -u option to show untracked files)"
-msgstr " (benutzen Sie die Option -u, um unbeobachteten Dateien anzuzeigen)"
+msgstr " (benutzen Sie die Option -u, um unbeobachtete Dateien anzuzeigen)"
#: wt-status.c:1376
msgid "No changes"
@@ -2810,7 +2810,7 @@ msgstr "Commits von <Datei> benutzen, anstatt \"git-rev-list\" aufzurufen"
#: builtin/blame.c:2518
msgid "Use <file>'s contents as the final image"
-msgstr "Inhalte der <Datei>en als entgültiges Abbild benutzen"
+msgstr "Inhalte der <Datei>en als endgültiges Abbild benutzen"
#: builtin/blame.c:2519 builtin/blame.c:2520
msgid "score"
@@ -3078,7 +3078,7 @@ msgstr "Informationen zum Upstream-Branch ändern"
#: builtin/branch.c:823
msgid "use colored output"
-msgstr "farbliche Ausgaben verwenden"
+msgstr "farbige Ausgaben verwenden"
#: builtin/branch.c:824
msgid "act on remote-tracking branches"
@@ -5585,7 +5585,7 @@ msgstr "Platzhalter als Python-String formatieren"
#: builtin/for-each-ref.c:1078
msgid "quote placeholders suitably for tcl"
-msgstr "Platzhalter als TCL-String formatieren"
+msgstr "Platzhalter als Tcl-String formatieren"
#: builtin/for-each-ref.c:1081
msgid "show only <n> matched refs"
@@ -6892,7 +6892,7 @@ msgstr ""
#: builtin/ls-files.c:462
msgid "show cached files in the output (default)"
-msgstr "zwischengespeicherten Dateien in der Ausgabe anzeigen (Standard)"
+msgstr "zwischengespeicherte Dateien in der Ausgabe anzeigen (Standard)"
#: builtin/ls-files.c:464
msgid "show deleted files in the output"
@@ -8119,7 +8119,7 @@ msgstr "Komprimierungsgrad für Paketierung"
#: builtin/pack-objects.c:2685
msgid "do not hide commits by grafts"
-msgstr "keine künstlichen Vorgänger-Commit (\"grafts\") verbergen"
+msgstr "keine künstlichen Vorgänger-Commits (\"grafts\") verbergen"
#: builtin/pack-objects.c:2687
msgid "use a bitmap index if available to speed up counting objects"
@@ -9695,7 +9695,7 @@ msgstr "Remote-Tracking-Branches anzeigen"
#: builtin/show-branch.c:653
msgid "color '*!+-' corresponding to the branch"
-msgstr "'*!+-' entsprechend des Branches einfärgen"
+msgstr "'*!+-' entsprechend des Branches einfärben"
#: builtin/show-branch.c:655
msgid "show <n> more commits after the common ancestor"
diff --git a/read-cache.c b/read-cache.c
index 8f3e9eb..9cff715 100644
--- a/read-cache.c
+++ b/read-cache.c
@@ -17,6 +17,7 @@
#include "varint.h"
#include "split-index.h"
#include "sigchain.h"
+#include "utf8.h"
static struct cache_entry *refresh_cache_entry(struct cache_entry *ce,
unsigned int options);
@@ -776,9 +777,10 @@ static int verify_dotfile(const char *rest)
* shares the path end test with the ".." case.
*/
case 'g':
- if (rest[1] != 'i')
+ case 'G':
+ if (rest[1] != 'i' && rest[1] != 'I')
break;
- if (rest[2] != 't')
+ if (rest[2] != 't' && rest[2] != 'T')
break;
rest += 2;
/* fallthrough */
@@ -802,6 +804,10 @@ int verify_path(const char *path)
return 1;
if (is_dir_sep(c)) {
inside:
+ if (protect_hfs && is_hfs_dotgit(path))
+ return 0;
+ if (protect_ntfs && is_ntfs_dotgit(path))
+ return 0;
c = *path++;
if ((c == '.' && !verify_dotfile(path)) ||
is_dir_sep(c) || c == '\0')
diff --git a/refs.c b/refs.c
index 5ff457e..0347328 100644
--- a/refs.c
+++ b/refs.c
@@ -2318,6 +2318,7 @@ static struct ref_lock *lock_ref_sha1_basic(const char *refname,
lock->lock_fd = hold_lock_file_for_update(lock->lk, ref_file, lflags);
if (lock->lock_fd < 0) {
+ last_errno = errno;
if (errno == ENOENT && --attempts_remaining > 0)
/*
* Maybe somebody just deleted one of the
@@ -2325,8 +2326,13 @@ static struct ref_lock *lock_ref_sha1_basic(const char *refname,
* again:
*/
goto retry;
- else
- unable_to_lock_die(ref_file, errno);
+ else {
+ struct strbuf err = STRBUF_INIT;
+ unable_to_lock_message(ref_file, errno, &err);
+ error("%s", err.buf);
+ strbuf_reset(&err);
+ goto error_return;
+ }
}
return old_sha1 ? verify_lock(lock, old_sha1, mustexist) : lock;
diff --git a/sequencer.c b/sequencer.c
index a03d4fa..77a1266 100644
--- a/sequencer.c
+++ b/sequencer.c
@@ -267,6 +267,23 @@ static int fast_forward_to(const unsigned char *to, const unsigned char *from,
return 0;
}
+void append_conflicts_hint(struct strbuf *msgbuf)
+{
+ int i;
+
+ strbuf_addch(msgbuf, '\n');
+ strbuf_commented_addf(msgbuf, "Conflicts:\n");
+ for (i = 0; i < active_nr;) {
+ const struct cache_entry *ce = active_cache[i++];
+ if (ce_stage(ce)) {
+ strbuf_commented_addf(msgbuf, "\t%s\n", ce->name);
+ while (i < active_nr && !strcmp(ce->name,
+ active_cache[i]->name))
+ i++;
+ }
+ }
+}
+
static int do_recursive_merge(struct commit *base, struct commit *next,
const char *base_label, const char *next_label,
unsigned char *head, struct strbuf *msgbuf,
@@ -307,21 +324,8 @@ static int do_recursive_merge(struct commit *base, struct commit *next,
if (opts->signoff)
append_signoff(msgbuf, 0, 0);
- if (!clean) {
- int i;
- strbuf_addstr(msgbuf, "\nConflicts:\n");
- for (i = 0; i < active_nr;) {
- const struct cache_entry *ce = active_cache[i++];
- if (ce_stage(ce)) {
- strbuf_addch(msgbuf, '\t');
- strbuf_addstr(msgbuf, ce->name);
- strbuf_addch(msgbuf, '\n');
- while (i < active_nr && !strcmp(ce->name,
- active_cache[i]->name))
- i++;
- }
- }
- }
+ if (!clean)
+ append_conflicts_hint(msgbuf);
return !clean;
}
diff --git a/sequencer.h b/sequencer.h
index db43e9c..5ed5cb1 100644
--- a/sequencer.h
+++ b/sequencer.h
@@ -53,5 +53,6 @@ int sequencer_pick_revisions(struct replay_opts *opts);
extern const char sign_off_header[];
void append_signoff(struct strbuf *msgbuf, int ignore_footer, unsigned flag);
+void append_conflicts_hint(struct strbuf *msgbuf);
#endif
diff --git a/t/t0001-init.sh b/t/t0001-init.sh
index e62c0ff..7de8d85 100755
--- a/t/t0001-init.sh
+++ b/t/t0001-init.sh
@@ -12,6 +12,13 @@ check_config () {
echo "expected a directory $1, a file $1/config and $1/refs"
return 1
fi
+
+ if test_have_prereq POSIXPERM && test -x "$1/config"
+ then
+ echo "$1/config is executable?"
+ return 1
+ fi
+
bare=$(cd "$1" && git config --bool core.bare)
worktree=$(cd "$1" && git config core.worktree) ||
worktree=unset
diff --git a/t/t0090-cache-tree.sh b/t/t0090-cache-tree.sh
index 158cf4f..067f4c6 100755
--- a/t/t0090-cache-tree.sh
+++ b/t/t0090-cache-tree.sh
@@ -131,7 +131,7 @@ test_expect_success 'second commit has cache-tree' '
test_cache_tree
'
-test_expect_success 'commit --interactive gives cache-tree on partial commit' '
+test_expect_success PERL 'commit --interactive gives cache-tree on partial commit' '
cat <<-\EOT >foo.c &&
int foo()
{
diff --git a/t/t1014-read-tree-confusing.sh b/t/t1014-read-tree-confusing.sh
new file mode 100755
index 0000000..2f5a25d
--- /dev/null
+++ b/t/t1014-read-tree-confusing.sh
@@ -0,0 +1,62 @@
+#!/bin/sh
+
+test_description='check that read-tree rejects confusing paths'
+. ./test-lib.sh
+
+test_expect_success 'create base tree' '
+ echo content >file &&
+ git add file &&
+ git commit -m base &&
+ blob=$(git rev-parse HEAD:file) &&
+ tree=$(git rev-parse HEAD^{tree})
+'
+
+test_expect_success 'enable core.protectHFS for rejection tests' '
+ git config core.protectHFS true
+'
+
+test_expect_success 'enable core.protectNTFS for rejection tests' '
+ git config core.protectNTFS true
+'
+
+while read path pretty; do
+ : ${pretty:=$path}
+ case "$path" in
+ *SPACE)
+ path="${path%SPACE} "
+ ;;
+ esac
+ test_expect_success "reject $pretty at end of path" '
+ printf "100644 blob %s\t%s" "$blob" "$path" >tree &&
+ bogus=$(git mktree <tree) &&
+ test_must_fail git read-tree $bogus
+ '
+
+ test_expect_success "reject $pretty as subtree" '
+ printf "040000 tree %s\t%s" "$tree" "$path" >tree &&
+ bogus=$(git mktree <tree) &&
+ test_must_fail git read-tree $bogus
+ '
+done <<-EOF
+.
+..
+.git
+.GIT
+${u200c}.Git {u200c}.Git
+.gI${u200c}T .gI{u200c}T
+.GiT${u200c} .GiT{u200c}
+git~1
+.git.SPACE .git.{space}
+.\\\\.GIT\\\\foobar backslashes
+.git\\\\foobar backslashes2
+EOF
+
+test_expect_success 'utf-8 paths allowed with core.protectHFS off' '
+ test_when_finished "git read-tree HEAD" &&
+ test_config core.protectHFS false &&
+ printf "100644 blob %s\t%s" "$blob" ".gi${u200c}t" >tree &&
+ ok=$(git mktree <tree) &&
+ git read-tree $ok
+'
+
+test_done
diff --git a/t/t1450-fsck.sh b/t/t1450-fsck.sh
index 019fddd..d00b70f 100755
--- a/t/t1450-fsck.sh
+++ b/t/t1450-fsck.sh
@@ -309,36 +309,41 @@ test_expect_success 'fsck notices submodule entry pointing to null sha1' '
)
'
-test_expect_success 'fsck notices "." and ".." in trees' '
- (
- git init dots &&
- cd dots &&
- blob=$(echo foo | git hash-object -w --stdin) &&
- tab=$(printf "\\t") &&
- git mktree <<-EOF &&
- 100644 blob $blob$tab.
- 100644 blob $blob$tab..
- EOF
- git fsck 2>out &&
- cat out &&
- grep "warning.*\\." out
- )
-'
-
-test_expect_success 'fsck notices ".git" in trees' '
- (
- git init dotgit &&
- cd dotgit &&
- blob=$(echo foo | git hash-object -w --stdin) &&
- tab=$(printf "\\t") &&
- git mktree <<-EOF &&
- 100644 blob $blob$tab.git
- EOF
- git fsck 2>out &&
- cat out &&
- grep "warning.*\\.git" out
- )
-'
+while read name path pretty; do
+ while read mode type; do
+ : ${pretty:=$path}
+ test_expect_success "fsck notices $pretty as $type" '
+ (
+ git init $name-$type &&
+ cd $name-$type &&
+ echo content >file &&
+ git add file &&
+ git commit -m base &&
+ blob=$(git rev-parse :file) &&
+ tree=$(git rev-parse HEAD^{tree}) &&
+ value=$(eval "echo \$$type") &&
+ printf "$mode $type %s\t%s" "$value" "$path" >bad &&
+ bad_tree=$(git mktree <bad) &&
+ git fsck 2>out &&
+ cat out &&
+ grep "warning.*tree $bad_tree" out
+ )'
+ done <<-\EOF
+ 100644 blob
+ 040000 tree
+ EOF
+done <<-EOF
+dot .
+dotdot ..
+dotgit .git
+dotgit-case .GIT
+dotgit-unicode .gI${u200c}T .gI{u200c}T
+dotgit-case2 .Git
+git-tilde1 git~1
+dotgitdot .git.
+dot-backslash-case .\\\\.GIT\\\\foobar
+dotgit-case-backslash .git\\\\foobar
+EOF
# create a static test repo which is broken by omitting
# one particular object ($1, which is looked up via rev-parse
diff --git a/t/t2022-checkout-paths.sh b/t/t2022-checkout-paths.sh
index 8e3545d..f46d049 100755
--- a/t/t2022-checkout-paths.sh
+++ b/t/t2022-checkout-paths.sh
@@ -61,4 +61,21 @@ test_expect_success 'do not touch unmerged entries matching $path but not in $tr
test_cmp expect.next0 actual.next0
'
+test_expect_success 'do not touch files that are already up-to-date' '
+ git reset --hard &&
+ echo one >file1 &&
+ echo two >file2 &&
+ git add file1 file2 &&
+ git commit -m base &&
+ echo modified >file1 &&
+ test-chmtime =1000000000 file2 &&
+ git update-index -q --refresh &&
+ git checkout HEAD -- file1 file2 &&
+ echo one >expect &&
+ test_cmp expect file1 &&
+ echo "1000000000 file2" >expect &&
+ test-chmtime -v +0 file2 >actual &&
+ test_cmp expect actual
+'
+
test_done
diff --git a/t/t3301-notes.sh b/t/t3301-notes.sh
index cfd67ff..245406a 100755
--- a/t/t3301-notes.sh
+++ b/t/t3301-notes.sh
@@ -7,28 +7,22 @@ test_description='Test commit notes'
. ./test-lib.sh
-cat > fake_editor.sh << \EOF
-#!/bin/sh
-echo "$MSG" > "$1"
-echo "$MSG" >& 2
+write_script fake_editor <<\EOF
+echo "$MSG" >"$1"
+echo "$MSG" >&2
EOF
-chmod a+x fake_editor.sh
-GIT_EDITOR=./fake_editor.sh
+GIT_EDITOR=./fake_editor
export GIT_EDITOR
+indent=" "
+
test_expect_success 'cannot annotate non-existing HEAD' '
test_must_fail env MSG=3 git notes add
'
-test_expect_success setup '
- : > a1 &&
- git add a1 &&
- test_tick &&
- git commit -m 1st &&
- : > a2 &&
- git add a2 &&
- test_tick &&
- git commit -m 2nd
+test_expect_success 'setup' '
+ test_commit 1st &&
+ test_commit 2nd
'
test_expect_success 'need valid notes ref' '
@@ -50,206 +44,186 @@ test_expect_success 'handle empty notes gracefully' '
'
test_expect_success 'show non-existent notes entry with %N' '
- for l in A B
- do
- echo "$l"
- done >expect &&
- git show -s --format='A%n%NB' >output &&
- test_cmp expect output
+ test_write_lines A B >expect &&
+ git show -s --format="A%n%NB" >actual &&
+ test_cmp expect actual
'
test_expect_success 'create notes' '
- git config core.notesRef refs/notes/commits &&
MSG=b4 git notes add &&
- test ! -f .git/NOTES_EDITMSG &&
- test 1 = $(git ls-tree refs/notes/commits | wc -l) &&
- test b4 = $(git notes show) &&
+ test_path_is_missing .git/NOTES_EDITMSG &&
+ git ls-tree -r refs/notes/commits >actual &&
+ test_line_count = 1 actual &&
+ test "b4" = "$(git notes show)" &&
git show HEAD^ &&
test_must_fail git notes show HEAD^
'
test_expect_success 'show notes entry with %N' '
- for l in A b4 B
- do
- echo "$l"
- done >expect &&
- git show -s --format='A%n%NB' >output &&
- test_cmp expect output
+ test_write_lines A b4 B >expect &&
+ git show -s --format="A%n%NB" >actual &&
+ test_cmp expect actual
'
-cat >expect <<EOF
-d423f8c refs/notes/commits@{0}: notes: Notes added by 'git notes add'
-EOF
-
test_expect_success 'create reflog entry' '
- git reflog show refs/notes/commits >output &&
- test_cmp expect output
+ cat <<-EOF >expect &&
+ a1d8fa6 refs/notes/commits@{0}: notes: Notes added by '\''git notes add'\''
+ EOF
+ git reflog show refs/notes/commits >actual &&
+ test_cmp expect actual
'
test_expect_success 'edit existing notes' '
MSG=b3 git notes edit &&
- test ! -f .git/NOTES_EDITMSG &&
- test 1 = $(git ls-tree refs/notes/commits | wc -l) &&
- test b3 = $(git notes show) &&
+ test_path_is_missing .git/NOTES_EDITMSG &&
+ git ls-tree -r refs/notes/commits >actual &&
+ test_line_count = 1 actual &&
+ test "b3" = "$(git notes show)" &&
git show HEAD^ &&
test_must_fail git notes show HEAD^
'
test_expect_success 'cannot "git notes add -m" where notes already exists' '
test_must_fail git notes add -m "b2" &&
- test ! -f .git/NOTES_EDITMSG &&
- test 1 = $(git ls-tree refs/notes/commits | wc -l) &&
- test b3 = $(git notes show) &&
+ test_path_is_missing .git/NOTES_EDITMSG &&
+ git ls-tree -r refs/notes/commits >actual &&
+ test_line_count = 1 actual &&
+ test "b3" = "$(git notes show)" &&
git show HEAD^ &&
test_must_fail git notes show HEAD^
'
test_expect_success 'can overwrite existing note with "git notes add -f -m"' '
git notes add -f -m "b1" &&
- test ! -f .git/NOTES_EDITMSG &&
- test 1 = $(git ls-tree refs/notes/commits | wc -l) &&
- test b1 = $(git notes show) &&
+ test_path_is_missing .git/NOTES_EDITMSG &&
+ git ls-tree -r refs/notes/commits >actual &&
+ test_line_count = 1 actual &&
+ test "b1" = "$(git notes show)" &&
git show HEAD^ &&
test_must_fail git notes show HEAD^
'
test_expect_success 'add w/no options on existing note morphs into edit' '
MSG=b2 git notes add &&
- test ! -f .git/NOTES_EDITMSG &&
- test 1 = $(git ls-tree refs/notes/commits | wc -l) &&
- test b2 = $(git notes show) &&
+ test_path_is_missing .git/NOTES_EDITMSG &&
+ git ls-tree -r refs/notes/commits >actual &&
+ test_line_count = 1 actual &&
+ test "b2" = "$(git notes show)" &&
git show HEAD^ &&
test_must_fail git notes show HEAD^
'
test_expect_success 'can overwrite existing note with "git notes add -f"' '
MSG=b1 git notes add -f &&
- test ! -f .git/NOTES_EDITMSG &&
- test 1 = $(git ls-tree refs/notes/commits | wc -l) &&
- test b1 = $(git notes show) &&
+ test_path_is_missing .git/NOTES_EDITMSG &&
+ git ls-tree -r refs/notes/commits >actual &&
+ test_line_count = 1 actual &&
+ test "b1" = "$(git notes show)" &&
git show HEAD^ &&
test_must_fail git notes show HEAD^
'
-cat > expect << EOF
-commit 268048bfb8a1fb38e703baceb8ab235421bf80c5
-Author: A U Thor <author@example.com>
-Date: Thu Apr 7 15:14:13 2005 -0700
-
- 2nd
+test_expect_success 'show notes' '
+ cat >expect <<-EOF &&
+ commit 7a4ca6ee52a974a66cbaa78e33214535dff1d691
+ Author: A U Thor <author@example.com>
+ Date: Thu Apr 7 15:14:13 2005 -0700
-Notes:
- b1
-EOF
+ ${indent}2nd
-test_expect_success 'show notes' '
+ Notes:
+ ${indent}b1
+ EOF
! (git cat-file commit HEAD | grep b1) &&
- git log -1 > output &&
- test_cmp expect output
-'
-
-test_expect_success 'create multi-line notes (setup)' '
- : > a3 &&
- git add a3 &&
- test_tick &&
- git commit -m 3rd &&
- MSG="b3
-c3c3c3c3
-d3d3d3" git notes add
+ git log -1 >actual &&
+ test_cmp expect actual
'
-cat > expect-multiline << EOF
-commit 1584215f1d29c65e99c6c6848626553fdd07fd75
-Author: A U Thor <author@example.com>
-Date: Thu Apr 7 15:15:13 2005 -0700
-
- 3rd
+test_expect_success 'show multi-line notes' '
+ test_commit 3rd &&
+ MSG="b3${LF}c3c3c3c3${LF}d3d3d3" git notes add &&
+ cat >expect-multiline <<-EOF &&
+ commit d07d62e5208f22eb5695e7eb47667dc8b9860290
+ Author: A U Thor <author@example.com>
+ Date: Thu Apr 7 15:15:13 2005 -0700
-Notes:
- b3
- c3c3c3c3
- d3d3d3
-EOF
+ ${indent}3rd
-printf "\n" >> expect-multiline
-cat expect >> expect-multiline
+ Notes:
+ ${indent}b3
+ ${indent}c3c3c3c3
+ ${indent}d3d3d3
-test_expect_success 'show multi-line notes' '
- git log -2 > output &&
- test_cmp expect-multiline output
-'
-test_expect_success 'create -F notes (setup)' '
- : > a4 &&
- git add a4 &&
- test_tick &&
- git commit -m 4th &&
- echo "xyzzy" > note5 &&
- git notes add -F note5
+ EOF
+ cat expect >>expect-multiline &&
+ git log -2 >actual &&
+ test_cmp expect-multiline actual
'
-cat > expect-F << EOF
-commit 15023535574ded8b1a89052b32673f84cf9582b8
-Author: A U Thor <author@example.com>
-Date: Thu Apr 7 15:16:13 2005 -0700
+test_expect_success 'show -F notes' '
+ test_commit 4th &&
+ echo "xyzzy" >note5 &&
+ git notes add -F note5 &&
+ cat >expect-F <<-EOF &&
+ commit 0f7aa3ec6325aeb88b910453bb3eb37c49d75c11
+ Author: A U Thor <author@example.com>
+ Date: Thu Apr 7 15:16:13 2005 -0700
- 4th
+ ${indent}4th
-Notes:
- xyzzy
-EOF
+ Notes:
+ ${indent}xyzzy
-printf "\n" >> expect-F
-cat expect-multiline >> expect-F
-
-test_expect_success 'show -F notes' '
- git log -3 > output &&
- test_cmp expect-F output
+ EOF
+ cat expect-multiline >>expect-F &&
+ git log -3 >actual &&
+ test_cmp expect-F actual
'
test_expect_success 'Re-adding -F notes without -f fails' '
- echo "zyxxy" > note5 &&
+ echo "zyxxy" >note5 &&
test_must_fail git notes add -F note5 &&
- git log -3 > output &&
- test_cmp expect-F output
+ git log -3 >actual &&
+ test_cmp expect-F actual
'
-cat >expect << EOF
-commit 15023535574ded8b1a89052b32673f84cf9582b8
-tree e070e3af51011e47b183c33adf9736736a525709
-parent 1584215f1d29c65e99c6c6848626553fdd07fd75
-author A U Thor <author@example.com> 1112912173 -0700
-committer C O Mitter <committer@example.com> 1112912173 -0700
-
- 4th
-EOF
test_expect_success 'git log --pretty=raw does not show notes' '
- git log -1 --pretty=raw >output &&
- test_cmp expect output
+ cat >expect <<-EOF &&
+ commit 0f7aa3ec6325aeb88b910453bb3eb37c49d75c11
+ tree 05ac65288c4c4b3b709a020ae94b2ece2f2201ae
+ parent d07d62e5208f22eb5695e7eb47667dc8b9860290
+ author A U Thor <author@example.com> 1112912173 -0700
+ committer C O Mitter <committer@example.com> 1112912173 -0700
+
+ ${indent}4th
+ EOF
+ git log -1 --pretty=raw >actual &&
+ test_cmp expect actual
'
-cat >>expect <<EOF
-
-Notes:
- xyzzy
-EOF
test_expect_success 'git log --show-notes' '
- git log -1 --pretty=raw --show-notes >output &&
- test_cmp expect output
+ cat >>expect <<-EOF &&
+
+ Notes:
+ ${indent}xyzzy
+ EOF
+ git log -1 --pretty=raw --show-notes >actual &&
+ test_cmp expect actual
'
test_expect_success 'git log --no-notes' '
- git log -1 --no-notes >output &&
- ! grep xyzzy output
+ git log -1 --no-notes >actual &&
+ ! grep xyzzy actual
'
test_expect_success 'git format-patch does not show notes' '
- git format-patch -1 --stdout >output &&
- ! grep xyzzy output
+ git format-patch -1 --stdout >actual &&
+ ! grep xyzzy actual
'
test_expect_success 'git format-patch --show-notes does show notes' '
- git format-patch --show-notes -1 --stdout >output &&
- grep xyzzy output
+ git format-patch --show-notes -1 --stdout >actual &&
+ grep xyzzy actual
'
for pretty in \
@@ -261,8 +235,8 @@ do
?*) p="$pretty" not=" not" negate="!" ;;
esac
test_expect_success "git show $pretty does$not show notes" '
- git show $p >output &&
- eval "$negate grep xyzzy output"
+ git show $p >actual &&
+ eval "$negate grep xyzzy actual"
'
done
@@ -271,161 +245,131 @@ test_expect_success 'setup alternate notes ref' '
'
test_expect_success 'git log --notes shows default notes' '
- git log -1 --notes >output &&
- grep xyzzy output &&
- ! grep alternate output
+ git log -1 --notes >actual &&
+ grep xyzzy actual &&
+ ! grep alternate actual
'
test_expect_success 'git log --notes=X shows only X' '
- git log -1 --notes=alternate >output &&
- ! grep xyzzy output &&
- grep alternate output
+ git log -1 --notes=alternate >actual &&
+ ! grep xyzzy actual &&
+ grep alternate actual
'
test_expect_success 'git log --notes --notes=X shows both' '
- git log -1 --notes --notes=alternate >output &&
- grep xyzzy output &&
- grep alternate output
+ git log -1 --notes --notes=alternate >actual &&
+ grep xyzzy actual &&
+ grep alternate actual
'
test_expect_success 'git log --no-notes resets default state' '
git log -1 --notes --notes=alternate \
--no-notes --notes=alternate \
- >output &&
- ! grep xyzzy output &&
- grep alternate output
+ >actual &&
+ ! grep xyzzy actual &&
+ grep alternate actual
'
test_expect_success 'git log --no-notes resets ref list' '
git log -1 --notes --notes=alternate \
--no-notes --notes \
- >output &&
- grep xyzzy output &&
- ! grep alternate output
-'
-
-test_expect_success 'create -m notes (setup)' '
- : > a5 &&
- git add a5 &&
- test_tick &&
- git commit -m 5th &&
- git notes add -m spam -m "foo
-bar
-baz"
-'
-
-whitespace=" "
-cat > expect-m << EOF
-commit bd1753200303d0a0344be813e504253b3d98e74d
-Author: A U Thor <author@example.com>
-Date: Thu Apr 7 15:17:13 2005 -0700
-
- 5th
-
-Notes:
- spam
-$whitespace
- foo
- bar
- baz
-EOF
-
-printf "\n" >> expect-m
-cat expect-F >> expect-m
-
-test_expect_success 'show -m notes' '
- git log -4 > output &&
- test_cmp expect-m output
+ >actual &&
+ grep xyzzy actual &&
+ ! grep alternate actual
'
-test_expect_success 'remove note with add -f -F /dev/null (setup)' '
- git notes add -f -F /dev/null
-'
-
-cat > expect-rm-F << EOF
-commit bd1753200303d0a0344be813e504253b3d98e74d
-Author: A U Thor <author@example.com>
-Date: Thu Apr 7 15:17:13 2005 -0700
-
- 5th
-EOF
-
-printf "\n" >> expect-rm-F
-cat expect-F >> expect-rm-F
-
-test_expect_success 'verify note removal with -F /dev/null' '
- git log -4 > output &&
- test_cmp expect-rm-F output &&
+test_expect_success 'show -m notes' '
+ test_commit 5th &&
+ git notes add -m spam -m "foo${LF}bar${LF}baz" &&
+ cat >expect-m <<-EOF &&
+ commit 7f9ad8836c775acb134c0a055fc55fb4cd1ba361
+ Author: A U Thor <author@example.com>
+ Date: Thu Apr 7 15:17:13 2005 -0700
+
+ ${indent}5th
+
+ Notes:
+ ${indent}spam
+ ${indent}
+ ${indent}foo
+ ${indent}bar
+ ${indent}baz
+
+ EOF
+ cat expect-F >>expect-m &&
+ git log -4 >actual &&
+ test_cmp expect-m actual
+'
+
+test_expect_success 'remove note with add -f -F /dev/null' '
+ git notes add -f -F /dev/null &&
+ cat >expect-rm-F <<-EOF &&
+ commit 7f9ad8836c775acb134c0a055fc55fb4cd1ba361
+ Author: A U Thor <author@example.com>
+ Date: Thu Apr 7 15:17:13 2005 -0700
+
+ ${indent}5th
+
+ EOF
+ cat expect-F >>expect-rm-F &&
+ git log -4 >actual &&
+ test_cmp expect-rm-F actual &&
test_must_fail git notes show
'
-test_expect_success 'do not create empty note with -m "" (setup)' '
- git notes add -m ""
-'
-
-test_expect_success 'verify non-creation of note with -m ""' '
- git log -4 > output &&
- test_cmp expect-rm-F output &&
+test_expect_success 'do not create empty note with -m ""' '
+ git notes add -m "" &&
+ git log -4 >actual &&
+ test_cmp expect-rm-F actual &&
test_must_fail git notes show
'
-cat > expect-combine_m_and_F << EOF
-foo
-
-xyzzy
+test_expect_success 'create note with combination of -m and -F' '
+ cat >expect-combine_m_and_F <<-EOF &&
+ foo
-bar
+ xyzzy
-zyxxy
+ bar
-baz
-EOF
+ zyxxy
-test_expect_success 'create note with combination of -m and -F' '
- echo "xyzzy" > note_a &&
- echo "zyxxy" > note_b &&
+ baz
+ EOF
+ echo "xyzzy" >note_a &&
+ echo "zyxxy" >note_b &&
git notes add -m "foo" -F note_a -m "bar" -F note_b -m "baz" &&
- git notes show > output &&
- test_cmp expect-combine_m_and_F output
+ git notes show >actual &&
+ test_cmp expect-combine_m_and_F actual
'
-test_expect_success 'remove note with "git notes remove" (setup)' '
+test_expect_success 'remove note with "git notes remove"' '
git notes remove HEAD^ &&
- git notes remove
-'
-
-cat > expect-rm-remove << EOF
-commit bd1753200303d0a0344be813e504253b3d98e74d
-Author: A U Thor <author@example.com>
-Date: Thu Apr 7 15:17:13 2005 -0700
+ git notes remove &&
+ cat >expect-rm-remove <<-EOF &&
+ commit 7f9ad8836c775acb134c0a055fc55fb4cd1ba361
+ Author: A U Thor <author@example.com>
+ Date: Thu Apr 7 15:17:13 2005 -0700
- 5th
+ ${indent}5th
-commit 15023535574ded8b1a89052b32673f84cf9582b8
-Author: A U Thor <author@example.com>
-Date: Thu Apr 7 15:16:13 2005 -0700
+ commit 0f7aa3ec6325aeb88b910453bb3eb37c49d75c11
+ Author: A U Thor <author@example.com>
+ Date: Thu Apr 7 15:16:13 2005 -0700
- 4th
-EOF
-
-printf "\n" >> expect-rm-remove
-cat expect-multiline >> expect-rm-remove
+ ${indent}4th
-test_expect_success 'verify note removal with "git notes remove"' '
- git log -4 > output &&
- test_cmp expect-rm-remove output &&
+ EOF
+ cat expect-multiline >>expect-rm-remove &&
+ git log -4 >actual &&
+ test_cmp expect-rm-remove actual &&
test_must_fail git notes show HEAD^
'
-cat > expect << EOF
-c18dc024e14f08d18d14eea0d747ff692d66d6a3 1584215f1d29c65e99c6c6848626553fdd07fd75
-c9c6af7f78bc47490dbf3e822cf2f3c24d4b9061 268048bfb8a1fb38e703baceb8ab235421bf80c5
-EOF
-
test_expect_success 'removing non-existing note should not create new commit' '
- git rev-parse --verify refs/notes/commits > before_commit &&
+ git rev-parse --verify refs/notes/commits >before_commit &&
test_must_fail git notes remove HEAD^ &&
- git rev-parse --verify refs/notes/commits > after_commit &&
+ git rev-parse --verify refs/notes/commits >after_commit &&
test_cmp before_commit after_commit
'
@@ -505,70 +449,68 @@ test_expect_success 'removing with --stdin --ignore-missing' '
'
test_expect_success 'list notes with "git notes list"' '
- git notes list > output &&
- test_cmp expect output
+ cat >expect <<-EOF &&
+ c9c6af7f78bc47490dbf3e822cf2f3c24d4b9061 7a4ca6ee52a974a66cbaa78e33214535dff1d691
+ c18dc024e14f08d18d14eea0d747ff692d66d6a3 d07d62e5208f22eb5695e7eb47667dc8b9860290
+ EOF
+ git notes list >actual &&
+ test_cmp expect actual
'
test_expect_success 'list notes with "git notes"' '
- git notes > output &&
- test_cmp expect output
+ git notes >actual &&
+ test_cmp expect actual
'
-cat > expect << EOF
-c18dc024e14f08d18d14eea0d747ff692d66d6a3
-EOF
-
test_expect_success 'list specific note with "git notes list <object>"' '
- git notes list HEAD^^ > output &&
- test_cmp expect output
+ cat >expect <<-EOF &&
+ c18dc024e14f08d18d14eea0d747ff692d66d6a3
+ EOF
+ git notes list HEAD^^ >actual &&
+ test_cmp expect actual
'
-cat > expect << EOF
-EOF
-
test_expect_success 'listing non-existing notes fails' '
- test_must_fail git notes list HEAD > output &&
- test_cmp expect output
+ cat >expect <<-EOF &&
+ EOF
+ test_must_fail git notes list HEAD >actual &&
+ test_cmp expect actual
'
-cat > expect << EOF
-Initial set of notes
-
-More notes appended with git notes append
-EOF
-
test_expect_success 'append to existing note with "git notes append"' '
+ cat >expect <<-EOF &&
+ Initial set of notes
+
+ More notes appended with git notes append
+ EOF
git notes add -m "Initial set of notes" &&
git notes append -m "More notes appended with git notes append" &&
- git notes show > output &&
- test_cmp expect output
+ git notes show >actual &&
+ test_cmp expect actual
'
-cat > expect_list << EOF
-c18dc024e14f08d18d14eea0d747ff692d66d6a3 1584215f1d29c65e99c6c6848626553fdd07fd75
-c9c6af7f78bc47490dbf3e822cf2f3c24d4b9061 268048bfb8a1fb38e703baceb8ab235421bf80c5
-4b6ad22357cc8a1296720574b8d2fbc22fab0671 bd1753200303d0a0344be813e504253b3d98e74d
-EOF
-
test_expect_success '"git notes list" does not expand to "git notes list HEAD"' '
- git notes list > output &&
- test_cmp expect_list output
+ cat >expect_list <<-EOF &&
+ c9c6af7f78bc47490dbf3e822cf2f3c24d4b9061 7a4ca6ee52a974a66cbaa78e33214535dff1d691
+ 4b6ad22357cc8a1296720574b8d2fbc22fab0671 7f9ad8836c775acb134c0a055fc55fb4cd1ba361
+ c18dc024e14f08d18d14eea0d747ff692d66d6a3 d07d62e5208f22eb5695e7eb47667dc8b9860290
+ EOF
+ git notes list >actual &&
+ test_cmp expect_list actual
'
test_expect_success 'appending empty string does not change existing note' '
git notes append -m "" &&
- git notes show > output &&
- test_cmp expect output
+ git notes show >actual &&
+ test_cmp expect actual
'
test_expect_success 'git notes append == add when there is no existing note' '
git notes remove HEAD &&
test_must_fail git notes list HEAD &&
- git notes append -m "Initial set of notes
-
-More notes appended with git notes append" &&
- git notes show > output &&
- test_cmp expect output
+ git notes append -m "Initial set of notes${LF}${LF}More notes appended with git notes append" &&
+ git notes show >actual &&
+ test_cmp expect actual
'
test_expect_success 'appending empty string to non-existing note does not create note' '
@@ -579,229 +521,208 @@ test_expect_success 'appending empty string to non-existing note does not create
'
test_expect_success 'create other note on a different notes ref (setup)' '
- : > a6 &&
- git add a6 &&
- test_tick &&
- git commit -m 6th &&
- GIT_NOTES_REF="refs/notes/other" git notes add -m "other note"
-'
+ test_commit 6th &&
+ GIT_NOTES_REF="refs/notes/other" git notes add -m "other note" &&
+ cat >expect-not-other <<-EOF &&
+ commit 2c125331118caba0ff8238b7f4958ac6e93fe39c
+ Author: A U Thor <author@example.com>
+ Date: Thu Apr 7 15:18:13 2005 -0700
-cat > expect-other << EOF
-commit 387a89921c73d7ed72cd94d179c1c7048ca47756
-Author: A U Thor <author@example.com>
-Date: Thu Apr 7 15:18:13 2005 -0700
-
- 6th
-
-Notes (other):
- other note
-EOF
+ ${indent}6th
+ EOF
+ cp expect-not-other expect-other &&
+ cat >>expect-other <<-EOF
-cat > expect-not-other << EOF
-commit 387a89921c73d7ed72cd94d179c1c7048ca47756
-Author: A U Thor <author@example.com>
-Date: Thu Apr 7 15:18:13 2005 -0700
-
- 6th
-EOF
+ Notes (other):
+ ${indent}other note
+ EOF
+'
test_expect_success 'Do not show note on other ref by default' '
- git log -1 > output &&
- test_cmp expect-not-other output
+ git log -1 >actual &&
+ test_cmp expect-not-other actual
'
test_expect_success 'Do show note when ref is given in GIT_NOTES_REF' '
- GIT_NOTES_REF="refs/notes/other" git log -1 > output &&
- test_cmp expect-other output
+ GIT_NOTES_REF="refs/notes/other" git log -1 >actual &&
+ test_cmp expect-other actual
'
test_expect_success 'Do show note when ref is given in core.notesRef config' '
- git config core.notesRef "refs/notes/other" &&
- git log -1 > output &&
- test_cmp expect-other output
+ test_config core.notesRef "refs/notes/other" &&
+ git log -1 >actual &&
+ test_cmp expect-other actual
'
test_expect_success 'Do not show note when core.notesRef is overridden' '
- GIT_NOTES_REF="refs/notes/wrong" git log -1 > output &&
- test_cmp expect-not-other output
+ test_config core.notesRef "refs/notes/other" &&
+ GIT_NOTES_REF="refs/notes/wrong" git log -1 >actual &&
+ test_cmp expect-not-other actual
'
-cat > expect-both << EOF
-commit 387a89921c73d7ed72cd94d179c1c7048ca47756
-Author: A U Thor <author@example.com>
-Date: Thu Apr 7 15:18:13 2005 -0700
-
- 6th
+test_expect_success 'Show all notes when notes.displayRef=refs/notes/*' '
+ cat >expect-both <<-EOF &&
+ commit 2c125331118caba0ff8238b7f4958ac6e93fe39c
+ Author: A U Thor <author@example.com>
+ Date: Thu Apr 7 15:18:13 2005 -0700
-Notes:
- order test
+ ${indent}6th
-Notes (other):
- other note
+ Notes:
+ ${indent}order test
-commit bd1753200303d0a0344be813e504253b3d98e74d
-Author: A U Thor <author@example.com>
-Date: Thu Apr 7 15:17:13 2005 -0700
+ Notes (other):
+ ${indent}other note
- 5th
+ commit 7f9ad8836c775acb134c0a055fc55fb4cd1ba361
+ Author: A U Thor <author@example.com>
+ Date: Thu Apr 7 15:17:13 2005 -0700
-Notes:
- replacement for deleted note
-EOF
+ ${indent}5th
-test_expect_success 'Show all notes when notes.displayRef=refs/notes/*' '
+ Notes:
+ ${indent}replacement for deleted note
+ EOF
GIT_NOTES_REF=refs/notes/commits git notes add \
-m"replacement for deleted note" HEAD^ &&
GIT_NOTES_REF=refs/notes/commits git notes add -m"order test" &&
- git config --unset core.notesRef &&
- git config notes.displayRef "refs/notes/*" &&
- git log -2 > output &&
- test_cmp expect-both output
+ test_unconfig core.notesRef &&
+ test_config notes.displayRef "refs/notes/*" &&
+ git log -2 >actual &&
+ test_cmp expect-both actual
'
test_expect_success 'core.notesRef is implicitly in notes.displayRef' '
- git config core.notesRef refs/notes/commits &&
- git config notes.displayRef refs/notes/other &&
- git log -2 > output &&
- test_cmp expect-both output
+ test_config core.notesRef refs/notes/commits &&
+ test_config notes.displayRef refs/notes/other &&
+ git log -2 >actual &&
+ test_cmp expect-both actual
'
test_expect_success 'notes.displayRef can be given more than once' '
- git config --unset core.notesRef &&
- git config notes.displayRef refs/notes/commits &&
+ test_unconfig core.notesRef &&
+ test_config notes.displayRef refs/notes/commits &&
git config --add notes.displayRef refs/notes/other &&
- git log -2 > output &&
- test_cmp expect-both output
+ git log -2 >actual &&
+ test_cmp expect-both actual
'
-cat > expect-both-reversed << EOF
-commit 387a89921c73d7ed72cd94d179c1c7048ca47756
-Author: A U Thor <author@example.com>
-Date: Thu Apr 7 15:18:13 2005 -0700
-
- 6th
+test_expect_success 'notes.displayRef respects order' '
+ cat >expect-both-reversed <<-EOF &&
+ commit 2c125331118caba0ff8238b7f4958ac6e93fe39c
+ Author: A U Thor <author@example.com>
+ Date: Thu Apr 7 15:18:13 2005 -0700
-Notes (other):
- other note
+ ${indent}6th
-Notes:
- order test
-EOF
+ Notes (other):
+ ${indent}other note
-test_expect_success 'notes.displayRef respects order' '
- git config core.notesRef refs/notes/other &&
- git config --unset-all notes.displayRef &&
- git config notes.displayRef refs/notes/commits &&
- git log -1 > output &&
- test_cmp expect-both-reversed output
+ Notes:
+ ${indent}order test
+ EOF
+ test_config core.notesRef refs/notes/other &&
+ test_config notes.displayRef refs/notes/commits &&
+ git log -1 >actual &&
+ test_cmp expect-both-reversed actual
'
test_expect_success 'GIT_NOTES_DISPLAY_REF works' '
- git config --unset-all core.notesRef &&
- git config --unset-all notes.displayRef &&
GIT_NOTES_DISPLAY_REF=refs/notes/commits:refs/notes/other \
- git log -2 > output &&
- test_cmp expect-both output
+ git log -2 >actual &&
+ test_cmp expect-both actual
'
-cat > expect-none << EOF
-commit 387a89921c73d7ed72cd94d179c1c7048ca47756
-Author: A U Thor <author@example.com>
-Date: Thu Apr 7 15:18:13 2005 -0700
-
- 6th
+test_expect_success 'GIT_NOTES_DISPLAY_REF overrides config' '
+ cat >expect-none <<-EOF &&
+ commit 2c125331118caba0ff8238b7f4958ac6e93fe39c
+ Author: A U Thor <author@example.com>
+ Date: Thu Apr 7 15:18:13 2005 -0700
-commit bd1753200303d0a0344be813e504253b3d98e74d
-Author: A U Thor <author@example.com>
-Date: Thu Apr 7 15:17:13 2005 -0700
+ ${indent}6th
- 5th
-EOF
+ commit 7f9ad8836c775acb134c0a055fc55fb4cd1ba361
+ Author: A U Thor <author@example.com>
+ Date: Thu Apr 7 15:17:13 2005 -0700
-test_expect_success 'GIT_NOTES_DISPLAY_REF overrides config' '
- git config notes.displayRef "refs/notes/*" &&
- GIT_NOTES_REF= GIT_NOTES_DISPLAY_REF= git log -2 > output &&
- test_cmp expect-none output
+ ${indent}5th
+ EOF
+ test_config notes.displayRef "refs/notes/*" &&
+ GIT_NOTES_REF= GIT_NOTES_DISPLAY_REF= git log -2 >actual &&
+ test_cmp expect-none actual
'
test_expect_success '--show-notes=* adds to GIT_NOTES_DISPLAY_REF' '
- GIT_NOTES_REF= GIT_NOTES_DISPLAY_REF= git log --show-notes=* -2 > output &&
- test_cmp expect-both output
+ GIT_NOTES_REF= GIT_NOTES_DISPLAY_REF= git log --show-notes=* -2 >actual &&
+ test_cmp expect-both actual
'
-cat > expect-commits << EOF
-commit 387a89921c73d7ed72cd94d179c1c7048ca47756
-Author: A U Thor <author@example.com>
-Date: Thu Apr 7 15:18:13 2005 -0700
-
- 6th
+test_expect_success '--no-standard-notes' '
+ cat >expect-commits <<EOF
+ commit 2c125331118caba0ff8238b7f4958ac6e93fe39c
+ Author: A U Thor <author@example.com>
+ Date: Thu Apr 7 15:18:13 2005 -0700
-Notes:
- order test
-EOF
+ ${indent}6th
-test_expect_success '--no-standard-notes' '
- git log --no-standard-notes --show-notes=commits -1 > output &&
- test_cmp expect-commits output
+ Notes:
+ ${indent}order test
+ EOF
+ git log --no-standard-notes --show-notes=commits -1 >actual &&
+ test_cmp expect-commits actual
'
test_expect_success '--standard-notes' '
+ test_config notes.displayRef "refs/notes/*" &&
git log --no-standard-notes --show-notes=commits \
- --standard-notes -2 > output &&
- test_cmp expect-both output
+ --standard-notes -2 >actual &&
+ test_cmp expect-both actual
'
test_expect_success '--show-notes=ref accumulates' '
git log --show-notes=other --show-notes=commits \
- --no-standard-notes -1 > output &&
- test_cmp expect-both-reversed output
+ --no-standard-notes -1 >actual &&
+ test_cmp expect-both-reversed actual
'
test_expect_success 'Allow notes on non-commits (trees, blobs, tags)' '
- git config core.notesRef refs/notes/other &&
- echo "Note on a tree" > expect &&
+ test_config core.notesRef refs/notes/other &&
+ echo "Note on a tree" >expect &&
git notes add -m "Note on a tree" HEAD: &&
- git notes show HEAD: > actual &&
+ git notes show HEAD: >actual &&
test_cmp expect actual &&
- echo "Note on a blob" > expect &&
+ echo "Note on a blob" >expect &&
filename=$(git ls-tree --name-only HEAD | head -n1) &&
git notes add -m "Note on a blob" HEAD:$filename &&
- git notes show HEAD:$filename > actual &&
+ git notes show HEAD:$filename >actual &&
test_cmp expect actual &&
- echo "Note on a tag" > expect &&
+ echo "Note on a tag" >expect &&
git tag -a -m "This is an annotated tag" foobar HEAD^ &&
git notes add -m "Note on a tag" foobar &&
- git notes show foobar > actual &&
+ git notes show foobar >actual &&
test_cmp expect actual
'
-cat > expect << EOF
-commit 2ede89468182a62d0bde2583c736089bcf7d7e92
-Author: A U Thor <author@example.com>
-Date: Thu Apr 7 15:19:13 2005 -0700
-
- 7th
+test_expect_success 'create note from other note with "git notes add -C"' '
+ cat >expect <<-EOF &&
+ commit fb01e0ca8c33b6cc0c6451dde747f97df567cb5c
+ Author: A U Thor <author@example.com>
+ Date: Thu Apr 7 15:19:13 2005 -0700
-Notes (other):
- other note
-EOF
+ ${indent}7th
-test_expect_success 'create note from other note with "git notes add -C"' '
- : > a7 &&
- git add a7 &&
- test_tick &&
- git commit -m 7th &&
+ Notes:
+ ${indent}order test
+ EOF
+ test_commit 7th &&
git notes add -C $(git notes list HEAD^) &&
- git log -1 > actual &&
+ git log -1 >actual &&
test_cmp expect actual &&
test "$(git notes list HEAD)" = "$(git notes list HEAD^)"
'
test_expect_success 'create note from non-existing note with "git notes add -C" fails' '
- : > a8 &&
- git add a8 &&
- test_tick &&
- git commit -m 8th &&
+ test_commit 8th &&
test_must_fail git notes add -C deadbeef &&
test_must_fail git notes list HEAD
'
@@ -814,405 +735,386 @@ test_expect_success 'create note from non-blob with "git notes add -C" fails' '
test_must_fail git notes list HEAD
'
-cat > expect << EOF
-commit 80d796defacd5db327b7a4e50099663902fbdc5c
-Author: A U Thor <author@example.com>
-Date: Thu Apr 7 15:20:13 2005 -0700
-
- 8th
+test_expect_success 'create note from blob with "git notes add -C" reuses blob id' '
+ cat >expect <<-EOF &&
+ commit 9a4c31c7f722b5d517e92c64e932dd751e1413bf
+ Author: A U Thor <author@example.com>
+ Date: Thu Apr 7 15:20:13 2005 -0700
-Notes (other):
- This is a blob object
-EOF
+ ${indent}8th
-test_expect_success 'create note from blob with "git notes add -C" reuses blob id' '
+ Notes:
+ ${indent}This is a blob object
+ EOF
blob=$(echo "This is a blob object" | git hash-object -w --stdin) &&
git notes add -C $blob &&
- git log -1 > actual &&
+ git log -1 >actual &&
test_cmp expect actual &&
test "$(git notes list HEAD)" = "$blob"
'
-cat > expect << EOF
-commit 016e982bad97eacdbda0fcbd7ce5b0ba87c81f1b
-Author: A U Thor <author@example.com>
-Date: Thu Apr 7 15:21:13 2005 -0700
-
- 9th
+test_expect_success 'create note from other note with "git notes add -c"' '
+ cat >expect <<-EOF &&
+ commit 2e0db4bc649e174d667a1cde19e725cf897a5bd2
+ Author: A U Thor <author@example.com>
+ Date: Thu Apr 7 15:21:13 2005 -0700
-Notes (other):
- yet another note
-EOF
+ ${indent}9th
-test_expect_success 'create note from other note with "git notes add -c"' '
- : > a9 &&
- git add a9 &&
- test_tick &&
- git commit -m 9th &&
+ Notes:
+ ${indent}yet another note
+ EOF
+ test_commit 9th &&
MSG="yet another note" git notes add -c $(git notes list HEAD^^) &&
- git log -1 > actual &&
+ git log -1 >actual &&
test_cmp expect actual
'
test_expect_success 'create note from non-existing note with "git notes add -c" fails' '
- : > a10 &&
- git add a10 &&
- test_tick &&
- git commit -m 10th &&
+ test_commit 10th &&
test_must_fail env MSG="yet another note" git notes add -c deadbeef &&
test_must_fail git notes list HEAD
'
-cat > expect << EOF
-commit 016e982bad97eacdbda0fcbd7ce5b0ba87c81f1b
-Author: A U Thor <author@example.com>
-Date: Thu Apr 7 15:21:13 2005 -0700
-
- 9th
-
-Notes (other):
- yet another note
-$whitespace
- yet another note
-EOF
-
test_expect_success 'append to note from other note with "git notes append -C"' '
+ cat >expect <<-EOF &&
+ commit 2e0db4bc649e174d667a1cde19e725cf897a5bd2
+ Author: A U Thor <author@example.com>
+ Date: Thu Apr 7 15:21:13 2005 -0700
+
+ ${indent}9th
+
+ Notes:
+ ${indent}yet another note
+ ${indent}
+ ${indent}yet another note
+ EOF
git notes append -C $(git notes list HEAD^) HEAD^ &&
- git log -1 HEAD^ > actual &&
+ git log -1 HEAD^ >actual &&
test_cmp expect actual
'
-cat > expect << EOF
-commit ffed603236bfa3891c49644257a83598afe8ae5a
-Author: A U Thor <author@example.com>
-Date: Thu Apr 7 15:22:13 2005 -0700
+test_expect_success 'create note from other note with "git notes append -c"' '
+ cat >expect <<-EOF &&
+ commit 7c3b87ab368f81e11b1ea87b2ab99a71ccd25406
+ Author: A U Thor <author@example.com>
+ Date: Thu Apr 7 15:22:13 2005 -0700
- 10th
+ ${indent}10th
-Notes (other):
- other note
-EOF
-
-test_expect_success 'create note from other note with "git notes append -c"' '
+ Notes:
+ ${indent}other note
+ EOF
MSG="other note" git notes append -c $(git notes list HEAD^) &&
- git log -1 > actual &&
+ git log -1 >actual &&
test_cmp expect actual
'
-cat > expect << EOF
-commit ffed603236bfa3891c49644257a83598afe8ae5a
-Author: A U Thor <author@example.com>
-Date: Thu Apr 7 15:22:13 2005 -0700
-
- 10th
-
-Notes (other):
- other note
-$whitespace
- yet another note
-EOF
-
test_expect_success 'append to note from other note with "git notes append -c"' '
+ cat >expect <<-EOF &&
+ commit 7c3b87ab368f81e11b1ea87b2ab99a71ccd25406
+ Author: A U Thor <author@example.com>
+ Date: Thu Apr 7 15:22:13 2005 -0700
+
+ ${indent}10th
+
+ Notes:
+ ${indent}other note
+ ${indent}
+ ${indent}yet another note
+ EOF
MSG="yet another note" git notes append -c $(git notes list HEAD) &&
- git log -1 > actual &&
+ git log -1 >actual &&
test_cmp expect actual
'
-cat > expect << EOF
-commit 6352c5e33dbcab725fe0579be16aa2ba8eb369be
-Author: A U Thor <author@example.com>
-Date: Thu Apr 7 15:23:13 2005 -0700
-
- 11th
-
-Notes (other):
- other note
-$whitespace
- yet another note
-EOF
-
test_expect_success 'copy note with "git notes copy"' '
- : > a11 &&
- git add a11 &&
- test_tick &&
- git commit -m 11th &&
+ cat >expect <<-EOF &&
+ commit a446fff8777efdc6eb8f4b7c8a5ff699484df0d5
+ Author: A U Thor <author@example.com>
+ Date: Thu Apr 7 15:23:13 2005 -0700
+
+ ${indent}11th
+
+ Notes:
+ ${indent}other note
+ ${indent}
+ ${indent}yet another note
+ EOF
+ test_commit 11th &&
git notes copy HEAD^ HEAD &&
- git log -1 > actual &&
+ git log -1 >actual &&
test_cmp expect actual &&
test "$(git notes list HEAD)" = "$(git notes list HEAD^)"
'
test_expect_success 'prevent overwrite with "git notes copy"' '
test_must_fail git notes copy HEAD~2 HEAD &&
- git log -1 > actual &&
+ git log -1 >actual &&
test_cmp expect actual &&
test "$(git notes list HEAD)" = "$(git notes list HEAD^)"
'
-cat > expect << EOF
-commit 6352c5e33dbcab725fe0579be16aa2ba8eb369be
-Author: A U Thor <author@example.com>
-Date: Thu Apr 7 15:23:13 2005 -0700
-
- 11th
-
-Notes (other):
- yet another note
-$whitespace
- yet another note
-EOF
-
test_expect_success 'allow overwrite with "git notes copy -f"' '
+ cat >expect <<-EOF &&
+ commit a446fff8777efdc6eb8f4b7c8a5ff699484df0d5
+ Author: A U Thor <author@example.com>
+ Date: Thu Apr 7 15:23:13 2005 -0700
+
+ ${indent}11th
+
+ Notes:
+ ${indent}yet another note
+ ${indent}
+ ${indent}yet another note
+ EOF
git notes copy -f HEAD~2 HEAD &&
- git log -1 > actual &&
+ git log -1 >actual &&
test_cmp expect actual &&
test "$(git notes list HEAD)" = "$(git notes list HEAD~2)"
'
test_expect_success 'cannot copy note from object without notes' '
- : > a12 &&
- git add a12 &&
- test_tick &&
- git commit -m 12th &&
- : > a13 &&
- git add a13 &&
- test_tick &&
- git commit -m 13th &&
+ test_commit 12th &&
+ test_commit 13th &&
test_must_fail git notes copy HEAD^ HEAD
'
-cat > expect << EOF
-commit e5d4fb5698d564ab8c73551538ecaf2b0c666185
-Author: A U Thor <author@example.com>
-Date: Thu Apr 7 15:25:13 2005 -0700
-
- 13th
+test_expect_success 'git notes copy --stdin' '
+ cat >expect <<-EOF &&
+ commit e871aa61182b1d95d0a6fb75445d891722863b6b
+ Author: A U Thor <author@example.com>
+ Date: Thu Apr 7 15:25:13 2005 -0700
-Notes (other):
- yet another note
-$whitespace
- yet another note
+ ${indent}13th
-commit 7038787dfe22a14c3867ce816dbba39845359719
-Author: A U Thor <author@example.com>
-Date: Thu Apr 7 15:24:13 2005 -0700
+ Notes:
+ ${indent}yet another note
+ ${indent}
+ ${indent}yet another note
- 12th
+ commit 65e263ded02ae4e8839bc151095113737579dc12
+ Author: A U Thor <author@example.com>
+ Date: Thu Apr 7 15:24:13 2005 -0700
-Notes (other):
- other note
-$whitespace
- yet another note
-EOF
+ ${indent}12th
-test_expect_success 'git notes copy --stdin' '
+ Notes:
+ ${indent}other note
+ ${indent}
+ ${indent}yet another note
+ EOF
(echo $(git rev-parse HEAD~3) $(git rev-parse HEAD^); \
echo $(git rev-parse HEAD~2) $(git rev-parse HEAD)) |
git notes copy --stdin &&
- git log -2 > output &&
- test_cmp expect output &&
+ git log -2 >actual &&
+ test_cmp expect actual &&
test "$(git notes list HEAD)" = "$(git notes list HEAD~2)" &&
test "$(git notes list HEAD^)" = "$(git notes list HEAD~3)"
'
-cat > expect << EOF
-commit 37a0d4cba38afef96ba54a3ea567e6dac575700b
-Author: A U Thor <author@example.com>
-Date: Thu Apr 7 15:27:13 2005 -0700
-
- 15th
+test_expect_success 'git notes copy --for-rewrite (unconfigured)' '
+ cat >expect <<-EOF &&
+ commit 4acf42e847e7fffbbf89ee365c20ac7caf40de89
+ Author: A U Thor <author@example.com>
+ Date: Thu Apr 7 15:27:13 2005 -0700
-commit be28d8b4d9951ad940d229ee3b0b9ee3b1ec273d
-Author: A U Thor <author@example.com>
-Date: Thu Apr 7 15:26:13 2005 -0700
+ ${indent}15th
- 14th
-EOF
+ commit 07c85d77059393ed0154b8c96906547a59dfcddd
+ Author: A U Thor <author@example.com>
+ Date: Thu Apr 7 15:26:13 2005 -0700
-test_expect_success 'git notes copy --for-rewrite (unconfigured)' '
+ ${indent}14th
+ EOF
test_commit 14th &&
test_commit 15th &&
(echo $(git rev-parse HEAD~3) $(git rev-parse HEAD^); \
echo $(git rev-parse HEAD~2) $(git rev-parse HEAD)) |
git notes copy --for-rewrite=foo &&
- git log -2 > output &&
- test_cmp expect output
+ git log -2 >actual &&
+ test_cmp expect actual
'
-cat > expect << EOF
-commit 37a0d4cba38afef96ba54a3ea567e6dac575700b
-Author: A U Thor <author@example.com>
-Date: Thu Apr 7 15:27:13 2005 -0700
-
- 15th
-
-Notes (other):
- yet another note
-$whitespace
- yet another note
-
-commit be28d8b4d9951ad940d229ee3b0b9ee3b1ec273d
-Author: A U Thor <author@example.com>
-Date: Thu Apr 7 15:26:13 2005 -0700
-
- 14th
-
-Notes (other):
- other note
-$whitespace
- yet another note
-EOF
-
test_expect_success 'git notes copy --for-rewrite (enabled)' '
- git config notes.rewriteMode overwrite &&
- git config notes.rewriteRef "refs/notes/*" &&
+ cat >expect <<-EOF &&
+ commit 4acf42e847e7fffbbf89ee365c20ac7caf40de89
+ Author: A U Thor <author@example.com>
+ Date: Thu Apr 7 15:27:13 2005 -0700
+
+ ${indent}15th
+
+ Notes:
+ ${indent}yet another note
+ ${indent}
+ ${indent}yet another note
+
+ commit 07c85d77059393ed0154b8c96906547a59dfcddd
+ Author: A U Thor <author@example.com>
+ Date: Thu Apr 7 15:26:13 2005 -0700
+
+ ${indent}14th
+
+ Notes:
+ ${indent}other note
+ ${indent}
+ ${indent}yet another note
+ EOF
+ test_config notes.rewriteMode overwrite &&
+ test_config notes.rewriteRef "refs/notes/*" &&
(echo $(git rev-parse HEAD~3) $(git rev-parse HEAD^); \
echo $(git rev-parse HEAD~2) $(git rev-parse HEAD)) |
git notes copy --for-rewrite=foo &&
- git log -2 > output &&
- test_cmp expect output
+ git log -2 >actual &&
+ test_cmp expect actual
'
test_expect_success 'git notes copy --for-rewrite (disabled)' '
- git config notes.rewrite.bar false &&
+ test_config notes.rewrite.bar false &&
echo $(git rev-parse HEAD~3) $(git rev-parse HEAD) |
git notes copy --for-rewrite=bar &&
- git log -2 > output &&
- test_cmp expect output
+ git log -2 >actual &&
+ test_cmp expect actual
'
-cat > expect << EOF
-commit 37a0d4cba38afef96ba54a3ea567e6dac575700b
-Author: A U Thor <author@example.com>
-Date: Thu Apr 7 15:27:13 2005 -0700
-
- 15th
+test_expect_success 'git notes copy --for-rewrite (overwrite)' '
+ cat >expect <<-EOF &&
+ commit 4acf42e847e7fffbbf89ee365c20ac7caf40de89
+ Author: A U Thor <author@example.com>
+ Date: Thu Apr 7 15:27:13 2005 -0700
-Notes (other):
- a fresh note
-EOF
+ ${indent}15th
-test_expect_success 'git notes copy --for-rewrite (overwrite)' '
+ Notes:
+ ${indent}a fresh note
+ EOF
git notes add -f -m"a fresh note" HEAD^ &&
+ test_config notes.rewriteMode overwrite &&
+ test_config notes.rewriteRef "refs/notes/*" &&
echo $(git rev-parse HEAD^) $(git rev-parse HEAD) |
git notes copy --for-rewrite=foo &&
- git log -1 > output &&
- test_cmp expect output
+ git log -1 >actual &&
+ test_cmp expect actual
'
test_expect_success 'git notes copy --for-rewrite (ignore)' '
- git config notes.rewriteMode ignore &&
+ test_config notes.rewriteMode ignore &&
+ test_config notes.rewriteRef "refs/notes/*" &&
echo $(git rev-parse HEAD^) $(git rev-parse HEAD) |
git notes copy --for-rewrite=foo &&
- git log -1 > output &&
- test_cmp expect output
+ git log -1 >actual &&
+ test_cmp expect actual
'
-cat > expect << EOF
-commit 37a0d4cba38afef96ba54a3ea567e6dac575700b
-Author: A U Thor <author@example.com>
-Date: Thu Apr 7 15:27:13 2005 -0700
-
- 15th
-
-Notes (other):
- a fresh note
-$whitespace
- another fresh note
-EOF
-
test_expect_success 'git notes copy --for-rewrite (append)' '
+ cat >expect <<-EOF &&
+ commit 4acf42e847e7fffbbf89ee365c20ac7caf40de89
+ Author: A U Thor <author@example.com>
+ Date: Thu Apr 7 15:27:13 2005 -0700
+
+ ${indent}15th
+
+ Notes:
+ ${indent}a fresh note
+ ${indent}
+ ${indent}another fresh note
+ EOF
git notes add -f -m"another fresh note" HEAD^ &&
- git config notes.rewriteMode concatenate &&
+ test_config notes.rewriteMode concatenate &&
+ test_config notes.rewriteRef "refs/notes/*" &&
echo $(git rev-parse HEAD^) $(git rev-parse HEAD) |
git notes copy --for-rewrite=foo &&
- git log -1 > output &&
- test_cmp expect output
+ git log -1 >actual &&
+ test_cmp expect actual
'
-cat > expect << EOF
-commit 37a0d4cba38afef96ba54a3ea567e6dac575700b
-Author: A U Thor <author@example.com>
-Date: Thu Apr 7 15:27:13 2005 -0700
-
- 15th
-
-Notes (other):
- a fresh note
-$whitespace
- another fresh note
-$whitespace
- append 1
-$whitespace
- append 2
-EOF
-
test_expect_success 'git notes copy --for-rewrite (append two to one)' '
+ cat >expect <<-EOF &&
+ commit 4acf42e847e7fffbbf89ee365c20ac7caf40de89
+ Author: A U Thor <author@example.com>
+ Date: Thu Apr 7 15:27:13 2005 -0700
+
+ ${indent}15th
+
+ Notes:
+ ${indent}a fresh note
+ ${indent}
+ ${indent}another fresh note
+ ${indent}
+ ${indent}append 1
+ ${indent}
+ ${indent}append 2
+ EOF
git notes add -f -m"append 1" HEAD^ &&
git notes add -f -m"append 2" HEAD^^ &&
+ test_config notes.rewriteMode concatenate &&
+ test_config notes.rewriteRef "refs/notes/*" &&
(echo $(git rev-parse HEAD^) $(git rev-parse HEAD);
echo $(git rev-parse HEAD^^) $(git rev-parse HEAD)) |
git notes copy --for-rewrite=foo &&
- git log -1 > output &&
- test_cmp expect output
+ git log -1 >actual &&
+ test_cmp expect actual
'
test_expect_success 'git notes copy --for-rewrite (append empty)' '
git notes remove HEAD^ &&
+ test_config notes.rewriteMode concatenate &&
+ test_config notes.rewriteRef "refs/notes/*" &&
echo $(git rev-parse HEAD^) $(git rev-parse HEAD) |
git notes copy --for-rewrite=foo &&
- git log -1 > output &&
- test_cmp expect output
+ git log -1 >actual &&
+ test_cmp expect actual
'
-cat > expect << EOF
-commit 37a0d4cba38afef96ba54a3ea567e6dac575700b
-Author: A U Thor <author@example.com>
-Date: Thu Apr 7 15:27:13 2005 -0700
-
- 15th
-
-Notes (other):
- replacement note 1
-EOF
-
test_expect_success 'GIT_NOTES_REWRITE_MODE works' '
+ cat >expect <<-EOF &&
+ commit 4acf42e847e7fffbbf89ee365c20ac7caf40de89
+ Author: A U Thor <author@example.com>
+ Date: Thu Apr 7 15:27:13 2005 -0700
+
+ ${indent}15th
+
+ Notes:
+ ${indent}replacement note 1
+ EOF
+ test_config notes.rewriteMode concatenate &&
+ test_config notes.rewriteRef "refs/notes/*" &&
git notes add -f -m"replacement note 1" HEAD^ &&
echo $(git rev-parse HEAD^) $(git rev-parse HEAD) |
GIT_NOTES_REWRITE_MODE=overwrite git notes copy --for-rewrite=foo &&
- git log -1 > output &&
- test_cmp expect output
+ git log -1 >actual &&
+ test_cmp expect actual
'
-cat > expect << EOF
-commit 37a0d4cba38afef96ba54a3ea567e6dac575700b
-Author: A U Thor <author@example.com>
-Date: Thu Apr 7 15:27:13 2005 -0700
+test_expect_success 'GIT_NOTES_REWRITE_REF works' '
+ cat >expect <<-EOF &&
+ commit 4acf42e847e7fffbbf89ee365c20ac7caf40de89
+ Author: A U Thor <author@example.com>
+ Date: Thu Apr 7 15:27:13 2005 -0700
- 15th
+ ${indent}15th
-Notes (other):
- replacement note 2
-EOF
-
-test_expect_success 'GIT_NOTES_REWRITE_REF works' '
- git config notes.rewriteMode overwrite &&
+ Notes:
+ ${indent}replacement note 2
+ EOF
git notes add -f -m"replacement note 2" HEAD^ &&
- git config --unset-all notes.rewriteRef &&
+ test_config notes.rewriteMode overwrite &&
+ test_unconfig notes.rewriteRef &&
echo $(git rev-parse HEAD^) $(git rev-parse HEAD) |
GIT_NOTES_REWRITE_REF=refs/notes/commits:refs/notes/other \
git notes copy --for-rewrite=foo &&
- git log -1 > output &&
- test_cmp expect output
+ git log -1 >actual &&
+ test_cmp expect actual
'
test_expect_success 'GIT_NOTES_REWRITE_REF overrides config' '
- git config notes.rewriteRef refs/notes/other &&
git notes add -f -m"replacement note 3" HEAD^ &&
+ test_config notes.rewriteMode overwrite &&
+ test_config notes.rewriteRef refs/notes/other &&
echo $(git rev-parse HEAD^) $(git rev-parse HEAD) |
GIT_NOTES_REWRITE_REF= git notes copy --for-rewrite=foo &&
- git log -1 > output &&
- test_cmp expect output
+ git log -1 >actual &&
+ test_cmp expect actual
'
test_expect_success 'git notes copy diagnoses too many or too few parameters' '
@@ -1221,13 +1123,13 @@ test_expect_success 'git notes copy diagnoses too many or too few parameters' '
'
test_expect_success 'git notes get-ref (no overrides)' '
- git config --unset core.notesRef &&
+ test_unconfig core.notesRef &&
sane_unset GIT_NOTES_REF &&
test "$(git notes get-ref)" = "refs/notes/commits"
'
test_expect_success 'git notes get-ref (core.notesRef)' '
- git config core.notesRef refs/notes/foo &&
+ test_config core.notesRef refs/notes/foo &&
test "$(git notes get-ref)" = "refs/notes/foo"
'
@@ -1239,4 +1141,51 @@ test_expect_success 'git notes get-ref (--ref)' '
test "$(GIT_NOTES_REF=refs/notes/bar git notes --ref=baz get-ref)" = "refs/notes/baz"
'
+test_expect_success 'setup testing of empty notes' '
+ test_unconfig core.notesRef &&
+ test_commit 16th &&
+ empty_blob=$(git hash-object -w /dev/null) &&
+ echo "$empty_blob" >expect_empty
+'
+
+while read cmd
+do
+ test_expect_success "'git notes $cmd' removes empty note" "
+ test_might_fail git notes remove HEAD &&
+ MSG= git notes $cmd &&
+ test_must_fail git notes list HEAD
+ "
+
+ test_expect_success "'git notes $cmd --allow-empty' stores empty note" "
+ test_might_fail git notes remove HEAD &&
+ MSG= git notes $cmd --allow-empty &&
+ git notes list HEAD >actual &&
+ test_cmp expect_empty actual
+ "
+done <<\EOF
+add
+add -F /dev/null
+add -m ""
+add -c "$empty_blob"
+add -C "$empty_blob"
+append
+append -F /dev/null
+append -m ""
+append -c "$empty_blob"
+append -C "$empty_blob"
+edit
+EOF
+
+test_expect_success 'empty notes are displayed by git log' '
+ test_commit 17th &&
+ git log -1 >expect &&
+ cat >>expect <<-EOF &&
+
+ Notes:
+ EOF
+ git notes add -C "$empty_blob" --allow-empty &&
+ git log -1 >actual &&
+ test_cmp expect actual
+'
+
test_done
diff --git a/t/t3507-cherry-pick-conflict.sh b/t/t3507-cherry-pick-conflict.sh
index 223b984..7c5ad08 100755
--- a/t/t3507-cherry-pick-conflict.sh
+++ b/t/t3507-cherry-pick-conflict.sh
@@ -351,19 +351,45 @@ test_expect_success 'commit after failed cherry-pick does not add duplicated -s'
test_expect_success 'commit after failed cherry-pick adds -s at the right place' '
pristine_detach initial &&
test_must_fail git cherry-pick picked &&
+
git commit -a -s &&
- pwd &&
- cat <<EOF > expected &&
-picked
-Signed-off-by: C O Mitter <committer@example.com>
+ # Do S-o-b and Conflicts appear in the right order?
+ cat <<-\EOF >expect &&
+ Signed-off-by: C O Mitter <committer@example.com>
+ # Conflicts:
+ EOF
+ grep -e "^# Conflicts:" -e '^Signed-off-by' <.git/COMMIT_EDITMSG >actual &&
+ test_cmp expect actual &&
+
+ cat <<-\EOF >expected &&
+ picked
-Conflicts:
- foo
-EOF
+ Signed-off-by: C O Mitter <committer@example.com>
+ EOF
- git show -s --pretty=format:%B > actual &&
+ git show -s --pretty=format:%B >actual &&
test_cmp expected actual
'
+test_expect_success 'commit --amend -s places the sign-off at the right place' '
+ pristine_detach initial &&
+ test_must_fail git cherry-pick picked &&
+
+ # emulate old-style conflicts block
+ mv .git/MERGE_MSG .git/MERGE_MSG+ &&
+ sed -e "/^# Conflicts:/,\$s/^# *//" <.git/MERGE_MSG+ >.git/MERGE_MSG &&
+
+ git commit -a &&
+ git commit --amend -s &&
+
+ # Do S-o-b and Conflicts appear in the right order?
+ cat <<-\EOF >expect &&
+ Signed-off-by: C O Mitter <committer@example.com>
+ Conflicts:
+ EOF
+ grep -e "^Conflicts:" -e '^Signed-off-by' <.git/COMMIT_EDITMSG >actual &&
+ test_cmp expect actual
+'
+
test_done
diff --git a/t/t4026-color.sh b/t/t4026-color.sh
index 3726a0e..63e4238 100755
--- a/t/t4026-color.sh
+++ b/t/t4026-color.sh
@@ -53,6 +53,14 @@ test_expect_success '256 colors' '
color "254 bold 255" "[1;38;5;254;48;5;255m"
'
+test_expect_success '"normal" yields no color at all"' '
+ color "normal black" "[40m"
+'
+
+test_expect_success '-1 is a synonym for "normal"' '
+ color "-1 black" "[40m"
+'
+
test_expect_success 'color too small' '
invalid_color "-2"
'
diff --git a/t/t5528-push-default.sh b/t/t5528-push-default.sh
index 6a5ac3a..cc74519 100755
--- a/t/t5528-push-default.sh
+++ b/t/t5528-push-default.sh
@@ -26,7 +26,7 @@ check_pushed_commit () {
# $2 = expected target branch for the push
# $3 = [optional] repo to check for actual output (repo1 by default)
test_push_success () {
- git -c push.default="$1" push &&
+ git ${1:+-c push.default="$1"} push &&
check_pushed_commit HEAD "$2" "$3"
}
@@ -34,7 +34,7 @@ test_push_success () {
# check that push fails and does not modify any remote branch
test_push_failure () {
git --git-dir=repo1 log --no-walk --format='%h %s' --all >expect &&
- test_must_fail git -c push.default="$1" push &&
+ test_must_fail git ${1:+-c push.default="$1"} push &&
git --git-dir=repo1 log --no-walk --format='%h %s' --all >actual &&
test_cmp expect actual
}
@@ -172,4 +172,32 @@ test_pushdefault_workflow success simple master triangular
# master is updated (parent2 does not have foo)
test_pushdefault_workflow success matching master triangular
+# default tests, when no push-default is specified. This
+# should behave the same as "simple" in non-triangular
+# settings, and as "current" otherwise.
+
+test_expect_success 'default behavior allows "simple" push' '
+ test_config branch.master.remote parent1 &&
+ test_config branch.master.merge refs/heads/master &&
+ test_config remote.pushdefault parent1 &&
+ test_commit default-master-master &&
+ test_push_success "" master
+'
+
+test_expect_success 'default behavior rejects non-simple push' '
+ test_config branch.master.remote parent1 &&
+ test_config branch.master.merge refs/heads/foo &&
+ test_config remote.pushdefault parent1 &&
+ test_commit default-master-foo &&
+ test_push_failure ""
+'
+
+test_expect_success 'default triangular behavior acts like "current"' '
+ test_config branch.master.remote parent1 &&
+ test_config branch.master.merge refs/heads/foo &&
+ test_config remote.pushdefault parent2 &&
+ test_commit default-triangular &&
+ test_push_success "" master repo2
+'
+
test_done
diff --git a/t/t7513-interpret-trailers.sh b/t/t7513-interpret-trailers.sh
index 1efb880..bd0ab46 100755
--- a/t/t7513-interpret-trailers.sh
+++ b/t/t7513-interpret-trailers.sh
@@ -213,7 +213,7 @@ test_expect_success 'with 2 files arguments' '
'
test_expect_success 'with message that has comments' '
- cat basic_message >>message_with_comments &&
+ cat basic_message >message_with_comments &&
sed -e "s/ Z\$/ /" >>message_with_comments <<-\EOF &&
# comment
@@ -232,12 +232,44 @@ test_expect_success 'with message that has comments' '
Reviewed-by: Johan
Cc: Peff
+ # last comment
+
EOF
cat basic_patch >>expected &&
git interpret-trailers --trim-empty --trailer "Cc: Peff" message_with_comments >actual &&
test_cmp expected actual
'
+test_expect_success 'with message that has an old style conflict block' '
+ cat basic_message >message_with_comments &&
+ sed -e "s/ Z\$/ /" >>message_with_comments <<-\EOF &&
+ # comment
+
+ # other comment
+ Cc: Z
+ # yet another comment
+ Reviewed-by: Johan
+ Reviewed-by: Z
+ # last comment
+
+ Conflicts:
+
+ EOF
+ cat basic_message >expected &&
+ cat >>expected <<-\EOF &&
+ # comment
+
+ Reviewed-by: Johan
+ Cc: Peff
+ # last comment
+
+ Conflicts:
+
+ EOF
+ git interpret-trailers --trim-empty --trailer "Cc: Peff" message_with_comments >actual &&
+ test_cmp expected actual
+'
+
test_expect_success 'with commit complex message and trailer args' '
cat complex_message_body >expected &&
sed -e "s/ Z\$/ /" >>expected <<-\EOF &&
diff --git a/t/t9603-cvsimport-patchsets.sh b/t/t9603-cvsimport-patchsets.sh
index 52034c8..c4c3c49 100755
--- a/t/t9603-cvsimport-patchsets.sh
+++ b/t/t9603-cvsimport-patchsets.sh
@@ -16,7 +16,7 @@ test_description='git cvsimport testing for correct patchset estimation'
setup_cvs_test_repository t9603
-test_expect_failure 'import with criss cross times on revisions' '
+test_expect_failure PERL 'import with criss cross times on revisions' '
git cvsimport -p"-x" -C module-git module &&
(cd module-git &&
diff --git a/t/t9604-cvsimport-timestamps.sh b/t/t9604-cvsimport-timestamps.sh
index 1fd5142..a4b3db2 100755
--- a/t/t9604-cvsimport-timestamps.sh
+++ b/t/t9604-cvsimport-timestamps.sh
@@ -5,7 +5,7 @@ test_description='git cvsimport timestamps'
setup_cvs_test_repository t9604
-test_expect_success 'check timestamps are UTC (TZ=CST6CDT)' '
+test_expect_success PERL 'check timestamps are UTC (TZ=CST6CDT)' '
TZ=CST6CDT git cvsimport -p"-x" -C module-1 module &&
git cvsimport -p"-x" -C module-1 module &&
@@ -34,7 +34,7 @@ test_expect_success 'check timestamps are UTC (TZ=CST6CDT)' '
test_cmp actual-1 expect-1
'
-test_expect_success 'check timestamps with author-specific timezones' '
+test_expect_success PERL 'check timestamps with author-specific timezones' '
cat >cvs-authors <<-EOF &&
user1=User One <user1@domain.org>
diff --git a/t/test-lib.sh b/t/test-lib.sh
index cf19339..79e8a33 100644
--- a/t/test-lib.sh
+++ b/t/test-lib.sh
@@ -169,7 +169,11 @@ _z40=0000000000000000000000000000000000000000
LF='
'
-export _x05 _x40 _z40 LF
+# UTF-8 ZERO WIDTH NON-JOINER, which HFS+ ignores
+# when case-folding filenames
+u200c=$(printf '\342\200\214')
+
+export _x05 _x40 _z40 LF u200c
# Each test should start with something like this, after copyright notices:
#
diff --git a/trailer.c b/trailer.c
index a905f5c..623adeb 100644
--- a/trailer.c
+++ b/trailer.c
@@ -2,6 +2,7 @@
#include "string-list.h"
#include "run-command.h"
#include "string-list.h"
+#include "commit.h"
#include "trailer.h"
/*
* Copyright (c) 2013, 2014 Christian Couder <chriscool@tuxfamily.org>
@@ -768,6 +769,22 @@ static int find_trailer_start(struct strbuf **lines, int count)
return only_spaces ? count : 0;
}
+/* Get the index of the end of the trailers */
+static int find_trailer_end(struct strbuf **lines, int patch_start)
+{
+ struct strbuf sb = STRBUF_INIT;
+ int i, ignore_bytes;
+
+ for (i = 0; i < patch_start; i++)
+ strbuf_addbuf(&sb, lines[i]);
+ ignore_bytes = ignore_non_trailer(&sb);
+ strbuf_release(&sb);
+ for (i = patch_start - 1; i >= 0 && ignore_bytes > 0; i--)
+ ignore_bytes -= lines[i]->len;
+
+ return i + 1;
+}
+
static int has_blank_line_before(struct strbuf **lines, int start)
{
for (;start >= 0; start--) {
@@ -790,14 +807,15 @@ static int process_input_file(struct strbuf **lines,
struct trailer_item **in_tok_last)
{
int count = 0;
- int patch_start, trailer_start, i;
+ int patch_start, trailer_start, trailer_end, i;
/* Get the line count */
while (lines[count])
count++;
patch_start = find_patch_start(lines, count);
- trailer_start = find_trailer_start(lines, patch_start);
+ trailer_end = find_trailer_end(lines, patch_start);
+ trailer_start = find_trailer_start(lines, trailer_end);
/* Print lines before the trailers as is */
print_lines(lines, 0, trailer_start);
@@ -806,14 +824,14 @@ static int process_input_file(struct strbuf **lines,
printf("\n");
/* Parse trailer lines */
- for (i = trailer_start; i < patch_start; i++) {
+ for (i = trailer_start; i < trailer_end; i++) {
if (lines[i]->buf[0] != comment_line_char) {
struct trailer_item *new = create_trailer_item(lines[i]->buf);
add_trailer_item(in_tok_first, in_tok_last, new);
}
}
- return patch_start;
+ return trailer_end;
}
static void free_all(struct trailer_item **first)
@@ -830,7 +848,7 @@ void process_trailers(const char *file, int trim_empty, struct string_list *trai
struct trailer_item *in_tok_last = NULL;
struct trailer_item *arg_tok_first;
struct strbuf **lines;
- int patch_start;
+ int trailer_end;
/* Default config must be setup first */
git_config(git_trailer_default_config, NULL);
@@ -839,7 +857,7 @@ void process_trailers(const char *file, int trim_empty, struct string_list *trai
lines = read_input_file(file);
/* Print the lines before the trailers */
- patch_start = process_input_file(lines, &in_tok_first, &in_tok_last);
+ trailer_end = process_input_file(lines, &in_tok_first, &in_tok_last);
arg_tok_first = process_command_line_args(trailers);
@@ -850,7 +868,7 @@ void process_trailers(const char *file, int trim_empty, struct string_list *trai
free_all(&in_tok_first);
/* Print the lines after the trailers as is */
- print_lines(lines, patch_start, INT_MAX);
+ print_lines(lines, trailer_end, INT_MAX);
strbuf_list_free(lines);
}
diff --git a/unpack-trees.c b/unpack-trees.c
index 629c658..be84ba2 100644
--- a/unpack-trees.c
+++ b/unpack-trees.c
@@ -98,7 +98,7 @@ void setup_unpack_trees_porcelain(struct unpack_trees_options *opts,
opts->unpack_rejects[i].strdup_strings = 1;
}
-static void do_add_entry(struct unpack_trees_options *o, struct cache_entry *ce,
+static int do_add_entry(struct unpack_trees_options *o, struct cache_entry *ce,
unsigned int set, unsigned int clear)
{
clear |= CE_HASHED;
@@ -107,8 +107,8 @@ static void do_add_entry(struct unpack_trees_options *o, struct cache_entry *ce,
set |= CE_WT_REMOVE;
ce->ce_flags = (ce->ce_flags & ~clear) | set;
- add_index_entry(&o->result, ce,
- ADD_CACHE_OK_TO_ADD | ADD_CACHE_OK_TO_REPLACE);
+ return add_index_entry(&o->result, ce,
+ ADD_CACHE_OK_TO_ADD | ADD_CACHE_OK_TO_REPLACE);
}
static struct cache_entry *dup_entry(const struct cache_entry *ce)
@@ -609,7 +609,9 @@ static int unpack_nondirectories(int n, unsigned long mask,
for (i = 0; i < n; i++)
if (src[i] && src[i] != o->df_conflict_entry)
- do_add_entry(o, src[i], 0, 0);
+ if (do_add_entry(o, src[i], 0, 0))
+ return -1;
+
return 0;
}
@@ -1155,6 +1157,8 @@ int unpack_trees(unsigned len, struct tree_desc *t, struct unpack_trees_options
if (o->dst_index) {
discard_index(o->dst_index);
*o->dst_index = o->result;
+ } else {
+ discard_index(&o->result);
}
done:
diff --git a/utf8.c b/utf8.c
index 4541777..9a3f4ad 100644
--- a/utf8.c
+++ b/utf8.c
@@ -561,3 +561,67 @@ int mbs_chrlen(const char **text, size_t *remainder_p, const char *encoding)
return chrlen;
}
+
+/*
+ * Pick the next char from the stream, folding as an HFS+ filename comparison
+ * would. Note that this is _not_ complete by any means. It's just enough
+ * to make is_hfs_dotgit() work, and should not be used otherwise.
+ */
+static ucs_char_t next_hfs_char(const char **in)
+{
+ while (1) {
+ ucs_char_t out = pick_one_utf8_char(in, NULL);
+ /*
+ * check for malformed utf8. Technically this
+ * gets converted to a percent-sequence, but
+ * returning 0 is good enough for is_hfs_dotgit
+ * to realize it cannot be .git
+ */
+ if (!*in)
+ return 0;
+
+ /* these code points are ignored completely */
+ switch (out) {
+ case 0x200c: /* ZERO WIDTH NON-JOINER */
+ case 0x200d: /* ZERO WIDTH JOINER */
+ case 0x200e: /* LEFT-TO-RIGHT MARK */
+ case 0x200f: /* RIGHT-TO-LEFT MARK */
+ case 0x202a: /* LEFT-TO-RIGHT EMBEDDING */
+ case 0x202b: /* RIGHT-TO-LEFT EMBEDDING */
+ case 0x202c: /* POP DIRECTIONAL FORMATTING */
+ case 0x202d: /* LEFT-TO-RIGHT OVERRIDE */
+ case 0x202e: /* RIGHT-TO-LEFT OVERRIDE */
+ case 0x206a: /* INHIBIT SYMMETRIC SWAPPING */
+ case 0x206b: /* ACTIVATE SYMMETRIC SWAPPING */
+ case 0x206c: /* INHIBIT ARABIC FORM SHAPING */
+ case 0x206d: /* ACTIVATE ARABIC FORM SHAPING */
+ case 0x206e: /* NATIONAL DIGIT SHAPES */
+ case 0x206f: /* NOMINAL DIGIT SHAPES */
+ case 0xfeff: /* ZERO WIDTH NO-BREAK SPACE */
+ continue;
+ }
+
+ /*
+ * there's a great deal of other case-folding that occurs,
+ * but this is enough to catch anything that will convert
+ * to ".git"
+ */
+ return tolower(out);
+ }
+}
+
+int is_hfs_dotgit(const char *path)
+{
+ ucs_char_t c;
+
+ if (next_hfs_char(&path) != '.' ||
+ next_hfs_char(&path) != 'g' ||
+ next_hfs_char(&path) != 'i' ||
+ next_hfs_char(&path) != 't')
+ return 0;
+ c = next_hfs_char(&path);
+ if (c && !is_dir_sep(c))
+ return 0;
+
+ return 1;
+}
diff --git a/utf8.h b/utf8.h
index 65d0e42..e4d9183 100644
--- a/utf8.h
+++ b/utf8.h
@@ -42,4 +42,12 @@ static inline char *reencode_string(const char *in,
int mbs_chrlen(const char **text, size_t *remainder_p, const char *encoding);
+/*
+ * Returns true if the the path would match ".git" after HFS case-folding.
+ * The path should be NUL-terminated, but we will match variants of both ".git\0"
+ * and ".git/..." (but _not_ ".../.git"). This makes it suitable for both fsck
+ * and verify_path().
+ */
+int is_hfs_dotgit(const char *path);
+
#endif
diff --git a/wt-status.c b/wt-status.c
index cdbc8d7..b54eac5 100644
--- a/wt-status.c
+++ b/wt-status.c
@@ -726,7 +726,6 @@ static void wt_status_print_changed(struct wt_status *s)
static void wt_status_print_submodule_summary(struct wt_status *s, int uncommitted)
{
struct child_process sm_summary = CHILD_PROCESS_INIT;
- struct argv_array argv = ARGV_ARRAY_INIT;
struct strbuf cmd_stdout = STRBUF_INIT;
struct strbuf summary = STRBUF_INIT;
char *summary_content;
@@ -735,23 +734,21 @@ static void wt_status_print_submodule_summary(struct wt_status *s, int uncommitt
argv_array_pushf(&sm_summary.env_array, "GIT_INDEX_FILE=%s",
s->index_file);
- argv_array_push(&argv, "submodule");
- argv_array_push(&argv, "summary");
- argv_array_push(&argv, uncommitted ? "--files" : "--cached");
- argv_array_push(&argv, "--for-status");
- argv_array_push(&argv, "--summary-limit");
- argv_array_pushf(&argv, "%d", s->submodule_summary);
+ argv_array_push(&sm_summary.args, "submodule");
+ argv_array_push(&sm_summary.args, "summary");
+ argv_array_push(&sm_summary.args, uncommitted ? "--files" : "--cached");
+ argv_array_push(&sm_summary.args, "--for-status");
+ argv_array_push(&sm_summary.args, "--summary-limit");
+ argv_array_pushf(&sm_summary.args, "%d", s->submodule_summary);
if (!uncommitted)
- argv_array_push(&argv, s->amend ? "HEAD^" : "HEAD");
+ argv_array_push(&sm_summary.args, s->amend ? "HEAD^" : "HEAD");
- sm_summary.argv = argv.argv;
sm_summary.git_cmd = 1;
sm_summary.no_stdin = 1;
fflush(s->fp);
sm_summary.out = -1;
run_command(&sm_summary);
- argv_array_clear(&argv);
len = strbuf_read(&cmd_stdout, sm_summary.out, 1024);