Skip to content

Commit

Permalink
Merge branch 'maint'
Browse files Browse the repository at this point in the history
* maint:
  sha1_file: link() returns -1 on failure, not errno
  Make git archive respect core.autocrlf when creating zip format archives
  Add new test to demonstrate git archive core.autocrlf inconsistency
  gitweb: avoid warnings for commits without body
  Clarified gitattributes documentation regarding custom hunk header.
  git-svn: fix handling of even funkier branch names
  git-svn: Always create a new RA when calling do_switch for svn://
  git-svn: factor out svnserve test code for later use
  diff/diff-files: do not use --cc too aggressively
  • Loading branch information
gitster committed Sep 19, 2008
2 parents e69a6f4 + ea2408b commit 3791f77
Show file tree
Hide file tree
Showing 12 changed files with 327 additions and 39 deletions.
18 changes: 9 additions & 9 deletions Documentation/gitattributes.txt
Original file line number Diff line number Diff line change
Expand Up @@ -270,27 +270,27 @@ See linkgit:git[1] for details.
Defining a custom hunk-header
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Each group of changes (called "hunk") in the textual diff output
Each group of changes (called a "hunk") in the textual diff output
is prefixed with a line of the form:

@@ -k,l +n,m @@ TEXT

The text is called 'hunk header', and by default a line that
begins with an alphabet, an underscore or a dollar sign is used,
which matches what GNU 'diff -p' output uses. This default
selection however is not suited for some contents, and you can
use customized pattern to make a selection.
This is called a 'hunk header'. The "TEXT" portion is by default a line
that begins with an alphabet, an underscore or a dollar sign; this
matches what GNU 'diff -p' output uses. This default selection however
is not suited for some contents, and you can use a customized pattern
to make a selection.

First in .gitattributes, you would assign the `diff` attribute
First, in .gitattributes, you would assign the `diff` attribute
for paths.

------------------------
*.tex diff=tex
------------------------

Then, you would define "diff.tex.funcname" configuration to
Then, you would define a "diff.tex.funcname" configuration to
specify a regular expression that matches a line that you would
want to appear as the hunk header, like this:
want to appear as the hunk header "TEXT", like this:

------------------------
[diff "tex"]
Expand Down
2 changes: 2 additions & 0 deletions builtin-archive.c
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,8 @@ int cmd_archive(int argc, const char **argv, const char *prefix)
{
const char *remote = NULL;

git_config(git_default_config, NULL);

remote = extract_remote_arg(&argc, argv);
if (remote)
return run_remote_archiver(remote, argc, argv);
Expand Down
7 changes: 6 additions & 1 deletion builtin-diff-files.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,12 @@ int cmd_diff_files(int argc, const char **argv, const char *prefix)
3 < rev.max_count)
usage(diff_files_usage);

if (rev.max_count == -1 &&
/*
* "diff-files --base -p" should not combine merges because it
* was not asked to. "diff-files -c -p" should not densify
* (the user should ask with "diff-files --cc" explicitly).
*/
if (rev.max_count == -1 && !rev.combine_merges &&
(rev.diffopt.output_format & DIFF_FORMAT_PATCH))
rev.combine_merges = rev.dense_combined_merges = 1;

Expand Down
8 changes: 7 additions & 1 deletion builtin-diff.c
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,13 @@ static int builtin_diff_files(struct rev_info *revs, int argc, const char **argv
argv++; argc--;
}

if (revs->max_count == -1 &&
/*
* "diff --base" should not combine merges because it was not
* asked to. "diff -c" should not densify (if the user wants
* dense one, --cc can be explicitly asked for, or just rely
* on the default).
*/
if (revs->max_count == -1 && !revs->combine_merges &&
(revs->diffopt.output_format & DIFF_FORMAT_PATCH))
revs->combine_merges = revs->dense_combined_merges = 1;

Expand Down
25 changes: 12 additions & 13 deletions git-svn.perl
Original file line number Diff line number Diff line change
Expand Up @@ -4010,20 +4010,19 @@ sub gs_do_switch {
my $old_url = $full_url;
$full_url .= '/' . escape_uri_only($path) if length $path;
my ($ra, $reparented);
if ($old_url ne $full_url) {
if ($old_url !~ m#^svn(\+ssh)?://#) {
SVN::_Ra::svn_ra_reparent($self->{session}, $full_url,
$pool);
$self->{url} = $full_url;
$reparented = 1;
} else {
$_[0] = undef;
$self = undef;
$RA = undef;
$ra = Git::SVN::Ra->new($full_url);
$ra_invalid = 1;
}

if ($old_url =~ m#^svn(\+ssh)?://#) {
$_[0] = undef;
$self = undef;
$RA = undef;
$ra = Git::SVN::Ra->new($full_url);
$ra_invalid = 1;
} elsif ($old_url ne $full_url) {
SVN::_Ra::svn_ra_reparent($self->{session}, $full_url, $pool);
$self->{url} = $full_url;
$reparented = 1;
}

$ra ||= $self;
$url_b = escape_url($url_b);
my $reporter = $ra->do_switch($rev_b, '', 1, $url_b, $editor, $pool);
Expand Down
2 changes: 1 addition & 1 deletion gitweb/gitweb.perl
Original file line number Diff line number Diff line change
Expand Up @@ -2123,7 +2123,7 @@ sub parse_commit_text {
last;
}
}
if ($co{'title'} eq "") {
if (! defined $co{'title'} || $co{'title'} eq "") {
$co{'title'} = $co{'title_short'} = '(no commit message)';
}
# remove added spaces
Expand Down
4 changes: 3 additions & 1 deletion sha1_file.c
Original file line number Diff line number Diff line change
Expand Up @@ -2136,7 +2136,9 @@ static void write_sha1_file_prepare(const void *buf, unsigned long len,
*/
int move_temp_to_file(const char *tmpfile, const char *filename)
{
int ret = link(tmpfile, filename);
int ret = 0;
if (link(tmpfile, filename))
ret = errno;

/*
* Coda hack - coda doesn't like cross-directory links,
Expand Down
17 changes: 17 additions & 0 deletions t/lib-git-svn.sh
Original file line number Diff line number Diff line change
Expand Up @@ -138,3 +138,20 @@ close $wr or die $!;
close $rd or die $!;
EOF
}

require_svnserve () {
if test -z "$SVNSERVE_PORT"
then
say 'skipping svnserve test. (set $SVNSERVE_PORT to enable)'
test_done
exit
fi
}

start_svnserve () {
svnserve --listen-port $SVNSERVE_PORT \
--root "$rawsvnrepo" \
--listen-once \
--listen-host 127.0.0.1 &
}

46 changes: 46 additions & 0 deletions t/t0024-crlf-archive.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#!/bin/sh

test_description='respect crlf in git archive'

. ./test-lib.sh
UNZIP=${UNZIP:-unzip}

test_expect_success setup '
git config core.autocrlf true
printf "CRLF line ending\r\nAnd another\r\n" > sample &&
git add sample &&
test_tick &&
git commit -m Initial
'

test_expect_success 'tar archive' '
git archive --format=tar HEAD |
( mkdir untarred && cd untarred && "$TAR" -xf - )
test_cmp sample untarred/sample
'

"$UNZIP" -v >/dev/null 2>&1
if [ $? -eq 127 ]; then
echo "Skipping ZIP test, because unzip was not found"
test_done
exit
fi

test_expect_success 'zip archive' '
git archive --format=zip HEAD >test.zip &&
( mkdir unzipped && cd unzipped && unzip ../test.zip ) &&
test_cmp sample unzipped/sample
'

test_done
14 changes: 1 addition & 13 deletions t/t9113-git-svn-dcommit-new-file.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,7 @@ test_description='git svn dcommit new files over svn:// test'

. ./lib-git-svn.sh

if test -z "$SVNSERVE_PORT"
then
say 'skipping svnserve test. (set $SVNSERVE_PORT to enable)'
test_done
exit
fi

start_svnserve () {
svnserve --listen-port $SVNSERVE_PORT \
--root "$rawsvnrepo" \
--listen-once \
--listen-host 127.0.0.1 &
}
require_svnserve

test_expect_success 'start tracking an empty repo' '
svn mkdir -m "empty dir" "$svnrepo"/empty-dir &&
Expand Down
22 changes: 22 additions & 0 deletions t/t9126-git-svn-follow-deleted-readded-directory.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/bin/sh
#
# Copyright (c) 2008 Alec Berryman

test_description='git svn fetch repository with deleted and readded directory'

. ./lib-git-svn.sh

# Don't run this by default; it opens up a port.
require_svnserve

test_expect_success 'load repository' '
svnadmin load -q "$rawsvnrepo" < "$TEST_DIRECTORY"/t9126/follow-deleted-readded.dump
'

test_expect_success 'fetch repository' '
start_svnserve &&
git svn init svn://127.0.0.1:$SVNSERVE_PORT &&
git svn fetch
'

test_done
Loading

0 comments on commit 3791f77

Please sign in to comment.