Skip to content

Commit 46dc1b0

Browse files
committed
Merge branch 'maint'
* maint: t1301-shared-repo.sh: don't let a default ACL interfere with the test git-check-attr(1): add output and example sections xdiff-interface.c: strip newline (and cr) from line before pattern matching t4018-diff-funcname: demonstrate end of line funcname matching flaw t4018-diff-funcname: rework negated last expression test Typo "does not exists" when git remote update remote. remote.c: correct the check for a leading '/' in a remote name Add testcase to ensure merging an early part of a branch is done properly Conflicts: t/t7600-merge.sh
2 parents 84ed4c5 + 8ed0a74 commit 46dc1b0

File tree

7 files changed

+101
-6
lines changed

7 files changed

+101
-6
lines changed

Documentation/git-check-attr.txt

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,56 @@ OPTIONS
2222
arguments as path names. If not supplied, only the first argument will
2323
be treated as an attribute.
2424

25+
OUTPUT
26+
------
27+
28+
The output is of the form:
29+
<path> COLON SP <attribute> COLON SP <info> LF
30+
31+
Where <path> is the path of a file being queried, <attribute> is an attribute
32+
being queried and <info> can be either:
33+
34+
'unspecified';; when the attribute is not defined for the path.
35+
'unset';; when the attribute is defined to false.
36+
'set';; when the attribute is defined to true.
37+
<value>;; when a value has been assigned to the attribute.
38+
39+
EXAMPLES
40+
--------
41+
42+
In the examples, the following '.gitattributes' file is used:
43+
---------------
44+
*.java diff=java -crlf myAttr
45+
NoMyAttr.java !myAttr
46+
README caveat=unspecified
47+
---------------
48+
49+
* Listing a single attribute:
50+
---------------
51+
$ git check-attr diff org/example/MyClass.java
52+
org/example/MyClass.java: diff: java
53+
---------------
54+
55+
* Listing multiple attributes for a file:
56+
---------------
57+
$ git check-attr crlf diff myAttr -- org/example/MyClass.java
58+
org/example/MyClass.java: crlf: unset
59+
org/example/MyClass.java: diff: java
60+
org/example/MyClass.java: myAttr: set
61+
---------------
62+
63+
* Listing attribute for multiple files:
64+
---------------
65+
$ git check-attr myAttr -- org/example/MyClass.java org/example/NoMyAttr.java
66+
org/example/MyClass.java: myAttr: set
67+
org/example/NoMyAttr.java: myAttr: unspecified
68+
---------------
69+
70+
* Not all values are equally unambiguous:
71+
---------------
72+
$ git check-attr caveat README
73+
README: caveat: unspecified
74+
---------------
2575

2676
SEE ALSO
2777
--------

contrib/examples/git-remote.perl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,7 @@ sub update_remote {
309309
}
310310
}
311311
} else {
312-
print STDERR "Remote group $name does not exists.\n";
312+
print STDERR "Remote group $name does not exist.\n";
313313
exit(1);
314314
}
315315
for (@remotes) {

remote.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -341,13 +341,14 @@ static int handle_config(const char *key, const char *value, void *cb)
341341
if (prefixcmp(key, "remote."))
342342
return 0;
343343
name = key + 7;
344+
if (*name == '/') {
345+
warning("Config remote shorthand cannot begin with '/': %s",
346+
name);
347+
return 0;
348+
}
344349
subkey = strrchr(name, '.');
345350
if (!subkey)
346351
return error("Config with no key for remote %s", name);
347-
if (*subkey == '/') {
348-
warning("Config remote shorthand cannot begin with '/': %s", name);
349-
return 0;
350-
}
351352
remote = make_remote(name, subkey - name);
352353
if (!strcmp(subkey, ".mirror"))
353354
remote->mirror = git_config_bool(key, value);

t/t1301-shared-repo.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ test_description='Test shared repository initialization'
77

88
. ./test-lib.sh
99

10+
# Remove a default ACL from the test dir if possible.
11+
setfacl -k . 2>/dev/null
12+
1013
# User must have read permissions to the repo -> failure on --shared=0400
1114
test_expect_success 'shared = 0400 (faulty permission u-w)' '
1215
mkdir sub && (

t/t4018-diff-funcname.sh

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,14 @@ test_expect_success 'custom pattern' '
6565

6666
test_expect_success 'last regexp must not be negated' '
6767
git config diff.java.funcname "!static" &&
68-
test_must_fail git diff --no-index Beer.java Beer-correct.java
68+
git diff --no-index Beer.java Beer-correct.java 2>&1 |
69+
grep "fatal: Last expression must not be negated:"
70+
'
71+
72+
test_expect_success 'pattern which matches to end of line' '
73+
git config diff.java.funcname "Beer$" &&
74+
git diff --no-index Beer.java Beer-correct.java |
75+
grep "^@@.*@@ Beer"
6976
'
7077

7178
test_expect_success 'alternation in pattern' '

t/t7600-merge.sh

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -518,6 +518,30 @@ test_expect_success 'refresh the index before merging' '
518518
git merge c3
519519
'
520520

521+
cat >expected <<EOF
522+
Merge branch 'c5' (early part)
523+
EOF
524+
525+
test_expect_success 'merge early part of c2' '
526+
git reset --hard c3 &&
527+
echo c4 > c4.c &&
528+
git add c4.c &&
529+
git commit -m c4 &&
530+
git tag c4 &&
531+
echo c5 > c5.c &&
532+
git add c5.c &&
533+
git commit -m c5 &&
534+
git tag c5 &&
535+
git reset --hard c3 &&
536+
echo c6 > c6.c &&
537+
git add c6.c &&
538+
git commit -m c6 &&
539+
git tag c6 &&
540+
git merge c5~1 &&
541+
git show -s --pretty=format:%s HEAD > actual &&
542+
test_cmp actual expected
543+
'
544+
521545
test_debug 'gitk --all'
522546

523547
test_done

xdiff-interface.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,16 @@ static long ff_regexp(const char *line, long len,
207207

208208
line_buffer = xstrndup(line, len); /* make NUL terminated */
209209

210+
/* Exclude terminating newline (and cr) from matching */
211+
if (len > 0 && line[len-1] == '\n') {
212+
if (len > 1 && line[len-2] == '\r')
213+
len -= 2;
214+
else
215+
len--;
216+
}
217+
218+
line_buffer = xstrndup(line, len); /* make NUL terminated */
219+
210220
for (i = 0; i < regs->nr; i++) {
211221
struct ff_reg *reg = regs->array + i;
212222
if (!regexec(&reg->re, line_buffer, 2, pmatch, 0)) {

0 commit comments

Comments
 (0)