diff --git a/Documentation/technical/api-diff.txt b/Documentation/technical/api-diff.txt index 20b0241d30..2d2ebc04b7 100644 --- a/Documentation/technical/api-diff.txt +++ b/Documentation/technical/api-diff.txt @@ -32,7 +32,7 @@ Calling sequence * As you find different pairs of files, call `diff_change()` to feed modified files, `diff_addremove()` to feed created or deleted files, - or `diff_unmerged()` to feed a file whose state is 'unmerged' to the + or `diff_unmerge()` to feed a file whose state is 'unmerged' to the API. These are thin wrappers to a lower-level `diff_queue()` function that is flexible enough to record any of these kinds of changes. @@ -50,7 +50,7 @@ Data structures This is the internal representation for a single file (blob). It records the blob object name (if known -- for a work tree file it typically is a NUL SHA-1), filemode and pathname. This is what the -`diff_addremove()`, `diff_change()` and `diff_unmerged()` synthesize and +`diff_addremove()`, `diff_change()` and `diff_unmerge()` synthesize and feed `diff_queue()` function with. * `struct diff_filepair` diff --git a/fsck.c b/fsck.c index 6f266c1ea4..60bd4bbf6a 100644 --- a/fsck.c +++ b/fsck.c @@ -349,7 +349,7 @@ int fsck_error_function(struct object *obj, int type, const char *fmt, ...) va_list ap; struct strbuf sb = STRBUF_INIT; - strbuf_addf(&sb, "object %s:", obj->sha1?sha1_to_hex(obj->sha1):"(null)"); + strbuf_addf(&sb, "object %s:", sha1_to_hex(obj->sha1)); va_start(ap, fmt); strbuf_vaddf(&sb, fmt, ap); diff --git a/git-submodule.sh b/git-submodule.sh index c1d3a5e2fa..c571d320d0 100755 --- a/git-submodule.sh +++ b/git-submodule.sh @@ -499,7 +499,7 @@ Maybe you want to use 'update --init'?")" # Run fetch only if $sha1 isn't present or it # is not reachable from a ref. (clear_local_git_env; cd "$path" && - ((rev=$(git rev-list -n 1 $sha1 --not --all 2>/dev/null) && + ( (rev=$(git rev-list -n 1 $sha1 --not --all 2>/dev/null) && test -z "$rev") || git-fetch)) || die "$(eval_gettext "Unable to fetch in submodule path '\$path'")" fi diff --git a/rerere.c b/rerere.c index e3407cf334..dcb525a4d0 100644 --- a/rerere.c +++ b/rerere.c @@ -47,8 +47,14 @@ static void read_rr(struct string_list *rr) name = xstrdup(buf); if (fgetc(in) != '\t') die("corrupt MERGE_RR"); - for (i = 0; i < sizeof(buf) && (buf[i] = fgetc(in)); i++) - ; /* do nothing */ + for (i = 0; i < sizeof(buf); i++) { + int c = fgetc(in); + if (c < 0) + die("corrupt MERGE_RR"); + buf[i] = c; + if (c == 0) + break; + } if (i == sizeof(buf)) die("filename too long"); string_list_insert(rr, buf)->util = name; diff --git a/setup.c b/setup.c index 013ad11275..ce87900ce3 100644 --- a/setup.c +++ b/setup.c @@ -382,7 +382,7 @@ const char *read_gitfile_gently(const char *path) const char *slash; struct stat st; int fd; - size_t len; + ssize_t len; if (stat(path, &st)) return NULL; diff --git a/t/t7810-grep.sh b/t/t7810-grep.sh index e061108a64..69bd576d1c 100755 --- a/t/t7810-grep.sh +++ b/t/t7810-grep.sh @@ -33,9 +33,9 @@ test_expect_success setup ' echo HeLLo_world } >hello_world && { - echo aab - echo a+b - echo a\\+b + echo "a+b*c" + echo "a+bc" + echo "abc" } >ab && echo vvv >v && echo ww w >w && @@ -233,14 +233,14 @@ do test_cmp expected actual ' test_expect_success "grep $L with grep.extendedRegexp=false" ' - echo "ab:a+b" >expected && - git -c grep.extendedRegexp=false grep "a+b" >actual && + echo "ab:a+bc" >expected && + git -c grep.extendedRegexp=false grep "a+b*c" ab >actual && test_cmp expected actual ' test_expect_success "grep $L with grep.extendedRegexp=true" ' - echo "ab:aab" >expected && - git -c grep.extendedRegexp=true grep "a+b" >actual && + echo "ab:abc" >expected && + git -c grep.extendedRegexp=true grep "a+b*c" ab >actual && test_cmp expected actual ' done @@ -636,7 +636,7 @@ test_expect_success LIBPCRE 'grep -P pattern' ' ' test_expect_success 'grep pattern with grep.extendedRegexp=true' ' - :>empty && + >empty && test_must_fail git -c grep.extendedregexp=true \ grep "\p{Ps}.*?\p{Pe}" hello.c >actual && test_cmp empty actual @@ -650,10 +650,10 @@ test_expect_success LIBPCRE 'grep -P pattern with grep.extendedRegexp=true' ' test_expect_success LIBPCRE 'grep -P -v pattern' ' { - echo ab:a+b - echo ab:a\\+b + echo "ab:a+b*c" + echo "ab:a+bc" } >expected && - git grep -P -v "aab" ab >actual && + git grep -P -v "abc" ab >actual && test_cmp expected actual ' @@ -686,39 +686,33 @@ test_expect_success LIBPCRE 'grep -P invalidpattern properly dies ' ' test_must_fail git grep -P "a[" ' -test_expect_success 'grep -F -E -G pattern' ' - echo ab:a+b >expected && - git grep -F -E -G a+b >actual && - test_cmp expected actual -' - -test_expect_success 'grep -F -G -E pattern' ' - echo ab:aab >expected && - git grep -F -G -E a+b >actual && +test_expect_success 'grep -G -E -F pattern' ' + echo "ab:a+b*c" >expected && + git grep -G -E -F "a+b*c" ab >actual && test_cmp expected actual ' test_expect_success 'grep -E -F -G pattern' ' - echo ab:aab >expected && - git grep -E -F -G a\\+b >actual && + echo "ab:a+bc" >expected && + git grep -E -F -G "a+b*c" ab >actual && test_cmp expected actual ' -test_expect_success 'grep -E -G -F pattern' ' - echo ab:a\\+b >expected && - git grep -E -G -F a\\+b >actual && +test_expect_success 'grep -F -G -E pattern' ' + echo "ab:abc" >expected && + git grep -F -G -E "a+b*c" ab >actual && test_cmp expected actual ' -test_expect_success 'grep -G -F -E pattern' ' - echo ab:a+b >expected && - git grep -G -F -E a\\+b >actual && - test_cmp expected actual +test_expect_success 'grep -G -F -P -E pattern' ' + >empty && + test_must_fail git grep -G -F -P -E "a\x{2b}b\x{2a}c" ab >actual && + test_cmp empty actual ' -test_expect_success LIBPCRE 'grep -E -G -F -P pattern' ' - echo ab:a+b >expected && - git grep -E -G -F -P a\\+b >actual && +test_expect_success LIBPCRE 'grep -G -F -E -P pattern' ' + echo "ab:a+b*c" >expected && + git grep -G -F -E -P "a\x{2b}b\x{2a}c" ab >actual && test_cmp expected actual ' diff --git a/transport.c b/transport.c index 1a3998ee51..c9c8056f9d 100644 --- a/transport.c +++ b/transport.c @@ -156,7 +156,7 @@ static void set_upstreams(struct transport *transport, struct ref *refs, continue; if (!ref->peer_ref) continue; - if (!ref->new_sha1 || is_null_sha1(ref->new_sha1)) + if (is_null_sha1(ref->new_sha1)) continue; /* Follow symbolic refs (mainly for HEAD). */