Skip to content

Commit 3791f77

Browse files
committed
Merge branch 'maint'
* 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
2 parents e69a6f4 + ea2408b commit 3791f77

12 files changed

+327
-39
lines changed

Documentation/gitattributes.txt

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -270,27 +270,27 @@ See linkgit:git[1] for details.
270270
Defining a custom hunk-header
271271
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
272272

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

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

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

284-
First in .gitattributes, you would assign the `diff` attribute
284+
First, in .gitattributes, you would assign the `diff` attribute
285285
for paths.
286286

287287
------------------------
288288
*.tex diff=tex
289289
------------------------
290290

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

295295
------------------------
296296
[diff "tex"]

builtin-archive.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,8 @@ int cmd_archive(int argc, const char **argv, const char *prefix)
111111
{
112112
const char *remote = NULL;
113113

114+
git_config(git_default_config, NULL);
115+
114116
remote = extract_remote_arg(&argc, argv);
115117
if (remote)
116118
return run_remote_archiver(remote, argc, argv);

builtin-diff-files.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,12 @@ int cmd_diff_files(int argc, const char **argv, const char *prefix)
5050
3 < rev.max_count)
5151
usage(diff_files_usage);
5252

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

builtin-diff.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,13 @@ static int builtin_diff_files(struct rev_info *revs, int argc, const char **argv
225225
argv++; argc--;
226226
}
227227

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

git-svn.perl

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4010,20 +4010,19 @@ sub gs_do_switch {
40104010
my $old_url = $full_url;
40114011
$full_url .= '/' . escape_uri_only($path) if length $path;
40124012
my ($ra, $reparented);
4013-
if ($old_url ne $full_url) {
4014-
if ($old_url !~ m#^svn(\+ssh)?://#) {
4015-
SVN::_Ra::svn_ra_reparent($self->{session}, $full_url,
4016-
$pool);
4017-
$self->{url} = $full_url;
4018-
$reparented = 1;
4019-
} else {
4020-
$_[0] = undef;
4021-
$self = undef;
4022-
$RA = undef;
4023-
$ra = Git::SVN::Ra->new($full_url);
4024-
$ra_invalid = 1;
4025-
}
4013+
4014+
if ($old_url =~ m#^svn(\+ssh)?://#) {
4015+
$_[0] = undef;
4016+
$self = undef;
4017+
$RA = undef;
4018+
$ra = Git::SVN::Ra->new($full_url);
4019+
$ra_invalid = 1;
4020+
} elsif ($old_url ne $full_url) {
4021+
SVN::_Ra::svn_ra_reparent($self->{session}, $full_url, $pool);
4022+
$self->{url} = $full_url;
4023+
$reparented = 1;
40264024
}
4025+
40274026
$ra ||= $self;
40284027
$url_b = escape_url($url_b);
40294028
my $reporter = $ra->do_switch($rev_b, '', 1, $url_b, $editor, $pool);

gitweb/gitweb.perl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2123,7 +2123,7 @@ sub parse_commit_text {
21232123
last;
21242124
}
21252125
}
2126-
if ($co{'title'} eq "") {
2126+
if (! defined $co{'title'} || $co{'title'} eq "") {
21272127
$co{'title'} = $co{'title_short'} = '(no commit message)';
21282128
}
21292129
# remove added spaces

sha1_file.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2136,7 +2136,9 @@ static void write_sha1_file_prepare(const void *buf, unsigned long len,
21362136
*/
21372137
int move_temp_to_file(const char *tmpfile, const char *filename)
21382138
{
2139-
int ret = link(tmpfile, filename);
2139+
int ret = 0;
2140+
if (link(tmpfile, filename))
2141+
ret = errno;
21402142

21412143
/*
21422144
* Coda hack - coda doesn't like cross-directory links,

t/lib-git-svn.sh

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,3 +138,20 @@ close $wr or die $!;
138138
close $rd or die $!;
139139
EOF
140140
}
141+
142+
require_svnserve () {
143+
if test -z "$SVNSERVE_PORT"
144+
then
145+
say 'skipping svnserve test. (set $SVNSERVE_PORT to enable)'
146+
test_done
147+
exit
148+
fi
149+
}
150+
151+
start_svnserve () {
152+
svnserve --listen-port $SVNSERVE_PORT \
153+
--root "$rawsvnrepo" \
154+
--listen-once \
155+
--listen-host 127.0.0.1 &
156+
}
157+

t/t0024-crlf-archive.sh

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
#!/bin/sh
2+
3+
test_description='respect crlf in git archive'
4+
5+
. ./test-lib.sh
6+
UNZIP=${UNZIP:-unzip}
7+
8+
test_expect_success setup '
9+
10+
git config core.autocrlf true
11+
12+
printf "CRLF line ending\r\nAnd another\r\n" > sample &&
13+
git add sample &&
14+
15+
test_tick &&
16+
git commit -m Initial
17+
18+
'
19+
20+
test_expect_success 'tar archive' '
21+
22+
git archive --format=tar HEAD |
23+
( mkdir untarred && cd untarred && "$TAR" -xf - )
24+
25+
test_cmp sample untarred/sample
26+
27+
'
28+
29+
"$UNZIP" -v >/dev/null 2>&1
30+
if [ $? -eq 127 ]; then
31+
echo "Skipping ZIP test, because unzip was not found"
32+
test_done
33+
exit
34+
fi
35+
36+
test_expect_success 'zip archive' '
37+
38+
git archive --format=zip HEAD >test.zip &&
39+
40+
( mkdir unzipped && cd unzipped && unzip ../test.zip ) &&
41+
42+
test_cmp sample unzipped/sample
43+
44+
'
45+
46+
test_done

t/t9113-git-svn-dcommit-new-file.sh

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,7 @@ test_description='git svn dcommit new files over svn:// test'
1212

1313
. ./lib-git-svn.sh
1414

15-
if test -z "$SVNSERVE_PORT"
16-
then
17-
say 'skipping svnserve test. (set $SVNSERVE_PORT to enable)'
18-
test_done
19-
exit
20-
fi
21-
22-
start_svnserve () {
23-
svnserve --listen-port $SVNSERVE_PORT \
24-
--root "$rawsvnrepo" \
25-
--listen-once \
26-
--listen-host 127.0.0.1 &
27-
}
15+
require_svnserve
2816

2917
test_expect_success 'start tracking an empty repo' '
3018
svn mkdir -m "empty dir" "$svnrepo"/empty-dir &&

0 commit comments

Comments
 (0)