From 4e6d4bc0f0f1388dfcad2af4804b35289ed4ec92 Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Mon, 13 Oct 2008 22:54:25 +0200 Subject: Add testcase to ensure merging an early part of a branch is done properly Signed-off-by: Miklos Vajna Signed-off-by: Junio C Hamano --- t/t7600-merge.sh | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/t/t7600-merge.sh b/t/t7600-merge.sh index 94bc556cb2..5abce3119b 100755 --- a/t/t7600-merge.sh +++ b/t/t7600-merge.sh @@ -507,4 +507,30 @@ test_expect_success 'in-index merge' ' test_debug 'gitk --all' +cat >expected < 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 -- cgit v1.2.3 From c82efafcfa741cdddbc68379c1905953f58ef21d Mon Sep 17 00:00:00 2001 From: Brandon Casey Date: Tue, 14 Oct 2008 15:30:21 -0500 Subject: remote.c: correct the check for a leading '/' in a remote name This test is supposed to disallow remote entries in the config file of the form: [remote "/foobar"] ... The leading slash in '/foobar' is not acceptable. Instead it was incorrectly testing that the subkey had no leading '/', which had no effect since the subkey pointer was made to point at a '.' in the preceding lines. Signed-off-by: Brandon Casey Acked-by: Daniel Barkalow Signed-off-by: Junio C Hamano --- remote.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/remote.c b/remote.c index 105668f8a3..7688f3b04d 100644 --- a/remote.c +++ b/remote.c @@ -342,13 +342,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); -- cgit v1.2.3 From 6c2a6022dbc5879f5d6c267925408e484be6214a Mon Sep 17 00:00:00 2001 From: Mikael Magnusson Date: Fri, 19 Sep 2008 15:48:08 +0200 Subject: Typo "does not exists" when git remote update remote. --- contrib/examples/git-remote.perl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contrib/examples/git-remote.perl b/contrib/examples/git-remote.perl index 36bd54c985..b17952a785 100755 --- a/contrib/examples/git-remote.perl +++ b/contrib/examples/git-remote.perl @@ -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) { -- cgit v1.2.3 From 16b26725368f7b80711d9a631029fbb869646f9c Mon Sep 17 00:00:00 2001 From: Brandon Casey Date: Wed, 15 Oct 2008 19:58:49 -0500 Subject: t4018-diff-funcname: rework negated last expression test This test used the non-zero exit status of 'git diff' to indicate that a negated funcname pattern, when placed last, was correctly rejected. The problem with this is that 'git diff' always returns non-zero if it finds differences in the files it is comparing, and the files must contain differences in order to trigger the funcname pattern codepath. Instead of checking for non-zero exit status, make sure the expected error message is printed. Signed-off-by: Brandon Casey Signed-off-by: Junio C Hamano --- t/t4018-diff-funcname.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/t/t4018-diff-funcname.sh b/t/t4018-diff-funcname.sh index 99fff973eb..72076eca80 100755 --- a/t/t4018-diff-funcname.sh +++ b/t/t4018-diff-funcname.sh @@ -65,7 +65,8 @@ 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 'alternation in pattern' ' -- cgit v1.2.3 From b19d288b4d440c76348b519d06a4ed7b62c93611 Mon Sep 17 00:00:00 2001 From: Brandon Casey Date: Wed, 15 Oct 2008 19:58:50 -0500 Subject: t4018-diff-funcname: demonstrate end of line funcname matching flaw Since the newline is not removed from lines before pattern matching, a pattern cannot match to the end of the line using the '$' operator without using an additional operator which will indirectly match the '\n' character. Introduce a test which should pass, but which does not due to this flaw. Signed-off-by: Brandon Casey Signed-off-by: Junio C Hamano --- t/t4018-diff-funcname.sh | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/t/t4018-diff-funcname.sh b/t/t4018-diff-funcname.sh index 72076eca80..40a805a866 100755 --- a/t/t4018-diff-funcname.sh +++ b/t/t4018-diff-funcname.sh @@ -69,6 +69,12 @@ test_expect_success 'last regexp must not be negated' ' grep "fatal: Last expression must not be negated:" ' +test_expect_failure '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' ' git config diff.java.xfuncname "^[ ]*((public|static).*)$" && git diff --no-index Beer.java Beer-correct.java | -- cgit v1.2.3 From 563d5a2c84fb5daf77dd8bfe569e92566a8fd52b Mon Sep 17 00:00:00 2001 From: Brandon Casey Date: Wed, 1 Oct 2008 14:28:26 -0500 Subject: xdiff-interface.c: strip newline (and cr) from line before pattern matching POSIX doth sayeth: "In the regular expression processing described in IEEE Std 1003.1-2001, the is regarded as an ordinary character and both a period and a non-matching list can match one. ... Those utilities (like grep) that do not allow s to match are responsible for eliminating any from strings before matching against the RE." Thus far git has not been removing the trailing newline from strings matched against regular expression patterns. This has the effect that (quoting Jonathan del Strother) "... a line containing just 'FUNCNAME' (terminated by a newline) will be matched by the pattern '^(FUNCNAME.$)' but not '^(FUNCNAME$)'", and more simply not '^FUNCNAME$'. Signed-off-by: Brandon Casey Signed-off-by: Shawn O. Pearce --- t/t4018-diff-funcname.sh | 2 +- xdiff-interface.c | 12 +++++++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/t/t4018-diff-funcname.sh b/t/t4018-diff-funcname.sh index 40a805a866..398bf4b5d8 100755 --- a/t/t4018-diff-funcname.sh +++ b/t/t4018-diff-funcname.sh @@ -69,7 +69,7 @@ test_expect_success 'last regexp must not be negated' ' grep "fatal: Last expression must not be negated:" ' -test_expect_failure 'pattern which matches to end of line' ' +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" diff --git a/xdiff-interface.c b/xdiff-interface.c index 2c81f40cb6..3bf83f81e3 100644 --- a/xdiff-interface.c +++ b/xdiff-interface.c @@ -179,11 +179,21 @@ struct ff_regs { static long ff_regexp(const char *line, long len, char *buffer, long buffer_size, void *priv) { - char *line_buffer = xstrndup(line, len); /* make NUL terminated */ + char *line_buffer; struct ff_regs *regs = priv; regmatch_t pmatch[2]; int result = 0, i; + /* 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 (reg->negate ^ !!regexec(®->re, -- cgit v1.2.3 From 5782566d7f2847bd94e33fd26c8a961e887ec10a Mon Sep 17 00:00:00 2001 From: Jonas Fonseca Date: Wed, 15 Oct 2008 09:10:58 +0200 Subject: git-check-attr(1): add output and example sections Plumbing tools should document what output can be expected. Signed-off-by: Jonas Fonseca Signed-off-by: Junio C Hamano --- Documentation/git-check-attr.txt | 50 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/Documentation/git-check-attr.txt b/Documentation/git-check-attr.txt index 2b821f2a1d..4b3c2b0b06 100644 --- a/Documentation/git-check-attr.txt +++ b/Documentation/git-check-attr.txt @@ -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: + COLON SP COLON SP LF + +Where is the path of a file being queried, is an attribute +being queried and 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. +;; 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 -------- -- cgit v1.2.3 From 8ed0a740dd42bd0724aebed6e3b07c4ea2a2d5e8 Mon Sep 17 00:00:00 2001 From: Matt McCutchen Date: Thu, 16 Oct 2008 22:32:14 -0400 Subject: t1301-shared-repo.sh: don't let a default ACL interfere with the test This test creates files with several different umasks and expects their permissions to be initialized according to the umask, so a default ACL on the trash directory (which overrides the umask for files created in that directory) causes the test to fail. To avoid that, remove the default ACL if possible with setfacl(1). Signed-off-by: Matt McCutchen Signed-off-by: Junio C Hamano --- t/t1301-shared-repo.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/t/t1301-shared-repo.sh b/t/t1301-shared-repo.sh index dc85e8b60a..2275caa317 100755 --- a/t/t1301-shared-repo.sh +++ b/t/t1301-shared-repo.sh @@ -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 && ( -- cgit v1.2.3