Compare
f0ef1b96a076d08dc972a8d2cb0d1cfd60931eb6..3bc0341126508f78f5869cbfc0005e987efdf0c7
Git 2.56-rc2
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Junio C Hamano <gitster@pobox.com> · 2026-09-22 12:36 UTC
15 files changed,
+153
−42
- .github/workflows/main.yml
- .mailmap
- Documentation/RelNotes/2.56.0.adoc
- Documentation/git-pack-refs.adoc
- Documentation/git-refs.adoc
- Documentation/pack-refs-options.adoc
- GIT-VERSION-GEN
- Makefile
- builtin/history.c
- ci/lib.sh
- config.mak.uname
- dir.c
- src/cargo-meson.sh
- t/t6132-pathspec-exclude.sh
- t/unit-tests/u-dir.c
modified .github/workflows/main.yml
| @@ -116,6 +116,30 @@ jobs: | |||
| 116 | 116 | steps: | |
| 117 | 117 | - uses: actions/checkout@v6 | |
| 118 | 118 | - uses: git-for-windows/setup-git-for-windows-sdk@v2 | |
| 119 | + | - name: Install GCC-compatible Rust target | |
| 120 | + | shell: bash | |
| 121 | + | run: | | |
| 122 | + | # The hosted Windows runners ship a rustup-managed Rust whose | |
| 123 | + | # default toolchain targets the MSVC ABI. That produces a | |
| 124 | + | # `gitcore.lib` which the MinGW GCC used by the rest of the | |
| 125 | + | # build cannot link. Install the precompiled `std` for a | |
| 126 | + | # GCC-compatible target triple matching the MSYS2 subsystem; | |
| 127 | + | # the Makefile selects the same triple via $(MSYSTEM) and | |
| 128 | + | # passes it to `cargo build --target`. | |
| 129 | + | case "$MSYSTEM" in | |
| 130 | + | CLANGARM64) target=aarch64-pc-windows-gnullvm ;; | |
| 131 | + | CLANG64) target=x86_64-pc-windows-gnullvm ;; | |
| 132 | + | CLANG32) target=i686-pc-windows-gnullvm ;; | |
| 133 | + | UCRT64) target=x86_64-pc-windows-gnu ;; | |
| 134 | + | MINGW64) target=x86_64-pc-windows-gnu ;; | |
| 135 | + | MINGW32) target=i686-pc-windows-gnu ;; | |
| 136 | + | *) echo "::error::Unsupported MSYSTEM: $MSYSTEM"; exit 1 ;; | |
| 137 | + | esac && | |
| 138 | + | rustup target add "$target" && | |
| 139 | + | ||
| 140 | + | # Ensure that cargo.exe is found even with the minimal SDK's restricted PATH | |
| 141 | + | CARGO="$(type -p cargo.exe)" && | |
| 142 | + | echo "export PATH=\$PATH:${CARGO%/cargo.exe}" >>/etc/profile | |
| 119 | 143 | - name: build | |
| 120 | 144 | shell: bash | |
| 121 | 145 | env: | |
modified .mailmap
| @@ -312,6 +312,7 @@ YONETANI Tomokazu <y0n3t4n1@gmail.com> <qhwt+git@les.ath.cx> | |||
| 312 | 312 | YONETANI Tomokazu <y0n3t4n1@gmail.com> <y0netan1@dragonflybsd.org> | |
| 313 | 313 | YOSHIFUJI Hideaki <yoshfuji@linux-ipv6.org> | |
| 314 | 314 | Yi-Jyun Pan <pan93412@gmail.com> | |
| 315 | + | Yoichi NAKAYAMA <yoichi.nakayama@gmail.com> | |
| 315 | 316 | # the two anonymous contributors are different persons: | |
| 316 | 317 | anonymous <linux@horizon.com> | |
| 317 | 318 | anonymous <linux@horizon.net> | |
modified Documentation/RelNotes/2.56.0.adoc
| @@ -560,6 +560,11 @@ Performance, Internal Implementation, Development Support etc. | |||
| 560 | 560 | backend-specific object source layers, making them pluggable for | |
| 561 | 561 | different object storage formats. | |
| 562 | 562 | ||
| 563 | + | * When cross-compiling with Cargo, the output artifact is placed in a | |
| 564 | + | target-specific subdirectory, which causes the build system to fail | |
| 565 | + | to locate it. The build system has been updated to respect the | |
| 566 | + | 'CARGO_BUILD_TARGET' environment variable. | |
| 567 | + | ||
| 563 | 568 | ||
| 564 | 569 | Fixes since v2.55 | |
| 565 | 570 | ----------------- | |
| @@ -883,7 +888,8 @@ Fixes since v2.55 | |||
| 883 | 888 | (merge ec602484bd kh/doc-datamodel later to maint). | |
| 884 | 889 | ||
| 885 | 890 | * Running "git history" in a corrupt repository can (unsurprisingly) | |
| 886 | - | segfault when a necessary tree object is not found. | |
| 891 | + | segfault when a necessary tree object is not found, which has been | |
| 892 | + | made to die more gracefully. | |
| 887 | 893 | (merge 76621488e8 jc/history-missing-tree-errorfix later to maint). | |
| 888 | 894 | ||
| 889 | 895 | * The development helper script to lint gitlink references in the | |
| @@ -897,6 +903,14 @@ Fixes since v2.55 | |||
| 897 | 903 | branch-switch message. | |
| 898 | 904 | (merge 2ba77ea828 hn/checkout-m-autostash-refine later to maint). | |
| 899 | 905 | ||
| 906 | + | * The memory leak caused by not unusing the commit buffer returned by | |
| 907 | + | repo_logmsg_reencode() during the rewording operation in 'git | |
| 908 | + | history' has been plugged. | |
| 909 | + | ||
| 910 | + | * The pathspec matching logic has been updated to avoid out-of-bounds | |
| 911 | + | memory accesses when a negative pathspec is shorter than the common | |
| 912 | + | prefix of positive pathspecs. | |
| 913 | + | ||
| 900 | 914 | * Other code cleanup, docfix, build fix, etc. | |
| 901 | 915 | (merge 026636128f ss/submittingpatches-typofix later to maint). | |
| 902 | 916 | (merge d2af22cc21 jc/rerere-doc-typofix later to maint). | |
modified Documentation/git-pack-refs.adoc
| @@ -7,8 +7,8 @@ git-pack-refs - Pack heads and tags for efficient repository access | |||
| 7 | 7 | ||
| 8 | 8 | SYNOPSIS | |
| 9 | 9 | -------- | |
| 10 | - | [verse] | |
| 11 | - | 'git pack-refs' [--all] [--no-prune] [--auto] [--include <pattern>] [--exclude <pattern>] | |
| 10 | + | [synopsis] | |
| 11 | + | git pack-refs [--all] [--no-prune] [--auto] [--include <pattern>] [--exclude <pattern>] | |
| 12 | 12 | ||
| 13 | 13 | DESCRIPTION | |
| 14 | 14 | ----------- | |
| @@ -52,8 +52,8 @@ BUGS | |||
| 52 | 52 | ---- | |
| 53 | 53 | ||
| 54 | 54 | Older documentation written before the packed-refs mechanism was | |
| 55 | - | introduced may still say things like ".git/refs/heads/<branch> file | |
| 56 | - | exists" when it means "branch <branch> exists". | |
| 55 | + | introduced may still say things like ".git/refs/heads/_<branch>_ file | |
| 56 | + | exists" when it means "branch _<branch>_ exists". | |
| 57 | 57 | ||
| 58 | 58 | ||
| 59 | 59 | GIT | |
modified Documentation/git-refs.adoc
| @@ -54,40 +54,40 @@ These limitations may eventually be lifted. | |||
| 54 | 54 | `verify`:: | |
| 55 | 55 | Verify reference database consistency. | |
| 56 | 56 | ||
| 57 | - | list:: | |
| 57 | + | `list`:: | |
| 58 | 58 | List references in the repository with support for filtering, | |
| 59 | 59 | formatting, and sorting. This subcommand is an alias for | |
| 60 | 60 | linkgit:git-for-each-ref[1] and offers identical functionality. | |
| 61 | 61 | ||
| 62 | - | exists:: | |
| 62 | + | `exists`:: | |
| 63 | 63 | Check whether the given reference exists. Returns an exit code of 0 if | |
| 64 | 64 | it does, 2 if it is missing, and 1 in case looking up the reference | |
| 65 | 65 | failed with an error other than the reference being missing. This does | |
| 66 | 66 | not verify whether the reference resolves to an actual object. | |
| 67 | 67 | ||
| 68 | - | optimize:: | |
| 68 | + | `optimize`:: | |
| 69 | 69 | Optimizes references to improve repository performance and reduce disk | |
| 70 | 70 | usage. This subcommand is an alias for linkgit:git-pack-refs[1] and | |
| 71 | 71 | offers identical functionality. | |
| 72 | 72 | ||
| 73 | - | create:: | |
| 73 | + | `create`:: | |
| 74 | 74 | Create the given reference, which must not already exist, pointing at | |
| 75 | 75 | `<new-value>`. | |
| 76 | 76 | ||
| 77 | - | delete:: | |
| 77 | + | `delete`:: | |
| 78 | 78 | Delete the given reference. This subcommand mirrors `git update-ref -d` | |
| 79 | 79 | (see linkgit:git-update-ref[1]). When `<old-value>` is given, the | |
| 80 | 80 | reference is only deleted after verifying that it currently contains | |
| 81 | 81 | `<old-value>`. | |
| 82 | 82 | ||
| 83 | - | update:: | |
| 83 | + | `update`:: | |
| 84 | 84 | Update the given reference to point at `<new-value>`. If `<old-value>` | |
| 85 | 85 | is given, the reference is only updated after verifying that it | |
| 86 | 86 | currently contains `<old-value>`. As a special case, an all-zeroes | |
| 87 | 87 | `<new-value>` deletes the branch, whereas an all-zeroes `<old-value>` | |
| 88 | 88 | ensures that the branch does not yet exist. | |
| 89 | 89 | ||
| 90 | - | rename:: | |
| 90 | + | `rename`:: | |
| 91 | 91 | Rename the reference `<oldref>` to `<newref>`. The old reference must | |
| 92 | 92 | exist and the new reference must not yet exist, and both must have a | |
| 93 | 93 | well-formed name (see linkgit:git-check-ref-format[1]). | |
modified Documentation/pack-refs-options.adoc
| @@ -1,4 +1,4 @@ | |||
| 1 | - | --all:: | |
| 1 | + | `--all`:: | |
| 2 | 2 | ||
| 3 | 3 | The command by default packs all tags and refs that are already | |
| 4 | 4 | packed, and leaves other refs | |
| @@ -8,12 +8,12 @@ This option causes all refs to be packed as well, with the exception | |||
| 8 | 8 | of hidden refs, broken refs, and symbolic refs. Useful for a repository | |
| 9 | 9 | with many branches of historical interests. | |
| 10 | 10 | ||
| 11 | - | --no-prune:: | |
| 11 | + | `--no-prune`:: | |
| 12 | 12 | ||
| 13 | 13 | The command usually removes loose refs under `$GIT_DIR/refs` | |
| 14 | 14 | hierarchy after packing them. This option tells it not to. | |
| 15 | 15 | ||
| 16 | - | --auto:: | |
| 16 | + | `--auto`:: | |
| 17 | 17 | ||
| 18 | 18 | Pack refs as needed depending on the current state of the ref database. The | |
| 19 | 19 | behavior depends on the ref format used by the repository and may change in the | |
| @@ -29,7 +29,7 @@ future. | |||
| 29 | 29 | maintains the property that N is at least twice as big as N+1. Only | |
| 30 | 30 | tables that violate this property are compacted. | |
| 31 | 31 | ||
| 32 | - | --include <pattern>:: | |
| 32 | + | `--include <pattern>`:: | |
| 33 | 33 | ||
| 34 | 34 | Pack refs based on a `glob(7)` pattern. Repetitions of this option | |
| 35 | 35 | accumulate inclusion patterns. If a ref is both included in `--include` and | |
| @@ -38,7 +38,7 @@ tags from being included by default. Symbolic refs and broken refs will never | |||
| 38 | 38 | be packed. When used with `--all`, it will be a noop. Use `--no-include` to clear | |
| 39 | 39 | and reset the list of patterns. | |
| 40 | 40 | ||
| 41 | - | --exclude <pattern>:: | |
| 41 | + | `--exclude <pattern>`:: | |
| 42 | 42 | ||
| 43 | 43 | Do not pack refs matching the given `glob(7)` pattern. Repetitions of this option | |
| 44 | 44 | accumulate exclusion patterns. Use `--no-exclude` to clear and reset the list of | |
modified GIT-VERSION-GEN
| @@ -1,6 +1,6 @@ | |||
| 1 | 1 | #!/bin/sh | |
| 2 | 2 | ||
| 3 | - | DEF_VER=v2.56.0-rc0 | |
| 3 | + | DEF_VER=v2.56.0-rc2 | |
| 4 | 4 | ||
| 5 | 5 | LF=' | |
| 6 | 6 | ' | |
modified Makefile
| @@ -959,7 +959,7 @@ RUST_LIB_NAME = gitcore.lib | |||
| 959 | 959 | else | |
| 960 | 960 | RUST_LIB_NAME = libgitcore.a | |
| 961 | 961 | endif | |
| 962 | - | RUST_LIB = target/$(RUST_BUILD_CONFIG)/$(RUST_LIB_NAME) | |
| 962 | + | RUST_LIB = target$(if $(CARGO_BUILD_TARGET),/$(CARGO_BUILD_TARGET))/$(RUST_BUILD_CONFIG)/$(RUST_LIB_NAME) | |
| 963 | 963 | endif | |
| 964 | 964 | ||
| 965 | 965 | GITLIBS = common-main.o $(LIB_FILE) | |
modified builtin/history.c
| @@ -161,6 +161,7 @@ out: | |||
| 161 | 161 | free_commit_extra_headers(original_extra_headers); | |
| 162 | 162 | strbuf_release(&commit_message); | |
| 163 | 163 | free(original_author); | |
| 164 | + | repo_unuse_commit_buffer(repo, commit_with_message, original_message); | |
| 164 | 165 | return ret; | |
| 165 | 166 | } | |
| 166 | 167 | ||
modified ci/lib.sh
| @@ -391,9 +391,6 @@ linux-asan-ubsan) | |||
| 391 | 391 | osx-meson) | |
| 392 | 392 | MESONFLAGS="$MESONFLAGS -Dcredential_helpers=osxkeychain" | |
| 393 | 393 | ;; | |
| 394 | - | windows-*) | |
| 395 | - | export NO_RUST=UnfortunatelyYes | |
| 396 | - | ;; | |
| 397 | 394 | esac | |
| 398 | 395 | ||
| 399 | 396 | MAKEFLAGS="$MAKEFLAGS CC=${CC:-cc}" | |
modified config.mak.uname
| @@ -760,7 +760,30 @@ ifeq ($(uname_S),MINGW) | |||
| 760 | 760 | MINGW_PREFIX := /$(shell echo '$(MSYSTEM)' | tr A-Z a-z) | |
| 761 | 761 | endif | |
| 762 | 762 | prefix = $(MINGW_PREFIX) | |
| 763 | - | HOST_CPU = $(patsubst %-w64-mingw32,%,$(MINGW_CHOST)) | |
| 763 | + | ||
| 764 | + | # A rustup-managed Rust on Windows defaults to the MSVC ABI and | |
| 765 | + | # produces a `gitcore.lib` that the MinGW `ld.exe` cannot link. | |
| 766 | + | # Pick a GCC-compatible Rust target triple matching the MSYS2 | |
| 767 | + | # subsystem instead: `*-pc-windows-gnullvm` for the Clang/LLVM | |
| 768 | + | # subsystems (which on Windows is also the only choice for | |
| 769 | + | # ARM64, where no MinGW-GCC port exists) and `*-pc-windows-gnu` | |
| 770 | + | # for the MSVCRT-based MinGW subsystems. For a `staticlib` | |
| 771 | + | # crate-type Cargo does not invoke an external linker, so | |
| 772 | + | # `rustup target add <triple>` is sufficient. | |
| 773 | + | ifneq (,$(filter %ARM64, $(MSYSTEM))) | |
| 774 | + | HOST_CPU = aarch64 | |
| 775 | + | else ifneq (,$(filter %32, $(MSYSTEM))) | |
| 776 | + | HOST_CPU = i686 | |
| 777 | + | else | |
| 778 | + | HOST_CPU = x86_64 | |
| 779 | + | endif | |
| 780 | + | ifneq (,$(filter CLANG%, $(MSYSTEM))) | |
| 781 | + | CARGO_BUILD_TARGET = $(HOST_CPU)-pc-windows-gnullvm | |
| 782 | + | else | |
| 783 | + | CARGO_BUILD_TARGET = $(HOST_CPU)-pc-windows-gnu | |
| 784 | + | endif | |
| 785 | + | export CARGO_BUILD_TARGET | |
| 786 | + | ||
| 764 | 787 | BASIC_LDFLAGS += -Wl,--pic-executable | |
| 765 | 788 | COMPAT_CFLAGS += -DDETECT_MSYS_TTY \ | |
| 766 | 789 | -DENSURE_MSYSTEM_IS_SET="\"$(MSYSTEM)\"" \ | |
modified dir.c
| @@ -212,9 +212,10 @@ static int fnmatch_icase_mem(const char *pattern, int patternlen, | |||
| 212 | 212 | return match_status; | |
| 213 | 213 | } | |
| 214 | 214 | ||
| 215 | - | static size_t common_prefix_len(const struct pathspec *pathspec) | |
| 215 | + | static size_t common_prefix_len(const struct pathspec *pathspec, | |
| 216 | + | const char **matched_prefix) | |
| 216 | 217 | { | |
| 217 | - | int n; | |
| 218 | + | int n, first = -1; | |
| 218 | 219 | size_t max = 0; | |
| 219 | 220 | ||
| 220 | 221 | /* | |
| @@ -237,43 +238,47 @@ static size_t common_prefix_len(const struct pathspec *pathspec) | |||
| 237 | 238 | size_t i = 0, len = 0, item_len; | |
| 238 | 239 | if (pathspec->items[n].magic & PATHSPEC_EXCLUDE) | |
| 239 | 240 | continue; | |
| 241 | + | if (first < 0) | |
| 242 | + | first = n; | |
| 240 | 243 | if (pathspec->items[n].magic & PATHSPEC_ICASE) | |
| 241 | 244 | item_len = pathspec->items[n].prefix; | |
| 242 | 245 | else | |
| 243 | 246 | item_len = pathspec->items[n].nowildcard_len; | |
| 244 | - | while (i < item_len && (n == 0 || i < max)) { | |
| 247 | + | while (i < item_len && (n == first || i < max)) { | |
| 245 | 248 | char c = pathspec->items[n].match[i]; | |
| 246 | - | if (c != pathspec->items[0].match[i]) | |
| 249 | + | if (c != pathspec->items[first].match[i]) | |
| 247 | 250 | break; | |
| 248 | 251 | if (c == '/') | |
| 249 | 252 | len = i + 1; | |
| 250 | 253 | i++; | |
| 251 | 254 | } | |
| 252 | - | if (n == 0 || len < max) { | |
| 255 | + | if (n == first || len < max) { | |
| 253 | 256 | max = len; | |
| 254 | 257 | if (!max) | |
| 255 | 258 | break; | |
| 256 | 259 | } | |
| 257 | 260 | } | |
| 261 | + | *matched_prefix = first < 0 ? NULL : pathspec->items[first].match; | |
| 258 | 262 | return max; | |
| 259 | 263 | } | |
| 260 | 264 | ||
| 261 | 265 | /* | |
| 262 | - | * Returns a copy of the longest leading path common among all | |
| 263 | - | * pathspecs. | |
| 266 | + | * Returns a copy of the longest leading path common among all pathspec | |
| 267 | + | * items that are not excluded. | |
| 264 | 268 | */ | |
| 265 | 269 | char *common_prefix(const struct pathspec *pathspec) | |
| 266 | 270 | { | |
| 267 | - | unsigned long len = common_prefix_len(pathspec); | |
| 271 | + | const char *matched_prefix; | |
| 272 | + | size_t len = common_prefix_len(pathspec, &matched_prefix); | |
| 268 | 273 | ||
| 269 | - | return len ? xmemdupz(pathspec->items[0].match, len) : NULL; | |
| 274 | + | return len ? xmemdupz(matched_prefix, len) : NULL; | |
| 270 | 275 | } | |
| 271 | 276 | ||
| 272 | 277 | int fill_directory(struct dir_struct *dir, | |
| 273 | 278 | struct index_state *istate, | |
| 274 | 279 | const struct pathspec *pathspec) | |
| 275 | 280 | { | |
| 276 | - | const char *prefix; | |
| 281 | + | const char *matched_prefix; | |
| 277 | 282 | size_t prefix_len; | |
| 278 | 283 | ||
| 279 | 284 | unsigned exclusive_flags = DIR_SHOW_IGNORED | DIR_SHOW_IGNORED_TOO; | |
| @@ -284,11 +289,11 @@ int fill_directory(struct dir_struct *dir, | |||
| 284 | 289 | * Calculate common prefix for the pathspec, and | |
| 285 | 290 | * use that to optimize the directory walk | |
| 286 | 291 | */ | |
| 287 | - | prefix_len = common_prefix_len(pathspec); | |
| 288 | - | prefix = prefix_len ? pathspec->items[0].match : ""; | |
| 292 | + | prefix_len = common_prefix_len(pathspec, &matched_prefix); | |
| 289 | 293 | ||
| 290 | 294 | /* Read the directory and prune it */ | |
| 291 | - | read_directory(dir, istate, prefix, prefix_len, pathspec); | |
| 295 | + | read_directory(dir, istate, prefix_len ? matched_prefix : "", | |
| 296 | + | prefix_len, pathspec); | |
| 292 | 297 | ||
| 293 | 298 | return prefix_len; | |
| 294 | 299 | } | |
| @@ -394,7 +399,7 @@ static int match_pathspec_item(struct index_state *istate, | |||
| 394 | 399 | ||
| 395 | 400 | /* | |
| 396 | 401 | * The normal call pattern is: | |
| 397 | - | * 1. prefix = common_prefix_len(ps); | |
| 402 | + | * 1. prefix = common_prefix_len(ps, &matched_prefix); | |
| 398 | 403 | * 2. prune something, or fill_directory | |
| 399 | 404 | * 3. match_pathspec() | |
| 400 | 405 | * | |
| @@ -414,8 +419,8 @@ static int match_pathspec_item(struct index_state *istate, | |||
| 414 | 419 | * Normally the caller (common_prefix_len() in fact) does | |
| 415 | 420 | * _exact_ matching on name[-prefix+1..-1] and we do not need | |
| 416 | 421 | * to check that part. Be defensive and check it anyway, in | |
| 417 | - | * case common_prefix_len is changed, or a new caller is | |
| 418 | - | * introduced that does not use common_prefix_len. | |
| 422 | + | * case common_prefix_len() is changed, or a new caller is | |
| 423 | + | * introduced that does not use common_prefix_len(). | |
| 419 | 424 | * | |
| 420 | 425 | * If the penalty turns out too high when prefix is really | |
| 421 | 426 | * long, maybe change it to | |
| @@ -593,7 +598,7 @@ static int match_pathspec_with_flags(struct index_state *istate, | |||
| 593 | 598 | if (!(ps->magic & PATHSPEC_EXCLUDE) || !positive) | |
| 594 | 599 | return positive; | |
| 595 | 600 | negative = do_match_pathspec(istate, ps, name, namelen, | |
| 596 | - | prefix, seen, | |
| 601 | + | 0, seen, | |
| 597 | 602 | flags | DO_MATCH_EXCLUDE); | |
| 598 | 603 | return negative ? 0 : positive; | |
| 599 | 604 | } | |
modified src/cargo-meson.sh
| @@ -38,7 +38,7 @@ then | |||
| 38 | 38 | exit $RET | |
| 39 | 39 | fi | |
| 40 | 40 | ||
| 41 | - | if ! cmp "$BUILD_DIR/$BUILD_TYPE/$LIBNAME" "$BUILD_DIR/libgitcore.a" >/dev/null 2>&1 | |
| 41 | + | if ! cmp "$BUILD_DIR/${CARGO_BUILD_TARGET:+$CARGO_BUILD_TARGET/}$BUILD_TYPE/$LIBNAME" "$BUILD_DIR/libgitcore.a" >/dev/null 2>&1 | |
| 42 | 42 | then | |
| 43 | - | cp "$BUILD_DIR/$BUILD_TYPE/$LIBNAME" "$BUILD_DIR/libgitcore.a" | |
| 43 | + | cp "$BUILD_DIR/${CARGO_BUILD_TARGET:+$CARGO_BUILD_TARGET/}$BUILD_TYPE/$LIBNAME" "$BUILD_DIR/libgitcore.a" | |
| 44 | 44 | fi | |
modified t/t6132-pathspec-exclude.sh
| @@ -183,6 +183,24 @@ EOF | |||
| 183 | 183 | test_cmp expect actual | |
| 184 | 184 | ' | |
| 185 | 185 | ||
| 186 | + | test_expect_success 'negative pathspec shorter than positive pathspec prefix' ' | |
| 187 | + | git ls-files -- sub/sub/ ":(exclude)sub2" >actual && | |
| 188 | + | cat <<-\EOF >expect && | |
| 189 | + | sub/sub/file | |
| 190 | + | sub/sub/sub/file | |
| 191 | + | EOF | |
| 192 | + | test_cmp expect actual | |
| 193 | + | ' | |
| 194 | + | ||
| 195 | + | test_expect_success 'exclude is matched against the full path' ' | |
| 196 | + | git ls-files -- sub/sub/ ":(exclude)zzzzzzz" >actual && | |
| 197 | + | cat <<-\EOF >expect && | |
| 198 | + | sub/sub/file | |
| 199 | + | sub/sub/sub/file | |
| 200 | + | EOF | |
| 201 | + | test_cmp expect actual | |
| 202 | + | ' | |
| 203 | + | ||
| 186 | 204 | test_expect_success 'multiple exclusions' ' | |
| 187 | 205 | git ls-files -- ":^*/file2" ":^sub2" >actual && | |
| 188 | 206 | cat <<-\EOF >expect && | |
modified t/unit-tests/u-dir.c
| @@ -45,3 +45,31 @@ void test_dir__within_depth(void) | |||
| 45 | 45 | ||
| 46 | 46 | ||
| 47 | 47 | } | |
| 48 | + | ||
| 49 | + | void test_dir__common_prefix_skips_excluded_pathspec_items(void) | |
| 50 | + | { | |
| 51 | + | struct pathspec_item items[] = { | |
| 52 | + | { | |
| 53 | + | .match = "unrelated/path", | |
| 54 | + | .magic = PATHSPEC_EXCLUDE, | |
| 55 | + | .nowildcard_len = 14, | |
| 56 | + | }, | |
| 57 | + | { | |
| 58 | + | .match = "foo/bar", | |
| 59 | + | .nowildcard_len = 7, | |
| 60 | + | }, | |
| 61 | + | { | |
| 62 | + | .match = "foo/baz", | |
| 63 | + | .nowildcard_len = 7, | |
| 64 | + | }, | |
| 65 | + | }; | |
| 66 | + | struct pathspec pathspec = { | |
| 67 | + | .nr = ARRAY_SIZE(items), | |
| 68 | + | .magic = PATHSPEC_EXCLUDE, | |
| 69 | + | .items = items, | |
| 70 | + | }; | |
| 71 | + | char *prefix = common_prefix(&pathspec); | |
| 72 | + | ||
| 73 | + | cl_assert_equal_s(prefix, "foo/"); | |
| 74 | + | free(prefix); | |
| 75 | + | } | |