Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/t
AgeCommit message (Collapse)Author
2022-05-31Merge branch 'cc/http-curlopt-resolve'Junio C Hamano
With the new http.curloptResolve configuration, the CURLOPT_RESOLVE mechanism that allows cURL based applications to use pre-resolved IP addresses for the requests is exposed to the scripts. * cc/http-curlopt-resolve: http: add custom hostname to IP address resolutions
2022-05-27Merge branch 'ac/remote-v-with-object-list-filters'Junio C Hamano
"git remote -v" now shows the list-objects-filter used during fetching from the remote, if available. * ac/remote-v-with-object-list-filters: builtin/remote.c: teach `-v` to list filters for promisor remotes
2022-05-27Merge branch 'cb/path-owner-check-with-sudo'Junio C Hamano
With a recent update to refuse access to repositories of other people by default, "sudo make install" and "sudo git describe" stopped working. This series intends to loosen it while keeping the safety. * cb/path-owner-check-with-sudo: t0034: add negative tests and allow git init to mostly work under sudo git-compat-util: avoid failing dir ownership checks if running privileged t: regression git needs safe.directory when using sudo
2022-05-27Merge branch 'tk/simple-autosetupmerge'Junio C Hamano
"git -c branch.autosetupmerge=simple branch $A $B" will set the $B as $A's upstream only when $A and $B shares the same name, and "git -c push.default=simple" on branch $A would push to update the branch $A at the remote $B came from. Also more places use the sole remote, if exists, before defaulting to 'origin'. * tk/simple-autosetupmerge: push: new config option "push.autoSetupRemote" supports "simple" push push: default to single remote even when not named origin branch: new autosetupmerge option 'simple' for matching branches
2022-05-26Merge branch 'jc/avoid-redundant-submodule-fetch'Junio C Hamano
"git fetch --recurse-submodules" from multiple remotes (either from a remote group, or "--all") used to make one extra "git fetch" in the submodules, which has been corrected. * jc/avoid-redundant-submodule-fetch: fetch: do not run a redundant fetch from submodule
2022-05-26Merge branch 'jc/show-branch-g-current'Junio C Hamano
The "--current" option of "git show-branch" should have been made incompatible with the "--reflog" mode, but this was not enforced, which has been corrected. * jc/show-branch-g-current: show-branch: -g and --current are incompatible
2022-05-24Merge branch 'ab/valgrind-fixes'Junio C Hamano
A bit of test framework fixes with a few fixes to issues found by valgrind. * ab/valgrind-fixes: commit-graph.c: don't assume that stat() succeeds object-file: fix a unpack_loose_header() regression in 3b6a8db3b03 log test: skip a failing mkstemp() test under valgrind tests: using custom GIT_EXEC_PATH breaks --valgrind tests
2022-05-24Merge branch 'ab/commit-plug-leaks'Junio C Hamano
Leakfix in the top-level called-once function. * ab/commit-plug-leaks: commit: fix "author_ident" leak
2022-05-21Merge branch 'tk/p4-metadata-coding-strategies'Junio C Hamano
"git p4" updates. * tk/p4-metadata-coding-strategies: git-p4: improve encoding handling to support inconsistent encodings
2022-05-21Merge branch 'ds/sparse-colon-path'Junio C Hamano
"git show :<path>" learned to work better with the sparse-index feature. * ds/sparse-colon-path: rev-parse: integrate with sparse index object-name: diagnose trees in index properly object-name: reject trees found in the index show: integrate with the sparse index t1092: add compatibility tests for 'git show'
2022-05-21Merge branch 'vd/sparse-stash'Junio C Hamano
Teach "git stash" to work better with sparse index entries. * vd/sparse-stash: unpack-trees: preserve index sparsity stash: apply stash using 'merge_ort_nonrecursive()' read-cache: set sparsity when index is new sparse-index: expose 'is_sparse_index_allowed()' stash: integrate with sparse index stash: expand sparse-checkout compatibility testing
2022-05-21Merge branch 'cd/bisect-messages-from-pre-flight-states'Junio C Hamano
"git bisect" was too silent before it is ready to start computing the actual bisection, which has been corrected. * cd/bisect-messages-from-pre-flight-states: bisect: output bisect setup status in bisect log bisect: output state before we are ready to compute bisection
2022-05-21Merge branch 'gc/pull-recurse-submodules'Junio C Hamano
"git pull" without "--recurse-submodules=<arg>" made submodule.recurse take precedence over fetch.recurseSubmodules by mistake, which has been corrected. * gc/pull-recurse-submodules: pull: do not let submodule.recurse override fetch.recurseSubmodules
2022-05-21Merge branch 'mv/log-since-as-filter'Junio C Hamano
"git log --since=X" will stop traversal upon seeing a commit that is older than X, but there may be commits behind it that is younger than X when the commit was created with a faulty clock. A new option is added to keep digging without stopping, and instead filter out commits with timestamp older than X. * mv/log-since-as-filter: log: "--since-as-filter" option is a non-terminating "--since" variant
2022-05-21Merge branch 'rs/external-diff-tempfile'Junio C Hamano
The temporary files fed to external diff command are now generated inside a new temporary directory under the same basename. * rs/external-diff-tempfile: diff: use mks_tempfile_dt() tempfile: add mks_tempfile_dt()
2022-05-21Merge branch 'tk/p4-with-explicity-sync'Junio C Hamano
"git p4" update. * tk/p4-with-explicity-sync: git-p4: support explicit sync of arbitrary existing git-p4 refs
2022-05-21Merge branch 'tk/p4-utf8-bom'Junio C Hamano
"git p4" update. * tk/p4-utf8-bom: git-p4: preserve utf8 BOM when importing from p4 to git
2022-05-21Merge branch 'sa/t1011-use-helpers'Junio C Hamano
A GSoC practice. * sa/t1011-use-helpers: t1011: replace test -f with test_path_is_file
2022-05-21Merge branch 'km/t3501-use-test-helpers'Junio C Hamano
Test script updates. * km/t3501-use-test-helpers: t3501: remove test -f and stop ignoring git <cmd> exit code
2022-05-21Merge branch 'ah/convert-warning-message'Junio C Hamano
Update a few end-user facing messages around eol conversion. * ah/convert-warning-message: convert: clarify line ending conversion warning
2022-05-21Merge branch 'gf/shorthand-version-and-help'Junio C Hamano
"git -v" and "git -h" are now understood as "git --version" and "git --help". * gf/shorthand-version-and-help: cli: add -v and -h shorthands
2022-05-21Merge branch 'rs/t7812-pcre2-ws-bug-test'Junio C Hamano
A test to ensure workaround for an earlier pcre2 bug does work. * rs/t7812-pcre2-ws-bug-test: t7812: test PCRE2 whitespace bug
2022-05-21Merge branch 'ds/do-not-call-bug-on-bad-refs'Junio C Hamano
Code clean-up. * ds/do-not-call-bug-on-bad-refs: clone: die() instead of BUG() on bad refs
2022-05-21Merge branch 'sg/safe-directory-tests-and-docs'Junio C Hamano
New tests for the safe.directory mechanism. * sg/safe-directory-tests-and-docs: safe.directory: document and check that it's ignored in the environment t0033-safe-directory: check when 'safe.directory' is ignored t0033-safe-directory: check the error message without matching the trash dir
2022-05-18fetch: do not run a redundant fetch from submoduleJunio C Hamano
When 7dce19d3 (fetch/pull: Add the --recurse-submodules option, 2010-11-12) introduced the "--recurse-submodule" option, the approach taken was to perform fetches in submodules only once, after all the main fetching (it may usually be a fetch from a single remote, but it could be fetching from a group of remotes using fetch_multiple()) succeeded. Later we added "--all" to fetch from all defined remotes, which complicated things even more. If your project has a submodule, and you try to run "git fetch --recurse-submodule --all", you'd see a fetch for the top-level, which invokes another fetch for the submodule, followed by another fetch for the same submodule. All but the last fetch for the submodule come from a "git fetch --recurse-submodules" subprocess that is spawned via the fetch_multiple() interface for the remotes, and the last fetch comes from the code at the end. Because recursive fetching from submodules is done in each fetch for the top-level in fetch_multiple(), the last fetch in the submodule is redundant. It only matters when fetch_one() interacts with a single remote at the top-level. While we are at it, there is one optimization that exists in dealing with a group of remote, but is missing when "--all" is used. In the former, when the group turns out to be a group of one, instead of spawning "git fetch" as a subprocess via the fetch_multiple() interface, we use the normal fetch_one() code path. Do the same when handing "--all", if it turns out that we have only one remote defined. Reviewed-by: Glen Choo <chooglen@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2022-05-16http: add custom hostname to IP address resolutionsChristian Couder
Libcurl has a CURLOPT_RESOLVE easy option that allows the result of hostname resolution in the following format to be passed: [+]HOST:PORT:ADDRESS[,ADDRESS] This way, redirects and everything operating against the HOST+PORT will use the provided ADDRESS(s). The following format is also allowed to stop using hostname resolutions that have already been passed: -HOST:PORT See https://curl.se/libcurl/c/CURLOPT_RESOLVE.html for more details. Let's add a corresponding "http.curloptResolve" config option that takes advantage of CURLOPT_RESOLVE. Each value configured for the "http.curloptResolve" key is passed "as is" to libcurl through CURLOPT_RESOLVE, so it should be in one of the above 2 formats. This keeps the implementation simple and makes us consistent with libcurl's CURLOPT_RESOLVE, and with curl's corresponding `--resolve` command line option. The implementation uses CURLOPT_RESOLVE only in get_active_slot() which is called by all the HTTP request sending functions. Signed-off-by: Christian Couder <chriscool@tuxfamily.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2022-05-13t0034: add negative tests and allow git init to mostly work under sudoCarlo Marcelo Arenas Belón
Add a support library that provides one function that can be used to run a "scriplet" of commands through sudo and that helps invoking sudo in the slightly awkward way that is required to ensure it doesn't block the call (if shell was allowed as tested in the prerequisite) and it doesn't run the command through a different shell than the one we intended. Add additional negative tests as suggested by Junio and that use a new workspace that is owned by root. Document a regression that was introduced by previous commits where root won't be able anymore to access directories they own unless SUDO_UID is removed from their environment. The tests document additional ways that this new restriction could be worked around and the documentation explains why it might be instead considered a feature, but a "fix" is planned for a future change. Helped-by: Junio C Hamano <gitster@pobox.com> Helped-by: Phillip Wood <phillip.wood123@gmail.com> Signed-off-by: Carlo Marcelo Arenas Belón <carenas@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2022-05-13git-compat-util: avoid failing dir ownership checks if running privilegedCarlo Marcelo Arenas Belón
bdc77d1d685 (Add a function to determine whether a path is owned by the current user, 2022-03-02) checks for the effective uid of the running process using geteuid() but didn't account for cases where that user was root (because git was invoked through sudo or a compatible tool) and the original uid that repository trusted for its config was no longer known, therefore failing the following otherwise safe call: guy@renard ~/Software/uncrustify $ sudo git describe --always --dirty [sudo] password for guy: fatal: unsafe repository ('/home/guy/Software/uncrustify' is owned by someone else) Attempt to detect those cases by using the environment variables that those tools create to keep track of the original user id, and do the ownership check using that instead. This assumes the environment the user is running on after going privileged can't be tampered with, and also adds code to restrict that the new behavior only applies if running as root, therefore keeping the most common case, which runs unprivileged, from changing, but because of that, it will miss cases where sudo (or an equivalent) was used to change to another unprivileged user or where the equivalent tool used to raise privileges didn't track the original id in a sudo compatible way. Because of compatibility with sudo, the code assumes that uid_t is an unsigned integer type (which is not required by the standard) but is used that way in their codebase to generate SUDO_UID. In systems where uid_t is signed, sudo might be also patched to NOT be unsigned and that might be able to trigger an edge case and a bug (as described in the code), but it is considered unlikely to happen and even if it does, the code would just mostly fail safely, so there was no attempt either to detect it or prevent it by the code, which is something that might change in the future, based on expected user feedback. Reported-by: Guy Maurel <guy.j@maurel.de> Helped-by: SZEDER Gábor <szeder.dev@gmail.com> Helped-by: Randall Becker <rsbecker@nexbridge.com> Helped-by: Phillip Wood <phillip.wood123@gmail.com> Suggested-by: Johannes Schindelin <Johannes.Schindelin@gmx.de> Signed-off-by: Carlo Marcelo Arenas Belón <carenas@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2022-05-13t: regression git needs safe.directory when using sudoCarlo Marcelo Arenas Belón
Originally reported after release of v2.35.2 (and other maint branches) for CVE-2022-24765 and blocking otherwise harmless commands that were done using sudo in a repository that was owned by the user. Add a new test script with very basic support to allow running git commands through sudo, so a reproduction could be implemented and that uses only `git status` as a proxy of the issue reported. Note that because of the way sudo interacts with the system, a much more complete integration with the test framework will require a lot more work and that was therefore intentionally punted for now. The current implementation requires the execution of a special cleanup function which should always be kept as the last "test" or otherwise the standard cleanup functions will fail because they can't remove the root owned directories that are used. This also means that if failures are found while running, the specifics of the failure might not be kept for further debugging and if the test was interrupted, it will be necessary to clean the working directory manually before restarting by running: $ sudo rm -rf trash\ directory.t0034-root-safe-directory/ The test file also uses at least one initial "setup" test that creates a parallel execution directory under the "root" sub directory, which should be used as top level directory for all repositories that are used in this test file. Unlike all other tests the repository provided by the test framework should go unused. Special care should be taken when invoking commands through sudo, since the environment is otherwise independent from what the test framework setup and might have changed the values for HOME, SHELL and dropped several relevant environment variables for your test. Indeed `git status` was used as a proxy because it doesn't even require commits in the repository to work and usually doesn't require much from the environment to run, but a future patch will add calls to `git init` and that will fail to honor the default branch name, unless that setting is NOT provided through an environment variable (which means even a CI run could fail that test if enabled incorrectly). A new SUDO prerequisite is provided that does some sanity checking to make sure the sudo command that will be used allows for passwordless execution as root without restrictions and doesn't mess with git's execution path. This matches what is provided by the macOS agents that are used as part of GitHub actions and probably nowhere else. Most of those characteristics make this test mostly only suitable for CI, but it might be executed locally if special care is taken to provide for all of them in the local configuration and maybe making use of the sudo credential cache by first invoking sudo, entering your password if needed, and then invoking the test with: $ GIT_TEST_ALLOW_SUDO=YES ./t0034-root-safe-directory.sh If it fails to run, then it means your local setup wouldn't work for the test because of the configuration sudo has or other system settings, and things that might help are to comment out sudo's secure_path config, and make sure that the account you are using has no restrictions on the commands it can run through sudo, just like is provided for the user in the CI. For example (assuming a username of marta for you) something probably similar to the following entry in your /etc/sudoers (or equivalent) file: marta ALL=(ALL:ALL) NOPASSWD: ALL Reported-by: SZEDER Gábor <szeder.dev@gmail.com> Helped-by: Phillip Wood <phillip.wood123@gmail.com> Signed-off-by: Carlo Marcelo Arenas Belón <carenas@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2022-05-13commit: fix "author_ident" leakJunio C Hamano
Since 4c28e4ada03 (commit: die before asking to edit the log message, 2010-12-20), we have been "leaking" the "author_ident" when prepare_to_commit() fails. Instead of returning from right there, introduce an exit status variable and jump to the clean-up label at the end. Instead of explicitly releasing the resource with strbuf_release(), mark the variable with UNLEAK() at the end, together with two other variables that are already marked as such. If this were in a utility function that is called number of times, but these are different, we should explicitly release resources that grow proportionally to the size of the problem being solved, but cmd_commit() is like main() and there is no point in spending extra cycles to release individual pieces of resource at the end, just before process exit will clean everything for us for free anyway. This fixes a leak demonstrated by e.g. "t3505-cherry-pick-empty.sh", but unfortunately we cannot mark it or other affected tests as passing now with "TEST_PASSES_SANITIZE_LEAK=true" as we'll need to fix many other memory leaks before doing so. Incidentally there are two tests that always passes the leak checker with or without this change. Mark them as such. This is based on an earlier patch by Ævar, but takes a different approach that is more maintainable. Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2022-05-13object-file: fix a unpack_loose_header() regression in 3b6a8db3b03Ævar Arnfjörð Bjarmason
Fix a regression in my 3b6a8db3b03 (object-file.c: use "enum" return type for unpack_loose_header(), 2021-10-01) revealed both by running the test suite with --valgrind, and with the amended "git fsck" test. In practice this regression in v2.34.0 caused us to claim that we couldn't parse the header, as opposed to not being able to unpack it. Before the change in the C code the test_cmp added here would emit: -error: unable to unpack header of ./objects/e6/9de29bb2d1d6434b8b29ae775ad8c2e48c5391 +error: unable to parse header of ./objects/e6/9de29bb2d1d6434b8b29ae775ad8c2e48c5391 I.e. we'd proceed to call parse_loose_header() on the uninitialized "hdr" value, and it would have been very unlikely for that uninitialized memory to be a valid git object. The other callers of unpack_loose_header() were already checking the enum values exhaustively. See 3b6a8db3b03 and 5848fb11acd (object-file.c: return ULHR_TOO_LONG on "header too long", 2021-10-01). Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2022-05-13log test: skip a failing mkstemp() test under valgrindÆvar Arnfjörð Bjarmason
Skip a test added in f1e3df31699 (t: increase test coverage of signature verification output, 2020-03-04) when running under valgrind. Due to valgrind's interception of mkstemp() this test will fail with: + pwd + TMPDIR=[...]/t/trash directory.t4202-log/bogus git log --show-signature -n1 plain-fail ==7696== VG_(mkstemp): failed to create temp file: [...]/t/trash directory.t4202-log/bogus/valgrind_proc_7696_cmdline_d545ddcf [... 10 more similar lines omitted ..] valgrind: Startup or configuration error: valgrind: Can't create client cmdline file in [...]/t/trash directory.t4202-log/bogus/valgrind_proc_7696_cmdline_6e542d1d valgrind: Unable to start up properly. Giving up. error: last command exited with $?=1 Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2022-05-13tests: using custom GIT_EXEC_PATH breaks --valgrind testsÆvar Arnfjörð Bjarmason
Fix a regression in b7d11a0f5d2 (tests: exercise the RUNTIME_PREFIX feature, 2021-07-24) where tests that want to set up and test a "git" wrapper in $PATH conflicted with the t/bin/valgrind wrapper(s) doing the same. Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2022-05-12pull: do not let submodule.recurse override fetch.recurseSubmodulesGlen Choo
Fix a bug in "git pull" where `submodule.recurse` is preferred over `fetch.recurseSubmodules` when performing a fetch (Documentation/config/fetch.txt says that `fetch.recurseSubmodules` should be preferred.). Do this by passing the value of the "--recurse-submodules" CLI option to the underlying fetch, instead of passing a value that combines the CLI option and config variables. In other words, this bug occurred because builtin/pull.c is conflating two similar-sounding, but different concepts: - Whether "git pull" itself should care about submodules e.g. whether it should update the submodule worktrees after performing a merge. - The value of "--recurse-submodules" to pass to the underlying "git fetch". Thus, when `submodule.recurse` is set, the underlying "git fetch" gets invoked with "--recurse-submodules[=value]", overriding the value of `fetch.recurseSubmodules`. An alternative (and more obvious) approach to fix the bug would be to teach "git pull" to understand `fetch.recurseSubmodules`, but the proposed solution works better because: - We don't maintain two identical config-parsing implementions in "git pull" and "git fetch". - It works better with other commands invoked by "git pull" e.g. "git merge" won't accidentally respect `fetch.recurseSubmodules`. Reported-by: Huang Zou <huang.zou@schrodinger.com> Helped-by: Philippe Blain <levraiphilippeblain@gmail.com> Signed-off-by: Glen Choo <chooglen@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2022-05-11Merge branch 'rs/commit-summary-wo-break-rewrite'Junio C Hamano
The commit summary shown after making a commit is matched to what is given in "git status" not to use the break-rewrite heuristics. * rs/commit-summary-wo-break-rewrite: commit, sequencer: turn off break_opt for commit summary
2022-05-11Merge branch 'pw/test-malloc-with-sanitize-address'Junio C Hamano
Avoid problems from interaction between malloc_check and address sanitizer. * pw/test-malloc-with-sanitize-address: tests: make SANITIZE=address imply TEST_NO_MALLOC_CHECK
2022-05-11Merge branch 'ah/rebase-keep-base-fix'Junio C Hamano
"git rebase --keep-base <upstream> <branch-to-rebase>" computed the commit to rebase onto incorrectly, which has been corrected. * ah/rebase-keep-base-fix: rebase: use correct base for --keep-base when a branch is given
2022-05-11bisect: output bisect setup status in bisect logChris Down
This allows seeing the current intermediate status without adding a new good or bad commit: $ git bisect log | tail -1 # status: waiting for bad commit, 1 good commit known Signed-off-by: Chris Down <chris@chrisdown.name> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2022-05-11bisect: output state before we are ready to compute bisectionChris Down
Commit 73c6de06aff8 ("bisect: don't use invalid oid as rev when starting") changes the behaviour of `git bisect` to consider invalid oids as pathspecs again, as in the old shell implementation. While that behaviour may be desirable, it can also cause confusion. For example, while bisecting in a particular repo I encountered this: $ git bisect start d93ff48803f0 v6.3 $ ...which led to me sitting for a few moments, wondering why there's no printout stating the first rev to check. It turns out that the tag was actually "6.3", not "v6.3", and thus the bisect was still silently started with only a bad rev, because d93ff48803f0 was a valid oid and "v6.3" was silently considered to be a pathspec. While this behaviour may be desirable, it can be confusing, especially with different repo conventions either using or not using "v" before release names, or when a branch name or tag is simply misspelled on the command line. In order to avoid situations like this, make it more clear what we're waiting for: $ git bisect start d93ff48803f0 v6.3 status: waiting for good commit(s), bad commit known We already have good output once the bisect process has begun in earnest, so we don't need to do anything more there. Signed-off-by: Chris Down <chris@chrisdown.name> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2022-05-11Merge branch 'ea/progress-partial-blame'Junio C Hamano
The progress meter of "git blame" was showing incorrect numbers when processing only parts of the file. * ea/progress-partial-blame: blame: report correct number of lines in progress when using ranges
2022-05-11Merge branch 'fr/vimdiff-layout'Junio C Hamano
Reimplement "vimdiff[123]" mergetool drivers with a more generic layout mechanism. * fr/vimdiff-layout: mergetools: add description to all diff/merge tools vimdiff: add tool documentation vimdiff: integrate layout tests in the unit tests framework ('t' folder) vimdiff: new implementation with layout support
2022-05-11Merge branch 'tk/untracked-cache-with-uall'Junio C Hamano
The performance of the "untracked cache" feature has been improved when "--untracked-files=<mode>" and "status.showUntrackedFiles" are combined. * tk/untracked-cache-with-uall: untracked-cache: support '--untracked-files=all' if configured untracked-cache: test untracked-cache-bypassing behavior with -uall
2022-05-11unpack-trees: preserve index sparsityVictoria Dye
When unpacking trees, set the default sparsity of the resultant index based on repo settings and 'is_sparse_index_allowed()'. Normally, when executing 'unpack_trees', the output index is marked sparse when (and only when) it unpacks a sparse directory. However, an index may be "sparse" even if it contains no sparse directories - when all files fall inside the sparse-checkout definition or otherwise have SKIP_WORKTREE disabled. Therefore, the output index may be marked "full" even when it is "sparse", resulting in unnecessary 'ensure_full_index' calls when writing to disk. Avoid this by setting the "default" index sparsity to match what is expected for the repository. As a consequence of this fix, the (non-merge) 'read-tree' performed when applying a stash with untracked files no longer expands the index. Update the corresponding test in 't1092'. Signed-off-by: Victoria Dye <vdye@github.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2022-05-11stash: apply stash using 'merge_ort_nonrecursive()'Victoria Dye
Update 'stash' to use 'merge_ort_nonrecursive()' to apply a stash to the current working tree. When 'git stash apply' was converted from its shell script implementation to a builtin in 8a0fc8d19d (stash: convert apply to builtin, 2019-02-25), 'merge_recursive_generic()' was used to merge a stash into the working tree as part of 'git stash (apply|pop)'. However, with the single merge base used in 'do_apply_stash()', the commit wrapping done by 'merge_recursive_generic()' is not only unnecessary, but misleading (the *real* merge base is labeled "constructed merge base"). Therefore, a non-recursive merge of the working tree, stashed tree, and stash base tree is more appropriate. There are two options for a non-recursive merge-then-update-worktree function: 'merge_trees()' and 'merge_ort_nonrecursive()'. Use 'merge_ort_nonrecursive()' to align with the default merge strategy used by 'git merge' (6a5fb96672 (Change default merge backend from recursive to ort, 2021-08-04)) and, because merge-ort does not operate in-place on the index, avoid unnecessary index expansion. Update tests in 't1092' verifying index expansion for 'git stash' accordingly. Signed-off-by: Victoria Dye <vdye@github.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2022-05-11read-cache: set sparsity when index is newVictoria Dye
When the index read in 'do_read_index()' does not exist on-disk, mark the index "sparse" if the executing command does not require a full index and sparse index is otherwise enabled. Some commands (such as 'git stash -u') implicitly create a new index (when the 'GIT_INDEX_FILE' variable points to a non-existent file) and perform some operation on it. However, when this index is created, it isn't created with the same sparsity settings as the repo index. As a result, while these indexes may be sparse during the operation, they are always expanded before being written to disk. We can avoid that expansion by defaulting the index to "sparse", in which case it will only be expanded if the full index is needed. Note that the function 'set_new_index_sparsity()' is created despite having only a single caller because additional callers will be added in a subsequent patch. Signed-off-by: Victoria Dye <vdye@github.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2022-05-11stash: integrate with sparse indexVictoria Dye
Enable sparse index in 'git stash' by disabling 'command_requires_full_index'. With sparse index enabled, some subcommands of 'stash' work without expanding the index, e.g., 'git stash', 'git stash list', 'git stash drop', etc. Others ensure the index is expanded either directly (as in the case of 'git stash [pop|apply]', where the call to 'merge_recursive_generic()' in 'do_apply_stash()' triggers the expansion), or in a command called internally by stash (e.g., 'git update-index' in 'git stash -u'). So, in addition to enabling sparse index, add tests to 't1092' demonstrating which variants of 'git stash' expand the index, and which do not. Finally, add the option to skip writing 'untracked.txt' in 'ensure_not_expanded', and use that option to successfully apply stashed untracked files without a conflict in 'untracked.txt'. Signed-off-by: Victoria Dye <vdye@github.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2022-05-11stash: expand sparse-checkout compatibility testingVictoria Dye
Add tests verifying expected 'git stash' behavior in 't1092-sparse-checkout-compatibility'. These cases establish the expected behavior of 'git stash' in a sparse-checkout and verify consistency both with and without a sparse index. Although no sparse index compatibility has been integrated into 'git stash' yet, the tests are all 'expect_success' - we don't want the cone-mode sparse-checkout behavior to change depending on whether it is using a sparse index or not. Therefore, we expect these tests to continue passing once sparse index is integrated with 'git stash'. Additionally, add performance test cases for 'git stash' both with and without untracked files. Note that, unlike the other tests in 'p2000-sparse-operations.sh', the tests added for 'stash' are combination operations. This is done to ensure the stash/unstash is not blocked by the modification of '$SPARSE_CONE/a' performed as part of 'test_perf_on_all'. Signed-off-by: Victoria Dye <vdye@github.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2022-05-09builtin/remote.c: teach `-v` to list filters for promisor remotesAbhradeep Chakraborty
`git remote -v` (`--verbose`) lists down the names of remotes along with their URLs. It would be beneficial for users to also specify the filter types for promisor remotes. Something like this - origin remote-url (fetch) [blob:none] origin remote-url (push) Teach `git remote -v` to also specify the filters for promisor remotes. Closes: https://github.com/gitgitgadget/git/issues/1211 Signed-off-by: Abhradeep Chakraborty <chakrabortyabhradeep79@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2022-05-06Merge branch 'rs/format-patch-pathspec-fix' into maintJunio C Hamano
"git format-patch <args> -- <pathspec>" lost the pathspec when showing the second and subsequent commits, which has been corrected. source: <c36896a1-6247-123b-4fa3-b7eb24af1897@web.de> * rs/format-patch-pathspec-fix: 2.36 format-patch regression fix
2022-05-06Merge branch 'rs/fast-export-pathspec-fix' into maintJunio C Hamano
"git fast-export -- <pathspec>" lost the pathspec when showing the second and subsequent commits, which has been corrected. source: <2c988c7b-0efe-4222-4a43-8124fe1a9da6@web.de> * rs/fast-export-pathspec-fix: 2.36 fast-export regression fix