From 82881b38235d0a46a4486dc5dc819c5d0ee3f2c1 Mon Sep 17 00:00:00 2001 From: Matthew Ogilvie Date: Tue, 22 Apr 2008 12:19:12 -0600 Subject: [PATCH 1/6] gitattributes: Fix subdirectory attributes specified from root directory Signed-off-by: Matthew Ogilvie Signed-off-by: Junio C Hamano --- attr.c | 4 +++- t/t0003-attributes.sh | 8 ++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/attr.c b/attr.c index 64b77b1663..1a15fad294 100644 --- a/attr.c +++ b/attr.c @@ -546,7 +546,9 @@ static int path_matches(const char *pathname, int pathlen, (baselen && pathname[baselen] != '/') || strncmp(pathname, base, baselen)) return 0; - return fnmatch(pattern, pathname + baselen + 1, FNM_PATHNAME) == 0; + if (baselen != 0) + baselen++; + return fnmatch(pattern, pathname + baselen, FNM_PATHNAME) == 0; } static int fill_one(const char *what, struct match_attr *a, int rem) diff --git a/t/t0003-attributes.sh b/t/t0003-attributes.sh index 47f08a46c2..e7fa4f5d43 100755 --- a/t/t0003-attributes.sh +++ b/t/t0003-attributes.sh @@ -21,6 +21,7 @@ test_expect_success 'setup' ' mkdir -p a/b/d a/c && ( echo "f test=f" + echo "a/i test=a/i" ) >.gitattributes && ( echo "g test=a/g" && @@ -46,4 +47,11 @@ test_expect_success 'attribute test' ' ' +test_expect_success 'root subdir attribute test' ' + + attr_check a/i a/i && + attr_check subdir/a/i unspecified + +' + test_done From 8b1f6de854ae95eb3f4225a71aad29ca086cfd2e Mon Sep 17 00:00:00 2001 From: Ariel Badichi Date: Wed, 23 Apr 2008 04:05:29 +0300 Subject: [PATCH 2/6] copy.c: copy_fd - correctly report write errors Previously, the errno could have been lost due to an intervening close() call. This patch also contains minor cosmetic changes. Signed-off-by: Ariel Badichi Signed-off-by: Junio C Hamano --- copy.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/copy.c b/copy.c index afc4fbf414..e54d15aced 100644 --- a/copy.c +++ b/copy.c @@ -9,8 +9,7 @@ int copy_fd(int ifd, int ofd) if (!len) break; if (len < 0) { - int read_error; - read_error = errno; + int read_error = errno; close(ifd); return error("copy-fd: read returned %s", strerror(read_error)); @@ -25,9 +24,10 @@ int copy_fd(int ifd, int ofd) close(ifd); return error("copy-fd: write returned 0"); } else { + int write_error = errno; close(ifd); return error("copy-fd: write returned %s", - strerror(errno)); + strerror(write_error)); } } } @@ -48,7 +48,7 @@ int copy_file(const char *dst, const char *src, int mode) } status = copy_fd(fdi, fdo); if (close(fdo) != 0) - return error("%s: write error: %s", dst, strerror(errno)); + return error("%s: close error: %s", dst, strerror(errno)); if (!status && adjust_shared_perm(dst)) return -1; From 75b7dfbdc030cfc6f09a6317444c36c4957a9133 Mon Sep 17 00:00:00 2001 From: Ariel Badichi Date: Wed, 23 Apr 2008 04:06:27 +0300 Subject: [PATCH 3/6] archive.c: format_subst - fixed bogus argument to memchr Also removed a superfluous test. Signed-off-by: Ariel Badichi Signed-off-by: Junio C Hamano --- archive.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/archive.c b/archive.c index fb159fe59e..7a32c19d3c 100644 --- a/archive.c +++ b/archive.c @@ -16,9 +16,9 @@ static void format_subst(const struct commit *commit, const char *b, *c; b = memmem(src, len, "$Format:", 8); - if (!b || src + len < b + 9) + if (!b) break; - c = memchr(b + 8, '$', len - 8); + c = memchr(b + 8, '$', (src + len) - b - 8); if (!c) break; From 9231f500c394ede405fcfdca151dd7758ce99ced Mon Sep 17 00:00:00 2001 From: Thomas Guyot-Sionnest Date: Tue, 22 Apr 2008 06:07:47 -0400 Subject: [PATCH 4/6] git-svn bug with blank commits and author file When trying to import from svn using an author file, git-svn bails out if it encounters a blank author. The attached patch changes this behavior and allow using the author file with blanks authors. I came across this bug while importing from a cvs2svn repo where the initial revision (1) has a blank author. This doesn't break the behavior of bailing out when an unknown author is encountered. Acked-by: Eric Wong Signed-off-by: Junio C Hamano --- git-svn.perl | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/git-svn.perl b/git-svn.perl index e0434099ce..fcfe4eeaa0 100755 --- a/git-svn.perl +++ b/git-svn.perl @@ -2363,8 +2363,7 @@ sub check_author { my ($author) = @_; if (!defined $author || length $author == 0) { $author = '(no author)'; - } - if (defined $::_authors && ! defined $::users{$author}) { + } elsif (defined $::_authors && ! defined $::users{$author}) { die "Author: $author not defined in $::_authors file\n"; } $author; From a6f47b2be43fbe70236316edc6c87ad9522c485d Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Tue, 22 Apr 2008 14:23:48 +0200 Subject: [PATCH 5/6] diff options documentation: refer to --diff-filter in --name-status git diff --name-status outputs letters, but the meaning of those letters is documented elsewhere. Add a note to make the manpage more intuitive. Signed-off-by: Miklos Vajna Signed-off-by: Junio C Hamano --- Documentation/diff-options.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Documentation/diff-options.txt b/Documentation/diff-options.txt index 8d35cbd60d..60d0e53a78 100644 --- a/Documentation/diff-options.txt +++ b/Documentation/diff-options.txt @@ -75,7 +75,8 @@ endif::git-format-patch[] Show only names of changed files. --name-status:: - Show only names and status of changed files. + Show only names and status of changed files. See the description + of the `--diff-filter` option on what the status letters mean. --color:: Show colored diff. From 4f7ec7970874d09be162bc7f16415a0ec2d36ae5 Mon Sep 17 00:00:00 2001 From: Michael Weber Date: Fri, 18 Apr 2008 15:12:04 +0200 Subject: [PATCH 6/6] svn-git: Use binmode for reading/writing binary rev maps Otherwise, there is a possible interaction with UTF-8 locales in combination with PERL_UNICODE, resulting in "inconsistent size: 40" or "read:"-type errors. See also: perldoc -f binmode Signed-off-by: Michael Weber Acked-by: Eric Wong Signed-off-by: Junio C Hamano --- git-svn.perl | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/git-svn.perl b/git-svn.perl index fcfe4eeaa0..49dd80644b 100755 --- a/git-svn.perl +++ b/git-svn.perl @@ -2506,6 +2506,7 @@ sub rebuild_from_rev_db { my ($self, $path) = @_; my $r = -1; open my $fh, '<', $path or croak "open: $!"; + binmode $fh or croak "binmode: $!"; while (<$fh>) { length($_) == 41 or croak "inconsistent size in ($_) != 41"; chomp($_); @@ -2603,6 +2604,7 @@ sub rebuild { sub _rev_map_set { my ($fh, $rev, $commit) = @_; + binmode $fh or croak "binmode: $!"; my $size = (stat($fh))[7]; ($size % 24) == 0 or croak "inconsistent size: $size"; @@ -2706,6 +2708,7 @@ sub rev_map_max { my $map_path = $self->map_path; stat $map_path or return $want_commit ? (0, undef) : 0; sysopen(my $fh, $map_path, O_RDONLY) or croak "open: $!"; + binmode $fh or croak "binmode: $!"; my $size = (stat($fh))[7]; ($size % 24) == 0 or croak "inconsistent size: $size"; @@ -2738,6 +2741,7 @@ sub rev_map_get { return undef unless -e $map_path; sysopen(my $fh, $map_path, O_RDONLY) or croak "open: $!"; + binmode $fh or croak "binmode: $!"; my $size = (stat($fh))[7]; ($size % 24) == 0 or croak "inconsistent size: $size";