Compare commits

..

38 Commits

Author SHA1 Message Date
3ab228137f Git 2.11.0-rc1
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2016-11-11 14:04:32 -08:00
371811751d Merge branch 'rt/fetch-pack-error-message-fix'
An error message in fetch-pack executable that was newly marked for
translation was misspelt, which has been fixed.

* rt/fetch-pack-error-message-fix:
  fetch-pack.c: correct command at the beginning of an error message
2016-11-11 13:56:31 -08:00
12133d52c1 Merge branch 'ps/common-info-doc'
Doc fix.

* ps/common-info-doc:
  doc: fix location of 'info/' with $GIT_COMMON_DIR
2016-11-11 13:56:31 -08:00
7f2a3921fb Merge branch 'js/pwd-var-vs-pwd-cmd-fix'
Last minute fixes to two fixups merged to 'master' recently.

* js/pwd-var-vs-pwd-cmd-fix:
  t0021, t5615: use $PWD instead of $(pwd) in PATH-like shell variables
2016-11-11 13:56:30 -08:00
332fd5655a Merge branch 'ls/macos-update'
Portability update and workaround for builds on recent Mac OS X.

* ls/macos-update:
  travis-ci: disable GIT_TEST_HTTPD for macOS
  Makefile: set NO_OPENSSL on macOS by default
2016-11-11 13:56:30 -08:00
5de732f647 Merge branch 'js/prepare-sequencer'
Silence a clang warning introduced by a recently graduated topic.

* js/prepare-sequencer:
  sequencer: silence -Wtautological-constant-out-of-range-compare
2016-11-11 13:56:30 -08:00
b18f6a0066 Merge branch 'ls/filter-process'
Test portability improvements and optimization for an
already-graduated topic.

* ls/filter-process:
  t0021: remove debugging cruft
2016-11-11 13:56:30 -08:00
f5a8ad4c5a Merge branch 'as/merge-attr-sleep'
Fix for a racy false-positive test failure.

* as/merge-attr-sleep:
  t6026: clarify the point of "kill $(cat sleep.pid)"
  t6026: ensure that long-running script really is
  Revert "t6026-merge-attr: don't fail if sleep exits early"
  Revert "t6026-merge-attr: ensure that the merge driver was called"
  t6026-merge-attr: ensure that the merge driver was called
  t6026-merge-attr: don't fail if sleep exits early
2016-11-11 13:56:30 -08:00
dfbfb9f377 fetch-pack.c: correct command at the beginning of an error message
One error message in fetch-pack.c uses 'git fetch_pack' at the beginning
which is not a git command.  Use 'git fetch-pack' instead.

Signed-off-by: Ralf Thielow <ralf.thielow@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2016-11-11 13:28:39 -08:00
a0d8b60da8 t0021: remove debugging cruft
The redirection of the standard error stream to a temporary file is
a leftover cruft during debugging.  Remove it.

Besides, it is reported by folks on the Windows that the test is
flaky with this redirection; somebody gets confused and this
merely-redirected-to file gets marked as delete-pending by git.exe
and makes it finish with a non-zero exit status when "git checkout"
finishes.  Windows folks may want to figure that one out, but for
the purpose of this test, it shouldn't become a show-stopper.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
2016-11-11 13:09:24 -08:00
fdf4f6c79b t6026: clarify the point of "kill $(cat sleep.pid)"
We lengthened the time the leftover process sleeps in the previous
commit to make sure it will be there while 'git merge' runs and
finishes.  It therefore needs to be killed before leaving the test.
And it needs to be killed even when 'git merge' fails, so it has to
be triggered via test_when_finished mechanism.

Explain all that in a large comment, and move the use site of
test_when_finished to immediately before 'git merge' invocation,
where the process is spawned.

Signed-off-by: Johannes Sixt <j6t@kdbg.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2016-11-11 12:53:21 -08:00
71dd50472d t0021, t5615: use $PWD instead of $(pwd) in PATH-like shell variables
We have to use $PWD instead of $(pwd) because on Windows the latter
would add a C: style path to bash's Unix-style $PATH variable, which
becomes confused by the colon after the drive letter. ($PWD is a
Unix-style path.)

In the case of GIT_ALTERNATE_OBJECT_DIRECTORIES, bash on Windows
assembles a Unix-style path list with the colon as separators. It
converts the value to a Windows-style path list with the semicolon as
path separator when it forwards the variable to git.exe. The same
confusion happens when bash's original value is contaminated with
Windows style paths.

Signed-off-by: Johannes Sixt <j6t@kdbg.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2016-11-11 10:54:46 -08:00
3285b7badb doc: fix location of 'info/' with $GIT_COMMON_DIR
With the introduction of the $GIT_COMMON_DIR variable, the
repository layout manual was changed to reflect the location for
many files in case the variable is set. While adding the new
locations, one typo snuck in regarding the location of the
'info/' folder, which is falsely claimed to reside at
"$GIT_COMMON_DIR/index".

Fix the typo to point to "$GIT_COMMON_DIR/info/" instead.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2016-11-11 09:37:33 -08:00
a7d6bcc329 t6026: ensure that long-running script really is
When making sure that background tasks are cleaned up in 5babb5b
(t6026-merge-attr: clean up background process at end of test case,
2016-09-07), we considered to let the background task sleep longer, just
to be certain that it will still be running when we want to kill it
after the test.

Sadly, the assumption appears not to hold true that the test case passes
quickly enough to kill the background task within a second.

Simply increase it to an hour. No system can be possibly slow enough to
make above-mentioned assumption incorrect.

Reported by Andreas Schwab.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2016-11-10 15:57:06 -08:00
b36b716cf6 Revert "t6026-merge-attr: don't fail if sleep exits early"
This reverts commit 734fde2d71.

The point of the test is that the stray process was still running
when 'git merge' did its thing through its completion, so a failure
to "kill" it means we didn't give a condition to the test to trigger
a possible future breakage.  Appending "|| :" to the "kill" is
sweeping a test-bug under the rug.
2016-11-10 15:55:13 -08:00
3b03097d66 Revert "t6026-merge-attr: ensure that the merge driver was called"
This reverts commit c1e0dc59bd.

We are not interested in the stray process in the merge driver
started; we want it to be still around.
2016-11-10 15:54:12 -08:00
0538b84027 Merge branch 'jk/alt-odb-cleanup'
Fix a corner-case regression in a topic that graduated during the
v2.11 cycle.

* jk/alt-odb-cleanup:
  alternates: re-allow relative paths from environment
2016-11-10 13:17:30 -08:00
7b2c338cae Merge branch 'jk/filter-process-fix'
Test portability improvements and cleanups for t0021.

* jk/filter-process-fix:
  t0021: fix filehandle usage on older perl
  t0021: use $PERL_PATH for rot13-filter.pl
  t0021: put $TEST_ROOT in $PATH
  t0021: use write_script to create rot13 shell script
2016-11-10 13:17:30 -08:00
81cf0b6c7e Merge branch 'ls/filter-process'
Test portability improvements and optimization for an
already-graduated topic.

* ls/filter-process:
  t0021: compute file size with a single process instead of a pipeline
  t0021: expect more variations in the output of uniq -c
2016-11-10 13:17:30 -08:00
c1e0dc59bd t6026-merge-attr: ensure that the merge driver was called
Explicitly check for the existence of the pid file to test that the
merge driver was actually called.

Signed-off-by: Andreas Schwab <schwab@suse.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2016-11-10 11:20:56 -08:00
a296bc0132 travis-ci: disable GIT_TEST_HTTPD for macOS
TravisCI changed their default macOS image from 10.10 to 10.11 [1].
Unfortunately the HTTPD tests do not run out of the box using the
pre-installed Apache web server anymore. Therefore we enable these
tests only for Linux and disable them for macOS.

[1] https://blog.travis-ci.com/2016-10-04-osx-73-default-image-live/

Signed-off-by: Lars Schneider <larsxschneider@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2016-11-10 11:13:14 -08:00
f01fe92b82 Makefile: set NO_OPENSSL on macOS by default
Apple removed the OpenSSL header files in macOS 10.11 and above. OpenSSL
was deprecated since macOS 10.7.

Set `NO_OPENSSL` and `APPLE_COMMON_CRYPTO` to `YesPlease` as default for
macOS. It is possible to override this and use OpenSSL by defining
`NO_APPLE_COMMON_CRYPTO`.

Original-patch-by: Torsten Bögershausen <tboegi@web.de>
Signed-off-by: Lars Schneider <larsxschneider@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2016-11-10 11:10:36 -08:00
2ae38f2a65 sequencer: silence -Wtautological-constant-out-of-range-compare
When clang compiles sequencer.c, it complains:

  sequencer.c:632:14: warning: comparison of constant 2 with
    expression of type 'const enum todo_command' is always
    true [-Wtautological-constant-out-of-range-compare]
          if (command < ARRAY_SIZE(todo_command_strings))

This is because "command" is an enum that may only have two
values (0 and 1) and the array in question has two elements.

As it turns out, clang is actually wrong here, at least
according to its own bug tracker:

  https://llvm.org/bugs/show_bug.cgi?id=16154

But it's still worth working around this, as the warning is
present with -Wall, meaning we fail compilation with "make
DEVELOPER=1".

Casting the enum to size_t sufficiently unconfuses clang. As
a bonus, it also catches any possible out-of-bounds access
if the enum takes on a negative value (which shouldn't
happen either, but again, this is a defensive check).

Signed-off-by: Jeff King <peff@peff.net>
2016-11-08 22:59:24 -05:00
734fde2d71 t6026-merge-attr: don't fail if sleep exits early
Commit 5babb5bdb3 ("t6026-merge-attr: clean up background process at end
of test case") added a kill command to clean up after the test, but this
can fail if the sleep command exits before the cleanup is executed.
Ignore the error from the kill command.

Signed-off-by: Andreas Schwab <schwab@suse.de>
Signed-off-by: Jeff King <peff@peff.net>
2016-11-08 15:29:24 -05:00
37a95862c6 alternates: re-allow relative paths from environment
Commit 670c359da (link_alt_odb_entry: handle normalize_path
errors, 2016-10-03) regressed the handling of relative paths
in the GIT_ALTERNATE_OBJECT_DIRECTORIES variable. It's not
entirely clear this was ever meant to work, but it _has_
worked for several years, so this commit restores the
original behavior.

When we get a path in GIT_ALTERNATE_OBJECT_DIRECTORIES, we
add it the path to the list of alternate object directories
as if it were found in objects/info/alternates, but with one
difference: we do not provide the link_alt_odb_entry()
function with a base for relative paths. That function
doesn't turn it into an absolute path, and we end up feeding
the relative path to the strbuf_normalize_path() function.

Most relative paths break out of the top-level directory
(e.g., "../foo.git/objects"), and thus normalizing fails.
Prior to 670c359da, we simply ignored the error, and due to
the way normalize_path_copy() was implemented it happened to
return the original path in this case. We then accessed the
alternate objects using this relative path.

By storing the relative path in the alt_odb list, the path
is relative to wherever we happen to be at the time we do an
object lookup. That means we look from $GIT_DIR in a bare
repository, and from the top of the worktree in a non-bare
repository.

If this were being designed from scratch, it would make
sense to pick a stable location (probably $GIT_DIR, or even
the object directory) and use that as the relative base,
turning the result into an absolute path.  However, given
the history, at this point the minimal fix is to match the
pre-670c359da behavior.

We can do this simply by ignoring the error when we have no
relative base and using the original value (which we now
reliably have, thanks to strbuf_normalize_path()).

That still leaves us with a relative path that foils our
duplicate detection, and may act strangely if we ever
chdir() later in the process. We could solve that by storing
an absolute path based on getcwd(). That may be a good
future direction; for now we'll do just the minimum to fix
the regression.

The new t5615 script demonstrates the fix in its final three
tests. Since we didn't have any tests of the alternates
environment variable at all, it also adds some tests of
absolute paths.

Reported-by: Bryan Turner <bturner@atlassian.com>
Signed-off-by: Jeff King <peff@peff.net>
2016-11-08 15:28:22 -05:00
ec2e8b3da2 t0021: compute file size with a single process instead of a pipeline
Avoid unwanted coding patterns (prodigal use of pipelines), and in
particular a useless use of cat.

Signed-off-by: Johannes Sixt <j6t@kdbg.org>
Signed-off-by: Jeff King <peff@peff.net>
2016-11-08 15:26:40 -05:00
038212c4c4 t0021: expect more variations in the output of uniq -c
Some versions of uniq -c write the count left-justified, other version
write it right-justified. Be prepared for both kinds.

Signed-off-by: Johannes Sixt <j6t@kdbg.org>
Signed-off-by: Jeff King <peff@peff.net>
2016-11-08 15:26:40 -05:00
4821494ebc t0021: fix filehandle usage on older perl
The rot13-filter.pl script calls methods on implicitly
defined filehandles (STDOUT, and the result of an open()
call).  Prior to perl 5.13, these methods are not
automatically loaded, and perl will complain with:

  Can't locate object method "flush" via package "IO::Handle"

Let's explicitly load IO::File (which inherits from
IO::Handle). That's more than we need for just "flush", but
matches what perl has done since:

  http://perl5.git.perl.org/perl.git/commit/15e6cdd91beb4cefae4b65e855d68cf64766965d

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2016-11-02 19:36:29 -07:00
f272696a35 t0021: use $PERL_PATH for rot13-filter.pl
The rot13-filter.pl script hardcodes "#!/usr/bin/perl", and
does not respect $PERL_PATH at all. That is a problem if the
system does not have perl at that path, or if it has a perl
that is too old to run a complicated script like the
rot13-filter (but PERL_PATH points to a more modern one).

We can fix this by using write_script() to create a new copy
of the script with the correct #!-line. In theory we could
move the whole script inside t0021-conversion.sh rather than
having it as an auxiliary file, but it's long enough that
it just makes things harder to read.

As a bonus, we can stop using the full path to the script in
the filter-process config we add (because the trash
directory is in our PATH). Not only is this shorter, but it
sidesteps any shell-quoting issues. The original was broken
when $TEST_DIRECTORY contained a space, because it was
interpolated in the outer script.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2016-11-02 19:36:29 -07:00
30030a36b6 t0021: put $TEST_ROOT in $PATH
We create a rot13.sh script in the trash directory, but need
to call it by its full path when we have moved our cwd to
another directory. Let's just put $TEST_ROOT in our $PATH so
that the script is always found.

This is a minor convenience for rot13.sh, but will be a
major one when we switch rot13-filter.pl to a script in the
same directory, as it means we will not have to deal with
shell quoting inside the filter-process config.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2016-11-02 19:36:29 -07:00
cbb6707b11 t0021: use write_script to create rot13 shell script
This avoids us fooling around with $SHELL_PATH and the
executable bit ourselves.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2016-11-02 19:36:29 -07:00
be5a750939 A bit of updates post -rc0
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2016-11-01 12:59:58 -07:00
bf2f63a781 Merge branch 'cc/split-index-typofix'
Typofix in a comment in code

* cc/split-index-typofix:
  split-index: s/eith/with/ typo fix
2016-11-01 12:58:49 -07:00
e828d33316 Merge branch 'jk/no-looking-at-dotgit-outside-repo'
A small code cleanup.

* jk/no-looking-at-dotgit-outside-repo:
  sha1_name: make wraparound of the index into ring-buffer explicit
2016-11-01 12:58:49 -07:00
bcb4425216 Merge branch 'rs/cocci'
Improve the rule to convert "unsigned char [20]" into "struct
object_id *" in contrib/coccinelle/

* rs/cocci:
  cocci: avoid self-references in object_id transformations
2016-11-01 12:58:49 -07:00
753c451501 split-index: s/eith/with/ typo fix
Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2016-11-01 11:48:02 -07:00
c2bb0c1d1e cocci: avoid self-references in object_id transformations
The object_id functions oid_to_hex, oid_to_hex_r, oidclr, oidcmp, and
oidcpy are defined as wrappers of their legacy counterparts sha1_to_hex,
sha1_to_hex_r, hashclr, hashcmp, and hashcpy, respectively.  Make sure
that the Coccinelle transformations for converting legacy function calls
are not applied to these wrappers themselves, which would result in
tautological declarations.

Signed-off-by: Rene Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2016-11-01 10:58:39 -07:00
3e98919a18 sha1_name: make wraparound of the index into ring-buffer explicit
Overflow is defined for unsigned integers, but not for signed ones.
Wrap around explicitly for the new ring-buffer in find_unique_abbrev()
as we did in bb84735c for the ones in sha1_to_hex() and get_pathname(),
thus avoiding signed overflows and getting rid of the magic number 3.

Signed-off-by: Rene Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2016-11-01 10:56:39 -07:00
14 changed files with 147 additions and 42 deletions

View File

@ -32,7 +32,6 @@ env:
- DEFAULT_TEST_TARGET=prove
- GIT_PROVE_OPTS="--timer --jobs 3 --state=failed,slow,save"
- GIT_TEST_OPTS="--verbose-log"
- GIT_TEST_HTTPD=true
- GIT_TEST_CLONE_2GB=YesPlease
# t9810 occasionally fails on Travis CI OS X
# t9816 occasionally fails with "TAP out of sequence errors" on Travis CI OS X
@ -57,6 +56,8 @@ before_install:
- >
case "${TRAVIS_OS_NAME:-linux}" in
linux)
export GIT_TEST_HTTPD=YesPlease
mkdir --parents custom/p4
pushd custom/p4
wget --quiet http://filehost.perforce.com/perforce/r$LINUX_P4_VERSION/bin.linux26x86_64/p4d

View File

@ -21,7 +21,7 @@ Backward compatibility notes.
* The default abbreviation length, which has historically been 7, now
scales as the repository grows, using the approximate number of
objects in the reopsitory and a bit of math around the birthday
objects in the repository and a bit of math around the birthday
paradox. The logic suggests to use 12 hexdigits for the Linux
kernel, and 9 to 10 for Git itself.
@ -45,10 +45,10 @@ UI, Workflows & Features
which was not intuitive, given that "git nosuchcommand" said "git:
'nosuchcommand' is not a git command".
* "git clone --resurse-submodules --reference $path $URL" is a way to
* "git clone --recurse-submodules --reference $path $URL" is a way to
reduce network transfer cost by borrowing objects in an existing
$path repository when cloning the superproject from $URL; it
learned to also peek into $path for presense of corresponding
learned to also peek into $path for presence of corresponding
repositories of submodules and borrow objects from there when able.
* The "git diff --submodule={short,log}" mechanism has been enhanced
@ -73,7 +73,7 @@ UI, Workflows & Features
* In some projects, it is common to use "[RFC PATCH]" as the subject
prefix for a patch meant for discussion rather than application. A
new option "--rfc" was a short-hand for "--subject-prefix=RFC PATCH"
new option "--rfc" is a short-hand for "--subject-prefix=RFC PATCH"
to help the participants of such projects.
* "git add --chmod=+x <pathspec>" added recently only toggled the
@ -96,8 +96,8 @@ UI, Workflows & Features
* When given an abbreviated object name that is not (or more
realistically, "no longer") unique, we gave a fatal error
"ambiguous argument". This error is now accompanied by hints that
lists the objects that begins with the given prefix. During the
"ambiguous argument". This error is now accompanied by a hint that
lists the objects beginning with the given prefix. During the
course of development of this new feature, numerous minor bugs were
uncovered and corrected, the most notable one of which is that we
gave "short SHA1 xxxx is ambiguous." twice without good reason.
@ -330,7 +330,7 @@ notes for details).
* "git diff -W" output needs to extend the context backward to
include the header line of the current function and also forward to
include the body of the entire current function up to the header
line of the next one. This process may have to merge to adjacent
line of the next one. This process may have to merge two adjacent
hunks, but the code forgot to do so in some cases.
* Performance tests done via "t/perf" did not use the same set of
@ -568,6 +568,12 @@ notes for details).
prefixing $(git --exec-path) output in front.
(merge 1073094f30 ak/sh-setup-dot-source-i18n-fix later to maint).
* Fix for a racy false-positive test failure.
(merge fdf4f6c79b as/merge-attr-sleep later to maint).
* Portability update and workaround for builds on recent Mac OS X.
(merge a296bc0132 ls/macos-update later to maint).
* Other minor doc, test and build updates and code cleanups.
(merge 5c238e29a8 jk/common-main later to maint).
(merge 5a5749e45b ak/pre-receive-hook-template-modefix later to maint).
@ -575,3 +581,5 @@ notes for details).
(merge de9f7fa3b0 rs/commit-pptr-simplify later to maint).
(merge 4259d693fc sc/fmt-merge-msg-doc-markup-fix later to maint).
(merge 28fab7b23d nd/test-helpers later to maint).
(merge c2bb0c1d1e rs/cocci later to maint).
(merge 3285b7badb ps/common-info-doc later to maint).

View File

@ -177,7 +177,7 @@ sharedindex.<SHA-1>::
info::
Additional information about the repository is recorded
in this directory. This directory is ignored if $GIT_COMMON_DIR
is set and "$GIT_COMMON_DIR/index" will be used instead.
is set and "$GIT_COMMON_DIR/info" will be used instead.
info/refs::
This file helps dumb transports discover what refs are

View File

@ -1047,6 +1047,7 @@ ifeq ($(uname_S),Darwin)
endif
endif
ifndef NO_APPLE_COMMON_CRYPTO
NO_OPENSSL = YesPlease
APPLE_COMMON_CRYPTO = YesPlease
COMPAT_CFLAGS += -DAPPLE_COMMON_CRYPTO
endif

View File

@ -17,10 +17,13 @@ expression E1;
+ oid_to_hex(&E1)
@@
identifier f != oid_to_hex;
expression E1;
@@
f(...) {...
- sha1_to_hex(E1->hash)
+ oid_to_hex(E1)
...}
@@
expression E1, E2;
@ -29,10 +32,13 @@ expression E1, E2;
+ oid_to_hex_r(E1, &E2)
@@
identifier f != oid_to_hex_r;
expression E1, E2;
@@
f(...) {...
- sha1_to_hex_r(E1, E2->hash)
+ oid_to_hex_r(E1, E2)
...}
@@
expression E1;
@ -41,10 +47,13 @@ expression E1;
+ oidclr(&E1)
@@
identifier f != oidclr;
expression E1;
@@
f(...) {...
- hashclr(E1->hash)
+ oidclr(E1)
...}
@@
expression E1, E2;
@ -53,10 +62,13 @@ expression E1, E2;
+ oidcmp(&E1, &E2)
@@
identifier f != oidcmp;
expression E1, E2;
@@
f(...) {...
- hashcmp(E1->hash, E2->hash)
+ oidcmp(E1, E2)
...}
@@
expression E1, E2;
@ -77,10 +89,13 @@ expression E1, E2;
+ oidcpy(&E1, &E2)
@@
identifier f != oidcpy;
expression E1, E2;
@@
f(...) {...
- hashcpy(E1->hash, E2->hash)
+ oidcpy(E1, E2)
...}
@@
expression E1, E2;

View File

@ -240,7 +240,7 @@ static enum ack_type get_ack(int fd, unsigned char *result_sha1)
return ACK;
}
}
die(_("git fetch_pack: expected ACK/NAK, got '%s'"), line);
die(_("git fetch-pack: expected ACK/NAK, got '%s'"), line);
}
static void send_request(struct fetch_pack_args *args,

View File

@ -629,7 +629,7 @@ static const char *todo_command_strings[] = {
static const char *command_to_string(const enum todo_command command)
{
if (command < ARRAY_SIZE(todo_command_strings))
if ((size_t)command < ARRAY_SIZE(todo_command_strings))
return todo_command_strings[command];
die("Unknown command: %d", command);
}

View File

@ -296,7 +296,7 @@ static int link_alt_odb_entry(const char *entry, const char *relative_base,
}
strbuf_addstr(&pathbuf, entry);
if (strbuf_normalize_path(&pathbuf) < 0) {
if (strbuf_normalize_path(&pathbuf) < 0 && relative_base) {
error("unable to normalize alternate object path: %s",
pathbuf.buf);
strbuf_release(&pathbuf);

View File

@ -510,7 +510,8 @@ const char *find_unique_abbrev(const unsigned char *sha1, int len)
{
static int bufno;
static char hexbuffer[4][GIT_SHA1_HEXSZ + 1];
char *hex = hexbuffer[3 & ++bufno];
char *hex = hexbuffer[bufno];
bufno = (bufno + 1) % ARRAY_SIZE(hexbuffer);
find_unique_abbrev_r(hex, sha1, len);
return hex;
}

View File

@ -187,7 +187,7 @@ void prepare_to_write_split_index(struct index_state *istate)
/* Go through istate->cache[] and mark CE_MATCHED to
* entry with positive index. We'll go through
* base->cache[] later to delete all entries in base
* that are not marked eith either CE_MATCHED or
* that are not marked with either CE_MATCHED or
* CE_UPDATE_IN_BASE. If istate->cache[i] is a
* duplicate, deduplicate it.
*/

View File

@ -4,15 +4,17 @@ test_description='blob conversion via gitattributes'
. ./test-lib.sh
TEST_ROOT="$(pwd)"
TEST_ROOT="$PWD"
PATH=$TEST_ROOT:$PATH
cat <<EOF >"$TEST_ROOT/rot13.sh"
#!$SHELL_PATH
write_script <<\EOF "$TEST_ROOT/rot13.sh"
tr \
'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ' \
'nopqrstuvwxyzabcdefghijklmNOPQRSTUVWXYZABCDEFGHIJKLM'
EOF
chmod +x "$TEST_ROOT/rot13.sh"
write_script rot13-filter.pl "$PERL_PATH" \
<"$TEST_DIRECTORY"/t0021/rot13-filter.pl
generate_random_characters () {
LEN=$1
@ -22,13 +24,12 @@ generate_random_characters () {
}
file_size () {
cat "$1" | wc -c | sed "s/^[ ]*//"
perl -e 'print -s $ARGV[0]' "$1"
}
filter_git () {
rm -f rot13-filter.log &&
git "$@" 2>git-stderr.log &&
rm -f git-stderr.log
git "$@"
}
# Compare two files and ensure that `clean` and `smudge` respectively are
@ -40,10 +41,9 @@ test_cmp_count () {
actual=$2
for FILE in "$expect" "$actual"
do
sort "$FILE" | uniq -c | sed "s/^[ ]*//" |
sed "s/^\([0-9]\) IN: clean/x IN: clean/" |
sed "s/^\([0-9]\) IN: smudge/x IN: smudge/" >"$FILE.tmp" &&
mv "$FILE.tmp" "$FILE"
sort "$FILE" | uniq -c |
sed -e "s/^ *[0-9][0-9]*[ ]*IN: /x IN: /" >"$FILE.tmp" &&
mv "$FILE.tmp" "$FILE" || return
done &&
test_cmp "$expect" "$actual"
}
@ -66,7 +66,7 @@ test_cmp_exclude_clean () {
# is equal to the committed content.
test_cmp_committed_rot13 () {
test_cmp "$1" "$2" &&
"$TEST_ROOT/rot13.sh" <"$1" >expected &&
rot13.sh <"$1" >expected &&
git cat-file blob :"$2" >actual &&
test_cmp expected actual
}
@ -342,7 +342,7 @@ test_expect_success 'diff does not reuse worktree files that need cleaning' '
'
test_expect_success PERL 'required process filter should filter data' '
test_config_global filter.protocol.process "$TEST_DIRECTORY/t0021/rot13-filter.pl clean smudge" &&
test_config_global filter.protocol.process "rot13-filter.pl clean smudge" &&
test_config_global filter.protocol.required true &&
rm -rf repo &&
mkdir repo &&
@ -435,7 +435,7 @@ test_expect_success PERL 'required process filter should filter data' '
test_expect_success PERL 'required process filter takes precedence' '
test_config_global filter.protocol.clean false &&
test_config_global filter.protocol.process "$TEST_DIRECTORY/t0021/rot13-filter.pl clean" &&
test_config_global filter.protocol.process "rot13-filter.pl clean" &&
test_config_global filter.protocol.required true &&
rm -rf repo &&
mkdir repo &&
@ -460,7 +460,7 @@ test_expect_success PERL 'required process filter takes precedence' '
'
test_expect_success PERL 'required process filter should be used only for "clean" operation only' '
test_config_global filter.protocol.process "$TEST_DIRECTORY/t0021/rot13-filter.pl clean" &&
test_config_global filter.protocol.process "rot13-filter.pl clean" &&
rm -rf repo &&
mkdir repo &&
(
@ -495,7 +495,7 @@ test_expect_success PERL 'required process filter should be used only for "clean
'
test_expect_success PERL 'required process filter should process multiple packets' '
test_config_global filter.protocol.process "$TEST_DIRECTORY/t0021/rot13-filter.pl clean smudge" &&
test_config_global filter.protocol.process "rot13-filter.pl clean smudge" &&
test_config_global filter.protocol.required true &&
rm -rf repo &&
@ -515,7 +515,7 @@ test_expect_success PERL 'required process filter should process multiple packet
for FILE in "$TEST_ROOT"/*.file
do
cp "$FILE" . &&
"$TEST_ROOT/rot13.sh" <"$FILE" >"$FILE.rot13"
rot13.sh <"$FILE" >"$FILE.rot13"
done &&
echo "*.file filter=protocol" >.gitattributes &&
@ -555,7 +555,7 @@ test_expect_success PERL 'required process filter should process multiple packet
'
test_expect_success PERL 'required process filter with clean error should fail' '
test_config_global filter.protocol.process "$TEST_DIRECTORY/t0021/rot13-filter.pl clean smudge" &&
test_config_global filter.protocol.process "rot13-filter.pl clean smudge" &&
test_config_global filter.protocol.required true &&
rm -rf repo &&
mkdir repo &&
@ -574,7 +574,7 @@ test_expect_success PERL 'required process filter with clean error should fail'
'
test_expect_success PERL 'process filter should restart after unexpected write failure' '
test_config_global filter.protocol.process "$TEST_DIRECTORY/t0021/rot13-filter.pl clean smudge" &&
test_config_global filter.protocol.process "rot13-filter.pl clean smudge" &&
rm -rf repo &&
mkdir repo &&
(
@ -618,14 +618,14 @@ test_expect_success PERL 'process filter should restart after unexpected write f
# Smudge failed
! test_cmp smudge-write-fail.o smudge-write-fail.r &&
"$TEST_ROOT/rot13.sh" <smudge-write-fail.o >expected &&
rot13.sh <smudge-write-fail.o >expected &&
git cat-file blob :smudge-write-fail.r >actual &&
test_cmp expected actual
)
'
test_expect_success PERL 'process filter should not be restarted if it signals an error' '
test_config_global filter.protocol.process "$TEST_DIRECTORY/t0021/rot13-filter.pl clean smudge" &&
test_config_global filter.protocol.process "rot13-filter.pl clean smudge" &&
rm -rf repo &&
mkdir repo &&
(
@ -664,7 +664,7 @@ test_expect_success PERL 'process filter should not be restarted if it signals a
'
test_expect_success PERL 'process filter abort stops processing of all further files' '
test_config_global filter.protocol.process "$TEST_DIRECTORY/t0021/rot13-filter.pl clean smudge" &&
test_config_global filter.protocol.process "rot13-filter.pl clean smudge" &&
rm -rf repo &&
mkdir repo &&
(

2
t/t0021/rot13-filter.pl Executable file → Normal file
View File

@ -1,4 +1,3 @@
#!/usr/bin/perl
#
# Example implementation for the Git filter protocol version 2
# See Documentation/gitattributes.txt, section "Filter Protocol"
@ -22,6 +21,7 @@
use strict;
use warnings;
use IO::File;
my $MAX_PACKET_CONTENT_SIZE = 65516;
my @capabilities = @ARGV;

71
t/t5615-alternate-env.sh Executable file
View File

@ -0,0 +1,71 @@
#!/bin/sh
test_description='handling of alternates in environment variables'
. ./test-lib.sh
check_obj () {
alt=$1; shift
while read obj expect
do
echo "$obj" >&3 &&
echo "$obj $expect" >&4
done 3>input 4>expect &&
GIT_ALTERNATE_OBJECT_DIRECTORIES=$alt \
git "$@" cat-file --batch-check='%(objectname) %(objecttype)' \
<input >actual &&
test_cmp expect actual
}
test_expect_success 'create alternate repositories' '
git init --bare one.git &&
one=$(echo one | git -C one.git hash-object -w --stdin) &&
git init --bare two.git &&
two=$(echo two | git -C two.git hash-object -w --stdin)
'
test_expect_success 'objects inaccessible without alternates' '
check_obj "" <<-EOF
$one missing
$two missing
EOF
'
test_expect_success 'access alternate via absolute path' '
check_obj "$PWD/one.git/objects" <<-EOF
$one blob
$two missing
EOF
'
test_expect_success 'access multiple alternates' '
check_obj "$PWD/one.git/objects:$PWD/two.git/objects" <<-EOF
$one blob
$two blob
EOF
'
# bare paths are relative from $GIT_DIR
test_expect_success 'access alternate via relative path (bare)' '
git init --bare bare.git &&
check_obj "../one.git/objects" -C bare.git <<-EOF
$one blob
EOF
'
# non-bare paths are relative to top of worktree
test_expect_success 'access alternate via relative path (worktree)' '
git init worktree &&
check_obj "../one.git/objects" -C worktree <<-EOF
$one blob
EOF
'
# path is computed after moving to top-level of worktree
test_expect_success 'access alternate via relative path (subdir)' '
mkdir subdir &&
check_obj "one.git/objects" -C subdir <<-EOF
$one blob
EOF
'
test_done

View File

@ -183,16 +183,24 @@ test_expect_success 'up-to-date merge without common ancestor' '
test_expect_success 'custom merge does not lock index' '
git reset --hard anchor &&
write_script sleep-one-second.sh <<-\EOF &&
sleep 1 &
write_script sleep-an-hour.sh <<-\EOF &&
sleep 3600 &
echo $! >sleep.pid
EOF
test_when_finished "kill \$(cat sleep.pid)" &&
test_write_lines >.gitattributes \
"* merge=ours" "text merge=sleep-one-second" &&
"* merge=ours" "text merge=sleep-an-hour" &&
test_config merge.ours.driver true &&
test_config merge.sleep-one-second.driver ./sleep-one-second.sh &&
test_config merge.sleep-an-hour.driver ./sleep-an-hour.sh &&
# We are testing that the custom merge driver does not block
# index.lock on Windows due to an inherited file handle.
# To ensure that the backgrounded process ran sufficiently
# long (and has been started in the first place), we do not
# ignore the result of the kill command.
# By packaging the command in test_when_finished, we get both
# the correctness check and the clean-up.
test_when_finished "kill \$(cat sleep.pid)" &&
git merge master
'