Merge branch 'maint'

* maint:
  Amend git-push refspec documentation
  git-gc --prune is deprecated
  svn-git: Use binmode for reading/writing binary rev maps
  diff options documentation: refer to --diff-filter in --name-status
  Don't force imap.host to be set when imap.tunnel is set
  git-clone.txt: Adjust note to --shared for new pruning behavior of git-gc
  git-svn bug with blank commits and author file
  archive.c: format_subst - fixed bogus argument to memchr
  copy.c: copy_fd - correctly report write errors
  gitattributes: Fix subdirectory attributes specified from root directory
This commit is contained in:
Junio C Hamano 2008-04-23 00:03:56 -07:00
commit 57cf5ca305
11 changed files with 54 additions and 46 deletions

View File

@ -83,7 +83,8 @@ endif::git-format-patch[]
Show only names of changed files. Show only names of changed files.
--name-status:: --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:: --color::
Show colored diff. Show colored diff.

View File

@ -48,14 +48,12 @@ $ git gc <3>
repository health reasonably well. repository health reasonably well.
<2> check how many loose objects there are and how much <2> check how many loose objects there are and how much
disk space is wasted by not repacking. disk space is wasted by not repacking.
<3> repacks the local repository and performs other housekeeping tasks. Running <3> repacks the local repository and performs other housekeeping tasks.
without `--prune` is a safe operation even while other ones are in progress.
Repack a small project into single pack.:: Repack a small project into single pack.::
+ +
------------ ------------
$ git gc <1> $ git gc <1>
$ git gc --prune
------------ ------------
+ +
<1> pack all the objects reachable from the refs into one pack, <1> pack all the objects reachable from the refs into one pack,
@ -182,7 +180,7 @@ $ git pull <3>
$ git log -p ORIG_HEAD.. arch/i386 include/asm-i386 <4> $ git log -p ORIG_HEAD.. arch/i386 include/asm-i386 <4>
$ git pull git://git.kernel.org/pub/.../jgarzik/libata-dev.git ALL <5> $ git pull git://git.kernel.org/pub/.../jgarzik/libata-dev.git ALL <5>
$ git reset --hard ORIG_HEAD <6> $ git reset --hard ORIG_HEAD <6>
$ git gc --prune <7> $ git gc <7>
$ git fetch --tags <8> $ git fetch --tags <8>
------------ ------------
+ +

View File

@ -65,10 +65,13 @@ OPTIONS
+ +
*NOTE*: this is a possibly dangerous operation; do *not* use *NOTE*: this is a possibly dangerous operation; do *not* use
it unless you understand what it does. If you clone your it unless you understand what it does. If you clone your
repository using this option, then delete branches in the repository using this option and then delete branches (or use any
source repository and then run linkgit:git-gc[1] using the other git command that makes any existing commit unreferenced) in the
'--prune' option in the source repository, it may remove source repository, some objects may become unreferenced (or dangling).
objects which are referenced by the cloned repository. These objects may be removed by normal git operations (such as git-commit[1])
which automatically call git-gc[1]. If these objects are removed and
were referenced by the cloned repository, then the cloned repository
will become corrupt.
@ -79,6 +82,8 @@ objects which are referenced by the cloned repository.
an already existing repository as an alternate will an already existing repository as an alternate will
require fewer objects to be copied from the repository require fewer objects to be copied from the repository
being cloned, reducing network and local storage costs. being cloned, reducing network and local storage costs.
+
*NOTE*: see NOTE to --shared option.
--quiet:: --quiet::
-q:: -q::

View File

@ -35,14 +35,15 @@ OPTIONS
by the source ref, followed by a colon `:`, followed by by the source ref, followed by a colon `:`, followed by
the destination ref. the destination ref.
+ +
The <src> side can be an The <src> side represents the source branch (or arbitrary
arbitrary "SHA1 expression" that can be used as an "SHA1 expression", such as `master~4` (four parents before the
argument to `git-cat-file -t`. E.g. `master~4` (push tip of `master` branch); see linkgit:git-rev-parse[1]) that you
four parents before the current master head). want to push. The <dst> side represents the destination location.
+ +
The local ref that matches <src> is used The local ref that matches <src> is used
to fast forward the remote ref that matches <dst>. If to fast forward the remote ref that matches <dst> (or, if no <dst> was
the optional plus `+` is used, the remote ref is updated specified, the same ref that <src> referred to locally). If
the optional leading plus `+` is used, the remote ref is updated
even if it does not result in a fast forward update. even if it does not result in a fast forward update.
+ +
Note: If no explicit refspec is found, (that is neither Note: If no explicit refspec is found, (that is neither
@ -165,7 +166,8 @@ git push origin master::
Find a ref that matches `master` in the source repository Find a ref that matches `master` in the source repository
(most likely, it would find `refs/heads/master`), and update (most likely, it would find `refs/heads/master`), and update
the same ref (e.g. `refs/heads/master`) in `origin` repository the same ref (e.g. `refs/heads/master`) in `origin` repository
with it. with it. If `master` did not exist remotely, it would be
created.
git push origin :experimental:: git push origin :experimental::
Find a ref that matches `experimental` in the `origin` repository Find a ref that matches `experimental` in the `origin` repository
@ -179,9 +181,10 @@ git push origin master:satellite/master::
git push origin master:refs/heads/experimental:: git push origin master:refs/heads/experimental::
Create the branch `experimental` in the `origin` repository Create the branch `experimental` in the `origin` repository
by copying the current `master` branch. This form is usually by copying the current `master` branch. This form is only
needed to create a new branch in the remote repository as needed to create a new branch or tag in the remote repository when
there is no `experimental` branch to match. the local name and the remote name are different; otherwise,
the ref name on its own will work.
Author Author
------ ------

View File

@ -1548,22 +1548,7 @@ dangling tree b24c2473f1fd3d91352a624795be026d64c8841f
Dangling objects are not a problem. At worst they may take up a little Dangling objects are not a problem. At worst they may take up a little
extra disk space. They can sometimes provide a last-resort method for extra disk space. They can sometimes provide a last-resort method for
recovering lost work--see <<dangling-objects>> for details. However, if recovering lost work--see <<dangling-objects>> for details.
you wish, you can remove them with linkgit:git-prune[1] or the `--prune`
option to linkgit:git-gc[1]:
-------------------------------------------------
$ git gc --prune
-------------------------------------------------
This may be time-consuming. Unlike most other git operations (including
git-gc when run without any options), it is not safe to prune while
other git operations are in progress in the same repository.
If linkgit:git-fsck[1] complains about sha1 mismatches or missing
objects, you may have a much more serious problem; your best option is
probably restoring from backups. See
<<recovering-from-repository-corruption>> for a detailed discussion.
[[recovering-lost-changes]] [[recovering-lost-changes]]
Recovering lost changes Recovering lost changes

View File

@ -16,9 +16,9 @@ static void format_subst(const struct commit *commit,
const char *b, *c; const char *b, *c;
b = memmem(src, len, "$Format:", 8); b = memmem(src, len, "$Format:", 8);
if (!b || src + len < b + 9) if (!b)
break; break;
c = memchr(b + 8, '$', len - 8); c = memchr(b + 8, '$', (src + len) - b - 8);
if (!c) if (!c)
break; break;

4
attr.c
View File

@ -546,7 +546,9 @@ static int path_matches(const char *pathname, int pathlen,
(baselen && pathname[baselen] != '/') || (baselen && pathname[baselen] != '/') ||
strncmp(pathname, base, baselen)) strncmp(pathname, base, baselen))
return 0; 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) static int fill_one(const char *what, struct match_attr *a, int rem)

8
copy.c
View File

@ -9,8 +9,7 @@ int copy_fd(int ifd, int ofd)
if (!len) if (!len)
break; break;
if (len < 0) { if (len < 0) {
int read_error; int read_error = errno;
read_error = errno;
close(ifd); close(ifd);
return error("copy-fd: read returned %s", return error("copy-fd: read returned %s",
strerror(read_error)); strerror(read_error));
@ -25,9 +24,10 @@ int copy_fd(int ifd, int ofd)
close(ifd); close(ifd);
return error("copy-fd: write returned 0"); return error("copy-fd: write returned 0");
} else { } else {
int write_error = errno;
close(ifd); close(ifd);
return error("copy-fd: write returned %s", 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); status = copy_fd(fdi, fdo);
if (close(fdo) != 0) 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)) if (!status && adjust_shared_perm(dst))
return -1; return -1;

View File

@ -2375,8 +2375,7 @@ sub check_author {
my ($author) = @_; my ($author) = @_;
if (!defined $author || length $author == 0) { if (!defined $author || length $author == 0) {
$author = '(no author)'; $author = '(no author)';
} } elsif (defined $::_authors && ! defined $::users{$author}) {
if (defined $::_authors && ! defined $::users{$author}) {
die "Author: $author not defined in $::_authors file\n"; die "Author: $author not defined in $::_authors file\n";
} }
$author; $author;
@ -2519,6 +2518,7 @@ sub rebuild_from_rev_db {
my ($self, $path) = @_; my ($self, $path) = @_;
my $r = -1; my $r = -1;
open my $fh, '<', $path or croak "open: $!"; open my $fh, '<', $path or croak "open: $!";
binmode $fh or croak "binmode: $!";
while (<$fh>) { while (<$fh>) {
length($_) == 41 or croak "inconsistent size in ($_) != 41"; length($_) == 41 or croak "inconsistent size in ($_) != 41";
chomp($_); chomp($_);
@ -2616,6 +2616,7 @@ sub rebuild {
sub _rev_map_set { sub _rev_map_set {
my ($fh, $rev, $commit) = @_; my ($fh, $rev, $commit) = @_;
binmode $fh or croak "binmode: $!";
my $size = (stat($fh))[7]; my $size = (stat($fh))[7];
($size % 24) == 0 or croak "inconsistent size: $size"; ($size % 24) == 0 or croak "inconsistent size: $size";
@ -2719,6 +2720,7 @@ sub rev_map_max {
my $map_path = $self->map_path; my $map_path = $self->map_path;
stat $map_path or return $want_commit ? (0, undef) : 0; stat $map_path or return $want_commit ? (0, undef) : 0;
sysopen(my $fh, $map_path, O_RDONLY) or croak "open: $!"; sysopen(my $fh, $map_path, O_RDONLY) or croak "open: $!";
binmode $fh or croak "binmode: $!";
my $size = (stat($fh))[7]; my $size = (stat($fh))[7];
($size % 24) == 0 or croak "inconsistent size: $size"; ($size % 24) == 0 or croak "inconsistent size: $size";
@ -2751,6 +2753,7 @@ sub rev_map_get {
return undef unless -e $map_path; return undef unless -e $map_path;
sysopen(my $fh, $map_path, O_RDONLY) or croak "open: $!"; sysopen(my $fh, $map_path, O_RDONLY) or croak "open: $!";
binmode $fh or croak "binmode: $!";
my $size = (stat($fh))[7]; my $size = (stat($fh))[7];
($size % 24) == 0 or croak "inconsistent size: $size"; ($size % 24) == 0 or croak "inconsistent size: $size";

View File

@ -1303,9 +1303,12 @@ main(int argc, char **argv)
return 1; return 1;
} }
if (!server.host) { if (!server.host) {
if (!server.tunnel) {
fprintf( stderr, "no imap host specified\n" ); fprintf( stderr, "no imap host specified\n" );
return 1; return 1;
} }
server.host = "tunnel";
}
/* read the messages */ /* read the messages */
if (!read_message( stdin, &all_msgs )) { if (!read_message( stdin, &all_msgs )) {

View File

@ -21,6 +21,7 @@ test_expect_success 'setup' '
mkdir -p a/b/d a/c && mkdir -p a/b/d a/c &&
( (
echo "f test=f" echo "f test=f"
echo "a/i test=a/i"
) >.gitattributes && ) >.gitattributes &&
( (
echo "g test=a/g" && 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 test_done