Skip to content

Commit

Permalink
Merge branch 'maint'
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
Junio C Hamano committed Oct 17, 2008
2 parents 84ed4c5 + 8ed0a74 commit 46dc1b0
Show file tree
Hide file tree
Showing 7 changed files with 101 additions and 6 deletions.
50 changes: 50 additions & 0 deletions Documentation/git-check-attr.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,56 @@ OPTIONS
arguments as path names. If not supplied, only the first argument will
be treated as an attribute.

OUTPUT
------

The output is of the form:
<path> COLON SP <attribute> COLON SP <info> LF

Where <path> is the path of a file being queried, <attribute> is an attribute
being queried and <info> can be either:

'unspecified';; when the attribute is not defined for the path.
'unset';; when the attribute is defined to false.
'set';; when the attribute is defined to true.
<value>;; when a value has been assigned to the attribute.

EXAMPLES
--------

In the examples, the following '.gitattributes' file is used:
---------------
*.java diff=java -crlf myAttr
NoMyAttr.java !myAttr
README caveat=unspecified
---------------

* Listing a single attribute:
---------------
$ git check-attr diff org/example/MyClass.java
org/example/MyClass.java: diff: java
---------------

* Listing multiple attributes for a file:
---------------
$ git check-attr crlf diff myAttr -- org/example/MyClass.java
org/example/MyClass.java: crlf: unset
org/example/MyClass.java: diff: java
org/example/MyClass.java: myAttr: set
---------------

* Listing attribute for multiple files:
---------------
$ git check-attr myAttr -- org/example/MyClass.java org/example/NoMyAttr.java
org/example/MyClass.java: myAttr: set
org/example/NoMyAttr.java: myAttr: unspecified
---------------

* Not all values are equally unambiguous:
---------------
$ git check-attr caveat README
README: caveat: unspecified
---------------

SEE ALSO
--------
Expand Down
2 changes: 1 addition & 1 deletion contrib/examples/git-remote.perl
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ sub update_remote {
}
}
} else {
print STDERR "Remote group $name does not exists.\n";
print STDERR "Remote group $name does not exist.\n";
exit(1);
}
for (@remotes) {
Expand Down
9 changes: 5 additions & 4 deletions remote.c
Original file line number Diff line number Diff line change
Expand Up @@ -341,13 +341,14 @@ static int handle_config(const char *key, const char *value, void *cb)
if (prefixcmp(key, "remote."))
return 0;
name = key + 7;
if (*name == '/') {
warning("Config remote shorthand cannot begin with '/': %s",
name);
return 0;
}
subkey = strrchr(name, '.');
if (!subkey)
return error("Config with no key for remote %s", name);
if (*subkey == '/') {
warning("Config remote shorthand cannot begin with '/': %s", name);
return 0;
}
remote = make_remote(name, subkey - name);
if (!strcmp(subkey, ".mirror"))
remote->mirror = git_config_bool(key, value);
Expand Down
3 changes: 3 additions & 0 deletions t/t1301-shared-repo.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ test_description='Test shared repository initialization'

. ./test-lib.sh

# Remove a default ACL from the test dir if possible.
setfacl -k . 2>/dev/null

# User must have read permissions to the repo -> failure on --shared=0400
test_expect_success 'shared = 0400 (faulty permission u-w)' '
mkdir sub && (
Expand Down
9 changes: 8 additions & 1 deletion t/t4018-diff-funcname.sh
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,14 @@ test_expect_success 'custom pattern' '

test_expect_success 'last regexp must not be negated' '
git config diff.java.funcname "!static" &&
test_must_fail git diff --no-index Beer.java Beer-correct.java
git diff --no-index Beer.java Beer-correct.java 2>&1 |
grep "fatal: Last expression must not be negated:"
'

test_expect_success 'pattern which matches to end of line' '
git config diff.java.funcname "Beer$" &&
git diff --no-index Beer.java Beer-correct.java |
grep "^@@.*@@ Beer"
'

test_expect_success 'alternation in pattern' '
Expand Down
24 changes: 24 additions & 0 deletions t/t7600-merge.sh
Original file line number Diff line number Diff line change
Expand Up @@ -518,6 +518,30 @@ test_expect_success 'refresh the index before merging' '
git merge c3
'

cat >expected <<EOF
Merge branch 'c5' (early part)
EOF

test_expect_success 'merge early part of c2' '
git reset --hard c3 &&
echo c4 > c4.c &&
git add c4.c &&
git commit -m c4 &&
git tag c4 &&
echo c5 > c5.c &&
git add c5.c &&
git commit -m c5 &&
git tag c5 &&
git reset --hard c3 &&
echo c6 > c6.c &&
git add c6.c &&
git commit -m c6 &&
git tag c6 &&
git merge c5~1 &&
git show -s --pretty=format:%s HEAD > actual &&
test_cmp actual expected
'

test_debug 'gitk --all'

test_done
10 changes: 10 additions & 0 deletions xdiff-interface.c
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,16 @@ static long ff_regexp(const char *line, long len,

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

/* Exclude terminating newline (and cr) from matching */
if (len > 0 && line[len-1] == '\n') {
if (len > 1 && line[len-2] == '\r')
len -= 2;
else
len--;
}

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

for (i = 0; i < regs->nr; i++) {
struct ff_reg *reg = regs->array + i;
if (!regexec(&reg->re, line_buffer, 2, pmatch, 0)) {
Expand Down

0 comments on commit 46dc1b0

Please sign in to comment.