Skip to content

Commit 5b590d7

Browse files
committed
Merge branch 'maint'
* maint: GIT 1.6.4.3 svn: properly escape arguments for authors-prog http.c: remove verification of remote packs grep: accept relative paths outside current working directory grep: fix exit status if external_grep() punts Conflicts: GIT-VERSION-GEN RelNotes
2 parents 0c3d3ac + 7fb6bcf commit 5b590d7

File tree

8 files changed

+76
-39
lines changed

8 files changed

+76
-39
lines changed

Documentation/RelNotes-1.6.4.3.txt

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
GIT v1.6.4.3 Release Notes
2+
==========================
3+
4+
Fixes since v1.6.4.2
5+
--------------------
6+
7+
* "git clone" from an empty repository gave unnecessary error message,
8+
even though it did everything else correctly.
9+
10+
* "git cvsserver" invoked git commands via "git-foo" style, which has long
11+
been deprecated.
12+
13+
* "git fetch" and "git clone" had an extra sanity check to verify the
14+
presense of the corresponding *.pack file before downloading *.idx
15+
file by issuing a HEAD request. Github server however sometimes
16+
gave 500 (Internal server error) response to HEAD even if a GET
17+
request for *.pack file to the same URL would have succeeded, and broke
18+
clone over HTTP from some of their repositories. As a workaround, this
19+
verification has been removed (as it is not absolutely necessary).
20+
21+
* "git grep" did not like relative pathname to refer outside the current
22+
directory when run from a subdirectory.
23+
24+
* an error message from "git push" was formatted in a very ugly way.
25+
26+
* "git svn" did not quote the subversion user name correctly when
27+
running its author-prog helper program.
28+
29+
Other minor documentation updates are included.

Documentation/git.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,10 @@ unreleased) version of git, that is available from 'master'
4343
branch of the `git.git` repository.
4444
Documentation for older releases are available here:
4545

46-
* link:v1.6.4.2/git.html[documentation for release 1.6.4.2]
46+
* link:v1.6.4.3/git.html[documentation for release 1.6.4.3]
4747

4848
* release notes for
49+
link:RelNotes-1.6.4.3.txt[1.6.4.3],
4950
link:RelNotes-1.6.4.2.txt[1.6.4.2],
5051
link:RelNotes-1.6.4.1.txt[1.6.4.1],
5152
link:RelNotes-1.6.4.txt[1.6.4].

builtin-grep.c

Lines changed: 12 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#include "parse-options.h"
1414
#include "userdiff.h"
1515
#include "grep.h"
16+
#include "quote.h"
1617

1718
#ifndef NO_EXTERNAL_GREP
1819
#ifdef __unix__
@@ -157,35 +158,22 @@ static int grep_sha1(struct grep_opt *opt, const unsigned char *sha1, const char
157158
unsigned long size;
158159
char *data;
159160
enum object_type type;
160-
char *to_free = NULL;
161161
int hit;
162+
struct strbuf pathbuf = STRBUF_INIT;
162163

163164
data = read_sha1_file(sha1, &type, &size);
164165
if (!data) {
165166
error("'%s': unable to read %s", name, sha1_to_hex(sha1));
166167
return 0;
167168
}
168169
if (opt->relative && opt->prefix_length) {
169-
static char name_buf[PATH_MAX];
170-
char *cp;
171-
int name_len = strlen(name) - opt->prefix_length + 1;
172-
173-
if (!tree_name_len)
174-
name += opt->prefix_length;
175-
else {
176-
if (ARRAY_SIZE(name_buf) <= name_len)
177-
cp = to_free = xmalloc(name_len);
178-
else
179-
cp = name_buf;
180-
memcpy(cp, name, tree_name_len);
181-
strcpy(cp + tree_name_len,
182-
name + tree_name_len + opt->prefix_length);
183-
name = cp;
184-
}
170+
quote_path_relative(name + tree_name_len, -1, &pathbuf, opt->prefix);
171+
strbuf_insert(&pathbuf, 0, name, tree_name_len);
172+
name = pathbuf.buf;
185173
}
186174
hit = grep_buffer(opt, name, data, size);
175+
strbuf_release(&pathbuf);
187176
free(data);
188-
free(to_free);
189177
return hit;
190178
}
191179

@@ -195,6 +183,7 @@ static int grep_file(struct grep_opt *opt, const char *filename)
195183
int i;
196184
char *data;
197185
size_t sz;
186+
struct strbuf buf = STRBUF_INIT;
198187

199188
if (lstat(filename, &st) < 0) {
200189
err_ret:
@@ -219,8 +208,9 @@ static int grep_file(struct grep_opt *opt, const char *filename)
219208
}
220209
close(i);
221210
if (opt->relative && opt->prefix_length)
222-
filename += opt->prefix_length;
211+
filename = quote_path_relative(filename, -1, &buf, opt->prefix);
223212
i = grep_buffer(opt, filename, data, sz);
213+
strbuf_release(&buf);
224214
free(data);
225215
return i;
226216
}
@@ -503,6 +493,7 @@ static int grep_cache(struct grep_opt *opt, const char **paths, int cached,
503493
hit = external_grep(opt, paths, cached);
504494
if (hit >= 0)
505495
return hit;
496+
hit = 0;
506497
}
507498
#endif
508499

@@ -798,6 +789,7 @@ int cmd_grep(int argc, const char **argv, const char *prefix)
798789
};
799790

800791
memset(&opt, 0, sizeof(opt));
792+
opt.prefix = prefix;
801793
opt.prefix_length = (prefix && *prefix) ? strlen(prefix) : 0;
802794
opt.relative = 1;
803795
opt.pathname = 1;
@@ -868,15 +860,8 @@ int cmd_grep(int argc, const char **argv, const char *prefix)
868860
verify_filename(prefix, argv[j]);
869861
}
870862

871-
if (i < argc) {
863+
if (i < argc)
872864
paths = get_pathspec(prefix, argv + i);
873-
if (opt.prefix_length && opt.relative) {
874-
/* Make sure we do not get outside of paths */
875-
for (i = 0; paths[i]; i++)
876-
if (strncmp(prefix, paths[i], opt.prefix_length))
877-
die("git grep: cannot generate relative filenames containing '..'");
878-
}
879-
}
880865
else if (prefix) {
881866
paths = xcalloc(2, sizeof(const char *));
882867
paths[0] = prefix;

git-svn.perl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2836,6 +2836,7 @@ sub other_gs {
28362836

28372837
sub call_authors_prog {
28382838
my ($orig_author) = @_;
2839+
$orig_author = command_oneline('rev-parse', '--sq-quote', $orig_author);
28392840
my $author = `$::_authors_prog $orig_author`;
28402841
if ($? != 0) {
28412842
die "$::_authors_prog failed with exit code $?\n"

grep.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ struct grep_opt {
5959
struct grep_pat *pattern_list;
6060
struct grep_pat **pattern_tail;
6161
struct grep_expr *pattern_expression;
62+
const char *prefix;
6263
int prefix_length;
6364
regex_t regexp;
6465
int linenum;

http.c

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -869,17 +869,6 @@ static int fetch_pack_index(unsigned char *sha1, const char *base_url)
869869
char *url;
870870
struct strbuf buf = STRBUF_INIT;
871871

872-
/* Don't use the index if the pack isn't there */
873-
end_url_with_slash(&buf, base_url);
874-
strbuf_addf(&buf, "objects/pack/pack-%s.pack", hex);
875-
url = strbuf_detach(&buf, 0);
876-
877-
if (http_get_strbuf(url, NULL, 0)) {
878-
ret = error("Unable to verify pack %s is available",
879-
hex);
880-
goto cleanup;
881-
}
882-
883872
if (has_pack_index(sha1)) {
884873
ret = 0;
885874
goto cleanup;

t/t7002-grep.sh

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -328,4 +328,21 @@ test_expect_success 'grep -p -B5' '
328328
test_cmp expected actual
329329
'
330330

331+
test_expect_success 'grep from a subdirectory to search wider area (1)' '
332+
mkdir -p s &&
333+
(
334+
cd s && git grep "x x x" ..
335+
)
336+
'
337+
338+
test_expect_success 'grep from a subdirectory to search wider area (2)' '
339+
mkdir -p s &&
340+
(
341+
cd s || exit 1
342+
( git grep xxyyzz .. >out ; echo $? >status )
343+
! test -s out &&
344+
test 1 = $(cat status)
345+
)
346+
'
347+
331348
test_done

t/t9138-git-svn-authors-prog.sh

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,4 +66,18 @@ test_expect_success 'authors-file overrode authors-prog' '
6666
)
6767
'
6868

69+
git --git-dir=x/.git config --unset svn.authorsfile
70+
git --git-dir=x/.git config --unset svn.authorsprog
71+
72+
test_expect_success 'authors-prog handled special characters in username' '
73+
svn mkdir -m bad --username "xyz; touch evil" "$svnrepo"/bad &&
74+
(
75+
cd x &&
76+
git svn --authors-prog=../svn-authors-prog fetch &&
77+
git rev-list -1 --pretty=raw refs/remotes/git-svn |
78+
grep "^author xyz; touch evil <xyz; touch evil@example\.com> " &&
79+
! test -f evil
80+
)
81+
'
82+
6983
test_done

0 commit comments

Comments
 (0)