summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Documentation/Makefile1
-rw-r--r--Documentation/RelNotes/1.8.5.txt42
-rw-r--r--Documentation/git-unpack-objects.txt2
-rw-r--r--Documentation/git-web--browse.txt1
-rw-r--r--Documentation/howto/recover-corrupted-object-harder.txt242
-rw-r--r--Documentation/howto/setup-git-server-over-http.txt4
-rw-r--r--builtin/for-each-ref.c29
-rw-r--r--builtin/mv.c13
-rw-r--r--builtin/reset.c2
-rw-r--r--cache.h1
-rwxr-xr-xcontrib/remote-helpers/git-remote-hg6
-rw-r--r--contrib/subtree/Makefile7
-rw-r--r--environment.c5
-rwxr-xr-xgit-add--interactive.perl22
-rwxr-xr-xgit-cvsserver.perl10
-rwxr-xr-xgit-web--browse.sh6
-rw-r--r--refs.c7
-rw-r--r--refs.h8
-rw-r--r--t/README27
-rw-r--r--t/gitweb-lib.sh2
-rwxr-xr-xt/lib-credential.sh4
-rw-r--r--t/lib-git-svn.sh4
-rw-r--r--t/lib-pack.sh8
-rw-r--r--t/lib-terminal.sh4
-rwxr-xr-xt/t0008-ignores.sh30
-rwxr-xr-xt/t0202-gettext-perl.sh4
-rwxr-xr-xt/t1010-mktree.sh4
-rwxr-xr-xt/t3200-branch.sh2
-rwxr-xr-xt/t3300-funny-names.sh6
-rwxr-xr-xt/t4014-format-patch.sh2
-rwxr-xr-xt/t4015-diff-whitespace.sh5
-rwxr-xr-xt/t4020-diff-external.sh2
-rwxr-xr-xt/t4029-diff-trailing-space.sh2
-rwxr-xr-xt/t4103-apply-binary.sh4
-rwxr-xr-xt/t4116-apply-reverse.sh4
-rwxr-xr-xt/t4200-rerere.sh8
-rwxr-xr-xt/t5300-pack-object.sh18
-rwxr-xr-xt/t5303-pack-corruption-resilience.sh4
-rwxr-xr-xt/t5551-http-fetch.sh2
-rwxr-xr-xt/t6011-rev-list-with-bad-commit.sh2
-rwxr-xr-xt/t6013-rev-list-reverse-parents.sh4
-rwxr-xr-xt/t6300-for-each-ref.sh4
-rwxr-xr-xt/t7001-mv.sh26
-rwxr-xr-xt/t7105-reset-patch.sh10
-rwxr-xr-xt/t7106-reset-unborn-branch.sh5
-rwxr-xr-xt/t7407-submodule-foreach.sh4
-rwxr-xr-xt/t7508-status.sh2
-rwxr-xr-xt/t9001-send-email.sh1
-rwxr-xr-xt/t9129-git-svn-i18n-commitencoding.sh2
-rwxr-xr-xt/t9137-git-svn-dcommit-clobber-series.sh8
-rwxr-xr-xt/t9300-fast-import.sh2
-rwxr-xr-xt/t9350-fast-export.sh2
-rwxr-xr-xt/t9400-git-cvsserver-server.sh2
-rwxr-xr-xt/t9401-git-cvsserver-crlf.sh2
-rwxr-xr-xt/t9402-git-cvsserver-refs.sh2
-rwxr-xr-xt/t9700-perl-git.sh4
-rwxr-xr-xt/t9810-git-p4-rcs.sh2
-rw-r--r--t/test-lib-functions.sh76
-rw-r--r--t/test-lib.sh1
59 files changed, 558 insertions, 157 deletions
diff --git a/Documentation/Makefile b/Documentation/Makefile
index 4f13a23..91a12c7 100644
--- a/Documentation/Makefile
+++ b/Documentation/Makefile
@@ -53,6 +53,7 @@ SP_ARTICLES += howto/setup-git-server-over-http
SP_ARTICLES += howto/separating-topic-branches
SP_ARTICLES += howto/revert-a-faulty-merge
SP_ARTICLES += howto/recover-corrupted-blob-object
+SP_ARTICLES += howto/recover-corrupted-object-harder
SP_ARTICLES += howto/rebuild-from-update-hook
SP_ARTICLES += howto/rebase-from-internal-branch
SP_ARTICLES += howto/maintain-git
diff --git a/Documentation/RelNotes/1.8.5.txt b/Documentation/RelNotes/1.8.5.txt
index d940c03..13b4336 100644
--- a/Documentation/RelNotes/1.8.5.txt
+++ b/Documentation/RelNotes/1.8.5.txt
@@ -76,6 +76,9 @@ Foreign interfaces, subsystems and ports.
UI, Workflows & Features
+ * xdg-open can be used as a browser backend for "git web-browse"
+ (hence to show "git help -w" output), when available.
+
* "git grep" and "git show" pays attention to "--textconv" option
when these commands are told to operate on blob objects (e.g. "git
grep -e pattern HEAD:Makefile").
@@ -132,10 +135,6 @@ UI, Workflows & Features
sync with the branch it builds on, and a branch that is configured
to build on some other branch that no longer exists.
- * A packfile that stores the same object more than once is broken and
- will be rejected by "git index-pack" that is run when receiving
- data over the wire.
-
* Earlier we started rejecting an attempt to add 0{40} object name to
the index and to tree objects, but it sometimes is necessary to
allow so to be able to use tools like filter-branch to correct such
@@ -153,8 +152,9 @@ UI, Workflows & Features
* "git push --no-thin" actually disables the "thin pack transfer"
optimization.
- * Magic pathspecs like ":(icase)makefile" that matches both
- Makefile and makefile can be used in more places.
+ * Magic pathspecs like ":(icase)makefile" that matches both Makefile
+ and makefile and ":(glob)foo/**/bar" that matches "bar" in "foo"
+ and any subdirectory of "foo" can be used in more places.
* The "http.*" variables can now be specified per URL that the
configuration applies. For example,
@@ -205,6 +205,10 @@ UI, Workflows & Features
Performance, Internal Implementation, etc.
+ * "git for-each-ref" when asking for merely the object name does not
+ have to parse the object pointed at by the refs; the codepath has
+ been optimized.
+
* The HTTP transport will try to use TCP keepalive when able.
* "git repack" is now written in C.
@@ -244,6 +248,32 @@ Unless otherwise noted, all the fixes since v1.8.4 in the maintenance
track are contained in this release (see release notes to them for
details).
+ * An ancient How-To on serving Git repositories on an HTTP server
+ lacked a warning that it has been mostly superseded with more
+ modern way.
+ (merge 6d52bc3 sc/doc-howto-dumb-http later to maint).
+
+ * The interaction between use of Perl in our test suite and NO_PERL
+ has been clarified a bit.
+ (merge f8fc0ee jn/test-prereq-perl-doc later to maint).
+
+ * The synopsis section of "git unpack-objects" documentation has been
+ clarified a bit.
+ (merge 61e2e22 vd/doc-unpack-objects later to maint).
+
+ * We did not generate HTML version of documentation to "git subtree"
+ in contrib/.
+ (merge 95c62fb jk/subtree-install-fix later to maint).
+
+ * A fast-import stream expresses a pathname with funny characters by
+ quoting them in C style; remote-hg remote helper forgot to unquote
+ such a path.
+ (merge 1136265 ap/remote-hg-unquote-cquote later to maint).
+
+ * "git reset -p HEAD" has a codepath to special case it to behave
+ differently from resetting to contents of other commits, but a
+ recent change broke it.
+
* Coloring around octopus merges in "log --graph" output was screwy.
(merge 339c17b hn/log-graph-color-octopus later to maint).
diff --git a/Documentation/git-unpack-objects.txt b/Documentation/git-unpack-objects.txt
index ff23494..12cb108 100644
--- a/Documentation/git-unpack-objects.txt
+++ b/Documentation/git-unpack-objects.txt
@@ -9,7 +9,7 @@ git-unpack-objects - Unpack objects from a packed archive
SYNOPSIS
--------
[verse]
-'git unpack-objects' [-n] [-q] [-r] [--strict] <pack-file
+'git unpack-objects' [-n] [-q] [-r] [--strict] < <pack-file>
DESCRIPTION
diff --git a/Documentation/git-web--browse.txt b/Documentation/git-web--browse.txt
index 5aec4ec..2de575f 100644
--- a/Documentation/git-web--browse.txt
+++ b/Documentation/git-web--browse.txt
@@ -35,6 +35,7 @@ The following browsers (or commands) are currently supported:
* open (this is the default under Mac OS X GUI)
* start (this is the default under MinGW)
* cygstart (this is the default under Cygwin)
+* xdg-open
Custom commands may also be specified.
diff --git a/Documentation/howto/recover-corrupted-object-harder.txt b/Documentation/howto/recover-corrupted-object-harder.txt
new file mode 100644
index 0000000..6f33dac
--- /dev/null
+++ b/Documentation/howto/recover-corrupted-object-harder.txt
@@ -0,0 +1,242 @@
+Date: Wed, 16 Oct 2013 04:34:01 -0400
+From: Jeff King <peff@peff.net>
+Subject: pack corruption post-mortem
+Abstract: Recovering a corrupted object when no good copy is available.
+Content-type: text/asciidoc
+
+How to recover an object from scratch
+=====================================
+
+I was recently presented with a repository with a corrupted packfile,
+and was asked if the data was recoverable. This post-mortem describes
+the steps I took to investigate and fix the problem. I thought others
+might find the process interesting, and it might help somebody in the
+same situation.
+
+********************************
+Note: In this case, no good copy of the repository was available. For
+the much easier case where you can get the corrupted object from
+elsewhere, see link:recover-corrupted-blob-object.html[this howto].
+********************************
+
+I started with an fsck, which found a problem with exactly one object
+(I've used $pack and $obj below to keep the output readable, and also
+because I'll refer to them later):
+
+-----------
+ $ git fsck
+ error: $pack SHA1 checksum mismatch
+ error: index CRC mismatch for object $obj from $pack at offset 51653873
+ error: inflate: data stream error (incorrect data check)
+ error: cannot unpack $obj from $pack at offset 51653873
+-----------
+
+The pack checksum failing means a byte is munged somewhere, and it is
+presumably in the object mentioned (since both the index checksum and
+zlib were failing).
+
+Reading the zlib source code, I found that "incorrect data check" means
+that the adler-32 checksum at the end of the zlib data did not match the
+inflated data. So stepping the data through zlib would not help, as it
+did not fail until the very end, when we realize the crc does not match.
+The problematic bytes could be anywhere in the object data.
+
+The first thing I did was pull the broken data out of the packfile. I
+needed to know how big the object was, which I found out with:
+
+------------
+ $ git show-index <$idx | cut -d' ' -f1 | sort -n | grep -A1 51653873
+ 51653873
+ 51664736
+------------
+
+Show-index gives us the list of objects and their offsets. We throw away
+everything but the offsets, and then sort them so that our interesting
+offset (which we got from the fsck output above) is followed immediately
+by the offset of the next object. Now we know that the object data is
+10863 bytes long, and we can grab it with:
+
+------------
+ dd if=$pack of=object bs=1 skip=51653873 count=10863
+------------
+
+I inspected a hexdump of the data, looking for any obvious bogosity
+(e.g., a 4K run of zeroes would be a good sign of filesystem
+corruption). But everything looked pretty reasonable.
+
+Note that the "object" file isn't fit for feeding straight to zlib; it
+has the git packed object header, which is variable-length. We want to
+strip that off so we can start playing with the zlib data directly. You
+can either work your way through it manually (the format is described in
+link:../technical/pack-format.html[Documentation/technical/pack-format.txt]),
+or you can walk through it in a debugger. I did the latter, creating a
+valid pack like:
+
+------------
+ # pack magic and version
+ printf 'PACK\0\0\0\2' >tmp.pack
+ # pack has one object
+ printf '\0\0\0\1' >>tmp.pack
+ # now add our object data
+ cat object >>tmp.pack
+ # and then append the pack trailer
+ /path/to/git.git/test-sha1 -b <tmp.pack >trailer
+ cat trailer >>tmp.pack
+------------
+
+and then running "git index-pack tmp.pack" in the debugger (stop at
+unpack_raw_entry). Doing this, I found that there were 3 bytes of header
+(and the header itself had a sane type and size). So I stripped those
+off with:
+
+------------
+ dd if=object of=zlib bs=1 skip=3
+------------
+
+I ran the result through zlib's inflate using a custom C program. And
+while it did report the error, I did get the right number of output
+bytes (i.e., it matched git's size header that we decoded above). But
+feeding the result back to "git hash-object" didn't produce the same
+sha1. So there were some wrong bytes, but I didn't know which. The file
+happened to be C source code, so I hoped I could notice something
+obviously wrong with it, but I didn't. I even got it to compile!
+
+I also tried comparing it to other versions of the same path in the
+repository, hoping that there would be some part of the diff that didn't
+make sense. Unfortunately, this happened to be the only revision of this
+particular file in the repository, so I had nothing to compare against.
+
+So I took a different approach. Working under the guess that the
+corruption was limited to a single byte, I wrote a program to munge each
+byte individually, and try inflating the result. Since the object was
+only 10K compressed, that worked out to about 2.5M attempts, which took
+a few minutes.
+
+The program I used is here:
+
+----------------------------------------------
+#include <stdio.h>
+#include <unistd.h>
+#include <string.h>
+#include <signal.h>
+#include <zlib.h>
+
+static int try_zlib(unsigned char *buf, int len)
+{
+ /* make this absurdly large so we don't have to loop */
+ static unsigned char out[1024*1024];
+ z_stream z;
+ int ret;
+
+ memset(&z, 0, sizeof(z));
+ inflateInit(&z);
+
+ z.next_in = buf;
+ z.avail_in = len;
+ z.next_out = out;
+ z.avail_out = sizeof(out);
+
+ ret = inflate(&z, 0);
+ inflateEnd(&z);
+ return ret >= 0;
+}
+
+/* eye candy */
+static int counter = 0;
+static void progress(int sig)
+{
+ fprintf(stderr, "\r%d", counter);
+ alarm(1);
+}
+
+int main(void)
+{
+ /* oversized so we can read the whole buffer in */
+ unsigned char buf[1024*1024];
+ int len;
+ unsigned i, j;
+
+ signal(SIGALRM, progress);
+ alarm(1);
+
+ len = read(0, buf, sizeof(buf));
+ for (i = 0; i < len; i++) {
+ unsigned char c = buf[i];
+ for (j = 0; j <= 0xff; j++) {
+ buf[i] = j;
+
+ counter++;
+ if (try_zlib(buf, len))
+ printf("i=%d, j=%x\n", i, j);
+ }
+ buf[i] = c;
+ }
+
+ alarm(0);
+ fprintf(stderr, "\n");
+ return 0;
+}
+----------------------------------------------
+
+I compiled and ran with:
+
+-------
+ gcc -Wall -Werror -O3 munge.c -o munge -lz
+ ./munge <zlib
+-------
+
+
+There were a few false positives early on (if you write "no data" in the
+zlib header, zlib thinks it's just fine :) ). But I got a hit about
+halfway through:
+
+-------
+ i=5642, j=c7
+-------
+
+I let it run to completion, and got a few more hits at the end (where it
+was munging the crc to match our broken data). So there was a good
+chance this middle hit was the source of the problem.
+
+I confirmed by tweaking the byte in a hex editor, zlib inflating the
+result (no errors!), and then piping the output into "git hash-object",
+which reported the sha1 of the broken object. Success!
+
+I fixed the packfile itself with:
+
+-------
+ chmod +w $pack
+ printf '\xc7' | dd of=$pack bs=1 seek=51659518 conv=notrunc
+ chmod -w $pack
+-------
+
+The `\xc7` comes from the replacement byte our "munge" program found.
+The offset 51659518 is derived by taking the original object offset
+(51653873), adding the replacement offset found by "munge" (5642), and
+then adding back in the 3 bytes of git header we stripped.
+
+After that, "git fsck" ran clean.
+
+As for the corruption itself, I was lucky that it was indeed a single
+byte. In fact, it turned out to be a single bit. The byte 0xc7 was
+corrupted to 0xc5. So presumably it was caused by faulty hardware, or a
+cosmic ray.
+
+And the aborted attempt to look at the inflated output to see what was
+wrong? I could have looked forever and never found it. Here's the diff
+between what the corrupted data inflates to, versus the real data:
+
+--------------
+ - cp = strtok (arg, "+");
+ + cp = strtok (arg, ".");
+--------------
+
+It tweaked one byte and still ended up as valid, readable C that just
+happened to do something totally different! One takeaway is that on a
+less unlucky day, looking at the zlib output might have actually been
+helpful, as most random changes would actually break the C code.
+
+But more importantly, git's hashing and checksumming noticed a problem
+that easily could have gone undetected in another system. The result
+still compiled, but would have caused an interesting bug (that would
+have been blamed on some random commit).
diff --git a/Documentation/howto/setup-git-server-over-http.txt b/Documentation/howto/setup-git-server-over-http.txt
index 981cbdd..6de4f3c 100644
--- a/Documentation/howto/setup-git-server-over-http.txt
+++ b/Documentation/howto/setup-git-server-over-http.txt
@@ -6,6 +6,10 @@ Content-type: text/asciidoc
How to setup Git server over http
=================================
+NOTE: This document is from 2006. A lot has happened since then, and this
+document is now relevant mainly if your web host is not CGI capable.
+Almost everyone else should instead look at linkgit:git-http-backend[1].
+
Since Apache is one of those packages people like to compile
themselves while others prefer the bureaucrat's dream Debian, it is
impossible to give guidelines which will work for everyone. Just send
diff --git a/builtin/for-each-ref.c b/builtin/for-each-ref.c
index 1d4083c..d096051 100644
--- a/builtin/for-each-ref.c
+++ b/builtin/for-each-ref.c
@@ -205,6 +205,22 @@ static void *get_obj(const unsigned char *sha1, struct object **obj, unsigned lo
return buf;
}
+static int grab_objectname(const char *name, const unsigned char *sha1,
+ struct atom_value *v)
+{
+ if (!strcmp(name, "objectname")) {
+ char *s = xmalloc(41);
+ strcpy(s, sha1_to_hex(sha1));
+ v->s = s;
+ return 1;
+ }
+ if (!strcmp(name, "objectname:short")) {
+ v->s = xstrdup(find_unique_abbrev(sha1, DEFAULT_ABBREV));
+ return 1;
+ }
+ return 0;
+}
+
/* See grab_values */
static void grab_common_values(struct atom_value *val, int deref, struct object *obj, void *buf, unsigned long sz)
{
@@ -225,15 +241,8 @@ static void grab_common_values(struct atom_value *val, int deref, struct object
v->ul = sz;
v->s = s;
}
- else if (!strcmp(name, "objectname")) {
- char *s = xmalloc(41);
- strcpy(s, sha1_to_hex(obj->sha1));
- v->s = s;
- }
- else if (!strcmp(name, "objectname:short")) {
- v->s = xstrdup(find_unique_abbrev(obj->sha1,
- DEFAULT_ABBREV));
- }
+ else if (deref)
+ grab_objectname(name, obj->sha1, v);
}
}
@@ -676,6 +685,8 @@ static void populate_value(struct refinfo *ref)
}
continue;
}
+ else if (!deref && grab_objectname(name, ref->objectname, v))
+ continue;
else
continue;
diff --git a/builtin/mv.c b/builtin/mv.c
index aec79d1..2e0e61b 100644
--- a/builtin/mv.c
+++ b/builtin/mv.c
@@ -55,6 +55,7 @@ static const char *add_slash(const char *path)
}
static struct lock_file lock_file;
+#define SUBMODULE_WITH_GITDIR ((const char *)1)
int cmd_mv(int argc, const char **argv, const char *prefix)
{
@@ -132,6 +133,8 @@ int cmd_mv(int argc, const char **argv, const char *prefix)
submodule_gitfile[i] = read_gitfile(submodule_dotgit.buf);
if (submodule_gitfile[i])
submodule_gitfile[i] = xstrdup(submodule_gitfile[i]);
+ else
+ submodule_gitfile[i] = SUBMODULE_WITH_GITDIR;
strbuf_release(&submodule_dotgit);
} else {
const char *src_w_slash = add_slash(src);
@@ -230,10 +233,12 @@ int cmd_mv(int argc, const char **argv, const char *prefix)
if (!show_only && mode != INDEX) {
if (rename(src, dst) < 0 && !ignore_errors)
die_errno (_("renaming '%s' failed"), src);
- if (submodule_gitfile[i])
- connect_work_tree_and_git_dir(dst, submodule_gitfile[i]);
- if (!update_path_in_gitmodules(src, dst))
- gitmodules_modified = 1;
+ if (submodule_gitfile[i]) {
+ if (submodule_gitfile[i] != SUBMODULE_WITH_GITDIR)
+ connect_work_tree_and_git_dir(dst, submodule_gitfile[i]);
+ if (!update_path_in_gitmodules(src, dst))
+ gitmodules_modified = 1;
+ }
}
if (mode == WORKING_DIRECTORY)
diff --git a/builtin/reset.c b/builtin/reset.c
index f2f9d55..6004803 100644
--- a/builtin/reset.c
+++ b/builtin/reset.c
@@ -304,7 +304,7 @@ int cmd_reset(int argc, const char **argv, const char *prefix)
if (patch_mode) {
if (reset_type != NONE)
die(_("--patch is incompatible with --{hard,mixed,soft}"));
- return run_add_interactive(sha1_to_hex(sha1), "--patch=reset", &pathspec);
+ return run_add_interactive(rev, "--patch=reset", &pathspec);
}
/* git reset tree [--] paths... can be used to
diff --git a/cache.h b/cache.h
index 9aa46e7..ce377e1 100644
--- a/cache.h
+++ b/cache.h
@@ -398,7 +398,6 @@ extern int is_bare_repository(void);
extern int is_inside_git_dir(void);
extern char *git_work_tree_cfg;
extern int is_inside_work_tree(void);
-extern int have_git_dir(void);
extern const char *get_git_dir(void);
extern int is_git_directory(const char *path);
extern char *get_object_directory(void);
diff --git a/contrib/remote-helpers/git-remote-hg b/contrib/remote-helpers/git-remote-hg
index 92d994e..3222afd 100755
--- a/contrib/remote-helpers/git-remote-hg
+++ b/contrib/remote-helpers/git-remote-hg
@@ -703,6 +703,11 @@ def get_merge_files(repo, p1, p2, files):
f = { 'ctx' : repo[p1][e] }
files[e] = f
+def c_style_unescape(string):
+ if string[0] == string[-1] == '"':
+ return string.decode('string-escape')[1:-1]
+ return string
+
def parse_commit(parser):
from_mark = merge_mark = None
@@ -742,6 +747,7 @@ def parse_commit(parser):
f = { 'deleted' : True }
else:
die('Unknown file command: %s' % line)
+ path = c_style_unescape(path).decode('utf-8')
files[path] = f
# only export the commits if we are on an internal proxy repo
diff --git a/contrib/subtree/Makefile b/contrib/subtree/Makefile
index 435b2de..4030a16 100644
--- a/contrib/subtree/Makefile
+++ b/contrib/subtree/Makefile
@@ -21,13 +21,14 @@ GIT_SUBTREE := git-subtree
GIT_SUBTREE_DOC := git-subtree.1
GIT_SUBTREE_XML := git-subtree.xml
GIT_SUBTREE_TXT := git-subtree.txt
+GIT_SUBTREE_HTML := git-subtree.html
all: $(GIT_SUBTREE)
$(GIT_SUBTREE): $(GIT_SUBTREE_SH)
cp $< $@ && chmod +x $@
-doc: $(GIT_SUBTREE_DOC)
+doc: $(GIT_SUBTREE_DOC) $(GIT_SUBTREE_HTML)
install: $(GIT_SUBTREE)
$(INSTALL) -d -m 755 $(DESTDIR)$(libexecdir)
@@ -46,6 +47,10 @@ $(GIT_SUBTREE_XML): $(GIT_SUBTREE_TXT)
asciidoc -b docbook -d manpage -f $(ASCIIDOC_CONF) \
-agit_version=$(gitver) $^
+$(GIT_SUBTREE_HTML): $(GIT_SUBTREE_TXT)
+ asciidoc -b xhtml11 -d manpage -f $(ASCIIDOC_CONF) \
+ -agit_version=$(gitver) $^
+
test:
$(MAKE) -C t/ test
diff --git a/environment.c b/environment.c
index 378254c..0a15349 100644
--- a/environment.c
+++ b/environment.c
@@ -155,11 +155,6 @@ int is_bare_repository(void)
return is_bare_repository_cfg && !get_git_work_tree();
}
-int have_git_dir(void)
-{
- return !!git_dir;
-}
-
const char *get_git_dir(void)
{
if (!git_dir)
diff --git a/git-add--interactive.perl b/git-add--interactive.perl
index 5156384..24bb1ab 100755
--- a/git-add--interactive.perl
+++ b/git-add--interactive.perl
@@ -263,6 +263,17 @@ sub get_empty_tree {
return '4b825dc642cb6eb9a060e54bf8d69288fbee4904';
}
+sub get_diff_reference {
+ my $ref = shift;
+ if (defined $ref and $ref ne 'HEAD') {
+ return $ref;
+ } elsif (is_initial_commit()) {
+ return get_empty_tree();
+ } else {
+ return 'HEAD';
+ }
+}
+
# Returns list of hashes, contents of each of which are:
# VALUE: pathname
# BINARY: is a binary path
@@ -286,14 +297,7 @@ sub list_modified {
return if (!@tracked);
}
- my $reference;
- if (defined $patch_mode_revision and $patch_mode_revision ne 'HEAD') {
- $reference = $patch_mode_revision;
- } elsif (is_initial_commit()) {
- $reference = get_empty_tree();
- } else {
- $reference = 'HEAD';
- }
+ my $reference = get_diff_reference($patch_mode_revision);
for (run_cmd_pipe(qw(git diff-index --cached
--numstat --summary), $reference,
'--', @tracked)) {
@@ -737,7 +741,7 @@ sub parse_diff {
splice @diff_cmd, 1, 0, "--diff-algorithm=${diff_algorithm}";
}
if (defined $patch_mode_revision) {
- push @diff_cmd, $patch_mode_revision;
+ push @diff_cmd, get_diff_reference($patch_mode_revision);
}
my @diff = run_cmd_pipe("git", @diff_cmd, "--", $path);
my @colored = ();
diff --git a/git-cvsserver.perl b/git-cvsserver.perl
index 74d1cc7..95e69b1 100755
--- a/git-cvsserver.perl
+++ b/git-cvsserver.perl
@@ -430,10 +430,10 @@ sub req_validrequests
$log->debug("req_validrequests");
- $log->debug("SEND : Valid-requests " . join(" ",keys %$methods));
+ $log->debug("SEND : Valid-requests " . join(" ",sort keys %$methods));
$log->debug("SEND : ok");
- print "Valid-requests " . join(" ",keys %$methods) . "\n";
+ print "Valid-requests " . join(" ",sort keys %$methods) . "\n";
print "ok\n";
}
@@ -2124,7 +2124,7 @@ sub req_diff
print "M retrieving revision $meta2->{revision}\n"
}
print "M diff ";
- foreach my $opt ( keys %{$state->{opt}} )
+ foreach my $opt ( sort keys %{$state->{opt}} )
{
if ( ref $state->{opt}{$opt} eq "ARRAY" )
{
@@ -4050,7 +4050,7 @@ sub update
close FILELIST;
# Detect deleted files
- foreach my $file ( keys %$head )
+ foreach my $file ( sort keys %$head )
{
unless ( exists $seen_files->{$file} or $head->{$file}{filehash} eq "deleted" )
{
@@ -4078,7 +4078,7 @@ sub update
}
$self->delete_head();
- foreach my $file ( keys %$head )
+ foreach my $file ( sort keys %$head )
{
$self->insert_head(
$file,
diff --git a/git-web--browse.sh b/git-web--browse.sh
index 1d72ec7..ebdfba6 100755
--- a/git-web--browse.sh
+++ b/git-web--browse.sh
@@ -34,7 +34,7 @@ valid_tool() {
firefox | iceweasel | seamonkey | iceape | \
chrome | google-chrome | chromium | chromium-browser | \
konqueror | opera | w3m | elinks | links | lynx | dillo | open | \
- start | cygstart)
+ start | cygstart | xdg-open)
;; # happy
*)
valid_custom_tool "$1" || return 1
@@ -112,7 +112,7 @@ fi
if test -z "$browser" ; then
if test -n "$DISPLAY"; then
- browser_candidates="firefox iceweasel google-chrome chrome chromium chromium-browser konqueror opera seamonkey iceape w3m elinks links lynx dillo"
+ browser_candidates="firefox iceweasel google-chrome chrome chromium chromium-browser konqueror opera seamonkey iceape w3m elinks links lynx dillo xdg-open"
if test "$KDE_FULL_SESSION" = "true"; then
browser_candidates="konqueror $browser_candidates"
fi
@@ -179,7 +179,7 @@ konqueror)
;;
esac
;;
-w3m|elinks|links|lynx|open|cygstart)
+w3m|elinks|links|lynx|open|cygstart|xdg-open)
"$browser_path" "$@"
;;
start)
diff --git a/refs.c b/refs.c
index 0c0e963..5e5a382 100644
--- a/refs.c
+++ b/refs.c
@@ -947,13 +947,6 @@ static struct ref_cache *get_ref_cache(const char *submodule)
return refs;
}
-void invalidate_ref_cache(const char *submodule)
-{
- struct ref_cache *refs = get_ref_cache(submodule);
- clear_packed_ref_cache(refs);
- clear_loose_ref_cache(refs);
-}
-
/* The length of a peeled reference line in packed-refs, including EOL: */
#define PEELED_LINE_LENGTH 42
diff --git a/refs.h b/refs.h
index b113377..87a1a79 100644
--- a/refs.h
+++ b/refs.h
@@ -165,14 +165,6 @@ extern void unlock_ref(struct ref_lock *lock);
/** Writes sha1 into the ref specified by the lock. **/
extern int write_ref_sha1(struct ref_lock *lock, const unsigned char *sha1, const char *msg);
-/*
- * Invalidate the reference cache for the specified submodule. Use
- * submodule=NULL to invalidate the cache for the main module. This
- * function must be called if references are changed via a mechanism
- * other than the refs API.
- */
-extern void invalidate_ref_cache(const char *submodule);
-
/** Setup reflog before using. **/
int log_ref_setup(const char *ref_name, char *logfile, int bufsize);
diff --git a/t/README b/t/README
index 2167125..caeeb9d 100644
--- a/t/README
+++ b/t/README
@@ -340,7 +340,11 @@ Don't:
- use perl without spelling it as "$PERL_PATH". This is to help our
friends on Windows where the platform Perl often adds CR before
the end of line, and they bundle Git with a version of Perl that
- does not do so, whose path is specified with $PERL_PATH.
+ does not do so, whose path is specified with $PERL_PATH. Note that we
+ provide a "perl" function which uses $PERL_PATH under the hood, so
+ you do not need to worry when simply running perl in the test scripts
+ (but you do, for example, on a shebang line or in a sub script
+ created via "write_script").
- use sh without spelling it as "$SHELL_PATH", when the script can
be misinterpreted by broken platform shell (e.g. Solaris).
@@ -387,7 +391,7 @@ of the test_* functions (see the "Test harness library" section
below), e.g.:
test_expect_success PERL 'I need Perl' '
- "$PERL_PATH" -e "hlagh() if unf_unf()"
+ perl -e "hlagh() if unf_unf()"
'
The advantage of skipping tests like this is that platforms that don't
@@ -520,7 +524,7 @@ library for your script to use.
test_external \
'GitwebCache::*FileCache*' \
- "$PERL_PATH" "$TEST_DIRECTORY"/t9503/test_cache_interface.pl
+ perl "$TEST_DIRECTORY"/t9503/test_cache_interface.pl
If the test is outputting its own TAP you should set the
test_external_has_tap variable somewhere before calling the first
@@ -536,7 +540,7 @@ library for your script to use.
test_external_without_stderr \
'Perl API' \
- "$PERL_PATH" "$TEST_DIRECTORY"/t9700/test.pl
+ perl "$TEST_DIRECTORY"/t9700/test.pl
- test_expect_code <exit-code> <command>
@@ -629,11 +633,18 @@ See the prereq argument to the test_* functions in the "Test harness
library" section above and the "test_have_prereq" function for how to
use these, and "test_set_prereq" for how to define your own.
- - PERL & PYTHON
+ - PYTHON
- Git wasn't compiled with NO_PERL=YesPlease or
- NO_PYTHON=YesPlease. Wrap any tests that need Perl or Python in
- these.
+ Git wasn't compiled with NO_PYTHON=YesPlease. Wrap any tests that
+ need Python with this.
+
+ - PERL
+
+ Git wasn't compiled with NO_PERL=YesPlease.
+
+ Even without the PERL prerequisite, tests can assume there is a
+ usable perl interpreter at $PERL_PATH, though it need not be
+ particularly modern.
- POSIXPERM
diff --git a/t/gitweb-lib.sh b/t/gitweb-lib.sh
index 9e381e0..8cf909a 100644
--- a/t/gitweb-lib.sh
+++ b/t/gitweb-lib.sh
@@ -69,7 +69,7 @@ gitweb_run () {
# written to web server logs, so we are not interested in that:
# we are interested only in properly formatted errors/warnings
rm -f gitweb.log &&
- "$PERL_PATH" -- "$SCRIPT_NAME" \
+ perl -- "$SCRIPT_NAME" \
>gitweb.output 2>gitweb.log &&
perl -w -e '
open O, ">gitweb.headers";
diff --git a/t/lib-credential.sh b/t/lib-credential.sh
index 3c43ff1..957ae93 100755
--- a/t/lib-credential.sh
+++ b/t/lib-credential.sh
@@ -18,10 +18,6 @@ check() {
cat stderr &&
false
fi &&
- if test_have_prereq MINGW
- then
- dos2unix -q stderr
- fi &&
test_cmp expect-stdout stdout &&
test_cmp expect-stderr stderr
}
diff --git a/t/lib-git-svn.sh b/t/lib-git-svn.sh
index c5e55b1..b0ec12f 100644
--- a/t/lib-git-svn.sh
+++ b/t/lib-git-svn.sh
@@ -29,7 +29,7 @@ export svnrepo
svnconf=$PWD/svnconf
export svnconf
-"$PERL_PATH" -w -e "
+perl -w -e "
use SVN::Core;
use SVN::Repos;
\$SVN::Core::VERSION gt '1.1.0' or exit(42);
@@ -146,7 +146,7 @@ stop_httpd () {
}
convert_to_rev_db () {
- "$PERL_PATH" -w -- - "$@" <<\EOF
+ perl -w -- - "$@" <<\EOF
use strict;
@ARGV == 2 or die "usage: convert_to_rev_db <input> <output>";
open my $wr, '+>', $ARGV[1] or die "$!: couldn't open: $ARGV[1]";
diff --git a/t/lib-pack.sh b/t/lib-pack.sh
index 7e8685b..b96e125 100644
--- a/t/lib-pack.sh
+++ b/t/lib-pack.sh
@@ -12,10 +12,10 @@
# Print the big-endian 4-byte octal representation of $1
uint32_octal () {
n=$1
- printf '\%o' $(($n / 16777216)); n=$((n % 16777216))
- printf '\%o' $(($n / 65536)); n=$((n % 65536))
- printf '\%o' $(($n / 256)); n=$((n % 256))
- printf '\%o' $(($n ));
+ printf '\\%o' $(($n / 16777216)); n=$((n % 16777216))
+ printf '\\%o' $(($n / 65536)); n=$((n % 65536))
+ printf '\\%o' $(($n / 256)); n=$((n % 256))
+ printf '\\%o' $(($n ));
}
# Print the big-endian 4-byte binary representation of $1
diff --git a/t/lib-terminal.sh b/t/lib-terminal.sh
index 58d911d..737df28 100644
--- a/t/lib-terminal.sh
+++ b/t/lib-terminal.sh
@@ -19,7 +19,7 @@ test_expect_success PERL 'set up terminal for tests' '
then
:
elif
- "$PERL_PATH" "$TEST_DIRECTORY"/test-terminal.perl \
+ perl "$TEST_DIRECTORY"/test-terminal.perl \
sh -c "test -t 1 && test -t 2"
then
test_set_prereq TTY &&
@@ -29,7 +29,7 @@ test_expect_success PERL 'set up terminal for tests' '
echo >&4 "test_terminal: need to declare TTY prerequisite"
return 127
fi
- "$PERL_PATH" "$TEST_DIRECTORY"/test-terminal.perl "$@"
+ perl "$TEST_DIRECTORY"/test-terminal.perl "$@"
}
fi
'
diff --git a/t/t0008-ignores.sh b/t/t0008-ignores.sh
index 181513a..b4d98e6 100755
--- a/t/t0008-ignores.sh
+++ b/t/t0008-ignores.sh
@@ -37,6 +37,14 @@ test_stderr () {
test_cmp "$HOME/expected-stderr" "$HOME/stderr"
}
+broken_c_unquote () {
+ "$PERL_PATH" -pe 's/^"//; s/\\//; s/"$//; tr/\n/\0/' "$@"
+}
+
+broken_c_unquote_verbose () {
+ "$PERL_PATH" -pe 's/ "/ /; s/\\//; s/"$//; tr/:\t\n/\0/' "$@"
+}
+
stderr_contains () {
regexp="$1"
if grep "$regexp" "$HOME/stderr"
@@ -606,12 +614,11 @@ cat <<-EOF >expected-verbose
$global_excludes:2:!globaltwo b/globaltwo
EOF
-sed -e 's/^"//' -e 's/\\//' -e 's/"$//' stdin | \
- tr "\n" "\0" >stdin0
-sed -e 's/^"//' -e 's/\\//' -e 's/"$//' expected-default | \
- tr "\n" "\0" >expected-default0
-sed -e 's/ "/ /' -e 's/\\//' -e 's/"$//' expected-verbose | \
- tr ":\t\n" "\0" >expected-verbose0
+broken_c_unquote stdin >stdin0
+
+broken_c_unquote expected-default >expected-default0
+
+broken_c_unquote_verbose expected-verbose >expected-verbose0
test_expect_success '--stdin' '
expect_from_stdin <expected-default &&
@@ -692,12 +699,11 @@ EOF
grep -v '^:: ' expected-all >expected-verbose
sed -e 's/.* //' expected-verbose >expected-default
-sed -e 's/^"//' -e 's/\\//' -e 's/"$//' stdin | \
- tr "\n" "\0" >stdin0
-sed -e 's/^"//' -e 's/\\//' -e 's/"$//' expected-default | \
- tr "\n" "\0" >expected-default0
-sed -e 's/ "/ /' -e 's/\\//' -e 's/"$//' expected-verbose | \
- tr ":\t\n" "\0" >expected-verbose0
+broken_c_unquote stdin >stdin0
+
+broken_c_unquote expected-default >expected-default0
+
+broken_c_unquote_verbose expected-verbose >expected-verbose0
test_expect_success '--stdin from subdirectory' '
expect_from_stdin <expected-default &&
diff --git a/t/t0202-gettext-perl.sh b/t/t0202-gettext-perl.sh
index 428ebb0..a29d166 100755
--- a/t/t0202-gettext-perl.sh
+++ b/t/t0202-gettext-perl.sh
@@ -12,7 +12,7 @@ if ! test_have_prereq PERL; then
test_done
fi
-"$PERL_PATH" -MTest::More -e 0 2>/dev/null || {
+perl -MTest::More -e 0 2>/dev/null || {
skip_all="Perl Test::More unavailable, skipping test"
test_done
}
@@ -22,6 +22,6 @@ test_external_has_tap=1
test_external_without_stderr \
'Perl Git::I18N API' \
- "$PERL_PATH" "$TEST_DIRECTORY"/t0202/test.pl
+ perl "$TEST_DIRECTORY"/t0202/test.pl
test_done
diff --git a/t/t1010-mktree.sh b/t/t1010-mktree.sh
index df573c4..b946f87 100755
--- a/t/t1010-mktree.sh
+++ b/t/t1010-mktree.sh
@@ -42,13 +42,13 @@ test_expect_success 'ls-tree piped to mktree (2)' '
'
test_expect_success 'ls-tree output in wrong order given to mktree (1)' '
- "$PERL_PATH" -e "print reverse <>" <top |
+ perl -e "print reverse <>" <top |
git mktree >actual &&
test_cmp tree actual
'
test_expect_success 'ls-tree output in wrong order given to mktree (2)' '
- "$PERL_PATH" -e "print reverse <>" <top.withsub |
+ perl -e "print reverse <>" <top.withsub |
git mktree >actual &&
test_cmp tree.withsub actual
'
diff --git a/t/t3200-branch.sh b/t/t3200-branch.sh
index 0fe7647..fcdb867 100755
--- a/t/t3200-branch.sh
+++ b/t/t3200-branch.sh
@@ -18,7 +18,7 @@ test_expect_success 'prepare a trivial repository' '
'
test_expect_success 'git branch --help should not have created a bogus branch' '
- test_might_fail git branch --help </dev/null >/dev/null 2>/dev/null &&
+ test_might_fail git branch --man --help </dev/null >/dev/null 2>&1 &&
test_path_is_missing .git/refs/heads/--help
'
diff --git a/t/t3300-funny-names.sh b/t/t3300-funny-names.sh
index 7480d6e..9a146f1 100755
--- a/t/t3300-funny-names.sh
+++ b/t/t3300-funny-names.sh
@@ -69,7 +69,7 @@ test_expect_success 'ls-files -z does not quote funny filename' '
tabs ," (dq) and spaces
EOF
git ls-files -z >ls-files.z &&
- "$PERL_PATH" -pe "y/\000/\012/" <ls-files.z >current &&
+ perl -pe "y/\000/\012/" <ls-files.z >current &&
test_cmp expected current
'
@@ -106,7 +106,7 @@ test_expect_success 'diff-index -z does not quote funny filename' '
tabs ," (dq) and spaces
EOF
git diff-index -z --name-status $t0 >diff-index.z &&
- "$PERL_PATH" -pe "y/\000/\012/" <diff-index.z >current &&
+ perl -pe "y/\000/\012/" <diff-index.z >current &&
test_cmp expected current
'
@@ -116,7 +116,7 @@ test_expect_success 'diff-tree -z does not quote funny filename' '
tabs ," (dq) and spaces
EOF
git diff-tree -z --name-status $t0 $t1 >diff-tree.z &&
- "$PERL_PATH" -pe y/\\000/\\012/ <diff-tree.z >current &&
+ perl -pe y/\\000/\\012/ <diff-tree.z >current &&
test_cmp expected current
'
diff --git a/t/t4014-format-patch.sh b/t/t4014-format-patch.sh
index 8f272bc..73194b2 100755
--- a/t/t4014-format-patch.sh
+++ b/t/t4014-format-patch.sh
@@ -293,7 +293,7 @@ check_threading () {
(git format-patch --stdout "$@"; echo $? > status.out) |
# Prints everything between the Message-ID and In-Reply-To,
# and replaces all Message-ID-lookalikes by a sequence number
- "$PERL_PATH" -ne '
+ perl -ne '
if (/^(message-id|references|in-reply-to)/i) {
$printing = 1;
} elsif (/^\S/) {
diff --git a/t/t4015-diff-whitespace.sh b/t/t4015-diff-whitespace.sh
index 3fb4b97..604a838 100755
--- a/t/t4015-diff-whitespace.sh
+++ b/t/t4015-diff-whitespace.sh
@@ -145,7 +145,7 @@ test_expect_success 'another test, with --ignore-space-at-eol' 'test_cmp expect
test_expect_success 'ignore-blank-lines: only new lines' '
test_seq 5 >x &&
git update-index x &&
- test_seq 5 | sed "/3/i \\
+ test_seq 5 | sed "/3/i\\
" >x &&
git diff --ignore-blank-lines >out &&
>expect &&
@@ -155,7 +155,8 @@ test_expect_success 'ignore-blank-lines: only new lines' '
test_expect_success 'ignore-blank-lines: only new lines with space' '
test_seq 5 >x &&
git update-index x &&
- test_seq 5 | sed "/3/i \ " >x &&
+ test_seq 5 | sed "/3/i\\
+ " >x &&
git diff -w --ignore-blank-lines >out &&
>expect &&
test_cmp out expect
diff --git a/t/t4020-diff-external.sh b/t/t4020-diff-external.sh
index 2e7d73f..8a30979 100755
--- a/t/t4020-diff-external.sh
+++ b/t/t4020-diff-external.sh
@@ -177,7 +177,7 @@ test_expect_success 'no diff with -diff' '
git diff | grep Binary
'
-echo NULZbetweenZwords | "$PERL_PATH" -pe 'y/Z/\000/' > file
+echo NULZbetweenZwords | perl -pe 'y/Z/\000/' > file
test_expect_success 'force diff with "diff"' '
echo >.gitattributes "file diff" &&
diff --git a/t/t4029-diff-trailing-space.sh b/t/t4029-diff-trailing-space.sh
index 36e2f07..3ccc237 100755
--- a/t/t4029-diff-trailing-space.sh
+++ b/t/t4029-diff-trailing-space.sh
@@ -27,7 +27,7 @@ test_expect_success \
git config --bool diff.suppressBlankEmpty true &&
git diff f > actual &&
test_cmp exp actual &&
- "$PERL_PATH" -i.bak -p -e "s/^\$/ /" exp &&
+ perl -i.bak -p -e "s/^\$/ /" exp &&
git config --bool diff.suppressBlankEmpty false &&
git diff f > actual &&
test_cmp exp actual &&
diff --git a/t/t4103-apply-binary.sh b/t/t4103-apply-binary.sh
index b1b906b..1b420e3 100755
--- a/t/t4103-apply-binary.sh
+++ b/t/t4103-apply-binary.sh
@@ -23,10 +23,10 @@ test_expect_success 'setup' '
git commit -m "Initial Version" 2>/dev/null &&
git checkout -b binary &&
- "$PERL_PATH" -pe "y/x/\000/" <file1 >file3 &&
+ perl -pe "y/x/\000/" <file1 >file3 &&
cat file3 >file4 &&
git add file2 &&
- "$PERL_PATH" -pe "y/\000/v/" <file3 >file1 &&
+ perl -pe "y/\000/v/" <file3 >file1 &&
rm -f file2 &&
git update-index --add --remove file1 file2 file3 file4 &&
git commit -m "Second Version" &&
diff --git a/t/t4116-apply-reverse.sh b/t/t4116-apply-reverse.sh
index fca8153..2298ece 100755
--- a/t/t4116-apply-reverse.sh
+++ b/t/t4116-apply-reverse.sh
@@ -12,14 +12,14 @@ test_description='git apply in reverse
test_expect_success setup '
for i in a b c d e f g h i j k l m n; do echo $i; done >file1 &&
- "$PERL_PATH" -pe "y/ijk/\\000\\001\\002/" <file1 >file2 &&
+ perl -pe "y/ijk/\\000\\001\\002/" <file1 >file2 &&
git add file1 file2 &&
git commit -m initial &&
git tag initial &&
for i in a b c g h i J K L m o n p q; do echo $i; done >file1 &&
- "$PERL_PATH" -pe "y/mon/\\000\\001\\002/" <file1 >file2 &&
+ perl -pe "y/mon/\\000\\001\\002/" <file1 >file2 &&
git commit -a -m second &&
git tag second &&
diff --git a/t/t4200-rerere.sh b/t/t4200-rerere.sh
index cf19eb7..ed9c91e 100755
--- a/t/t4200-rerere.sh
+++ b/t/t4200-rerere.sh
@@ -78,7 +78,7 @@ test_expect_success 'activate rerere, old style (conflicting merge)' '
test_might_fail git config --unset rerere.enabled &&
test_must_fail git merge first &&
- sha1=$("$PERL_PATH" -pe "s/ .*//" .git/MERGE_RR) &&
+ sha1=$(perl -pe "s/ .*//" .git/MERGE_RR) &&
rr=.git/rr-cache/$sha1 &&
grep "^=======\$" $rr/preimage &&
! test -f $rr/postimage &&
@@ -91,7 +91,7 @@ test_expect_success 'rerere.enabled works, too' '
git reset --hard &&
test_must_fail git merge first &&
- sha1=$("$PERL_PATH" -pe "s/ .*//" .git/MERGE_RR) &&
+ sha1=$(perl -pe "s/ .*//" .git/MERGE_RR) &&
rr=.git/rr-cache/$sha1 &&
grep ^=======$ $rr/preimage
'
@@ -101,7 +101,7 @@ test_expect_success 'set up rr-cache' '
git config rerere.enabled true &&
git reset --hard &&
test_must_fail git merge first &&
- sha1=$("$PERL_PATH" -pe "s/ .*//" .git/MERGE_RR) &&
+ sha1=$(perl -pe "s/ .*//" .git/MERGE_RR) &&
rr=.git/rr-cache/$sha1
'
@@ -185,7 +185,7 @@ test_expect_success 'rerere updates postimage timestamp' '
test_expect_success 'rerere clear' '
rm $rr/postimage &&
- echo "$sha1 a1" | "$PERL_PATH" -pe "y/\012/\000/" >.git/MERGE_RR &&
+ echo "$sha1 a1" | perl -pe "y/\012/\000/" >.git/MERGE_RR &&
git rerere clear &&
! test -d $rr
'
diff --git a/t/t5300-pack-object.sh b/t/t5300-pack-object.sh
index a07c871..20c1961 100755
--- a/t/t5300-pack-object.sh
+++ b/t/t5300-pack-object.sh
@@ -13,9 +13,9 @@ TRASH=`pwd`
test_expect_success \
'setup' \
'rm -f .git/index* &&
- "$PERL_PATH" -e "print \"a\" x 4096;" > a &&
- "$PERL_PATH" -e "print \"b\" x 4096;" > b &&
- "$PERL_PATH" -e "print \"c\" x 4096;" > c &&
+ perl -e "print \"a\" x 4096;" > a &&
+ perl -e "print \"b\" x 4096;" > b &&
+ perl -e "print \"c\" x 4096;" > c &&
test-genrandom "seed a" 2097152 > a_big &&
test-genrandom "seed b" 2097152 > b_big &&
git update-index --add a a_big b b_big c &&
@@ -129,7 +129,7 @@ test_expect_success \
cd "$TRASH"
test_expect_success 'compare delta flavors' '
- "$PERL_PATH" -e '\''
+ perl -e '\''
defined($_ = -s $_) or die for @ARGV;
exit 1 if $ARGV[0] <= $ARGV[1];
'\'' test-2-$packname_2.pack test-3-$packname_3.pack
@@ -151,7 +151,7 @@ test_expect_success \
git cat-file $t $object || return 1
done <obj-list
} >current &&
- test_cmp expect current'
+ cmp expect current'
test_expect_success \
'use packed deltified (REF_DELTA) objects' \
@@ -166,7 +166,7 @@ test_expect_success \
git cat-file $t $object || return 1
done <obj-list
} >current &&
- test_cmp expect current'
+ cmp expect current'
test_expect_success \
'use packed deltified (OFS_DELTA) objects' \
@@ -181,7 +181,7 @@ test_expect_success \
git cat-file $t $object || return 1
done <obj-list
} >current &&
- test_cmp expect current'
+ cmp expect current'
unset GIT_OBJECT_DIRECTORY
@@ -195,9 +195,9 @@ test_expect_success 'survive missing objects/pack directory' '
rm -fr $GOP &&
git index-pack --stdin --keep=test <../test-3-${packname_3}.pack &&
test -f $GOP/pack-${packname_3}.pack &&
- test_cmp $GOP/pack-${packname_3}.pack ../test-3-${packname_3}.pack &&
+ cmp $GOP/pack-${packname_3}.pack ../test-3-${packname_3}.pack &&
test -f $GOP/pack-${packname_3}.idx &&
- test_cmp $GOP/pack-${packname_3}.idx ../test-3-${packname_3}.idx &&
+ cmp $GOP/pack-${packname_3}.idx ../test-3-${packname_3}.idx &&
test -f $GOP/pack-${packname_3}.keep
)
'
diff --git a/t/t5303-pack-corruption-resilience.sh b/t/t5303-pack-corruption-resilience.sh
index 35926de..663b02b 100755
--- a/t/t5303-pack-corruption-resilience.sh
+++ b/t/t5303-pack-corruption-resilience.sh
@@ -98,7 +98,7 @@ test_expect_success \
'create_new_pack &&
git prune-packed &&
chmod +w ${pack}.pack &&
- "$PERL_PATH" -i.bak -pe "s/ base /abcdef/" ${pack}.pack &&
+ perl -i.bak -pe "s/ base /abcdef/" ${pack}.pack &&
test_must_fail git cat-file blob $blob_1 > /dev/null &&
test_must_fail git cat-file blob $blob_2 > /dev/null &&
test_must_fail git cat-file blob $blob_3 > /dev/null'
@@ -155,7 +155,7 @@ test_expect_success \
'create_new_pack &&
git prune-packed &&
chmod +w ${pack}.pack &&
- "$PERL_PATH" -i.bak -pe "s/ delta1 /abcdefgh/" ${pack}.pack &&
+ perl -i.bak -pe "s/ delta1 /abcdefgh/" ${pack}.pack &&
git cat-file blob $blob_1 > /dev/null &&
test_must_fail git cat-file blob $blob_2 > /dev/null &&
test_must_fail git cat-file blob $blob_3 > /dev/null'
diff --git a/t/t5551-http-fetch.sh b/t/t5551-http-fetch.sh
index fb16833..afb439e 100755
--- a/t/t5551-http-fetch.sh
+++ b/t/t5551-http-fetch.sh
@@ -235,7 +235,7 @@ test_expect_success EXPENSIVE 'create 50,000 tags in the repo' '
done | git fast-import --export-marks=marks &&
# now assign tags to all the dangling commits we created above
- tag=$("$PERL_PATH" -e "print \"bla\" x 30") &&
+ tag=$(perl -e "print \"bla\" x 30") &&
sed -e "s|^:\([^ ]*\) \(.*\)$|\2 refs/tags/$tag-\1|" <marks >>packed-refs
)
'
diff --git a/t/t6011-rev-list-with-bad-commit.sh b/t/t6011-rev-list-with-bad-commit.sh
index bbb0581..e51eb41 100755
--- a/t/t6011-rev-list-with-bad-commit.sh
+++ b/t/t6011-rev-list-with-bad-commit.sh
@@ -37,7 +37,7 @@ test_expect_success 'verify number of revisions' \
test_expect_success 'corrupt second commit object' \
'
- "$PERL_PATH" -i.bak -pe "s/second commit/socond commit/" .git/objects/pack/*.pack &&
+ perl -i.bak -pe "s/second commit/socond commit/" .git/objects/pack/*.pack &&
test_must_fail git fsck --full
'
diff --git a/t/t6013-rev-list-reverse-parents.sh b/t/t6013-rev-list-reverse-parents.sh
index 892a537..59fc2f0 100755
--- a/t/t6013-rev-list-reverse-parents.sh
+++ b/t/t6013-rev-list-reverse-parents.sh
@@ -25,7 +25,7 @@ test_expect_success 'set up --reverse example' '
test_expect_success '--reverse --parents --full-history combines correctly' '
git rev-list --parents --full-history master -- foo |
- "$PERL_PATH" -e "print reverse <>" > expected &&
+ perl -e "print reverse <>" > expected &&
git rev-list --reverse --parents --full-history master -- foo \
> actual &&
test_cmp actual expected
@@ -33,7 +33,7 @@ test_expect_success '--reverse --parents --full-history combines correctly' '
test_expect_success '--boundary does too' '
git rev-list --boundary --parents --full-history master ^root -- foo |
- "$PERL_PATH" -e "print reverse <>" > expected &&
+ perl -e "print reverse <>" > expected &&
git rev-list --boundary --reverse --parents --full-history \
master ^root -- foo > actual &&
test_cmp actual expected
diff --git a/t/t6300-for-each-ref.sh b/t/t6300-for-each-ref.sh
index 752f5cb..da5fb6c 100755
--- a/t/t6300-for-each-ref.sh
+++ b/t/t6300-for-each-ref.sh
@@ -58,6 +58,8 @@ test_atom head parent ''
test_atom head numparent 0
test_atom head object ''
test_atom head type ''
+test_atom head '*objectname' ''
+test_atom head '*objecttype' ''
test_atom head author 'A U Thor <author@example.com> 1151939924 +0200'
test_atom head authorname 'A U Thor'
test_atom head authoremail '<author@example.com>'
@@ -91,6 +93,8 @@ test_atom tag parent ''
test_atom tag numparent ''
test_atom tag object '67a36f10722846e891fbada1ba48ed035de75581'
test_atom tag type 'commit'
+test_atom tag '*objectname' '67a36f10722846e891fbada1ba48ed035de75581'
+test_atom tag '*objecttype' 'commit'
test_atom tag author ''
test_atom tag authorname ''
test_atom tag authoremail ''
diff --git a/t/t7001-mv.sh b/t/t7001-mv.sh
index d432f42..b90e985 100755
--- a/t/t7001-mv.sh
+++ b/t/t7001-mv.sh
@@ -293,6 +293,32 @@ test_expect_success 'git mv moves a submodule with a .git directory and no .gitm
git diff-files --quiet
'
+test_expect_success 'git mv moves a submodule with a .git directory and .gitmodules' '
+ rm -rf mod &&
+ git reset --hard &&
+ git submodule update &&
+ entry="$(git ls-files --stage sub | cut -f 1)" &&
+ (
+ cd sub &&
+ rm -f .git &&
+ cp -a ../.git/modules/sub .git &&
+ GIT_WORK_TREE=. git config --unset core.worktree
+ ) &&
+ mkdir mod &&
+ git mv sub mod/sub &&
+ ! test -e sub &&
+ [ "$entry" = "$(git ls-files --stage mod/sub | cut -f 1)" ] &&
+ (
+ cd mod/sub &&
+ git status
+ ) &&
+ echo mod/sub >expected &&
+ git config -f .gitmodules submodule.sub.path >actual &&
+ test_cmp expected actual &&
+ git update-index --refresh &&
+ git diff-files --quiet
+'
+
test_expect_success 'git mv moves a submodule with gitfile' '
rm -rf mod/sub &&
git reset --hard &&
diff --git a/t/t7105-reset-patch.sh b/t/t7105-reset-patch.sh
index 95fab20..98b7d7b 100755
--- a/t/t7105-reset-patch.sh
+++ b/t/t7105-reset-patch.sh
@@ -25,15 +25,17 @@ test_expect_success PERL 'saying "n" does nothing' '
'
test_expect_success PERL 'git reset -p' '
- (echo n; echo y) | git reset -p &&
+ (echo n; echo y) | git reset -p >output &&
verify_state dir/foo work head &&
- verify_saved_state bar
+ verify_saved_state bar &&
+ test_i18ngrep "Unstage" output
'
test_expect_success PERL 'git reset -p HEAD^' '
- (echo n; echo y) | git reset -p HEAD^ &&
+ (echo n; echo y) | git reset -p HEAD^ >output &&
verify_state dir/foo work parent &&
- verify_saved_state bar
+ verify_saved_state bar &&
+ test_i18ngrep "Apply" output
'
# The idea in the rest is that bar sorts first, so we always say 'y'
diff --git a/t/t7106-reset-unborn-branch.sh b/t/t7106-reset-unborn-branch.sh
index af00ab4..0f95f00 100755
--- a/t/t7106-reset-unborn-branch.sh
+++ b/t/t7106-reset-unborn-branch.sh
@@ -37,11 +37,12 @@ test_expect_success PERL 'reset -p' '
rm .git/index &&
git add a &&
echo y >yes &&
- git reset -p <yes &&
+ git reset -p <yes >output &&
>expect &&
git ls-files >actual &&
- test_cmp expect actual
+ test_cmp expect actual &&
+ test_i18ngrep "Unstage" output
'
test_expect_success 'reset --soft is a no-op' '
diff --git a/t/t7407-submodule-foreach.sh b/t/t7407-submodule-foreach.sh
index be93f10..b64c9ed 100755
--- a/t/t7407-submodule-foreach.sh
+++ b/t/t7407-submodule-foreach.sh
@@ -254,10 +254,6 @@ test_expect_success 'ensure "status --cached --recursive" preserves the --cached
) &&
git submodule status --cached --recursive -- nested1 > ../actual
) &&
- if test_have_prereq MINGW
- then
- dos2unix actual
- fi &&
test_cmp expect actual
'
diff --git a/t/t7508-status.sh b/t/t7508-status.sh
index 6fb59f3..c987b5e 100755
--- a/t/t7508-status.sh
+++ b/t/t7508-status.sh
@@ -994,7 +994,7 @@ test_expect_success 'status -s submodule summary (clean submodule)' '
test_expect_success 'status -z implies porcelain' '
git status --porcelain |
- "$PERL_PATH" -pe "s/\012/\000/g" >expect &&
+ perl -pe "s/\012/\000/g" >expect &&
git status -z >output &&
test_cmp expect output
'
diff --git a/t/t9001-send-email.sh b/t/t9001-send-email.sh
index 2813aa9..3119c8c 100755
--- a/t/t9001-send-email.sh
+++ b/t/t9001-send-email.sh
@@ -23,7 +23,6 @@ test_expect_success $PREREQ \
echo do
echo " echo \"!\$a!\""
echo "done >commandline\$output"
- test_have_prereq MINGW && echo "dos2unix commandline\$output"
echo "cat > msgtxt\$output"
) >fake.sendmail &&
chmod +x ./fake.sendmail &&
diff --git a/t/t9129-git-svn-i18n-commitencoding.sh b/t/t9129-git-svn-i18n-commitencoding.sh
index 9a40f1e..8cfdfe7 100755
--- a/t/t9129-git-svn-i18n-commitencoding.sh
+++ b/t/t9129-git-svn-i18n-commitencoding.sh
@@ -29,7 +29,7 @@ fi
compare_svn_head_with () {
# extract just the log message and strip out committer info.
# don't use --limit here since svn 1.1.x doesn't have it,
- LC_ALL="$a_utf8_locale" svn log `git svn info --url` | "$PERL_PATH" -w -e '
+ LC_ALL="$a_utf8_locale" svn log `git svn info --url` | perl -w -e '
use bytes;
$/ = ("-"x72) . "\n";
my @x = <STDIN>;
diff --git a/t/t9137-git-svn-dcommit-clobber-series.sh b/t/t9137-git-svn-dcommit-clobber-series.sh
index c17aa31..d60da63 100755
--- a/t/t9137-git-svn-dcommit-clobber-series.sh
+++ b/t/t9137-git-svn-dcommit-clobber-series.sh
@@ -20,8 +20,8 @@ test_expect_success '(supposedly) non-conflicting change from SVN' '
test x"`sed -n -e 61p < file`" = x61 &&
svn_cmd co "$svnrepo" tmp &&
(cd tmp &&
- "$PERL_PATH" -i.bak -p -e "s/^58$/5588/" file &&
- "$PERL_PATH" -i.bak -p -e "s/^61$/6611/" file &&
+ perl -i.bak -p -e "s/^58$/5588/" file &&
+ perl -i.bak -p -e "s/^61$/6611/" file &&
poke file &&
test x"`sed -n -e 58p < file`" = x5588 &&
test x"`sed -n -e 61p < file`" = x6611 &&
@@ -40,8 +40,8 @@ test_expect_success 'some unrelated changes to git' "
test_expect_success 'change file but in unrelated area' "
test x\"\`sed -n -e 4p < file\`\" = x4 &&
test x\"\`sed -n -e 7p < file\`\" = x7 &&
- "$PERL_PATH" -i.bak -p -e 's/^4\$/4444/' file &&
- "$PERL_PATH" -i.bak -p -e 's/^7\$/7777/' file &&
+ perl -i.bak -p -e 's/^4\$/4444/' file &&
+ perl -i.bak -p -e 's/^7\$/7777/' file &&
test x\"\`sed -n -e 4p < file\`\" = x4444 &&
test x\"\`sed -n -e 7p < file\`\" = x7777 &&
git commit -m '4 => 4444, 7 => 7777' file &&
diff --git a/t/t9300-fast-import.sh b/t/t9300-fast-import.sh
index 88fc407..27263df 100755
--- a/t/t9300-fast-import.sh
+++ b/t/t9300-fast-import.sh
@@ -12,7 +12,7 @@ test_description='test git fast-import utility'
# This could be written as "head -c $1", but IRIX "head" does not
# support the -c option.
head_c () {
- "$PERL_PATH" -e '
+ perl -e '
my $len = $ARGV[1];
while ($len > 0) {
my $s;
diff --git a/t/t9350-fast-export.sh b/t/t9350-fast-export.sh
index 34c2d8f..2312dec 100755
--- a/t/t9350-fast-export.sh
+++ b/t/t9350-fast-export.sh
@@ -429,7 +429,7 @@ test_expect_success 'fast-export quotes pathnames' '
--cacheinfo 100644 $blob "path with \\backslash" \
--cacheinfo 100644 $blob "path with space" &&
git commit -m addition &&
- git ls-files -z -s | "$PERL_PATH" -0pe "s{\\t}{$&subdir/}" >index &&
+ git ls-files -z -s | perl -0pe "s{\\t}{$&subdir/}" >index &&
git read-tree --empty &&
git update-index -z --index-info <index &&
git commit -m rename &&
diff --git a/t/t9400-git-cvsserver-server.sh b/t/t9400-git-cvsserver-server.sh
index 0431386..3edc408 100755
--- a/t/t9400-git-cvsserver-server.sh
+++ b/t/t9400-git-cvsserver-server.sh
@@ -20,7 +20,7 @@ then
skip_all='skipping git-cvsserver tests, cvs not found'
test_done
fi
-"$PERL_PATH" -e 'use DBI; use DBD::SQLite' >/dev/null 2>&1 || {
+perl -e 'use DBI; use DBD::SQLite' >/dev/null 2>&1 || {
skip_all='skipping git-cvsserver tests, Perl SQLite interface unavailable'
test_done
}
diff --git a/t/t9401-git-cvsserver-crlf.sh b/t/t9401-git-cvsserver-crlf.sh
index 8c3db76..5a4ed28 100755
--- a/t/t9401-git-cvsserver-crlf.sh
+++ b/t/t9401-git-cvsserver-crlf.sh
@@ -68,7 +68,7 @@ then
skip_all='skipping git-cvsserver tests, perl not available'
test_done
fi
-"$PERL_PATH" -e 'use DBI; use DBD::SQLite' >/dev/null 2>&1 || {
+perl -e 'use DBI; use DBD::SQLite' >/dev/null 2>&1 || {
skip_all='skipping git-cvsserver tests, Perl SQLite interface unavailable'
test_done
}
diff --git a/t/t9402-git-cvsserver-refs.sh b/t/t9402-git-cvsserver-refs.sh
index db69af2..1e266ef 100755
--- a/t/t9402-git-cvsserver-refs.sh
+++ b/t/t9402-git-cvsserver-refs.sh
@@ -76,7 +76,7 @@ then
skip_all='skipping git-cvsserver tests, perl not available'
test_done
fi
-"$PERL_PATH" -e 'use DBI; use DBD::SQLite' >/dev/null 2>&1 || {
+perl -e 'use DBI; use DBD::SQLite' >/dev/null 2>&1 || {
skip_all='skipping git-cvsserver tests, Perl SQLite interface unavailable'
test_done
}
diff --git a/t/t9700-perl-git.sh b/t/t9700-perl-git.sh
index 435d896..102c133 100755
--- a/t/t9700-perl-git.sh
+++ b/t/t9700-perl-git.sh
@@ -11,7 +11,7 @@ if ! test_have_prereq PERL; then
test_done
fi
-"$PERL_PATH" -MTest::More -e 0 2>/dev/null || {
+perl -MTest::More -e 0 2>/dev/null || {
skip_all="Perl Test::More unavailable, skipping test"
test_done
}
@@ -55,6 +55,6 @@ test_external_has_tap=1
test_external_without_stderr \
'Perl API' \
- "$PERL_PATH" "$TEST_DIRECTORY"/t9700/test.pl
+ perl "$TEST_DIRECTORY"/t9700/test.pl
test_done
diff --git a/t/t9810-git-p4-rcs.sh b/t/t9810-git-p4-rcs.sh
index 34fbc90..8134ab4 100755
--- a/t/t9810-git-p4-rcs.sh
+++ b/t/t9810-git-p4-rcs.sh
@@ -263,7 +263,7 @@ test_expect_success 'cope with rcs keyword expansion damage' '
git config git-p4.attemptRCSCleanup true &&
(cd "$cli" && p4_append_to_file kwfile1.c) &&
old_lines=$(wc -l <kwfile1.c) &&
- "$PERL_PATH" -n -i -e "print unless m/Revision:/" kwfile1.c &&
+ perl -n -i -e "print unless m/Revision:/" kwfile1.c &&
new_lines=$(wc -l <kwfile1.c) &&
test $new_lines = $(($old_lines - 1)) &&
diff --git a/t/test-lib-functions.sh b/t/test-lib-functions.sh
index a7e9aac..2f79146 100644
--- a/t/test-lib-functions.sh
+++ b/t/test-lib-functions.sh
@@ -76,11 +76,11 @@ test_decode_color () {
}
nul_to_q () {
- "$PERL_PATH" -pe 'y/\000/Q/'
+ perl -pe 'y/\000/Q/'
}
q_to_nul () {
- "$PERL_PATH" -pe 'y/Q/\000/'
+ perl -pe 'y/Q/\000/'
}
q_to_cr () {
@@ -648,7 +648,7 @@ test_seq () {
2) ;;
*) error "bug in the test script: not 1 or 2 parameters to test_seq" ;;
esac
- "$PERL_PATH" -le 'print for $ARGV[0]..$ARGV[1]' -- "$@"
+ perl -le 'print for $ARGV[0]..$ARGV[1]' -- "$@"
}
# This function can be used to schedule some commands to be run
@@ -710,3 +710,73 @@ test_ln_s_add () {
git update-index --add --cacheinfo 120000 $ln_s_obj "$2"
fi
}
+
+perl () {
+ command "$PERL_PATH" "$@"
+}
+
+# The following mingw_* functions obey POSIX shell syntax, but are actually
+# bash scripts, and are meant to be used only with bash on Windows.
+
+# A test_cmp function that treats LF and CRLF equal and avoids to fork
+# diff when possible.
+mingw_test_cmp () {
+ # Read text into shell variables and compare them. If the results
+ # are different, use regular diff to report the difference.
+ local test_cmp_a= test_cmp_b=
+
+ # When text came from stdin (one argument is '-') we must feed it
+ # to diff.
+ local stdin_for_diff=
+
+ # Since it is difficult to detect the difference between an
+ # empty input file and a failure to read the files, we go straight
+ # to diff if one of the inputs is empty.
+ if test -s "$1" && test -s "$2"
+ then
+ # regular case: both files non-empty
+ mingw_read_file_strip_cr_ test_cmp_a <"$1"
+ mingw_read_file_strip_cr_ test_cmp_b <"$2"
+ elif test -s "$1" && test "$2" = -
+ then
+ # read 2nd file from stdin
+ mingw_read_file_strip_cr_ test_cmp_a <"$1"
+ mingw_read_file_strip_cr_ test_cmp_b
+ stdin_for_diff='<<<"$test_cmp_b"'
+ elif test "$1" = - && test -s "$2"
+ then
+ # read 1st file from stdin
+ mingw_read_file_strip_cr_ test_cmp_a
+ mingw_read_file_strip_cr_ test_cmp_b <"$2"
+ stdin_for_diff='<<<"$test_cmp_a"'
+ fi
+ test -n "$test_cmp_a" &&
+ test -n "$test_cmp_b" &&
+ test "$test_cmp_a" = "$test_cmp_b" ||
+ eval "diff -u \"\$@\" $stdin_for_diff"
+}
+
+# $1 is the name of the shell variable to fill in
+mingw_read_file_strip_cr_ () {
+ # Read line-wise using LF as the line separator
+ # and use IFS to strip CR.
+ local line
+ while :
+ do
+ if IFS=$'\r' read -r -d $'\n' line
+ then
+ # good
+ line=$line$'\n'
+ else
+ # we get here at EOF, but also if the last line
+ # was not terminated by LF; in the latter case,
+ # some text was read
+ if test -z "$line"
+ then
+ # EOF, really
+ break
+ fi
+ fi
+ eval "$1=\$$1\$line"
+ done
+}
diff --git a/t/test-lib.sh b/t/test-lib.sh
index 9802b0b..b25249e 100644
--- a/t/test-lib.sh
+++ b/t/test-lib.sh
@@ -752,6 +752,7 @@ case $(uname -s) in
test_set_prereq NOT_CYGWIN
test_set_prereq SED_STRIPS_CR
test_set_prereq GREP_STRIPS_CR
+ GIT_TEST_CMP=mingw_test_cmp
;;
*CYGWIN*)
test_set_prereq POSIXPERM