What's cooking in git.git (Dec 2021, #04; Wed, 15)
Unfortunately, the number of topics in the "undecided" category is creeping upwards since the previous issues of the report.
Here are the topics that have been cooking in my tree. Commits prefixed with '+' are in 'next' (being in 'next' is a sign that a topic is stable enough to be used and are candidate to be in a future release). Commits prefixed with '-' are only in 'seen', which means nothing more than that I have found them of interest for some reason (like "it may have hard-to-resolve conflicts with another topic already in flight" or "this may turn out to be useful"). Do not read too much into a topic being in (or not in) 'seen'. The ones marked with '.' do not appear in any of the integration branches, but I am still holding onto them.
Copies of the source code to Git live in many repositories, and the following is a list of the ones I push into or their mirrors. Some repositories have only a subset of branches.
With maint, master, next, seen, todo:
git://git.kernel.org/pub/scm/git/git.git/ git://repo.or.cz/alt-git.git/ https://kernel.googlesource.com/pub/scm/git/git/ https://github.com/git/git/ https://gitlab.com/git-vcs/git/
With all the integration branches and topics broken out:
https://github.com/gitster/git/
Even though the preformatted documentation in HTML and man format are not sources, they are published in these repositories for convenience (replace "htmldocs" with "manpages" for the manual pages):
git://git.kernel.org/pub/scm/git/git-htmldocs.git/
https://github.com/gitster/git-htmldocs.git/
Release tarballs are available at:
https://www.kernel.org/pub/software/scm/git/
--------------------------------------------------
[Graduated to 'master']
* ab/ci-updates (2021-11-23) 5 commits
(merged to 'next' on 2021-12-07 at 1d855a6b33)
+ CI: don't run "make test" twice in one job
+ CI: use "$runs_on_pool", not "$jobname" to select packages & config
+ CI: rename the "Linux32" job to lower-case "linux32"
+ CI: use shorter names that fit in UX tooltips
+ CI: remove Travis CI support
Drop support for TravisCI and update test workflows at GitHub.
source: <[email protected]>
* ab/die-with-bug (2021-12-07) 4 commits
(merged to 'next' on 2021-12-08 at 9b7440fafd)
+ object.c: use BUG(...) no die("BUG: ...") in lookup_object_by_type()
+ pathspec: use BUG(...) not die("BUG:%s:%d....", <file>, <line>)
+ strbuf.h: use BUG(...) not die("BUG: ...")
+ pack-objects: use BUG(...) not die("BUG: ...")
Code clean-up.
source: <[email protected]>
* ab/mark-leak-free-tests-even-more (2021-11-01) 15 commits (merged to 'next' on 2021-12-03 at 1d8c342dab)
+ leak tests: mark some fast-import tests as passing with SANITIZE=leak
+ leak tests: mark some config tests as passing with SANITIZE=leak
+ leak tests: mark some status tests as passing with SANITIZE=leak
+ leak tests: mark some clone tests as passing with SANITIZE=leak
+ leak tests: mark some add tests as passing with SANITIZE=leak
+ leak tests: mark some diff tests as passing with SANITIZE=leak
+ leak tests: mark some apply tests as passing with SANITIZE=leak
+ leak tests: mark some notes tests as passing with SANITIZE=leak
+ leak tests: mark some update-index tests as passing with SANITIZE=leak
+ leak tests: mark some rev-parse tests as passing with SANITIZE=leak
+ leak tests: mark some rev-list tests as passing with SANITIZE=leak
+ leak tests: mark some misc tests as passing with SANITIZE=leak
+ leak tests: mark most gettext tests as passing with SANITIZE=leak
+ leak tests: mark "sort" test as passing SANITIZE=leak
+ leak tests: mark a read-tree test as passing SANITIZE=leak
More tests are marked as leak-free.
source: <[email protected]>
* ab/parse-options-cleanup (2021-11-10) 1 commit
(merged to 'next' on 2021-12-08 at f9a2ceb9f6)
+ parse-options.c: use "enum parse_opt_result" for parse_nodash_opt()
Change the type of an internal function to return an enum (instead of int) and replace -2 that was used to signal an error with -1.
source: <[email protected]>
* ab/run-command (2021-11-25) 9 commits
(merged to 'next' on 2021-12-07 at 5c0bedf853)
+ run-command API: remove "env" member, always use "env_array"
+ difftool: use "env_array" to simplify memory management
+ run-command API: remove "argv" member, always use "args"
+ run-command API users: use strvec_push(), not argv construction
+ run-command API users: use strvec_pushl(), not argv construction
+ run-command tests: use strvec_pushv(), not argv assignment
+ run-command API users: use strvec_pushv(), not argv assignment
+ upload-archive: use regular "struct child_process" pattern
+ worktree: stop being overly intimate with run_command() internals
API clean-up.
cf. <[email protected]>
cf. <CAPig+cSvFgJTiq8pXrWy_7ukQwE1y9ZGwMgKmyjWuQHdNGxiDQ@mail.gmail.com>
source: <[email protected]>
* ds/sparse-deep-pattern-checkout-fix (2021-12-06) 2 commits (merged to 'next' on 2021-12-07 at 7b7f74216a)
+ unpack-trees: use traverse_path instead of name
+ t1092: add deeper changes during a checkout
The sparse-index/sparse-checkout feature had a bug in its use of the matching code to determine which path is in or outside the sparse checkout patterns.
source: <[email protected]>
* ds/trace2-regions-in-tests (2021-11-29) 2 commits (merged to 'next' on 2021-12-07 at ebf31cbaad)
+ t/t*: remove custom GIT_TRACE2_EVENT_NESTING
+ test-lib.sh: set GIT_TRACE2_EVENT_NESTING
The default setting for trace2 event nesting was too low to cause test failures, which is worked around by bumping it up in the test framework.
source: <[email protected]>
* en/zdiff3 (2021-12-01) 2 commits
(merged to 'next' on 2021-12-07 at baa3b24593)
+ update documentation for new zdiff3 conflictStyle
+ xdiff: implement a zealous diff3, or "zdiff3"
"Zealous diff3" style of merge conflict presentation has been added.
source: <[email protected]>
* es/doc-stdout-vs-stderr (2021-12-04) 1 commit
(merged to 'next' on 2021-12-07 at d6487c1256)
+ CodingGuidelines: document which output goes to stdout vs. stderr
Coding guideline document has been updated to clarify what goes to standard error in our system.
source: <[email protected]>
* es/pretty-describe-more (2021-11-01) 3 commits
(merged to 'next' on 2021-12-07 at e7862a34c8)
+ pretty: add abbrev option to %(describe)
+ pretty: add tag option to %(describe)
+ pretty.c: rework describe options parsing for better extensibility
Extend "git log --format=%(describe)" placeholder to allow passing selected command-line options to the underlying "git describe" command.
source: <[email protected]>
* es/worktree-chatty-to-stderr (2021-12-04) 2 commits (merged to 'next' on 2021-12-07 at 84ba7de37c)
+ git-worktree.txt: add missing -v to synopsis for worktree list
+ worktree: send "chatty" messages to stderr
"git worktree add" showed "Preparing worktree" message to the standard output stream, but when it failed, the message from die() went to the standard error stream. Depending on the order the stdio streams are flushed at the program end, this resulted in confusing output. It has been corrected by sending all the chatty messages to the standard error stream.
source: <[email protected]>
* ew/cbtree-remove-unused-and-broken-cb-unlink (2021-12-07) 1 commit (merged to 'next' on 2021-12-07 at e37b4e16d0)
+ cbtree: remove broken and unused cb_unlink
Code clean-up.
source: <[email protected]>
* ew/test-wo-fsync (2021-10-29) 1 commit
(merged to 'next' on 2021-12-08 at 4b90e4870a)
+ tests: disable fsync everywhere
Allow running our tests while disabling fsync.
Received a lukewarm reactions overall. Perhaps we should drop instead?
source: <20211029001552.GA29647@dcvr>
* fs/test-prereq (2021-12-01) 3 commits (merged to 'next' on 2021-12-07 at fc8a8e0006)
+ test-lib: make BAIL_OUT() work in tests and prereq
+ test-lib: introduce required prereq for test runs
+ test-lib: show missing prereq summary
The test framework learns to list unsatisfied test prerequisites, and optionally error out when prerequisites that are expected to be satisfied are not.
source: <[email protected]>
* hn/allow-bogus-oid-in-ref-tests (2021-12-07) 8 commits (merged to 'next' on 2021-12-08 at 8fb70ef68b)
+ t1430: create valid symrefs using test-helper
+ t1430: remove refs using test-tool
+ refs: introduce REF_SKIP_REFNAME_VERIFICATION flag
+ refs: introduce REF_SKIP_OID_VERIFICATION flag
+ refs: update comment.
+ test-ref-store: plug memory leak in cmd_delete_refs
+ test-ref-store: parse symbolic flag constants
+ test-ref-store: remove force-create argument for create-reflog
The test helper for refs subsystem learned to write bogus and/or nonexistent object name to refs to simulate error situations we want to test Git in.
source: <[email protected]>
* hn/reflog-tests (2021-12-02) 5 commits
(merged to 'next' on 2021-12-07 at 84d4e4b211)
+ refs/debug: trim trailing LF from reflog message
+ test-ref-store: tweaks to for-each-reflog-ent format
+ t1405: check for_each_reflog_ent_reverse() more thoroughly
+ test-ref-store: don't add newline to reflog message
+ show-branch: show reflog message
Prepare tests on ref API to help testing reftable backends.
source: <[email protected]>
* hn/reftable (2021-10-08) 19 commits
(merged to 'next' on 2021-12-03 at 767ec5d9b3)
+ Add "test-tool dump-reftable" command.
+ reftable: add dump utility
+ reftable: implement stack, a mutable database of reftable files.
+ reftable: implement refname validation
+ reftable: add merged table view
+ reftable: add a heap-based priority queue for reftable records
+ reftable: reftable file level tests
+ reftable: read reftable files
+ reftable: generic interface to tables
+ reftable: write reftable files
+ reftable: a generic binary tree implementation
+ reftable: reading/writing blocks
+ Provide zlib's uncompress2 from compat/zlib-compat.c
+ reftable: (de)serialization for the polymorphic record type.
+ reftable: add blocksource, an abstraction for random access reads
+ reftable: utility functions
+ reftable: add error related functionality
+ reftable: add LICENSE
+ hash.h: provide constants for the hash IDs
(this branch is used by hn/reftable-coverity-fixes.)
The "reftable" backend for the refs API, without integrating into the refs subsystem, has been added.
source: <[email protected]>
* hn/t1404-df-limitation-is-ref-files-only (2021-11-29) 1 commit (merged to 'next' on 2021-12-07 at 074438a4ba)
+ t1404: mark directory/file conflict tests with REFFILES
Test update.
source: <[email protected]>
* jc/reflog-iterator-callback-doc (2021-11-28) 1 commit (merged to 'next' on 2021-12-08 at ba5693952d)
+ refs: document callback for reflog-ent iterators
Document the parameters given to the reflog entry iterator callback functions.
source: <[email protected]>
* js/test-initial-branch-override-cleanup (2021-12-05) 1 commit (merged to 'next' on 2021-12-07 at 0ab3e72b4f)
+ tests: set GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME only when needed
Many tests that used to need GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME mechanism to force "git" to use 'master' as the default name for the initial branch no longer need it; the use of the mechanism from them have been removed.
source: <[email protected]>
* re/color-default-reset (2021-10-28) 3 commits (merged to 'next' on 2021-12-08 at ab3ff50ce2)
+ color: allow colors to be prefixed with "reset"
+ color: support "default" to restore fg/bg color
+ color: add missing GIT_COLOR_* white/black constants
"default" and "reset" colors have been added to our palette. Seems to have stalled, but I am OK to merge it as-is. cf. <[email protected]>
source: <[email protected]>
source: <[email protected]>
* rj/receive-pack-avoid-sigpipe-during-status-reporting (2021-11-10) 1 commit (merged to 'next' on 2021-12-07 at 91039a781e)
+ receive-pack: ignore SIGPIPE while reporting status to client
When the "git push" command is killed while the receiving end is trying to report what happened to the ref update proposals, the latter used to die, due to SIGPIPE. The code now ignores SIGPIPE to increase our chances to run the post-receive hook after it happens.
source: <[email protected]>
* tb/pack-revindex-on-disk-cleanup (2021-12-04) 1 commit (merged to 'next' on 2021-12-07 at 912c270b70)
+ packfile: make close_pack_revindex() static
Code clean-up.
source: <dad2b73c84f1c1575a6bce04a449ee1236680b10.1638658219.git.me@ttaylorr.com>
--------------------------------------------------
[New Topics]
* es/chainlint (2021-12-13) 15 commits
(merged to 'next' on 2021-12-15 at 49b7a37334)
+ chainlint.sed: stop splitting "(..." into separate lines "(" and "..."
+ chainlint.sed: swallow comments consistently
+ chainlint.sed: stop throwing away here-doc tags
+ chainlint.sed: don't mistake << word in string as here-doc operator
+ chainlint.sed: make here-doc "<<-" operator recognition more POSIX-like
+ chainlint.sed: drop subshell-closing ">" annotation
+ chainlint.sed: drop unnecessary distinction between ?!AMP?! and ?!SEMI?!
+ chainlint.sed: tolerate harmless ";" at end of last line in block
+ chainlint.sed: improve ?!SEMI?! placement accuracy
+ chainlint.sed: improve ?!AMP?! placement accuracy
+ t/Makefile: optimize chainlint self-test
+ t/chainlint/one-liner: avoid overly intimate chainlint.sed knowledge
+ t/chainlint/*.test: generalize self-test commentary
+ t/chainlint/*.test: fix invalid test cases due to mixing quote types
+ t/chainlint/*.test: don't use invalid shell syntax
The chainlint test script linter in the test suite has been updated.
Will merge to 'master'.
source: <[email protected]>
* jh/p4-rcs-expansion-in-bytestring (2021-12-13) 4 commits
- git-p4: resolve RCS keywords in binary
- git-p4: add raw option to read_pipelines
- git-p4: pre-compile RCS keyword regexes
- git-p4: use with statements to close files after use in patchRCSKeywords
The RCS keyword substitution in "git p4" used to be done assuming that the contents are UTF-8 text, which can trigger decoding errors. We now treat the contents as a bytestring for robustness and correctness.
Will merge to 'next'?
source: <[email protected]>
* jz/apply-quiet-and-allow-empty (2021-12-13) 2 commits (merged to 'next' on 2021-12-15 at e3f643eaa3)
+ git-apply: add --allow-empty flag
+ git-apply: add --quiet flag
"git apply" has been taught to ignore a message without a patch with the "--allow-empty" option. It also learned to honor the "--quiet" option given from the command line.
Will merge to 'master'.
source: <[email protected]>
* ds/sparse-checkout-malformed-pattern-fix (2021-12-15) 3 commits
- sparse-checkout: refuse to add to bad patterns
- sparse-checkout: fix OOM error with mixed patterns
- sparse-checkout: fix segfault on malformed patterns
source: <[email protected]>
* gc/branch-recurse-submodules (2021-12-15) 6 commits
- branch.c: replace questionable exit() codes
- branch: add --recurse-submodules option for branch creation
- builtin/branch: clean up action-picking logic in cmd_branch()
- branch: remove forward declaration of validate_branch_start()
- branch: move --set-upstream-to behavior to setup_tracking()
- Merge branch 'js/branch-track-inherit' into gc/branch-recurse-submodules (this branch uses js/branch-track-inherit.)
source: <[email protected]>
* jk/ssh-signing-doc-markup-fix (2021-12-15) 1 commit
- doc/config: mark ssh allowedSigners example as literal
source: <YboWlOG3vZD/[email protected]>
* jv/use-larger-buffer-in-upload-pack (2021-12-15) 1 commit
- upload-pack.c: increase output buffer size
source: <[email protected]>
--------------------------------------------------
[Stalled]
* cb/save-term-across-editor-invocation (2021-12-01) 3 commits
- fixup! editor: allow for saving/restoring terminal state
- editor: allow for saving/restoring terminal state
- terminal: teach save_term to fail when not foreground
Some editors are reported to leave the terminal in funny state after they exit on Windows. Work it around by saving and restoring the terminal state when needed.
Expecting a reroll.
cf. <CAPUEsphktbdxeV7hvF52Or3CVHS8oOk5-WV=xfEZa8kfCVVnVg@mail.gmail.com>
source: <[email protected]>
* ar/submodule-update (2021-10-13) 9 commits
. submodule--helper: rename helper functions
. submodule--helper: remove unused helpers
. submodule: move core cmd_update() logic to C
. submodule--helper: run update using child process struct . submodule--helper: allow setting superprefix for init_submodule() . submodule--helper: refactor get_submodule_displaypath() . submodule--helper: rename helpers for update-clone
. submodule--helper: get remote names from any repository . submodule--helper: split up ensure_core_worktree()
Rewrite of "git submodule update" in C.
Expecting a reroll?
cf. <[email protected]>
source: <[email protected]>
--------------------------------------------------
[Cooking]
* en/sparse-checkout-set (2021-12-15) 10 commits
- clone: avoid using deprecated sparse-checkout init
- Documentation: clarify/correct a few sparsity related statements
- git-sparse-checkout.txt: update to document init/set/reapply changes
- sparse-checkout: enable reapply to take --[no-]{cone,sparse-index}
- sparse-checkout: enable set to initialize sparse-checkout mode
- sparse-checkout: split out code for tweaking settings config
- sparse-checkout: disallow --no-stdin as an argument to set
- sparse-checkout: add sanity-checks on initial sparsity state
- sparse-checkout: break apart functions for sparse_checkout_(set|add)
- sparse-checkout: pass use_stdin as a parameter instead of as a global
The "init" and "set" subcommands in "git sparse-checkout" have been unified for a better user experience and performance.
Will merge to 'next'.
source: <[email protected]>
* hn/reftable-coverity-fixes (2021-12-15) 13 commits
- reftable: make reftable_record a tagged union
- reftable: handle null refnames in reftable_ref_record_equal
- reftable: drop stray printf in readwrite_test
- reftable: order unittests by complexity
- reftable: all xxx_free() functions accept NULL arguments
- reftable: fix resource warning
- reftable: ignore remove() return value in stack_test.c
- reftable: check reftable_stack_auto_compact() return value
- reftable: fix resource leak blocksource.c
- reftable: fix resource leak in block.c error path
- reftable: fix OOB stack write in print functions
- Merge branch 'hn/create-reflog-simplify' into hn/reftable-coverity-fixes
- Merge branch 'hn/reftable' into hn/reftable-coverity-fixes
Problems identified by Coverity in the reftable code have been corrected.
Will merge to 'next'?
source: <[email protected]>
* jk/limit-developers-to-gnu99 (2021-12-08) 2 commits (merged to 'next' on 2021-12-15 at 6b40e01445)
+ config.mak.dev: specify -std=gnu99 for gcc/clang
+ Merge branch 'bc/require-c99' into jk/limit-developers-to-gnu99
Enable -std=gnu99 option in DEVELOPER builds.
Will merge to 'master'.
source: <[email protected]>
* tb/midx-bitmap-corruption-fix (2021-12-15) 9 commits
- fixup! midx: read RIDX chunk when present
- midx: read RIDX chunk when present
- t/lib-bitmap.sh: parameterize tests over reverse index source
- t5326: move tests to t/lib-bitmap.sh
- t5326: extract test_rev_exists
- t5326: drop unnecessary setup
- pack-revindex.c: instrument loading on-disk reverse index
- midx.c: make changing the preferred pack safe
- t5326: demonstrate bitmap corruption after permutation
A bug that made multi-pack bitmap and the object order out-of-sync (hence the .midx data gets corrupted) has been fixed.
source: <[email protected]>
* es/test-chain-lint (2021-12-13) 19 commits
- t6000-t9999: detect and signal failure within loop
- t5000-t5999: detect and signal failure within loop
- t4000-t4999: detect and signal failure within loop
- t0000-t3999: detect and signal failure within loop
- tests: simplify by dropping unnecessary for loops
- tests: apply modern idiom for exiting loop upon failure
- tests: apply modern idiom for signaling test failure
- tests: fix broken &&-chains in {...} groups
- tests: fix broken &&-chains in $(...) command substitutions
- tests: fix broken &&-chains in compound statements
- tests: use test_write_lines() to generate line-oriented output
- tests: simplify construction of large blocks of text
- t9107: use shell parameter expansion to avoid breaking &&-chain
- t6300: make %(raw:size) --shell test more robust
- t5516: drop unnecessary subshell and command invocation
- t4202: clarify intent by creating expected content less cleverly
- t1020: avoid aborting entire test script when one test fails
- t1010: fix unnoticed failure on Windows
- t/lib-pager: use sane_unset() to avoid breaking &&-chain
Broken &&-chains in the test scripts have been corrected.
Will merge to 'next'.
source: <[email protected]>
* jc/flex-array-definition (2021-12-08) 1 commit
- flex-array: simplify compiler-specific workaround
The conditions to choose different definitions of the FLEX_ARRAY macro for vendor compilers has been simplified to make it easier to maintain.
Will merge to 'next'?
source: <[email protected]>
* pw/fix-some-issues-in-reset-head (2021-12-08) 14 commits
- rebase -m: don't fork git checkout
- rebase --apply: set ORIG_HEAD correctly
- rebase --apply: fix reflog
- reset_head(): take struct rebase_head_opts
- rebase: cleanup reset_head() calls
- reset_head(): make default_reflog_action optional
- reset_head(): factor out ref updates
- create_autostash(): remove unneeded parameter
- reset_head(): remove action parameter
- rebase --apply: don't run post-checkout hook if there is an error
- rebase: do not remove untracked files on checkout
- rebase: pass correct arguments to post-checkout hook
- t5403: refactor rebase post-checkout hook tests
- rebase: factor out checkout for up to date branch
Fix "some issues" in a helper function reset_head().
source: <[email protected]>
* je/http-better-error-output (2021-12-03) 1 commit
. http-backend: give a hint that web browser access is not supported
When the http-backend program, which is the server-side component for the smart HTTP transport, sends a "404 Not found" error, we deliberately did not say anything to the requesting client. We now send a message back to the browser to tell the user that they do not want to visit the URL via their browser, instead of a totally blank page.
Expecting a reroll.
Breaks its self tests.
cf. <[email protected]>
source: <[email protected]>
* en/name-rev-shorter-output (2021-12-04) 1 commit (merged to 'next' on 2021-12-10 at ae8ec3912f)
+ name-rev: prefer shorter names over following merges
"git name-rev" has been tweaked to give output that is shorter and easier to understand.
Will merge to 'master'.
source: <[email protected]>
* en/rebase-x-wo-git-dir-env (2021-12-04) 1 commit (merged to 'next' on 2021-12-07 at 44f2663314)
+ sequencer: do not export GIT_DIR and GIT_WORK_TREE for 'exec'
"git rebase -x" by mistake started exporting the GIT_DIR and GIT_WORK_TREE environment variables when the command was rewritten in C, which has been corrected.
Will merge to 'master'.
source: <[email protected]>
* ja/i18n-similar-messages (2021-12-05) 10 commits
- i18n: ref-filter: factorize "%(foo) atom used without %(bar) atom"
- i18n: factorize "--foo outside a repository"
- i18n: refactor "unrecognized %(foo) argument" strings
- i18n: factorize "no directory given for --foo"
- i18n: factorize "--foo requires --bar" and the like
- i18n: tag.c factorize i18n strings
- i18n: standardize "cannot open" and "cannot read"
- i18n: turn "options are incompatible" into "are mutually exclusive"
- i18n: refactor "%s, %s and %s are mutually exclusive"
- i18n: refactor "foo and bar are mutually exclusive"
Similar message templates have been consolidated so that translators need to work on fewer number of messages.
Needs review.
source: <[email protected]>
* ab/usage-die-message (2021-12-07) 6 commits
- config API: use get_error_routine(), not vreportf()
- usage.c + gc: add and use a die_message_errno()
- gc: return from cmd_gc(), don't call exit()
- usage.c API users: use die_message() for error() + exit 128
- usage.c API users: use die_message() for "fatal :" + exit 128
- usage.c: add a die_message() routine
Code clean-up to hide vreportf() from public API.
Needs review.
source: <[email protected]>
* ab/common-main-cleanup (2021-12-07) 1 commit
(merged to 'next' on 2021-12-15 at ff08c86f65)
+ common-main.c: call exit(), don't return
Code clean-up.
Will merge to 'master'.
source: <[email protected]>
* ab/fetch-set-upstream-while-detached (2021-12-07) 1 commit (merged to 'next' on 2021-12-15 at d0406f880a)
+ pull, fetch: fix segfault in --set-upstream option
"git fetch --set-upstream" did not check if there is a current branch, leading to a segfault when it is run on a detached HEAD, which has been corrected.
Will merge to 'master'.
source: <[email protected]>
* ab/cat-file (2021-12-08) 10 commits
- cat-file: use GET_OID_ONLY_TO_DIE in --(textconv|filters)
- object-name.c: don't have GET_OID_ONLY_TO_DIE imply *_QUIETLY
- cat-file: correct and improve usage information
- cat-file: fix remaining usage bugs
- cat-file: make --batch-all-objects a CMDMODE
- cat-file: move "usage" variable to cmd_cat_file()
- cat-file docs: fix SYNOPSIS and "-h" output
- parse-options API: add a usage_msg_optf()
- cat-file tests: test messaging on bad objects/paths
- cat-file tests: test bad usage
Assorted updates to "git cat-file", especially "-h".
source: <[email protected]>
* ab/grep-patterntype (2021-12-04) 7 commits
- grep: simplify config parsing and option parsing
- grep API: call grep_config() after grep_init()
- grep.c: don't pass along NULL callback value
- built-ins: trust the "prefix" from run_builtin()
- grep tests: add missing "grep.patternType" config test
- log tests: check if grep_config() is called by "log"-like cmds
- grep.h: remove unused "regex_t regexp" from grep_opt
Some code clean-up in the "git grep" machinery.
Needs review.
source: <[email protected]>
* js/use-builtin-add-i (2021-12-01) 2 commits
- add -i: default to the built-in implementation
- t2016: require the PERL prereq only when necessary
"git add -i" was rewritten in C some time ago and has been in testing; the reimplementation is now exposed to general public by default.
On hold.
There are known breakages on macOS.
cf. <[email protected]>
source: <[email protected]>
* jt/conditional-config-on-remote-url (2021-12-15) 2 commits
- config: include file if remote URL matches a glob
- config: make git_config_include() static
The conditional inclusion mechanism of configuration files using "[includeIf <condition>]" learns to base its decision on the URL of the remote repository the repository interacts with.
source: <[email protected]>
* tb/cruft-packs (2021-11-29) 17 commits
- sha1-file.c: don't freshen cruft packs
- builtin/gc.c: conditionally avoid pruning objects via loose
- builtin/repack.c: add cruft packs to MIDX during geometric repack
- builtin/repack.c: use named flags for existing_packs
- builtin/repack.c: allow configuring cruft pack generation
- builtin/repack.c: support generating a cruft pack
- builtin/pack-objects.c: --cruft with expiration
- reachable: report precise timestamps from objects in cruft packs
- reachable: add options to add_unseen_recent_objects_to_traversal
- builtin/pack-objects.c: --cruft without expiration
- builtin/pack-objects.c: return from create_object_entry()
- t/helper: add 'pack-mtimes' test-tool
- pack-mtimes: support writing pack .mtimes files
- chunk-format.h: extract oid_version()
- pack-write: pass 'struct packing_data' to 'stage_tmp_packfiles'
- pack-mtimes: support reading .mtimes files
- Documentation/technical: add cruft-packs.txt
Instead of leaving unreachable objects in loose form when packing, or ejecting them into loose form when repacking, gather them in a packfile with an auxiliary file that records the last-use time of these objects.
Expecting a reroll.
source: <[email protected]>
* jk/log-decorate-opts-with-implicit-decorate (2021-12-01) 2 commits (merged to 'next' on 2021-12-10 at 80585b2755)
+ log: load decorations with --simplify-by-decoration
+ log: handle --decorate-refs with userformat "%d"
When "git log" implicitly enabled the "decoration" processing without being explicitly asked with "--decorate" option, it failed to read and honor the settings given by the "--decorate-refs" option.
Will merge to 'master'.
source: <[email protected]>
* jl/subtree-check-parents-argument-passing-fix (2021-12-05) 1 commit
- subtree: fix argument handling in check_parents
Fix performance-releated bug in "git subtree" (in contrib/).
Expecting a reroll.
cf. <[email protected]>
source: <[email protected]>
* ab/ambiguous-object-name (2021-11-26) 6 commits
- object-name: re-use "struct strbuf" in show_ambiguous_object()
- object-name: iterate ambiguous objects before showing header
- object-name: show date for ambiguous tag objects
- object-name: make ambiguous object output translatable
- object-name: explicitly handle OBJ_BAD in show_ambiguous_object()
- object-name tests: add tests for ambiguous object blind spots
Error output given in response to an ambiguous object name has been improved.
Needs review.
An earlier iteration that was much smaller had seen some reviews, but the latest round enlarged its scope and needs to be reviewed afresh.
source: <[email protected]>
* jc/grep-patterntype-default-doc (2021-12-05) 1 commit (merged to 'next' on 2021-12-10 at e46385ad9d)
+ grep: clarify what grep.patternType=default means
Doc update.
Will merge to 'master'.
source: <[email protected]>
* en/keep-cwd (2021-12-09) 11 commits
- t2501: simplify the tests since we can now assume desired behavior
- dir: new flag to remove_dir_recurse() to spare the original_cwd
- dir: avoid incidentally removing the original_cwd in remove_path()
- stash: do not attempt to remove startup_info->original_cwd
- rebase: do not attempt to remove startup_info->original_cwd
- clean: do not attempt to remove startup_info->original_cwd
- symlinks: do not include startup_info->original_cwd in dir removal
- unpack-trees: add special cwd handling
- unpack-trees: refuse to remove startup_info->original_cwd
- setup: introduce startup_info->original_cwd
- t2501: add various tests for removing the current working directory
Many git commands that deal with working tree files try to remove a directory that becomes empty (i.e. "git switch" from a branch that has the directory to another branch that does not would attempt remove all files in the directory and the directory itself). This drops users into an unfamiliar situation if the command was run in a subdirectory that becomes subject to removal due to the command. The commands have been taught to keep an empty directory if it is the directory they were started in to avoid surprising users.
Will merge to 'next'?
source: <[email protected]>
* tl/ls-tree-oid-only (2021-12-15) 1 commit
- ls-tree.c: support --object-only option for "git-ls-tree"
"git ls-tree" learns "--oid-only" option, similar to "--name-only".
Expecting a reroll.
source: <[email protected]>
* ab/make-dependency (2021-11-18) 24 commits
- Makefile: move ".SUFFIXES" rule to shared.mak
- Makefile: define $(LIB_H) in terms of $(FIND_SOURCE_FILES)
- Makefile: disable GNU make built-in wildcard rules
- Makefile: use $(file) I/O instead of "FORCE" when possible
- Makefile: correct the dependency graph of hook-list.h
- Makefiles: add and use wildcard "mkdir -p" template
- Makefile: use $(wspfx) for $(QUIET...) in shared.mak
- Makefile: add "$(QUIET)" boilerplate to shared.mak
- Makefile: add a "TRACK_template" for GIT-*{FLAGS,DEFINES,...}
- Makefile: re-add and use the "shellquote" macros
- Makefile: move $(comma), $(empty) and $(space) to shared.mak
- Makefiles: add "shared.mak", move ".DELETE_ON_ERROR" to it
- Makefile: stop needing @@GIT_VERSION@@ in *.perl scripts
- Makefile: create a GIT-PYTHON-DEFINES, like "PERL"
- Makefile: correct "GIT-PERL-{DEFINES,HEADER}" dependency graph
- Makefile: adjust Perl-related comments & whitespace
- Makefile: change "ifndef NO_PERL" to "ifdef NO_PERL"
- Makefile: guard Perl-only variable assignments
- Makefile: remove "mv $@ $@+" dance redundant to .DELETE_ON_ERROR
- Makefile: clean perl/build/ even with NO_PERL=Y
- Makefile: use "=" not ":=" for po/* and perl/*
- Makefile: don't set up "perl/build" rules under NO_PERL=Y
- Makefile: don't invoke msgfmt with --statistics
- Merge branch 'ab/sh-retire-helper-functions' into ab/make-dependency
Dependency clean-up.
Needs review.
There are some comments on earlier rounds; the latest one needs a serious review or at least Acks from past commentors.
source: <[email protected]>
* ds/fetch-pull-with-sparse-index (2021-12-08) 6 commits
. test-read-cache: remove --table, --expand options
. t1091/t3705: remove 'test-tool read-cache --table'
. t1092: replace 'read-cache --table' with 'ls-files --sparse' . ls-files: add --sparse option
. fetch/pull: use the sparse index
. Merge branch 'ld/sparse-diff-blame' into ds/fetch-pull-with-sparse-index (this branch uses ld/sparse-diff-blame.)
"git fetch" and "git pull" are now declared sparse-index clean. Also "git ls-files" learns the "--sparse" option to help debugging.
Ejected from 'seen', as it seems to fail its self-test.
source: <[email protected]>
* fs/ssh-signing-other-keytypes (2021-11-19) 2 commits (merged to 'next' on 2021-12-10 at 2d0c8cb8e6)
+ ssh signing: make sign/amend test more resilient
+ ssh signing: support non ssh-* keytypes
The cryptographic signing using ssh keys can specify literal keys for keytypes whose name do not begin with the "ssh-" prefix by using the "key::" prefix mechanism (e.g. "key::ecdsa-sha2-nistp256").
Will merge to 'master'.
source: <[email protected]>
* pw/xdiff-classify-record-in-histogram (2021-12-04) 6 commits (merged to 'next' on 2021-12-07 at 8cdad7bc9a)
+ xdiff: drop unused flags parameter from recs_match
+ xdiff: drop xpparam_t parameter from histogram cmp_recs()
+ xdiff: drop CMP_ENV macro from xhistogram
(merged to 'next' on 2021-12-02 at 5ccd12d09b)
+ xdiff: simplify comparison
+ xdiff: avoid unnecessary memory allocations
+ diff histogram: intern strings
"diff --histogram" optimization.
Will merge to 'master'.
source: <[email protected]>
source: <[email protected]>
* xw/am-empty (2021-12-07) 3 commits
- am: support --allow-empty to record specific empty patches
- am: support --empty=<option> to handle empty patches
- doc: git-format-patch: describe the option --always
"git am" learns "--empty=(die|drop|keep)" option to tweak what is done to a piece of e-mail without a patch in it.
Almost there.
source: <[email protected]>
* jc/c99-var-decl-in-for-loop (2021-12-03) 1 commit (merged to 'next' on 2021-12-03 at 57100223b2)
+ revision: use C99 declaration of variable in for() loop
Weather balloon to find compilers that do not grok variable declaration in the for() loop.
Will merge to 'master'.
source: <[email protected]>
* ak/protect-any-current-branch (2021-12-01) 8 commits (merged to 'next' on 2021-12-10 at dd2c6a557c)
+ branch: protect branches checked out in all worktrees
+ receive-pack: protect current branch for bare repository worktree
+ receive-pack: clean dead code from update_worktree()
+ fetch: protect branches checked out in all worktrees
+ worktree: simplify find_shared_symref() memory ownership model
+ branch: lowercase error messages
+ receive-pack: lowercase error messages
+ fetch: lowercase error messages
"git fetch" without the "--update-head-ok" option ought to protect a checked out branch from getting updated, to prevent the working tree that checks it out to go out of sync. The code was written before the use of "git worktree" got widespread, and only checked the branch that was checked out in the current worktree, which has been updated.
(originally called ak/fetch-not-overwrite-any-current-branch)
Will merge to 'master'.
source: <[email protected]>
* pw/diff-color-moved-fix (2021-12-09) 15 commits
- diff --color-moved: intern strings
- diff: use designated initializers for emitted_diff_symbol
- diff --color-moved-ws=allow-indentation-change: improve hash lookups
- diff --color-moved: stop clearing potential moved blocks
- diff --color-moved: shrink potential moved blocks as we go
- diff --color-moved: unify moved block growth functions
- diff --color-moved: call comparison function directly
- diff --color-moved-ws=allow-indentation-change: simplify and optimize
- diff: simplify allow-indentation-change delta calculation
- diff --color-moved: avoid false short line matches and bad zebra coloring
- diff --color-moved=zebra: fix alternate coloring
- diff --color-moved: rewind when discarding pmb
- diff --color-moved: factor out function
- diff --color-moved: clear all flags on blocks that are too short
- diff --color-moved: add perf tests
Correctness and performance update to "diff --color-moved" feature.
Will merge to 'next'.
source: <[email protected]>
* fs/ssh-signing-key-lifetime (2021-12-09) 9 commits (merged to 'next' on 2021-12-10 at d5e7bd8b79)
+ ssh signing: verify ssh-keygen in test prereq
+ ssh signing: make fmt-merge-msg consider key lifetime
+ ssh signing: make verify-tag consider key lifetime
+ ssh signing: make git log verify key lifetime
+ ssh signing: make verify-commit consider key lifetime
+ ssh signing: add key lifetime test prereqs
+ ssh signing: use sigc struct to pass payload
+ t/fmt-merge-msg: make gpgssh tests more specific
+ t/fmt-merge-msg: do not redirect stderr
Extend the signing of objects with SSH keys and learn to pay attention to the key validity time range when verifying.
Will merge to 'master'.
source: <[email protected]>
* jc/doc-submitting-patches-choice-of-base (2021-10-25) 2 commits
- (wip) reword the final review part
- SubmittingPatchs: clarify choice of base and testing
Extend the guidance to choose the base commit to build your work on, and hint/nudge contributors to read others' changes.
Expecting a reroll.
Stalled after one incremental update suggestion.
cf. <[email protected]>
source: <[email protected]>
* ab/config-based-hooks-2 (2021-11-24) 18 commits
- run-command: remove old run_hook_{le,ve}() hook API
- receive-pack: convert push-to-checkout hook to hook.h
- read-cache: convert post-index-change to use hook.h
- commit: convert {pre-commit,prepare-commit-msg} hook to hook.h
- git-p4: use 'git hook' to run hooks
- send-email: use 'git hook run' for 'sendemail-validate'
- git hook run: add an --ignore-missing flag
- hooks: convert worktree 'post-checkout' hook to hook library
- hooks: convert non-worktree 'post-checkout' hook to hook library
- merge: convert post-merge to use hook.h
- am: convert applypatch-msg to use hook.h
- rebase: convert pre-rebase to use hook.h
- hook API: add a run_hooks_l() wrapper
- am: convert {pre,post}-applypatch to use hook.h
- gc: use hook library for pre-auto-gc hook
- hook API: add a run_hooks() wrapper
- hook: add 'run' subcommand
- Merge branch 'ab/config-based-hooks-1' into ab/config-based-hooks-2
More "config-based hooks".
Needs review.
At this point, as Ævar and Emily both read the major part of this series, a final and quick read-over plus an Ack by Emily on her part plus a serious review on the patches attributed to Ævar by somebody other than Ævar would be sufficient to move it in some direction (hopefully forward).
source: <[email protected]>
* js/branch-track-inherit (2021-12-15) 3 commits
- config: require lowercase for branch.autosetupmerge
- branch: add flags and config to inherit tracking
- branch: accept multiple upstream branches for tracking (this branch is used by gc/branch-recurse-submodules.)
"git -c branch.autosetupmerge=inherit branch new old" makes "new" to have the same upstream as the "old" branch, instead of marking "old" itself as its upstream.
source: <[email protected]>
* jh/builtin-fsmonitor-part2 (2021-10-21) 29 commits
- t7527: test status with untracked-cache and fsmonitor--daemon
- fsmonitor: force update index after large responses
- fsmonitor--daemon: use a cookie file to sync with file system
- fsmonitor--daemon: periodically truncate list of modified files
- t/perf/p7519: add fsmonitor--daemon test cases
- t/perf/p7519: speed up test on Windows
- t/helper/test-chmtime: skip directories on Windows
- t/perf: avoid copying builtin fsmonitor files into test repo
- t7527: create test for fsmonitor--daemon
- t/helper/fsmonitor-client: create IPC client to talk to FSMonitor Daemon
- help: include fsmonitor--daemon feature flag in version info
- fsmonitor--daemon: implement handle_client callback
- compat/fsmonitor/fsm-listen-darwin: implement FSEvent listener on MacOS
- compat/fsmonitor/fsm-listen-darwin: add macos header files for FSEvent
- compat/fsmonitor/fsm-listen-win32: implement FSMonitor backend on Windows
- fsmonitor--daemon: create token-based changed path cache
- fsmonitor--daemon: define token-ids
- fsmonitor--daemon: add pathname classification
- fsmonitor--daemon: implement 'start' command
- fsmonitor--daemon: implement 'run' command
- compat/fsmonitor/fsm-listen-darwin: stub in backend for Darwin
- compat/fsmonitor/fsm-listen-win32: stub in backend for Windows
- fsmonitor--daemon: implement 'stop' and 'status' commands
- fsmonitor--daemon: add a built-in fsmonitor daemon
- fsmonitor: document builtin fsmonitor
- fsmonitor: use IPC to query the builtin FSMonitor daemon
- fsmonitor: config settings are repository-specific
- fsmonitor-ipc: create client routines for git-fsmonitor--daemon
- fsmonitor: enhance existing comments
Built-in fsmonitor (part 2).
Expecting a reroll.
Seems that the discussion stalled.
cf. <[email protected]>
source: <[email protected]>
* ld/sparse-diff-blame (2021-12-06) 8 commits (merged to 'next' on 2021-12-10 at 57b89936d6)
+ blame: enable and test the sparse index
+ diff: enable and test the sparse index
+ diff: replace --staged with --cached in t1092 tests
+ repo-settings: prepare_repo_settings only in git repos
+ test-read-cache: set up repo after git directory
+ commit-graph: return if there is no git directory
+ git: ensure correct git directory setup with -h
+ Merge branch 'vd/sparse-reset' into ld/sparse-diff-blame (this branch is used by ds/fetch-pull-with-sparse-index.)
Teach diff and blame to work well with sparse index.
Will merge to 'master'.
source: <[email protected]>
* ns/tmp-objdir (2021-12-08) 2 commits
- tmp-objdir: disable ref updates when replacing the primary odb
- tmp-objdir: new API for creating temporary writable databases (this branch is used by ns/batched-fsync and ns/remerge-diff.)
New interface into the tmp-objdir API to help in-core use of the quarantine feature.
Will merge to 'next'.
source: <[email protected]>
* es/superproject-aware-submodules (2021-11-18) 5 commits
- submodule: use config to find superproject worktree
- submodule: record superproject gitdir during 'update'
- submodule: record superproject gitdir during absorbgitdirs
- introduce submodule.superprojectGitDir record
- t7400-submodule-basic: modernize inspect() helper
A configuration variable in a submodule points at the location of the superproject it is bound to (RFC).
Expecting a reroll.
cf. <[email protected]>
source: <[email protected]>
* js/scalar (2021-12-04) 15 commits
(merged to 'next' on 2021-12-10 at 6248603a80)
+ scalar: implement the version command
+ scalar: implement the delete command
+ scalar: teach 'reconfigure' to optionally handle all registered enlistments
+ scalar: allow reconfiguring an existing enlistment
+ scalar: implement the run command
+ scalar: teach 'clone' to support the --single-branch option
+ scalar: implement the clone subcommand
+ scalar: implement 'scalar list'
+ scalar: let 'unregister' handle a deleted enlistment directory gracefully
+ scalar: 'unregister' stops background maintenance
+ scalar: 'register' sets recommended config and starts maintenance
+ scalar: create test infrastructure
+ scalar: start documenting the command
+ scalar: create a rudimentary executable
+ scalar: add a README with a roadmap
Add pieces from "scalar" to contrib/.
Will merge to 'master'.
source: <[email protected]>
* ab/only-single-progress-at-once (2021-11-03) 8 commits
- progress.c: add & assert a "global_progress" variable
- various *.c: use isatty(0|2), not isatty(STDIN_FILENO|STDERR_FILENO)
- pack-bitmap-write.c: don't return without stop_progress()
- progress.c: add temporary variable from progress struct
- progress.c tests: test some invalid usage
- progress.c tests: make start/stop commands on stdin
- progress.c test helper: add missing braces
- leak tests: fix a memory leaks in "test-progress" helper
Further tweaks on progress API.
Needs review.
The last three rounds has seen little reaction, even though earlier round saw a lot of responses. The latest round needs a serious review or at least Acks from past commentors.
source: <[email protected]>
--------------------------------------------------
[Discarded]
* cf/fetch-set-upstream-while-detached (2021-07-06) 1 commit . fetch: fix segfault on --set-upstream while on a detached HEAD
"git fetch --set-upstream" while on detached HEAD segfaulted instead of noticing that such an operation did not make sense.
Superseded by the ab/fetch-set-upstream-while-detached topic
source: <[email protected]>
* js/compat-util-msvc-flex-array (2021-12-06) 1 commit
. git-compat-util(msvc): C11 does not imply support for zero-sized arrays
MSVC build started to break on flex arrays?
It seems that there is no breakage in the toolchain; the code was buggy.
source: <[email protected]>
* ns/batched-fsync (2021-12-08) 8 commits
. core.fsyncobjectfiles: performance tests for add and stash . core.fsyncobjectfiles: tests for batch mode
. unpack-objects: use the bulk-checkin infrastructure
. update-index: use the bulk-checkin infrastructure
. core.fsyncobjectfiles: add windows support for batch mode . core.fsyncobjectfiles: batched disk flushes
. bulk-checkin: rename 'state' variable and separate 'plugged' boolean . Merge branch 'ns/tmp-objdir' into ns/batched-fsync
(this branch uses ns/tmp-objdir.)
The "core.fsyncobjectfiles" configuration variable can now be set to "batch" for improved performance.
cf. [email protected]
source: <[email protected]>
* ns/remerge-diff (2021-12-08) 8 commits
. doc/diff-options: explain the new --remerge-diff option
. show, log: adapt Elijah Newren's changes to common tmp-objdir API . show, log: provide a --remerge-diff capability
. merge-ort: capture and print ll-merge warnings in our preferred fashion . ll-merge: add API for capturing warnings in a strbuf instead of stderr . merge-ort: add ability to record conflict messages in a file . merge-ort: mark a few more conflict messages as omittable
. Merge branch 'ns/tmp-objdir' into ns/remerge-diff
(this branch uses ns/tmp-objdir.)
A new presentation for two-parent merge "--remerge-diff" can be used to show the difference between mechanical (and possibly conflicted) merge results and the recorded resolution.
cf. <CABPp-BE4ZD4dsr=ofbZeWqxEV=8do93o_Gus_wsGw6Fq7V2ETA@mail.gmail.com> This is Elijah's remerge-diff rebased on ns/tmp-objdir to share the "create objects temporarily, only to discard without committing them to longer-term storage" infrastructure with another topic.
* ms/customizable-ident-expansion (2021-09-01) 1 commit
- keyword expansion: make "$Id$" string configurable
Instead of "$Id$", user-specified string (like $FreeBSD$) can be used as an in-blob placeholder for keyword expansion.
Will discard.
Stalled for too long.
cf. <[email protected]>
cf. <[email protected]>
source: <[email protected]>
* jc/make-test-all (2021-12-13) 2 commits
. WIP to add "test-extra-clean"
. Makefile: add test-all target
"make test" target in subdirectories of contrib/ are now exercised in CI tests.
source: <[email protected]>
* jh/make-p4-python3-only (2021-12-09) 6 commits
. git-p4: Resolve RCS keywords in binary
. git-p4: Eliminate decode_stream and encode_stream
. git-p4: Decode byte strings before printing
. git-p4: Removed support for Python 2
. git-p4: Don't print shell commands as python lists
. git-p4: Always pass cmd arguments to subprocess as a python lists
Support for Python2 in "git p4" has been removed (not just deprecated).
Superseded by jh/p4-rcs-expansion-in-bytestring topic, leaving the "drop Python-2 support" for a separate topic in the future.
source: <[email protected]>
ab/run-command (was: What's cooking in git.git (Dec 2021, #04; Wed, 15))
Quoted 14 lines · Junio C Hamano
[Graduated to 'master']
[...]
* ab/run-command (2021-11-25) 9 commits
(merged to 'next' on 2021-12-07 at5c0bedf853)
+ run-command API: remove "env" member, always use "env_array"
+ difftool: use "env_array" to simplify memory management
+ run-command API: remove "argv" member, always use "args"
+ run-command API users: usestrvec_push(), not argv construction
+ run-command API users: usestrvec_pushl(), not argv construction
+ run-command tests: usestrvec_pushv(), not argv assignment
+ run-command API users: usestrvec_pushv(), not argv assignment
+ upload-archive: use regular "structchild_process" pattern
+ worktree: stop being overly intimate withrun_command()internals
Quoted 4 lines
API clean-up.
cf. <[email protected]>
cf. <CAPig+cSvFgJTiq8pXrWy_7ukQwE1y9ZGwMgKmyjWuQHdNGxiDQ@mail.gmail.com>
source: <[email protected]>
Thanks! FWIW the tip commit mentioned that renaming "env_array" to "env" probably wasn't worth it, but having tried it just now I think it's probably a worthwhile follow-up at some point. The diff is just:
diff --git a/run-command.h b/run-command.h
index 2be5f5d6422..c5d44cc9a5c 100644
--- a/run-command.h
+++ b/run-command.h
@@ -73,7 +73,7 @@ struct child_process {
* The memory in .env_array will be cleaned up automatically during
* `finish_command` (or during `start_command` when it is unsuccessful).
*/
- struct strvec env_array;
+ struct strvec env;
pid_t pid;
int trace2_child_id;
@@ -147,7 +147,7 @@ struct child_process {
#define CHILD_PROCESS_INIT { \
.args = STRVEC_INIT, \
- .env_array = STRVEC_INIT, \
+ .env = STRVEC_INIT, \
}
/**Followed by a rather large mechanical change, but that change can almost entirely be done with this cocci rule:
@@
struct child_process E;
@@
- E.env_array
+ E.env
@@
struct child_process *E;
@@
- E->env_array
+ E->envThe "almost" being that we'll also need this on top:
builtin/submodule--helper.c | 2 +-
run-command.c | 6 +++---
run-command.h | 10 +++++-----
sequencer.c | 6 +++---
submodule.h | 4 ++--
5 files changed, 14 insertions(+), 14 deletions(-)Which changes comments and function/variable names that refer to "env_array" to refer to "env".
I won't submit it now because we've got some "env_array" in master..seen, but there'll probably be a time when there'll be none which might make it trivial.
Or maybe you're not interested in either case, which is also fine. It's really not needed for anything other than to resolve the minor oddity that we have two "struct strvec"'s, "args" and "env_array". It's just a bit odd to have one with "_array" in the name, which is only because the now-removed "env" was taken at the time.
Re: ab/run-command (was: What's cooking in git.git (Dec 2021, #04; Wed, 15))
Quoted 5 lines · Ævar Arnfjörð Bjarmason
Or maybe you're not interested in either case, which is also fine. It's really not needed for anything other than to resolve the minor oddity that we have two "struct strvec"'s, "args" and "
env_array". It's just a bit odd to have one with "_array" in the name, which is only because the now-removed "env" was taken at the time.
Yeah, FWIW I absolutely hated "env_array" when I added it, but didn't want to do the transition all at once, so needed another name. So I would be happy to see it become "env" now. ;)
Turning "args" into "argv" is less important, just because the name is less long and ugly. And since "argv" is both the concept of the arg list and also the well-known main() parameter with a different type, arguably using it for a type besides "const char **" could be confusing (though I don't find it so personally).
-Peff
Re: ab/run-command (was: What's cooking in git.git (Dec 2021, #04; Wed, 15))
Quoted 11 lines · Jeff King
Quoted 5 lines · Ævar Arnfjörð Bjarmason
Or maybe you're not interested in either case, which is also fine. It's really not needed for anything other than to resolve the minor oddity that we have two "struct strvec"'s, "args" and "
env_array". It's just a bit odd to have one with "_array" in the name, which is only because the now-removed "env" was taken at the time.Yeah, FWIW I absolutely hated "
env_array" when I added it, but didn't want to do the transition all at once, so needed another name. So I would be happy to see it become "env" now. ;)
Thanks.
Quoted 5 lines
Turning "args" into "argv" is less important, just because the name is less long and ugly. And since "argv" is both the concept of the arg list and also the well-known
main()parameter with a different type, arguably using it for a type besides "const char **" could be confusing (though I don't find it so personally).
I like that it's just "args", so I don't think I'd change it even if I could waive the proverbial magic wand to d oit.
We also have non-run-command.h code that uses "struct strvec args = STRVEC_INIT" (although most of that ends up being passed into the run_command.c function).
Saying "argv.v" also seems a bit more strange than "args.v", IMO.
Re: ab/run-command
Quoted 8 lines · Ævar Arnfjörð Bjarmason
I like that it's just "args", so I don't think I'd change it even if I could waive the proverbial magic wand to d oit.
We also have
non-run-command.hcode that uses "struct strvec args =STRVEC_INIT" (although most of that ends up being passed into therun_command.cfunction).Saying "argv.v" also seems a bit more strange than "args.v", IMO.
So perhaps the renamed member will be called envs?
;-)
cover run-command.h: rename "env_array" to "env"
In reply to Jeff KingQuoted 11 lines · Jeff King
Quoted 5 lines · Ævar Arnfjörð Bjarmason
Or maybe you're not interested in either case, which is also fine. It's really not needed for anything other than to resolve the minor oddity that we have two "struct strvec"'s, "args" and "
env_array". It's just a bit odd to have one with "_array" in the name, which is only because the now-removed "env" was taken at the time.Yeah, FWIW I absolutely hated "
env_array" when I added it, but didn't want to do the transition all at once, so needed another name. So I would be happy to see it become "env" now. ;)
Perhaps this follow-up to 832ec72c3e1 (Merge branch 'ab/run-command', 2021-12-15) will warm Jeff's heart if/when he returns from his git sabbatical :)
Junio: We're in the RC period, but perhaps this change if we're ever going to make it would be good to make around that time of patch slowdown. I.e. for the first batch after release.
I've been holding onto this since around December, but when I checked there was always 1-2 series that was adding new use of "env_array", resolving that conflict didn't seem worth the hassle.
Right now this doesn't conflict with anything in "seen". The scary-at-first diffstat is almost entirely in 2/3, and everything except a two-line change in that commit is made by the coccinelle rule added in 1/3.
So this series for reviewing is really:
* A trivial coccinelle rule in 1/3
* The trivial 2 line change in run-command.h in 2/3 that isn't made by that rule
* Subsequent trivial cleanup in 3/3 changing s/env_array/env/g in comments & variable names
Ævar Arnfjörð Bjarmason (3):
cocci: add a rename of "struct child_process"'s "env_array" to "env" run-command API: rename "env_array" to "env"
run-command API users: use "env" not "env_array" in comments & names
add-patch.c | 2 +- branch.c | 2 +- builtin/difftool.c | 6 ++-- builtin/receive-pack.c | 32 ++++++++++---------- builtin/stash.c | 16 +++++----- builtin/submodule--helper.c | 44 ++++++++++++++-------------- builtin/worktree.c | 8 ++--- connect.c | 9 +++--- connected.c | 2 +- contrib/coccinelle/run_command.cocci | 11 +++++++ daemon.c | 14 ++++----- editor.c | 2 +- hook.c | 2 +- http-backend.c | 4 +-- object-file.c | 2 +- pager.c | 4 +-- promisor-remote.c | 2 +- run-command.c | 19 ++++++------ run-command.h | 14 ++++----- sequencer.c | 18 ++++++------ submodule.c | 38 ++++++++++++------------ submodule.h | 4 +-- t/helper/test-run-command.c | 2 +- trailer.c | 2 +- transport-helper.c | 2 +- wt-status.c | 2 +- 26 files changed, 138 insertions(+), 125 deletions(-) create mode 100644 contrib/coccinelle/run_command.cocci
Signature · 1 line
2.36.0.rc0.849.g2d5b5d9ab01
PATCH 1/3 cocci: add a rename of "struct child_process"'s "env_array" to "env"
Start following-up on the rename mentioned in c7c4bdeccf3 (run-command
API: remove "env" member, always use "env_array", 2021-11-25) of "env_array" to "env".
The "env_array" name was picked in 19a583dc39e (run-command: add env_array, an optional argv_array for env, 2014-10-19) because "env" was taken. Let's not forever keep the oddity of "*_array" for this "struct strvec", but not for its "args" sibling.
This is added as a "pending" migration because it'll need a couple of manual changes to go along with it, those will be performed in the subsequent commit.
--- contrib/coccinelle/run_command.pending.cocci | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 contrib/coccinelle/run_command.pending.cocci
contrib/coccinelle/run_command.pending.cocci new file +11 -0
@@ -0,0 +1,11 @@ +@@ +struct child_process E; +@@ +- E.env_array ++ E.env + +@@ +struct child_process *E; +@@ +- E->env_array ++ E->env
Signature · 1 line
2.36.0.rc0.849.g2d5b5d9ab01
PATCH 2/3 run-command API: rename "env_array" to "env"
In reply to Ævar Arnfjörð BjarmasonAs noted in the preceding commit it would be nice to not deal with the oddity of having an "_array" suffix for the "env" strvec, but not for its "args" sibling.
We can do that with coccinelle in a way that's easy to review. The only manual changes in this commit are:
* git mv contrib/coccinelle/run_command{.pending,}.cocci
* The change in run-command.h to rename the struct member itself, and to change its initializer.
The rest of this is all the result of a subsequent:
* make contrib/coccinelle/run_command.cocci.patch
* patch -p1 <contrib/coccinelle/run_command.cocci.patch
* git add -u
I've avoided changing any comments and derived variable names here, that will all be done in the next commit.
---
add-patch.c | 2 +-
branch.c | 2 +-
builtin/difftool.c | 6 +--
builtin/receive-pack.c | 32 +++++++-------
builtin/stash.c | 16 +++----
builtin/submodule--helper.c | 42 +++++++++----------
builtin/worktree.c | 8 ++--
connect.c | 9 ++--
connected.c | 2 +-
...ommand.pending.cocci => run_command.cocci} | 0
daemon.c | 14 +++----
editor.c | 2 +-
hook.c | 2 +-
http-backend.c | 4 +-
object-file.c | 2 +-
pager.c | 4 +-
promisor-remote.c | 2 +-
run-command.c | 13 +++---
run-command.h | 4 +-
sequencer.c | 16 +++----
submodule.c | 38 ++++++++---------
t/helper/test-run-command.c | 2 +-
trailer.c | 2 +-
transport-helper.c | 2 +-
wt-status.c | 2 +-
25 files changed, 115 insertions(+), 113 deletions(-)
rename contrib/coccinelle/{run_command.pending.cocci => run_command.cocci} (100%)add-patch.c +1 -1
@@ -305,7 +305,7 @@ static void setup_child_process(struct add_p_state *s,va_end (ap); cp->git_cmd =1 ; -strvec_pushf (&cp->env_array, +strvec_pushf (&cp->env,INDEX_ENVIRONMENT "=%s" , s->s.r->index_file); }
branch.c +1 -1
@@ -564,7 +564,7 @@ static int submodule_create_branch(struct repository *r, child.err =-1 ; child.stdout_to_stderr =1 ; -prepare_other_repo_env (&child.env_array, r->gitdir); +prepare_other_repo_env (&child.env, r->gitdir);/* * submodule_create_branch() is indirectly invoked by "git * branch", but we cannot invoke "git branch" in the child
builtin/difftool.c +3 -3
@@ -217,7 +217,7 @@ static void changed_files(struct hashmap *result, const char *index_path, update_index.use_shell =0 ; update_index.clean_on_exit =1 ; update_index.dir = workdir; -strvec_pushf (&update_index.env_array,"GIT_INDEX_FILE=%s" , index_path); +strvec_pushf (&update_index.env,"GIT_INDEX_FILE=%s" , index_path);/* Ignore any errors of update-index */ run_command (&update_index);
@@ -230,7 +230,7 @@ static void changed_files(struct hashmap *result, const char *index_path, diff_files.clean_on_exit =1 ; diff_files.out =-1 ; diff_files.dir = workdir; -strvec_pushf (&diff_files.env_array,"GIT_INDEX_FILE=%s" , index_path); +strvec_pushf (&diff_files.env,"GIT_INDEX_FILE=%s" , index_path);if (start_command (&diff_files))die ("could not obtain raw diff" ); fp =xfdopen (diff_files.out,"r" );
@@ -675,7 +675,7 @@ static int run_file_diff(int prompt, const char *prefix, child->git_cmd =1 ; child->dir = prefix; -strvec_pushv (&child->env_array, env); +strvec_pushv (&child->env, env);return run_command (child); }
builtin/receive-pack.c +16 -16
@@ -764,23 +764,23 @@ static void prepare_push_cert_sha1(struct child_process *proc) nonce_status =check_nonce (push_cert.buf, bogs); }if (!is_null_oid (&push_cert_oid)) { -strvec_pushf (&proc->env_array,"GIT_PUSH_CERT=%s" , +strvec_pushf (&proc->env,"GIT_PUSH_CERT=%s" ,oid_to_hex (&push_cert_oid)); -strvec_pushf (&proc->env_array,"GIT_PUSH_CERT_SIGNER=%s" , +strvec_pushf (&proc->env,"GIT_PUSH_CERT_SIGNER=%s" , sigcheck.signer ? sigcheck.signer :"" ); -strvec_pushf (&proc->env_array,"GIT_PUSH_CERT_KEY=%s" , +strvec_pushf (&proc->env,"GIT_PUSH_CERT_KEY=%s" , sigcheck.key ? sigcheck.key :"" ); -strvec_pushf (&proc->env_array,"GIT_PUSH_CERT_STATUS=%c" , +strvec_pushf (&proc->env,"GIT_PUSH_CERT_STATUS=%c" , sigcheck.result);if (push_cert_nonce) { -strvec_pushf (&proc->env_array, +strvec_pushf (&proc->env,"GIT_PUSH_CERT_NONCE=%s" , push_cert_nonce); -strvec_pushf (&proc->env_array, +strvec_pushf (&proc->env,"GIT_PUSH_CERT_NONCE_STATUS=%s" , nonce_status);if (nonce_status ==NONCE_SLOP ) -strvec_pushf (&proc->env_array, +strvec_pushf (&proc->env,"GIT_PUSH_CERT_NONCE_SLOP=%ld" , nonce_stamp_slop); }
@@ -815,17 +815,17 @@ static int run_and_feed_hook(const char *hook_name, feed_fn feed,if (feed_state->push_options) {size_t i;for (i =0 ; i < feed_state->push_options->nr; i++) -strvec_pushf (&proc.env_array, +strvec_pushf (&proc.env,"GIT_PUSH_OPTION_%" PRIuMAX"=%s" , (uintmax_t )i, feed_state->push_options->items[i].string); -strvec_pushf (&proc.env_array,"GIT_PUSH_OPTION_COUNT=%" PRIuMAX"" , +strvec_pushf (&proc.env,"GIT_PUSH_OPTION_COUNT=%" PRIuMAX"" , (uintmax_t )feed_state->push_options->nr); }else -strvec_pushf (&proc.env_array,"GIT_PUSH_OPTION_COUNT" ); +strvec_pushf (&proc.env,"GIT_PUSH_OPTION_COUNT" );if (tmp_objdir) -strvec_pushv (&proc.env_array,tmp_objdir_env (tmp_objdir)); +strvec_pushv (&proc.env,tmp_objdir_env (tmp_objdir));if (use_sideband) {memset (&muxer,0 ,sizeof (muxer));
@@ -1357,7 +1357,7 @@ static const char *push_to_deploy(unsigned char *sha1,strvec_pushl (&child.args,"update-index" ,"-q" ,"--ignore-submodules" ,"--refresh" ,NULL ); -strvec_pushv (&child.env_array, env->v); +strvec_pushv (&child.env, env->v); child.dir = work_tree; child.no_stdin =1 ; child.stdout_to_stderr =1 ;
@@ -1369,7 +1369,7 @@ static const char *push_to_deploy(unsigned char *sha1,child_process_init (&child);strvec_pushl (&child.args,"diff-files" ,"--quiet" ,"--ignore-submodules" ,"--" ,NULL ); -strvec_pushv (&child.env_array, env->v); +strvec_pushv (&child.env, env->v); child.dir = work_tree; child.no_stdin =1 ; child.stdout_to_stderr =1 ;
@@ -1383,7 +1383,7 @@ static const char *push_to_deploy(unsigned char *sha1,/* diff-index with either HEAD or an empty tree */ head_has_history () ?"HEAD" :empty_tree_oid_hex (), "--", NULL); -strvec_pushv (&child.env_array, env->v); +strvec_pushv (&child.env, env->v); child.no_stdin =1 ; child.no_stdout =1 ; child.stdout_to_stderr =0 ;
@@ -1394,7 +1394,7 @@ static const char *push_to_deploy(unsigned char *sha1,child_process_init (&child);strvec_pushl (&child.args,"read-tree" ,"-u" ,"-m" ,hash_to_hex (sha1),NULL ); -strvec_pushv (&child.env_array, env->v); +strvec_pushv (&child.env, env->v); child.dir = work_tree; child.no_stdin =1 ; child.no_stdout =1 ;
@@ -2215,7 +2215,7 @@ static const char *unpack(int err_fd, struct shallow_info *si)return "unable to create temporary object directory" ; }if (tmp_objdir) -strvec_pushv (&child.env_array,tmp_objdir_env (tmp_objdir)); +strvec_pushv (&child.env,tmp_objdir_env (tmp_objdir));/* * Normally we just pass the tmp_objdir environment to the child
builtin/stash.c +8 -8
@@ -356,7 +356,7 @@ static int restore_untracked(struct object_id *u_tree) cp.git_cmd =1 ;strvec_push (&cp.args,"read-tree" );strvec_push (&cp.args,oid_to_hex (u_tree)); -strvec_pushf (&cp.env_array,"GIT_INDEX_FILE=%s" , +strvec_pushf (&cp.env,"GIT_INDEX_FILE=%s" , stash_index_path.buf);if (run_command (&cp)) {remove_path (stash_index_path.buf);
@@ -366,7 +366,7 @@ static int restore_untracked(struct object_id *u_tree)child_process_init (&cp); cp.git_cmd =1 ;strvec_pushl (&cp.args,"checkout-index" ,"--all" ,NULL ); -strvec_pushf (&cp.env_array,"GIT_INDEX_FILE=%s" , +strvec_pushf (&cp.env,"GIT_INDEX_FILE=%s" , stash_index_path.buf); res =run_command (&cp);
@@ -585,9 +585,9 @@ static int do_apply_stash(const char *prefix, struct stash_info *info,*/ cp.git_cmd =1 ; cp.dir = prefix; -strvec_pushf (&cp.env_array,GIT_WORK_TREE_ENVIRONMENT "=%s" , +strvec_pushf (&cp.env,GIT_WORK_TREE_ENVIRONMENT "=%s" ,absolute_path (get_git_work_tree ())); -strvec_pushf (&cp.env_array,GIT_DIR_ENVIRONMENT "=%s" , +strvec_pushf (&cp.env,GIT_DIR_ENVIRONMENT "=%s" ,absolute_path (get_git_dir ()));strvec_push (&cp.args,"status" );run_command (&cp);
@@ -1088,7 +1088,7 @@ static int save_untracked_files(struct stash_info *info, struct strbuf *msg, cp_upd_index.git_cmd =1 ;strvec_pushl (&cp_upd_index.args,"update-index" ,"-z" ,"--add" ,"--remove" ,"--stdin" ,NULL ); -strvec_pushf (&cp_upd_index.env_array,"GIT_INDEX_FILE=%s" , +strvec_pushf (&cp_upd_index.env,"GIT_INDEX_FILE=%s" , stash_index_path.buf);strbuf_addf (&untracked_msg,"untracked files on %s\n" , msg->buf);
@@ -1162,7 +1162,7 @@ static int stash_patch(struct stash_info *info, const struct pathspec *ps, cp_read_tree.git_cmd =1 ;strvec_pushl (&cp_read_tree.args,"read-tree" ,"HEAD" ,NULL ); -strvec_pushf (&cp_read_tree.env_array,"GIT_INDEX_FILE=%s" , +strvec_pushf (&cp_read_tree.env,"GIT_INDEX_FILE=%s" , stash_index_path.buf);if (run_command (&cp_read_tree)) { ret =-1 ;
@@ -1249,7 +1249,7 @@ static int stash_working_tree(struct stash_info *info, const struct pathspec *psstrvec_pushl (&cp_upd_index.args,"update-index" ,"--ignore-skip-worktree-entries" ,"-z" ,"--add" ,"--remove" ,"--stdin" ,NULL ); -strvec_pushf (&cp_upd_index.env_array,"GIT_INDEX_FILE=%s" , +strvec_pushf (&cp_upd_index.env,"GIT_INDEX_FILE=%s" , stash_index_path.buf); if (pipe_command(&cp_upd_index, diff_output.buf, diff_output.len,
@@ -1525,7 +1525,7 @@ static int do_push_stash(const struct pathspec *ps, const char *stash_msg, int q cp.git_cmd =1 ;if (startup_info->original_cwd) { cp.dir = startup_info->original_cwd; -strvec_pushf (&cp.env_array,"%s=%s" , +strvec_pushf (&cp.env,"%s=%s" ,GIT_WORK_TREE_ENVIRONMENT , the_repository->worktree); }
builtin/submodule--helper.c +21 -21
140 lines not on this page · raw message
builtin/worktree.c +4 -4
@@ -301,7 +301,7 @@ static int checkout_worktree(const struct add_opts *opts,strvec_pushl (&cp.args,"reset" ,"--hard" ,"--no-recurse-submodules" ,NULL );if (opts->quiet)strvec_push (&cp.args,"--quiet" ); -strvec_pushv (&cp.env_array, child_env->v); +strvec_pushv (&cp.env, child_env->v);return run_command (&cp); }
@@ -433,7 +433,7 @@ static int add_worktree(const char *path, const char *refname,strvec_push (&cp.args,"--quiet" ); } -strvec_pushv (&cp.env_array, child_env.v); +strvec_pushv (&cp.env, child_env.v); ret =run_command (&cp);if (ret) goto done;
@@ -989,9 +989,9 @@ static void check_clean_worktree(struct worktree *wt,validate_no_submodules (wt);child_process_init (&cp); -strvec_pushf (&cp.env_array,"%s=%s/.git" , +strvec_pushf (&cp.env,"%s=%s/.git" ,GIT_DIR_ENVIRONMENT , wt->path); -strvec_pushf (&cp.env_array,"%s=%s" , +strvec_pushf (&cp.env,"%s=%s" ,GIT_WORK_TREE_ENVIRONMENT , wt->path); strvec_pushl(&cp.args, "status", "--porcelain", "--ignore-submodules=none",
connect.c +5 -4
@@ -1327,7 +1327,7 @@ static void fill_ssh_args(struct child_process *conn, const char *ssh_host,strvec_push (&detect.args, ssh);strvec_push (&detect.args,"-G" ); -push_ssh_options (&detect.args, &detect.env_array, +push_ssh_options (&detect.args, &detect.env,VARIANT_SSH , port, version, flags);strvec_push (&detect.args, ssh_host);
@@ -1335,7 +1335,8 @@ static void fill_ssh_args(struct child_process *conn, const char *ssh_host, }strvec_push (&conn->args, ssh); -push_ssh_options (&conn->args, &conn->env_array, variant, port, version, flags); +push_ssh_options (&conn->args, &conn->env, variant, port, version, + flags);strvec_push (&conn->args, ssh_host); }
@@ -1397,7 +1398,7 @@ struct child_process *git_connect(int fd[2], const char *url,/* remove repo-local variables from the environment */ for (var = local_repo_env; *var; var++) -strvec_push (&conn->env_array, *var); +strvec_push (&conn->env, *var); conn->use_shell =1 ; conn->in = conn->out =-1 ;
@@ -1429,7 +1430,7 @@ struct child_process *git_connect(int fd[2], const char *url,transport_check_allowed ("file" ); conn->trace2_child_class ="transport/file" ;if (version >0 ) { -strvec_pushf (&conn->env_array, +strvec_pushf (&conn->env,GIT_PROTOCOL_ENVIRONMENT "=version=%d" , version); }
connected.c +1 -1
@@ -110,7 +110,7 @@ int check_connected(oid_iterate_fn fn, void *cb_data, rev_list.git_cmd =1 ;if (opt->env) -strvec_pushv (&rev_list.env_array, opt->env); +strvec_pushv (&rev_list.env, opt->env); rev_list.in =-1 ; rev_list.no_stdout =1 ;if (opt->err_fd)
contrib/coccinelle/run_command.cocci renamed from contrib/coccinelle/run_command.pending.cocci +0 -0
daemon.c +7 -7
@@ -484,7 +484,7 @@ static int upload_pack(const struct strvec *env)strvec_pushl (&cld.args,"upload-pack" ,"--strict" ,NULL );strvec_pushf (&cld.args,"--timeout=%u" , timeout); -strvec_pushv (&cld.env_array, env->v); +strvec_pushv (&cld.env, env->v);return run_service_command (&cld); }
@@ -494,7 +494,7 @@ static int upload_archive(const struct strvec *env)struct child_process cld =CHILD_PROCESS_INIT ;strvec_push (&cld.args,"upload-archive" ); -strvec_pushv (&cld.env_array, env->v); +strvec_pushv (&cld.env, env->v);return run_service_command (&cld); }
@@ -504,7 +504,7 @@ static int receive_pack(const struct strvec *env)struct child_process cld =CHILD_PROCESS_INIT ;strvec_push (&cld.args,"receive-pack" ); -strvec_pushv (&cld.env_array, env->v); +strvec_pushv (&cld.env, env->v);return run_service_command (&cld); }
@@ -904,16 +904,16 @@ static void handle(int incoming, struct sockaddr *addr, socklen_t addrlen)char buf[128 ] ="" ;struct sockaddr_in *sin_addr = (void *) addr;inet_ntop (addr->sa_family, &sin_addr->sin_addr, buf,sizeof (buf)); -strvec_pushf (&cld.env_array,"REMOTE_ADDR=%s" , buf); -strvec_pushf (&cld.env_array,"REMOTE_PORT=%d" , +strvec_pushf (&cld.env,"REMOTE_ADDR=%s" , buf); +strvec_pushf (&cld.env,"REMOTE_PORT=%d" ,ntohs (sin_addr->sin_port)); #ifndef NO_IPV6 }else if (addr->sa_family ==AF_INET6 ) {char buf[128 ] ="" ;struct sockaddr_in6 *sin6_addr = (void *) addr;inet_ntop (AF_INET6 , &sin6_addr->sin6_addr, buf,sizeof (buf)); -strvec_pushf (&cld.env_array,"REMOTE_ADDR=[%s]" , buf); -strvec_pushf (&cld.env_array,"REMOTE_PORT=%d" , +strvec_pushf (&cld.env,"REMOTE_ADDR=[%s]" , buf); +strvec_pushf (&cld.env,"REMOTE_PORT=%d" ,ntohs (sin6_addr->sin6_port));#endif }
editor.c +1 -1
@@ -80,7 +80,7 @@ static int launch_specified_editor(const char *editor, const char *path,strvec_pushl (&p.args, editor, realpath.buf,NULL );if (env) -strvec_pushv (&p.env_array, (const char **)env); +strvec_pushv (&p.env, (const char **)env); p.use_shell =1 ; p.trace2_child_class ="editor" ;if (start_command (&p) <0 ) {
hook.c +1 -1
@@ -54,7 +54,7 @@ static int pick_next_hook(struct child_process *cp,return 0 ; cp->no_stdin =1 ; -strvec_pushv (&cp->env_array, hook_cb->options->env.v); +strvec_pushv (&cp->env, hook_cb->options->env.v); cp->stdout_to_stderr =1 ; cp->trace2_hook_name = hook_cb->hook_name; cp->dir = hook_cb->options->dir;
http-backend.c +2 -2
@@ -476,9 +476,9 @@ static void run_service(const char **argv, int buffer_input) host ="(none)" ;if (!getenv ("GIT_COMMITTER_NAME" )) -strvec_pushf (&cld.env_array,"GIT_COMMITTER_NAME=%s" , user); +strvec_pushf (&cld.env,"GIT_COMMITTER_NAME=%s" , user);if (!getenv ("GIT_COMMITTER_EMAIL" )) -strvec_pushf (&cld.env_array, +strvec_pushf (&cld.env,"GIT_COMMITTER_EMAIL=%s@http.%s" , user, host);strvec_pushv (&cld.args, argv);
object-file.c +1 -1
@@ -838,7 +838,7 @@ static void fill_alternate_refs_command(struct child_process *cmd, } } -strvec_pushv (&cmd->env_array, (const char **)local_repo_env); +strvec_pushv (&cmd->env, (const char **)local_repo_env); cmd->out =-1 ; }
pager.c +2 -2
@@ -99,7 +99,7 @@ void prepare_pager_args(struct child_process *pager_process, const char *pager) {strvec_push (&pager_process->args, pager); pager_process->use_shell =1 ; -setup_pager_env (&pager_process->env_array); +setup_pager_env (&pager_process->env); pager_process->trace2_child_class ="pager" ; }
@@ -129,7 +129,7 @@ void setup_pager(void)/* spawn the pager */ prepare_pager_args (&pager_process, pager); pager_process.in =-1 ; -strvec_push (&pager_process.env_array,"GIT_PAGER_IN_USE" ); +strvec_push (&pager_process.env,"GIT_PAGER_IN_USE" );if (start_command (&pager_process))return ;
promisor-remote.c +1 -1
@@ -22,7 +22,7 @@ static int fetch_objects(struct repository *repo, child.git_cmd =1 ; child.in =-1 ;if (repo != the_repository) -prepare_other_repo_env (&child.env_array, repo->gitdir); +prepare_other_repo_env (&child.env, repo->gitdir); strvec_pushl(&child.args, "-c", "fetch.negotiationAlgorithm=noop", "fetch", remote_name, "--no-tags", "--no-write-fetch-head", "--recurse-submodules=no",
run-command.c +7 -6
@@ -20,7 +20,7 @@ void child_process_init(struct child_process *child)void child_process_clear (struct child_process *child) {strvec_clear (&child->args); -strvec_clear (&child->env_array); +strvec_clear (&child->env); }struct child_to_clean {
@@ -646,7 +646,7 @@ static void trace_run_command(const struct child_process *cp)sq_quote_buf_pretty (&buf, cp->dir);strbuf_addch (&buf,';' ); } -trace_add_env (&buf, cp->env_array.v); +trace_add_env (&buf, cp->env.v);if (cp->git_cmd)strbuf_addstr (&buf," git" );sq_quote_argv_pretty (&buf, cp->args.v);
@@ -751,7 +751,7 @@ int start_command(struct child_process *cmd)set_cloexec (null_fd); } - childenv =prep_childenv (cmd->env_array.v); + childenv =prep_childenv (cmd->env.v);atfork_prepare (&as);/*
@@ -914,8 +914,9 @@ int start_command(struct child_process *cmd)else if (cmd->use_shell) cmd->args.v =prepare_shell_cmd (&nargv, sargv); - cmd->pid =mingw_spawnvpe (cmd->args.v[0 ], cmd->args.v, (char **) cmd->env_array.v, - cmd->dir, fhin, fhout, fherr); + cmd->pid =mingw_spawnvpe (cmd->args.v[0 ], cmd->args.v, + (char **) cmd->env.v, + cmd->dir, fhin, fhout, fherr); failed_errno = errno;if (cmd->pid <0 && (!cmd->silent_exec_failure || errno !=ENOENT ))error_errno ("cannot spawn %s" , cmd->args.v[0 ]);
@@ -1031,7 +1032,7 @@ int run_command_v_opt_cd_env_tr2(const char **argv, int opt, const char *dir, cmd.close_object_store = opt &RUN_CLOSE_OBJECT_STORE ?1 :0 ; cmd.dir = dir;if (env) -strvec_pushv (&cmd.env_array, (const char **)env); +strvec_pushv (&cmd.env, (const char **)env); cmd.trace2_child_class = tr2_class;return run_command (&cmd); }
run-command.h +2 -2
@@ -73,7 +73,7 @@ struct child_process {* The memory in .env_array will be cleaned up automatically during * `finish_command` (or during `start_command` when it is unsuccessful). */ -struct strvec env_array; +struct strvec env;pid_t pid;int trace2_child_id;
@@ -147,7 +147,7 @@ struct child_process {#define CHILD_PROCESS_INIT { \ .args = STRVEC_INIT, \ - .env_array = STRVEC_INIT, \ + .env = STRVEC_INIT, \ }/**
sequencer.c +8 -8
@@ -1000,7 +1000,7 @@ static int run_git_commit(const char *defmsg,if (is_rebase_i (opts) && ((opts->committer_date_is_author_date && !opts->ignore_date) || !(!defmsg && (flags &AMEND_MSG ))) && -read_env_script (&cmd.env_array)) { +read_env_script (&cmd.env)) {const char *gpg_opt =gpg_sign_opt_quoted (opts); return error(_(staged_changes_advice),
@@ -1008,12 +1008,12 @@ static int run_git_commit(const char *defmsg, }if (opts->committer_date_is_author_date) -strvec_pushf (&cmd.env_array,"GIT_COMMITTER_DATE=%s" , +strvec_pushf (&cmd.env,"GIT_COMMITTER_DATE=%s" , opts->ignore_date ?"" : -author_date_from_env_array (&cmd.env_array)); +author_date_from_env_array (&cmd.env));if (opts->ignore_date) -strvec_push (&cmd.env_array,"GIT_AUTHOR_DATE=" ); +strvec_push (&cmd.env,"GIT_AUTHOR_DATE=" );strvec_push (&cmd.args,"commit" );
@@ -3912,7 +3912,7 @@ static int do_merge(struct repository *r,/* Octopus merge */ struct child_process cmd =CHILD_PROCESS_INIT ; -if (read_env_script (&cmd.env_array)) { +if (read_env_script (&cmd.env)) {const char *gpg_opt =gpg_sign_opt_quoted (opts); ret =error (_ (staged_changes_advice), gpg_opt, gpg_opt);
@@ -3920,12 +3920,12 @@ static int do_merge(struct repository *r, }if (opts->committer_date_is_author_date) -strvec_pushf (&cmd.env_array,"GIT_COMMITTER_DATE=%s" , +strvec_pushf (&cmd.env,"GIT_COMMITTER_DATE=%s" , opts->ignore_date ?"" : -author_date_from_env_array (&cmd.env_array)); +author_date_from_env_array (&cmd.env));if (opts->ignore_date) -strvec_push (&cmd.env_array,"GIT_AUTHOR_DATE=" ); +strvec_push (&cmd.env,"GIT_AUTHOR_DATE=" ); cmd.git_cmd =1 ;strvec_push (&cmd.args,"merge" );
submodule.c +19 -19
@@ -711,15 +711,15 @@ void show_submodule_inline_diff(struct diff_options *o, const char *path,if (!(dirty_submodule &DIRTY_SUBMODULE_MODIFIED ))strvec_push (&cp.args,oid_to_hex (new_oid)); -prepare_submodule_repo_env (&cp.env_array); +prepare_submodule_repo_env (&cp.env);if (!is_directory (path)) {/* fall back to absorbed git dir, if any */ if (!sub) goto done; cp.dir = sub->gitdir; -strvec_push (&cp.env_array,GIT_DIR_ENVIRONMENT "=." ); -strvec_push (&cp.env_array,GIT_WORK_TREE_ENVIRONMENT "=." ); +strvec_push (&cp.env,GIT_DIR_ENVIRONMENT "=." ); +strvec_push (&cp.env,GIT_WORK_TREE_ENVIRONMENT "=." ); }if (start_command (&cp)) {
@@ -1019,7 +1019,7 @@ static int submodule_has_commits(struct repository *r,oid_array_for_each_unique (commits, append_oid_to_argv, &cp.args);strvec_pushl (&cp.args,"--not" ,"--all" ,NULL ); -prepare_submodule_repo_env (&cp.env_array); +prepare_submodule_repo_env (&cp.env); cp.git_cmd =1 ; cp.no_stdin =1 ; cp.dir = path;
@@ -1060,7 +1060,7 @@ static int submodule_needs_pushing(struct repository *r,oid_array_for_each_unique (commits, append_oid_to_argv, &cp.args);strvec_pushl (&cp.args,"--not" ,"--remotes" ,"-n" ,"1" ,NULL ); -prepare_submodule_repo_env (&cp.env_array); +prepare_submodule_repo_env (&cp.env); cp.git_cmd =1 ; cp.no_stdin =1 ; cp.out =-1 ;
@@ -1146,7 +1146,7 @@ static int push_submodule(const char *path,strvec_push (&cp.args, rs->raw[i]); } -prepare_submodule_repo_env (&cp.env_array); +prepare_submodule_repo_env (&cp.env); cp.git_cmd =1 ; cp.no_stdin =1 ; cp.dir = path;
@@ -1177,7 +1177,7 @@ static void submodule_push_check(const char *path, const char *head,for (i =0 ; i < rs->raw_nr; i++)strvec_push (&cp.args, rs->raw[i]); -prepare_submodule_repo_env (&cp.env_array); +prepare_submodule_repo_env (&cp.env); cp.git_cmd =1 ; cp.no_stdin =1 ; cp.no_stdout =1 ;
@@ -1678,7 +1678,7 @@ static int get_next_submodule(struct child_process *cp, struct strbuf *err,child_process_init (cp); cp->dir = task->repo->gitdir; -prepare_submodule_repo_env_in_gitdir (&cp->env_array); +prepare_submodule_repo_env_in_gitdir (&cp->env); cp->git_cmd =1 ;strvec_init (&cp->args);if (task->git_args.nr)
@@ -1708,7 +1708,7 @@ static int get_next_submodule(struct child_process *cp, struct strbuf *err, spf->prefix, task->sub->path);child_process_init (cp); -prepare_submodule_repo_env_in_gitdir (&cp->env_array); +prepare_submodule_repo_env_in_gitdir (&cp->env); cp->git_cmd =1 ; cp->dir = task->repo->gitdir;
@@ -1882,7 +1882,7 @@ unsigned is_submodule_modified(const char *path, int ignore_untracked)if (ignore_untracked)strvec_push (&cp.args,"-uno" ); -prepare_submodule_repo_env (&cp.env_array); +prepare_submodule_repo_env (&cp.env); cp.git_cmd =1 ; cp.no_stdin =1 ; cp.out =-1 ;
@@ -1954,7 +1954,7 @@ int submodule_uses_gitfile(const char *path)"submodule" ,"foreach" ,"--quiet" ,"--recursive" , "test -f .git", NULL); -prepare_submodule_repo_env (&cp.env_array); +prepare_submodule_repo_env (&cp.env); cp.git_cmd =1 ; cp.no_stdin =1 ; cp.no_stderr =1 ;
@@ -1997,7 +1997,7 @@ int bad_to_remove_submodule(const char *path, unsigned flags)if (!(flags &SUBMODULE_REMOVAL_IGNORE_IGNORED_UNTRACKED ))strvec_push (&cp.args,"--ignored" ); -prepare_submodule_repo_env (&cp.env_array); +prepare_submodule_repo_env (&cp.env); cp.git_cmd =1 ; cp.no_stdin =1 ; cp.out =-1 ;
@@ -2052,7 +2052,7 @@ static int submodule_has_dirty_index(const struct submodule *sub) {struct child_process cp =CHILD_PROCESS_INIT ; -prepare_submodule_repo_env (&cp.env_array); +prepare_submodule_repo_env (&cp.env); cp.git_cmd =1 ; strvec_pushl(&cp.args, "diff-index", "--quiet",
@@ -2069,7 +2069,7 @@ static int submodule_has_dirty_index(const struct submodule *sub)static void submodule_reset_index (const char *path) {struct child_process cp =CHILD_PROCESS_INIT ; -prepare_submodule_repo_env (&cp.env_array); +prepare_submodule_repo_env (&cp.env); cp.git_cmd =1 ; cp.no_stdin =1 ;
@@ -2153,7 +2153,7 @@ int submodule_move_head(const char *path, } } -prepare_submodule_repo_env (&cp.env_array); +prepare_submodule_repo_env (&cp.env); cp.git_cmd =1 ; cp.no_stdin =1 ;
@@ -2191,7 +2191,7 @@ int submodule_move_head(const char *path, cp.no_stdin =1 ; cp.dir = path; -prepare_submodule_repo_env (&cp.env_array); +prepare_submodule_repo_env (&cp.env);strvec_pushl (&cp.args,"update-ref" ,"HEAD" ,"--no-deref" , new_head,NULL );
@@ -2374,7 +2374,7 @@ void absorb_git_dir_into_superproject(const char *path,strvec_pushl (&cp.args,"--super-prefix" , sb.buf,"submodule--helper" ,"absorb-git-dirs" ,NULL ); -prepare_submodule_repo_env (&cp.env_array); +prepare_submodule_repo_env (&cp.env);if (run_command (&cp))die (_ ("could not recurse into submodule '%s'" ), path);
@@ -2407,8 +2407,8 @@ int get_superproject_working_tree(struct strbuf *buf) subpath =relative_path (cwd, one_up.buf, &sb);strbuf_release (&one_up); -prepare_submodule_repo_env (&cp.env_array); -strvec_pop (&cp.env_array); +prepare_submodule_repo_env (&cp.env); +strvec_pop (&cp.env); strvec_pushl(&cp.args, "--literal-pathspecs", "-C", "..", "ls-files", "-z", "--stage", "--full-name", "--",
t/helper/test-run-command.c +1 -1
@@ -390,7 +390,7 @@ int cmd__run_command(int argc, const char **argv)while (!strcmp (argv[1 ],"env" )) {if (!argv[2 ])die ("env specifier without a value" ); -strvec_push (&proc.env_array, argv[2 ]); +strvec_push (&proc.env, argv[2 ]); argv +=2 ; argc -=2 ; }
trailer.c +1 -1
@@ -236,7 +236,7 @@ static char *apply_command(struct conf_info *conf, const char *arg)strbuf_replace (&cmd,TRAILER_ARG_STRING , arg);strvec_push (&cp.args, cmd.buf); } -strvec_pushv (&cp.env_array, (const char **)local_repo_env); +strvec_pushv (&cp.env, (const char **)local_repo_env); cp.no_stdin =1 ; cp.use_shell =1 ;
transport-helper.c +1 -1
@@ -135,7 +135,7 @@ static struct child_process *get_helper(struct transport *transport) helper->silent_exec_failure =1 ;if (have_git_dir ()) -strvec_pushf (&helper->env_array,"%s=%s" , +strvec_pushf (&helper->env,"%s=%s" ,GIT_DIR_ENVIRONMENT ,get_git_dir ()); helper->trace2_child_class = helper->args.v[0 ];/* "remote-<name>" */
wt-status.c +1 -1
@@ -982,7 +982,7 @@ static void wt_longstatus_print_submodule_summary(struct wt_status *s, int uncomstruct strbuf summary =STRBUF_INIT ;char *summary_content; -strvec_pushf (&sm_summary.env_array,"GIT_INDEX_FILE=%s" , s->index_file); +strvec_pushf (&sm_summary.env,"GIT_INDEX_FILE=%s" , s->index_file);strvec_push (&sm_summary.args,"submodule" );strvec_push (&sm_summary.args,"summary" );
Signature · 1 line
2.36.0.rc0.849.g2d5b5d9ab01
PATCH 3/3 run-command API users: use "env" not "env_array" in comments & names
In reply to Ævar Arnfjörð BjarmasonFollow-up on the preceding commit which changed all references to the "env_array" when referring to the "struct child_process" member. These changes are all unnecessary for the compiler, but help the code's human readers.
All the comments that referred to "env_array" have now been updated, as well as function names and variables that had "env_array" in their name, they now refer to "env".
In addition the "out" name for the submodule.h prototype was inconsistent with the function definition's use of "env_array" in submodule.c. Both of them use "env" now.
--- builtin/submodule--helper.c | 2 +- run-command.c | 6 +++--- run-command.h | 10 +++++----- sequencer.c | 6 +++--- submodule.h | 4 ++-- 5 files changed, 14 insertions(+), 14 deletions(-)
builtin/submodule--helper.c +1 -1
@@ -513,7 +513,7 @@ static void runcommand_in_submodule_cb(const struct cache_entry *list_item,* on windows. And since environment variables are * case-insensitive in windows, it interferes with the * existing PATH variable. Hence, to avoid that, we expose -* path via the args strvec and not via env_array. +* path via the args strvec and not via env. */ sq_quote_buf (&sb, path); strvec_pushf(&cp.args, "path=%s; %s",
run-command.c +3 -3
@@ -1816,16 +1816,16 @@ int run_auto_maintenance(int quiet)return run_command (&maint); } -void prepare_other_repo_env (struct strvec *env_array,const char *new_git_dir) +void prepare_other_repo_env (struct strvec *env,const char *new_git_dir) {const char *const *var;for (var = local_repo_env; *var; var++) {if (strcmp (*var,CONFIG_DATA_ENVIRONMENT ) &&strcmp (*var,CONFIG_COUNT_ENVIRONMENT )) -strvec_push (env_array, *var); +strvec_push (env, *var); } -strvec_pushf (env_array,"%s=%s" ,GIT_DIR_ENVIRONMENT , new_git_dir); +strvec_pushf (env,"%s=%s" ,GIT_DIR_ENVIRONMENT , new_git_dir); } enum start_bg_result start_bg_command(struct child_process *cmd,
run-command.h +5 -5
@@ -58,7 +58,7 @@ struct child_process {struct strvec args;/** -* Like .args the .env_array is a `struct strvec'. +* Like .args the .env is a `struct strvec'. * * To modify the environment of the sub-process, specify an array of * environment settings. Each string in the array manipulates the
@@ -70,7 +70,7 @@ struct child_process {* - If the string does not contain '=', it names an environment * variable that will be removed from the child process's environment. * -* The memory in .env_array will be cleaned up automatically during +* The memory in .env will be cleaned up automatically during * `finish_command` (or during `start_command` when it is unsuccessful). */ struct strvec env;
@@ -480,14 +480,14 @@ int run_processes_parallel_tr2(int n, get_next_task_fn, start_failure_fn, const char *tr2_category, const char *tr2_label);/** -* Convenience function which prepares env_array for a command to be run in a -* new repo. This adds all GIT_* environment variables to env_array with the +* Convenience function which prepares env for a command to be run in a +* new repo. This adds all GIT_* environment variables to env with the * exception of GIT_CONFIG_PARAMETERS and GIT_CONFIG_COUNT (which cause the * corresponding environment variables to be unset in the subprocess) and adds * an environment variable pointing to new_git_dir. See local_repo_env in * cache.h for more information. */ -void prepare_other_repo_env (struct strvec *env_array,const char *new_git_dir); +void prepare_other_repo_env (struct strvec *env,const char *new_git_dir);/** * Possible return values for start_bg_command().
sequencer.c +3 -3
@@ -919,7 +919,7 @@ static char *get_author(const char *message)return NULL ; } -static const char *author_date_from_env_array (const struct strvec *env) +static const char *author_date_from_env (const struct strvec *env) {int i;const char *date;
@@ -1011,7 +1011,7 @@ static int run_git_commit(const char *defmsg,strvec_pushf (&cmd.env,"GIT_COMMITTER_DATE=%s" , opts->ignore_date ?"" : -author_date_from_env_array (&cmd.env)); +author_date_from_env (&cmd.env));if (opts->ignore_date)strvec_push (&cmd.env,"GIT_AUTHOR_DATE=" );
@@ -3923,7 +3923,7 @@ static int do_merge(struct repository *r,strvec_pushf (&cmd.env,"GIT_COMMITTER_DATE=%s" , opts->ignore_date ?"" : -author_date_from_env_array (&cmd.env)); +author_date_from_env (&cmd.env));if (opts->ignore_date)strvec_push (&cmd.env,"GIT_AUTHOR_DATE=" );
submodule.h +2 -2
@@ -158,11 +158,11 @@ int submodule_move_head(const char *path,void submodule_unset_core_worktree (const struct submodule *sub);/* -* Prepare the "env_array" parameter of a "struct child_process" for executing +* Prepare the "env" parameter of a "struct child_process" for executing * a submodule by clearing any repo-specific environment variables, but * retaining any config in the environment. */ -void prepare_submodule_repo_env (struct strvec *out); +void prepare_submodule_repo_env (struct strvec *env);#define ABSORB_GITDIR_RECURSE_SUBMODULES (1<<0) void absorb_git_dir_into_superproject(const char *path,
Signature · 1 line
2.36.0.rc0.849.g2d5b5d9ab01
Re: [PATCH 0/3] run-command.h: rename "env_array" to "env"
In reply to Ævar Arnfjörð BjarmasonHi Ævar,
Quoted 3 lines · Ævar Arnfjörð Bjarmason
Junio: We're in the RC period, but perhaps this change if we're ever going to make it would be good to make around that time of patch slowdown. I.e. for the first batch after release.
Good thinking about the first batch after release. However, please do send such cleanups really only after the release. The reason for the patch slowdown is that we want to be able to focus on making a rock-solid v2.36.0. This here patch series is very much a distraction at this point.
Thank you,
Johannes
Re: [PATCH 0/3] run-command.h: rename "env_array" to "env"
Quoted 10 lines · Johannes Schindelin
Quoted 3 lines · Ævar Arnfjörð Bjarmason
Junio: We're in the RC period, but perhaps this change if we're ever going to make it would be good to make around that time of patch slowdown. I.e. for the first batch after release.
Good thinking about the first batch after release. However, please do send such cleanups really only after the release. The reason for the patch slowdown is that we want to be able to focus on making a rock-solid v2.36.0. This here patch series is very much a distraction at this point.
OK.
FWIW, I have it near the tip of 'seen', but if any fix that is more urgent than these changes need to be added to 'next' and down to 'master' makes the version queued no longer apply, I will drop it immediately, instead of spending cycles to figure out if it is worth resolving the conflict and requeuing it in 'seen' during the -rc period ;-)
Re: [PATCH 0/3] run-command.h: rename "env_array" to "env"
Quoted 5 lines · Junio C Hamano
Quoted 4 lines
Good thinking about the first batch after release. However, please do send such cleanups really only after the release. The reason for the patch slowdown is that we want to be able to focus on making a rock-solid v2.36.0. This here patch series is very much a distraction at this point.
Quoted 8 lines
OK.
FWIW, I have it near the tip of 'seen', but if any fix that is more urgent than these changes need to be added to 'next' and down to 'master' makes the version queued no longer apply, I will drop it immediately, instead of spending cycles to figure out if it is worth resolving the conflict and requeuing it in 'seen' during the -rc period ;-)
To be fair, I actually do appreciate an early heads-up to warn against other contributors to think twice before adding more uses of the env-array and consider if a different approach without using the env-array would result in better code. It would have been better to stress on such an early warning aspect of the series by marking the series explicitly "not for application during -rc".
The true -rc freeze where nothing goes into 'next' (unless it is a regression fix for this cycle) starts tomorrow at -rc1; I think I've picked up everything relevant that have been posted in the past few days.
Thanks.
v2 cover run-command.h: rename "env_array" to "env"
In reply to Ævar Arnfjörð BjarmasonFollow-up 32ec72c3e1 (Merge branch 'ab/run-command', 2021-12-15) and rename the "env_array" member to simply "env" in the "struct child_process".
Changes since v1:
* Added a commit to remove the coccinelle rule after its application, as suggested by Junio in
https://lore.kernel.org/git/[email protected]/
* Minor commit rewording for 4/4 to adjust for that new 3/4.
Ævar Arnfjörð Bjarmason (4):
cocci: add a rename of "struct child_process"'s "env_array" to "env" run-command API: rename "env_array" to "env"
cocci: remove env_array -> env migration
run-command API users: use "env" not "env_array" in comments & names
add-patch.c | 2 +- branch.c | 2 +- builtin/difftool.c | 6 ++--- builtin/receive-pack.c | 32 +++++++++++++-------------- builtin/stash.c | 16 +++++++------- builtin/submodule--helper.c | 44 ++++++++++++++++++------------------- builtin/worktree.c | 8 +++---- connect.c | 9 ++++---- connected.c | 2 +- daemon.c | 14 ++++++------ editor.c | 2 +- hook.c | 2 +- http-backend.c | 4 ++-- object-file.c | 2 +- pager.c | 4 ++-- promisor-remote.c | 2 +- run-command.c | 19 ++++++++-------- run-command.h | 14 ++++++------ sequencer.c | 18 +++++++-------- submodule.c | 38 ++++++++++++++++---------------- submodule.h | 4 ++-- t/helper/test-run-command.c | 2 +- trailer.c | 2 +- transport-helper.c | 2 +- wt-status.c | 2 +- 25 files changed, 127 insertions(+), 125 deletions(-)
Range-diff against v1:
1: b943ed5d5b7 = 1: e3f33fce566 cocci: add a rename of "struct child_process"'s "env_array" to "env" 2: 51063a31b16 = 2: 5aeb6ec9117 run-command API: rename "env_array" to "env" -: ----------- > 3: ca09da570ef cocci: remove env_array -> env migration 3: 8af76f39b9f ! 4: 5419f839c74 run-command API users: use "env" not "env_array" in comments & names
@@ Metadata
## Commit message ##
run-command API users: use "env" not "env_array" in comments & names
- Follow-up on the preceding commit which changed all references to the
+ Follow-up on a preceding commit which changed all references to the
"env_array" when referring to the "struct child_process" member. These changes are all unnecessary for the compiler, but help the code's human readers.
Signature · 1 line
2.36.1.957.g2c13267e09b
PATCH v2 1/4 cocci: add a rename of "struct child_process"'s "env_array" to "env"
Start following-up on the rename mentioned in c7c4bdeccf3 (run-command
API: remove "env" member, always use "env_array", 2021-11-25) of "env_array" to "env".
The "env_array" name was picked in 19a583dc39e (run-command: add env_array, an optional argv_array for env, 2014-10-19) because "env" was taken. Let's not forever keep the oddity of "*_array" for this "struct strvec", but not for its "args" sibling.
This is added as a "pending" migration because it'll need a couple of manual changes to go along with it, those will be performed in the subsequent commit.
--- contrib/coccinelle/run_command.pending.cocci | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 contrib/coccinelle/run_command.pending.cocci
contrib/coccinelle/run_command.pending.cocci new file +11 -0
@@ -0,0 +1,11 @@ +@@ +struct child_process E; +@@ +- E.env_array ++ E.env + +@@ +struct child_process *E; +@@ +- E->env_array ++ E->env
Signature · 1 line
2.36.1.957.g2c13267e09b
PATCH v2 2/4 run-command API: rename "env_array" to "env"
In reply to Ævar Arnfjörð BjarmasonAs noted in the preceding commit it would be nice to not deal with the oddity of having an "_array" suffix for the "env" strvec, but not for its "args" sibling.
We can do that with coccinelle in a way that's easy to review. The only manual changes in this commit are:
* git mv contrib/coccinelle/run_command{.pending,}.cocci
* The change in run-command.h to rename the struct member itself, and to change its initializer.
The rest of this is all the result of a subsequent:
* make contrib/coccinelle/run_command.cocci.patch
* patch -p1 <contrib/coccinelle/run_command.cocci.patch
* git add -u
I've avoided changing any comments and derived variable names here, that will all be done in the next commit.
---
add-patch.c | 2 +-
branch.c | 2 +-
builtin/difftool.c | 6 +--
builtin/receive-pack.c | 32 +++++++-------
builtin/stash.c | 16 +++----
builtin/submodule--helper.c | 42 +++++++++----------
builtin/worktree.c | 8 ++--
connect.c | 9 ++--
connected.c | 2 +-
...ommand.pending.cocci => run_command.cocci} | 0
daemon.c | 14 +++----
editor.c | 2 +-
hook.c | 2 +-
http-backend.c | 4 +-
object-file.c | 2 +-
pager.c | 4 +-
promisor-remote.c | 2 +-
run-command.c | 13 +++---
run-command.h | 4 +-
sequencer.c | 16 +++----
submodule.c | 38 ++++++++---------
t/helper/test-run-command.c | 2 +-
trailer.c | 2 +-
transport-helper.c | 2 +-
wt-status.c | 2 +-
25 files changed, 115 insertions(+), 113 deletions(-)
rename contrib/coccinelle/{run_command.pending.cocci => run_command.cocci} (100%)add-patch.c +1 -1
@@ -305,7 +305,7 @@ static void setup_child_process(struct add_p_state *s,va_end (ap); cp->git_cmd =1 ; -strvec_pushf (&cp->env_array, +strvec_pushf (&cp->env,INDEX_ENVIRONMENT "=%s" , s->s.r->index_file); }
branch.c +1 -1
@@ -564,7 +564,7 @@ static int submodule_create_branch(struct repository *r, child.err =-1 ; child.stdout_to_stderr =1 ; -prepare_other_repo_env (&child.env_array, r->gitdir); +prepare_other_repo_env (&child.env, r->gitdir);/* * submodule_create_branch() is indirectly invoked by "git * branch", but we cannot invoke "git branch" in the child
builtin/difftool.c +3 -3
@@ -217,7 +217,7 @@ static void changed_files(struct hashmap *result, const char *index_path, update_index.use_shell =0 ; update_index.clean_on_exit =1 ; update_index.dir = workdir; -strvec_pushf (&update_index.env_array,"GIT_INDEX_FILE=%s" , index_path); +strvec_pushf (&update_index.env,"GIT_INDEX_FILE=%s" , index_path);/* Ignore any errors of update-index */ run_command (&update_index);
@@ -230,7 +230,7 @@ static void changed_files(struct hashmap *result, const char *index_path, diff_files.clean_on_exit =1 ; diff_files.out =-1 ; diff_files.dir = workdir; -strvec_pushf (&diff_files.env_array,"GIT_INDEX_FILE=%s" , index_path); +strvec_pushf (&diff_files.env,"GIT_INDEX_FILE=%s" , index_path);if (start_command (&diff_files))die ("could not obtain raw diff" ); fp =xfdopen (diff_files.out,"r" );
@@ -675,7 +675,7 @@ static int run_file_diff(int prompt, const char *prefix, child->git_cmd =1 ; child->dir = prefix; -strvec_pushv (&child->env_array, env); +strvec_pushv (&child->env, env);return run_command (child); }
builtin/receive-pack.c +16 -16
@@ -764,23 +764,23 @@ static void prepare_push_cert_sha1(struct child_process *proc) nonce_status =check_nonce (push_cert.buf, bogs); }if (!is_null_oid (&push_cert_oid)) { -strvec_pushf (&proc->env_array,"GIT_PUSH_CERT=%s" , +strvec_pushf (&proc->env,"GIT_PUSH_CERT=%s" ,oid_to_hex (&push_cert_oid)); -strvec_pushf (&proc->env_array,"GIT_PUSH_CERT_SIGNER=%s" , +strvec_pushf (&proc->env,"GIT_PUSH_CERT_SIGNER=%s" , sigcheck.signer ? sigcheck.signer :"" ); -strvec_pushf (&proc->env_array,"GIT_PUSH_CERT_KEY=%s" , +strvec_pushf (&proc->env,"GIT_PUSH_CERT_KEY=%s" , sigcheck.key ? sigcheck.key :"" ); -strvec_pushf (&proc->env_array,"GIT_PUSH_CERT_STATUS=%c" , +strvec_pushf (&proc->env,"GIT_PUSH_CERT_STATUS=%c" , sigcheck.result);if (push_cert_nonce) { -strvec_pushf (&proc->env_array, +strvec_pushf (&proc->env,"GIT_PUSH_CERT_NONCE=%s" , push_cert_nonce); -strvec_pushf (&proc->env_array, +strvec_pushf (&proc->env,"GIT_PUSH_CERT_NONCE_STATUS=%s" , nonce_status);if (nonce_status ==NONCE_SLOP ) -strvec_pushf (&proc->env_array, +strvec_pushf (&proc->env,"GIT_PUSH_CERT_NONCE_SLOP=%ld" , nonce_stamp_slop); }
@@ -815,17 +815,17 @@ static int run_and_feed_hook(const char *hook_name, feed_fn feed,if (feed_state->push_options) {size_t i;for (i =0 ; i < feed_state->push_options->nr; i++) -strvec_pushf (&proc.env_array, +strvec_pushf (&proc.env,"GIT_PUSH_OPTION_%" PRIuMAX"=%s" , (uintmax_t )i, feed_state->push_options->items[i].string); -strvec_pushf (&proc.env_array,"GIT_PUSH_OPTION_COUNT=%" PRIuMAX"" , +strvec_pushf (&proc.env,"GIT_PUSH_OPTION_COUNT=%" PRIuMAX"" , (uintmax_t )feed_state->push_options->nr); }else -strvec_pushf (&proc.env_array,"GIT_PUSH_OPTION_COUNT" ); +strvec_pushf (&proc.env,"GIT_PUSH_OPTION_COUNT" );if (tmp_objdir) -strvec_pushv (&proc.env_array,tmp_objdir_env (tmp_objdir)); +strvec_pushv (&proc.env,tmp_objdir_env (tmp_objdir));if (use_sideband) {memset (&muxer,0 ,sizeof (muxer));
@@ -1357,7 +1357,7 @@ static const char *push_to_deploy(unsigned char *sha1,strvec_pushl (&child.args,"update-index" ,"-q" ,"--ignore-submodules" ,"--refresh" ,NULL ); -strvec_pushv (&child.env_array, env->v); +strvec_pushv (&child.env, env->v); child.dir = work_tree; child.no_stdin =1 ; child.stdout_to_stderr =1 ;
@@ -1369,7 +1369,7 @@ static const char *push_to_deploy(unsigned char *sha1,child_process_init (&child);strvec_pushl (&child.args,"diff-files" ,"--quiet" ,"--ignore-submodules" ,"--" ,NULL ); -strvec_pushv (&child.env_array, env->v); +strvec_pushv (&child.env, env->v); child.dir = work_tree; child.no_stdin =1 ; child.stdout_to_stderr =1 ;
@@ -1383,7 +1383,7 @@ static const char *push_to_deploy(unsigned char *sha1,/* diff-index with either HEAD or an empty tree */ head_has_history () ?"HEAD" :empty_tree_oid_hex (), "--", NULL); -strvec_pushv (&child.env_array, env->v); +strvec_pushv (&child.env, env->v); child.no_stdin =1 ; child.no_stdout =1 ; child.stdout_to_stderr =0 ;
@@ -1394,7 +1394,7 @@ static const char *push_to_deploy(unsigned char *sha1,child_process_init (&child);strvec_pushl (&child.args,"read-tree" ,"-u" ,"-m" ,hash_to_hex (sha1),NULL ); -strvec_pushv (&child.env_array, env->v); +strvec_pushv (&child.env, env->v); child.dir = work_tree; child.no_stdin =1 ; child.no_stdout =1 ;
@@ -2215,7 +2215,7 @@ static const char *unpack(int err_fd, struct shallow_info *si)return "unable to create temporary object directory" ; }if (tmp_objdir) -strvec_pushv (&child.env_array,tmp_objdir_env (tmp_objdir)); +strvec_pushv (&child.env,tmp_objdir_env (tmp_objdir));/* * Normally we just pass the tmp_objdir environment to the child
builtin/stash.c +8 -8
@@ -356,7 +356,7 @@ static int restore_untracked(struct object_id *u_tree) cp.git_cmd =1 ;strvec_push (&cp.args,"read-tree" );strvec_push (&cp.args,oid_to_hex (u_tree)); -strvec_pushf (&cp.env_array,"GIT_INDEX_FILE=%s" , +strvec_pushf (&cp.env,"GIT_INDEX_FILE=%s" , stash_index_path.buf);if (run_command (&cp)) {remove_path (stash_index_path.buf);
@@ -366,7 +366,7 @@ static int restore_untracked(struct object_id *u_tree)child_process_init (&cp); cp.git_cmd =1 ;strvec_pushl (&cp.args,"checkout-index" ,"--all" ,NULL ); -strvec_pushf (&cp.env_array,"GIT_INDEX_FILE=%s" , +strvec_pushf (&cp.env,"GIT_INDEX_FILE=%s" , stash_index_path.buf); res =run_command (&cp);
@@ -585,9 +585,9 @@ static int do_apply_stash(const char *prefix, struct stash_info *info,*/ cp.git_cmd =1 ; cp.dir = prefix; -strvec_pushf (&cp.env_array,GIT_WORK_TREE_ENVIRONMENT "=%s" , +strvec_pushf (&cp.env,GIT_WORK_TREE_ENVIRONMENT "=%s" ,absolute_path (get_git_work_tree ())); -strvec_pushf (&cp.env_array,GIT_DIR_ENVIRONMENT "=%s" , +strvec_pushf (&cp.env,GIT_DIR_ENVIRONMENT "=%s" ,absolute_path (get_git_dir ()));strvec_push (&cp.args,"status" );run_command (&cp);
@@ -1088,7 +1088,7 @@ static int save_untracked_files(struct stash_info *info, struct strbuf *msg, cp_upd_index.git_cmd =1 ;strvec_pushl (&cp_upd_index.args,"update-index" ,"-z" ,"--add" ,"--remove" ,"--stdin" ,NULL ); -strvec_pushf (&cp_upd_index.env_array,"GIT_INDEX_FILE=%s" , +strvec_pushf (&cp_upd_index.env,"GIT_INDEX_FILE=%s" , stash_index_path.buf);strbuf_addf (&untracked_msg,"untracked files on %s\n" , msg->buf);
@@ -1162,7 +1162,7 @@ static int stash_patch(struct stash_info *info, const struct pathspec *ps, cp_read_tree.git_cmd =1 ;strvec_pushl (&cp_read_tree.args,"read-tree" ,"HEAD" ,NULL ); -strvec_pushf (&cp_read_tree.env_array,"GIT_INDEX_FILE=%s" , +strvec_pushf (&cp_read_tree.env,"GIT_INDEX_FILE=%s" , stash_index_path.buf);if (run_command (&cp_read_tree)) { ret =-1 ;
@@ -1249,7 +1249,7 @@ static int stash_working_tree(struct stash_info *info, const struct pathspec *psstrvec_pushl (&cp_upd_index.args,"update-index" ,"--ignore-skip-worktree-entries" ,"-z" ,"--add" ,"--remove" ,"--stdin" ,NULL ); -strvec_pushf (&cp_upd_index.env_array,"GIT_INDEX_FILE=%s" , +strvec_pushf (&cp_upd_index.env,"GIT_INDEX_FILE=%s" , stash_index_path.buf); if (pipe_command(&cp_upd_index, diff_output.buf, diff_output.len,
@@ -1525,7 +1525,7 @@ static int do_push_stash(const struct pathspec *ps, const char *stash_msg, int q cp.git_cmd =1 ;if (startup_info->original_cwd) { cp.dir = startup_info->original_cwd; -strvec_pushf (&cp.env_array,"%s=%s" , +strvec_pushf (&cp.env,"%s=%s" ,GIT_WORK_TREE_ENVIRONMENT , the_repository->worktree); }
builtin/submodule--helper.c +21 -21
140 lines not on this page · raw message
builtin/worktree.c +4 -4
@@ -301,7 +301,7 @@ static int checkout_worktree(const struct add_opts *opts,strvec_pushl (&cp.args,"reset" ,"--hard" ,"--no-recurse-submodules" ,NULL );if (opts->quiet)strvec_push (&cp.args,"--quiet" ); -strvec_pushv (&cp.env_array, child_env->v); +strvec_pushv (&cp.env, child_env->v);return run_command (&cp); }
@@ -433,7 +433,7 @@ static int add_worktree(const char *path, const char *refname,strvec_push (&cp.args,"--quiet" ); } -strvec_pushv (&cp.env_array, child_env.v); +strvec_pushv (&cp.env, child_env.v); ret =run_command (&cp);if (ret) goto done;
@@ -989,9 +989,9 @@ static void check_clean_worktree(struct worktree *wt,validate_no_submodules (wt);child_process_init (&cp); -strvec_pushf (&cp.env_array,"%s=%s/.git" , +strvec_pushf (&cp.env,"%s=%s/.git" ,GIT_DIR_ENVIRONMENT , wt->path); -strvec_pushf (&cp.env_array,"%s=%s" , +strvec_pushf (&cp.env,"%s=%s" ,GIT_WORK_TREE_ENVIRONMENT , wt->path); strvec_pushl(&cp.args, "status", "--porcelain", "--ignore-submodules=none",
connect.c +5 -4
@@ -1327,7 +1327,7 @@ static void fill_ssh_args(struct child_process *conn, const char *ssh_host,strvec_push (&detect.args, ssh);strvec_push (&detect.args,"-G" ); -push_ssh_options (&detect.args, &detect.env_array, +push_ssh_options (&detect.args, &detect.env,VARIANT_SSH , port, version, flags);strvec_push (&detect.args, ssh_host);
@@ -1335,7 +1335,8 @@ static void fill_ssh_args(struct child_process *conn, const char *ssh_host, }strvec_push (&conn->args, ssh); -push_ssh_options (&conn->args, &conn->env_array, variant, port, version, flags); +push_ssh_options (&conn->args, &conn->env, variant, port, version, + flags);strvec_push (&conn->args, ssh_host); }
@@ -1397,7 +1398,7 @@ struct child_process *git_connect(int fd[2], const char *url,/* remove repo-local variables from the environment */ for (var = local_repo_env; *var; var++) -strvec_push (&conn->env_array, *var); +strvec_push (&conn->env, *var); conn->use_shell =1 ; conn->in = conn->out =-1 ;
@@ -1429,7 +1430,7 @@ struct child_process *git_connect(int fd[2], const char *url,transport_check_allowed ("file" ); conn->trace2_child_class ="transport/file" ;if (version >0 ) { -strvec_pushf (&conn->env_array, +strvec_pushf (&conn->env,GIT_PROTOCOL_ENVIRONMENT "=version=%d" , version); }
connected.c +1 -1
@@ -110,7 +110,7 @@ int check_connected(oid_iterate_fn fn, void *cb_data, rev_list.git_cmd =1 ;if (opt->env) -strvec_pushv (&rev_list.env_array, opt->env); +strvec_pushv (&rev_list.env, opt->env); rev_list.in =-1 ; rev_list.no_stdout =1 ;if (opt->err_fd)
contrib/coccinelle/run_command.cocci renamed from contrib/coccinelle/run_command.pending.cocci +0 -0
daemon.c +7 -7
@@ -484,7 +484,7 @@ static int upload_pack(const struct strvec *env)strvec_pushl (&cld.args,"upload-pack" ,"--strict" ,NULL );strvec_pushf (&cld.args,"--timeout=%u" , timeout); -strvec_pushv (&cld.env_array, env->v); +strvec_pushv (&cld.env, env->v);return run_service_command (&cld); }
@@ -494,7 +494,7 @@ static int upload_archive(const struct strvec *env)struct child_process cld =CHILD_PROCESS_INIT ;strvec_push (&cld.args,"upload-archive" ); -strvec_pushv (&cld.env_array, env->v); +strvec_pushv (&cld.env, env->v);return run_service_command (&cld); }
@@ -504,7 +504,7 @@ static int receive_pack(const struct strvec *env)struct child_process cld =CHILD_PROCESS_INIT ;strvec_push (&cld.args,"receive-pack" ); -strvec_pushv (&cld.env_array, env->v); +strvec_pushv (&cld.env, env->v);return run_service_command (&cld); }
@@ -904,16 +904,16 @@ static void handle(int incoming, struct sockaddr *addr, socklen_t addrlen)char buf[128 ] ="" ;struct sockaddr_in *sin_addr = (void *) addr;inet_ntop (addr->sa_family, &sin_addr->sin_addr, buf,sizeof (buf)); -strvec_pushf (&cld.env_array,"REMOTE_ADDR=%s" , buf); -strvec_pushf (&cld.env_array,"REMOTE_PORT=%d" , +strvec_pushf (&cld.env,"REMOTE_ADDR=%s" , buf); +strvec_pushf (&cld.env,"REMOTE_PORT=%d" ,ntohs (sin_addr->sin_port)); #ifndef NO_IPV6 }else if (addr->sa_family ==AF_INET6 ) {char buf[128 ] ="" ;struct sockaddr_in6 *sin6_addr = (void *) addr;inet_ntop (AF_INET6 , &sin6_addr->sin6_addr, buf,sizeof (buf)); -strvec_pushf (&cld.env_array,"REMOTE_ADDR=[%s]" , buf); -strvec_pushf (&cld.env_array,"REMOTE_PORT=%d" , +strvec_pushf (&cld.env,"REMOTE_ADDR=[%s]" , buf); +strvec_pushf (&cld.env,"REMOTE_PORT=%d" ,ntohs (sin6_addr->sin6_port));#endif }
editor.c +1 -1
@@ -80,7 +80,7 @@ static int launch_specified_editor(const char *editor, const char *path,strvec_pushl (&p.args, editor, realpath.buf,NULL );if (env) -strvec_pushv (&p.env_array, (const char **)env); +strvec_pushv (&p.env, (const char **)env); p.use_shell =1 ; p.trace2_child_class ="editor" ;if (start_command (&p) <0 ) {
hook.c +1 -1
@@ -54,7 +54,7 @@ static int pick_next_hook(struct child_process *cp,return 0 ; cp->no_stdin =1 ; -strvec_pushv (&cp->env_array, hook_cb->options->env.v); +strvec_pushv (&cp->env, hook_cb->options->env.v); cp->stdout_to_stderr =1 ; cp->trace2_hook_name = hook_cb->hook_name; cp->dir = hook_cb->options->dir;
http-backend.c +2 -2
@@ -476,9 +476,9 @@ static void run_service(const char **argv, int buffer_input) host ="(none)" ;if (!getenv ("GIT_COMMITTER_NAME" )) -strvec_pushf (&cld.env_array,"GIT_COMMITTER_NAME=%s" , user); +strvec_pushf (&cld.env,"GIT_COMMITTER_NAME=%s" , user);if (!getenv ("GIT_COMMITTER_EMAIL" )) -strvec_pushf (&cld.env_array, +strvec_pushf (&cld.env,"GIT_COMMITTER_EMAIL=%s@http.%s" , user, host);strvec_pushv (&cld.args, argv);
object-file.c +1 -1
@@ -838,7 +838,7 @@ static void fill_alternate_refs_command(struct child_process *cmd, } } -strvec_pushv (&cmd->env_array, (const char **)local_repo_env); +strvec_pushv (&cmd->env, (const char **)local_repo_env); cmd->out =-1 ; }
pager.c +2 -2
@@ -99,7 +99,7 @@ void prepare_pager_args(struct child_process *pager_process, const char *pager) {strvec_push (&pager_process->args, pager); pager_process->use_shell =1 ; -setup_pager_env (&pager_process->env_array); +setup_pager_env (&pager_process->env); pager_process->trace2_child_class ="pager" ; }
@@ -129,7 +129,7 @@ void setup_pager(void)/* spawn the pager */ prepare_pager_args (&pager_process, pager); pager_process.in =-1 ; -strvec_push (&pager_process.env_array,"GIT_PAGER_IN_USE" ); +strvec_push (&pager_process.env,"GIT_PAGER_IN_USE" );if (start_command (&pager_process))return ;
promisor-remote.c +1 -1
@@ -22,7 +22,7 @@ static int fetch_objects(struct repository *repo, child.git_cmd =1 ; child.in =-1 ;if (repo != the_repository) -prepare_other_repo_env (&child.env_array, repo->gitdir); +prepare_other_repo_env (&child.env, repo->gitdir); strvec_pushl(&child.args, "-c", "fetch.negotiationAlgorithm=noop", "fetch", remote_name, "--no-tags", "--no-write-fetch-head", "--recurse-submodules=no",
run-command.c +7 -6
@@ -20,7 +20,7 @@ void child_process_init(struct child_process *child)void child_process_clear (struct child_process *child) {strvec_clear (&child->args); -strvec_clear (&child->env_array); +strvec_clear (&child->env); }struct child_to_clean {
@@ -646,7 +646,7 @@ static void trace_run_command(const struct child_process *cp)sq_quote_buf_pretty (&buf, cp->dir);strbuf_addch (&buf,';' ); } -trace_add_env (&buf, cp->env_array.v); +trace_add_env (&buf, cp->env.v);if (cp->git_cmd)strbuf_addstr (&buf," git" );sq_quote_argv_pretty (&buf, cp->args.v);
@@ -751,7 +751,7 @@ int start_command(struct child_process *cmd)set_cloexec (null_fd); } - childenv =prep_childenv (cmd->env_array.v); + childenv =prep_childenv (cmd->env.v);atfork_prepare (&as);/*
@@ -914,8 +914,9 @@ int start_command(struct child_process *cmd)else if (cmd->use_shell) cmd->args.v =prepare_shell_cmd (&nargv, sargv); - cmd->pid =mingw_spawnvpe (cmd->args.v[0 ], cmd->args.v, (char **) cmd->env_array.v, - cmd->dir, fhin, fhout, fherr); + cmd->pid =mingw_spawnvpe (cmd->args.v[0 ], cmd->args.v, + (char **) cmd->env.v, + cmd->dir, fhin, fhout, fherr); failed_errno = errno;if (cmd->pid <0 && (!cmd->silent_exec_failure || errno !=ENOENT ))error_errno ("cannot spawn %s" , cmd->args.v[0 ]);
@@ -1031,7 +1032,7 @@ int run_command_v_opt_cd_env_tr2(const char **argv, int opt, const char *dir, cmd.close_object_store = opt &RUN_CLOSE_OBJECT_STORE ?1 :0 ; cmd.dir = dir;if (env) -strvec_pushv (&cmd.env_array, (const char **)env); +strvec_pushv (&cmd.env, (const char **)env); cmd.trace2_child_class = tr2_class;return run_command (&cmd); }
run-command.h +2 -2
@@ -73,7 +73,7 @@ struct child_process {* The memory in .env_array will be cleaned up automatically during * `finish_command` (or during `start_command` when it is unsuccessful). */ -struct strvec env_array; +struct strvec env;pid_t pid;int trace2_child_id;
@@ -146,7 +146,7 @@ struct child_process {#define CHILD_PROCESS_INIT { \ .args = STRVEC_INIT, \ - .env_array = STRVEC_INIT, \ + .env = STRVEC_INIT, \ }/**
sequencer.c +8 -8
@@ -1000,7 +1000,7 @@ static int run_git_commit(const char *defmsg,if (is_rebase_i (opts) && ((opts->committer_date_is_author_date && !opts->ignore_date) || !(!defmsg && (flags &AMEND_MSG ))) && -read_env_script (&cmd.env_array)) { +read_env_script (&cmd.env)) {const char *gpg_opt =gpg_sign_opt_quoted (opts); return error(_(staged_changes_advice),
@@ -1008,12 +1008,12 @@ static int run_git_commit(const char *defmsg, }if (opts->committer_date_is_author_date) -strvec_pushf (&cmd.env_array,"GIT_COMMITTER_DATE=%s" , +strvec_pushf (&cmd.env,"GIT_COMMITTER_DATE=%s" , opts->ignore_date ?"" : -author_date_from_env_array (&cmd.env_array)); +author_date_from_env_array (&cmd.env));if (opts->ignore_date) -strvec_push (&cmd.env_array,"GIT_AUTHOR_DATE=" ); +strvec_push (&cmd.env,"GIT_AUTHOR_DATE=" );strvec_push (&cmd.args,"commit" );
@@ -3911,7 +3911,7 @@ static int do_merge(struct repository *r,/* Octopus merge */ struct child_process cmd =CHILD_PROCESS_INIT ; -if (read_env_script (&cmd.env_array)) { +if (read_env_script (&cmd.env)) {const char *gpg_opt =gpg_sign_opt_quoted (opts); ret =error (_ (staged_changes_advice), gpg_opt, gpg_opt);
@@ -3919,12 +3919,12 @@ static int do_merge(struct repository *r, }if (opts->committer_date_is_author_date) -strvec_pushf (&cmd.env_array,"GIT_COMMITTER_DATE=%s" , +strvec_pushf (&cmd.env,"GIT_COMMITTER_DATE=%s" , opts->ignore_date ?"" : -author_date_from_env_array (&cmd.env_array)); +author_date_from_env_array (&cmd.env));if (opts->ignore_date) -strvec_push (&cmd.env_array,"GIT_AUTHOR_DATE=" ); +strvec_push (&cmd.env,"GIT_AUTHOR_DATE=" ); cmd.git_cmd =1 ;strvec_push (&cmd.args,"merge" );
submodule.c +19 -19
@@ -711,15 +711,15 @@ void show_submodule_inline_diff(struct diff_options *o, const char *path,if (!(dirty_submodule &DIRTY_SUBMODULE_MODIFIED ))strvec_push (&cp.args,oid_to_hex (new_oid)); -prepare_submodule_repo_env (&cp.env_array); +prepare_submodule_repo_env (&cp.env);if (!is_directory (path)) {/* fall back to absorbed git dir, if any */ if (!sub) goto done; cp.dir = sub->gitdir; -strvec_push (&cp.env_array,GIT_DIR_ENVIRONMENT "=." ); -strvec_push (&cp.env_array,GIT_WORK_TREE_ENVIRONMENT "=." ); +strvec_push (&cp.env,GIT_DIR_ENVIRONMENT "=." ); +strvec_push (&cp.env,GIT_WORK_TREE_ENVIRONMENT "=." ); }if (start_command (&cp)) {
@@ -1019,7 +1019,7 @@ static int submodule_has_commits(struct repository *r,oid_array_for_each_unique (commits, append_oid_to_argv, &cp.args);strvec_pushl (&cp.args,"--not" ,"--all" ,NULL ); -prepare_submodule_repo_env (&cp.env_array); +prepare_submodule_repo_env (&cp.env); cp.git_cmd =1 ; cp.no_stdin =1 ; cp.dir = path;
@@ -1060,7 +1060,7 @@ static int submodule_needs_pushing(struct repository *r,oid_array_for_each_unique (commits, append_oid_to_argv, &cp.args);strvec_pushl (&cp.args,"--not" ,"--remotes" ,"-n" ,"1" ,NULL ); -prepare_submodule_repo_env (&cp.env_array); +prepare_submodule_repo_env (&cp.env); cp.git_cmd =1 ; cp.no_stdin =1 ; cp.out =-1 ;
@@ -1146,7 +1146,7 @@ static int push_submodule(const char *path,strvec_push (&cp.args, rs->raw[i]); } -prepare_submodule_repo_env (&cp.env_array); +prepare_submodule_repo_env (&cp.env); cp.git_cmd =1 ; cp.no_stdin =1 ; cp.dir = path;
@@ -1177,7 +1177,7 @@ static void submodule_push_check(const char *path, const char *head,for (i =0 ; i < rs->raw_nr; i++)strvec_push (&cp.args, rs->raw[i]); -prepare_submodule_repo_env (&cp.env_array); +prepare_submodule_repo_env (&cp.env); cp.git_cmd =1 ; cp.no_stdin =1 ; cp.no_stdout =1 ;
@@ -1678,7 +1678,7 @@ static int get_next_submodule(struct child_process *cp, struct strbuf *err,child_process_init (cp); cp->dir = task->repo->gitdir; -prepare_submodule_repo_env_in_gitdir (&cp->env_array); +prepare_submodule_repo_env_in_gitdir (&cp->env); cp->git_cmd =1 ;strvec_init (&cp->args);if (task->git_args.nr)
@@ -1708,7 +1708,7 @@ static int get_next_submodule(struct child_process *cp, struct strbuf *err, spf->prefix, task->sub->path);child_process_init (cp); -prepare_submodule_repo_env_in_gitdir (&cp->env_array); +prepare_submodule_repo_env_in_gitdir (&cp->env); cp->git_cmd =1 ; cp->dir = task->repo->gitdir;
@@ -1882,7 +1882,7 @@ unsigned is_submodule_modified(const char *path, int ignore_untracked)if (ignore_untracked)strvec_push (&cp.args,"-uno" ); -prepare_submodule_repo_env (&cp.env_array); +prepare_submodule_repo_env (&cp.env); cp.git_cmd =1 ; cp.no_stdin =1 ; cp.out =-1 ;
@@ -1954,7 +1954,7 @@ int submodule_uses_gitfile(const char *path)"submodule" ,"foreach" ,"--quiet" ,"--recursive" , "test -f .git", NULL); -prepare_submodule_repo_env (&cp.env_array); +prepare_submodule_repo_env (&cp.env); cp.git_cmd =1 ; cp.no_stdin =1 ; cp.no_stderr =1 ;
@@ -1997,7 +1997,7 @@ int bad_to_remove_submodule(const char *path, unsigned flags)if (!(flags &SUBMODULE_REMOVAL_IGNORE_IGNORED_UNTRACKED ))strvec_push (&cp.args,"--ignored" ); -prepare_submodule_repo_env (&cp.env_array); +prepare_submodule_repo_env (&cp.env); cp.git_cmd =1 ; cp.no_stdin =1 ; cp.out =-1 ;
@@ -2052,7 +2052,7 @@ static int submodule_has_dirty_index(const struct submodule *sub) {struct child_process cp =CHILD_PROCESS_INIT ; -prepare_submodule_repo_env (&cp.env_array); +prepare_submodule_repo_env (&cp.env); cp.git_cmd =1 ; strvec_pushl(&cp.args, "diff-index", "--quiet",
@@ -2069,7 +2069,7 @@ static int submodule_has_dirty_index(const struct submodule *sub)static void submodule_reset_index (const char *path) {struct child_process cp =CHILD_PROCESS_INIT ; -prepare_submodule_repo_env (&cp.env_array); +prepare_submodule_repo_env (&cp.env); cp.git_cmd =1 ; cp.no_stdin =1 ;
@@ -2153,7 +2153,7 @@ int submodule_move_head(const char *path, } } -prepare_submodule_repo_env (&cp.env_array); +prepare_submodule_repo_env (&cp.env); cp.git_cmd =1 ; cp.no_stdin =1 ;
@@ -2191,7 +2191,7 @@ int submodule_move_head(const char *path, cp.no_stdin =1 ; cp.dir = path; -prepare_submodule_repo_env (&cp.env_array); +prepare_submodule_repo_env (&cp.env);strvec_pushl (&cp.args,"update-ref" ,"HEAD" ,"--no-deref" , new_head,NULL );
@@ -2374,7 +2374,7 @@ void absorb_git_dir_into_superproject(const char *path,strvec_pushl (&cp.args,"--super-prefix" , sb.buf,"submodule--helper" ,"absorb-git-dirs" ,NULL ); -prepare_submodule_repo_env (&cp.env_array); +prepare_submodule_repo_env (&cp.env);if (run_command (&cp))die (_ ("could not recurse into submodule '%s'" ), path);
@@ -2407,8 +2407,8 @@ int get_superproject_working_tree(struct strbuf *buf) subpath =relative_path (cwd, one_up.buf, &sb);strbuf_release (&one_up); -prepare_submodule_repo_env (&cp.env_array); -strvec_pop (&cp.env_array); +prepare_submodule_repo_env (&cp.env); +strvec_pop (&cp.env); strvec_pushl(&cp.args, "--literal-pathspecs", "-C", "..", "ls-files", "-z", "--stage", "--full-name", "--",
t/helper/test-run-command.c +1 -1
@@ -390,7 +390,7 @@ int cmd__run_command(int argc, const char **argv)while (!strcmp (argv[1 ],"env" )) {if (!argv[2 ])die ("env specifier without a value" ); -strvec_push (&proc.env_array, argv[2 ]); +strvec_push (&proc.env, argv[2 ]); argv +=2 ; argc -=2 ; }
trailer.c +1 -1
@@ -236,7 +236,7 @@ static char *apply_command(struct conf_info *conf, const char *arg)strbuf_replace (&cmd,TRAILER_ARG_STRING , arg);strvec_push (&cp.args, cmd.buf); } -strvec_pushv (&cp.env_array, (const char **)local_repo_env); +strvec_pushv (&cp.env, (const char **)local_repo_env); cp.no_stdin =1 ; cp.use_shell =1 ;
transport-helper.c +1 -1
@@ -135,7 +135,7 @@ static struct child_process *get_helper(struct transport *transport) helper->silent_exec_failure =1 ;if (have_git_dir ()) -strvec_pushf (&helper->env_array,"%s=%s" , +strvec_pushf (&helper->env,"%s=%s" ,GIT_DIR_ENVIRONMENT ,get_git_dir ()); helper->trace2_child_class = helper->args.v[0 ];/* "remote-<name>" */
wt-status.c +1 -1
@@ -982,7 +982,7 @@ static void wt_longstatus_print_submodule_summary(struct wt_status *s, int uncomstruct strbuf summary =STRBUF_INIT ;char *summary_content; -strvec_pushf (&sm_summary.env_array,"GIT_INDEX_FILE=%s" , s->index_file); +strvec_pushf (&sm_summary.env,"GIT_INDEX_FILE=%s" , s->index_file);strvec_push (&sm_summary.args,"submodule" );strvec_push (&sm_summary.args,"summary" );
Signature · 1 line
2.36.1.957.g2c13267e09b
PATCH v2 3/4 cocci: remove env_array -> env migration
In reply to Ævar Arnfjörð BjarmasonRemove the coccinelle rule renaming "env_array" to "env". In the preceding commit we carried out this rename based on this rule, anyone with out-of-tree patches still referring to "env" will now get a compilation error.
We could keep the rule to help those developers change their code by running "make coccicheck", but as the solution is obvious in this case let's not leave this stale rule in place.
--- contrib/coccinelle/run_command.cocci | 11 ----------- 1 file changed, 11 deletions(-) delete mode 100644 contrib/coccinelle/run_command.cocci
contrib/coccinelle/run_command.cocci deleted +0 -11
@@ -1,11 +0,0 @@ -@@ -struct child_process E; -@@ -- E.env_array -+ E.env - -@@ -struct child_process *E; -@@ -- E->env_array -+ E->env
Signature · 1 line
2.36.1.957.g2c13267e09b
PATCH v2 4/4 run-command API users: use "env" not "env_array" in comments & names
In reply to Ævar Arnfjörð BjarmasonFollow-up on a preceding commit which changed all references to the "env_array" when referring to the "struct child_process" member. These changes are all unnecessary for the compiler, but help the code's human readers.
All the comments that referred to "env_array" have now been updated, as well as function names and variables that had "env_array" in their name, they now refer to "env".
In addition the "out" name for the submodule.h prototype was inconsistent with the function definition's use of "env_array" in submodule.c. Both of them use "env" now.
--- builtin/submodule--helper.c | 2 +- run-command.c | 6 +++--- run-command.h | 10 +++++----- sequencer.c | 6 +++--- submodule.h | 4 ++-- 5 files changed, 14 insertions(+), 14 deletions(-)
builtin/submodule--helper.c +1 -1
@@ -513,7 +513,7 @@ static void runcommand_in_submodule_cb(const struct cache_entry *list_item,* on windows. And since environment variables are * case-insensitive in windows, it interferes with the * existing PATH variable. Hence, to avoid that, we expose -* path via the args strvec and not via env_array. +* path via the args strvec and not via env. */ sq_quote_buf (&sb, path); strvec_pushf(&cp.args, "path=%s; %s",
run-command.c +3 -3
@@ -1816,16 +1816,16 @@ int run_auto_maintenance(int quiet)return run_command (&maint); } -void prepare_other_repo_env (struct strvec *env_array,const char *new_git_dir) +void prepare_other_repo_env (struct strvec *env,const char *new_git_dir) {const char *const *var;for (var = local_repo_env; *var; var++) {if (strcmp (*var,CONFIG_DATA_ENVIRONMENT ) &&strcmp (*var,CONFIG_COUNT_ENVIRONMENT )) -strvec_push (env_array, *var); +strvec_push (env, *var); } -strvec_pushf (env_array,"%s=%s" ,GIT_DIR_ENVIRONMENT , new_git_dir); +strvec_pushf (env,"%s=%s" ,GIT_DIR_ENVIRONMENT , new_git_dir); } enum start_bg_result start_bg_command(struct child_process *cmd,
run-command.h +5 -5
@@ -58,7 +58,7 @@ struct child_process {struct strvec args;/** -* Like .args the .env_array is a `struct strvec'. +* Like .args the .env is a `struct strvec'. * * To modify the environment of the sub-process, specify an array of * environment settings. Each string in the array manipulates the
@@ -70,7 +70,7 @@ struct child_process {* - If the string does not contain '=', it names an environment * variable that will be removed from the child process's environment. * -* The memory in .env_array will be cleaned up automatically during +* The memory in .env will be cleaned up automatically during * `finish_command` (or during `start_command` when it is unsuccessful). */ struct strvec env;
@@ -479,14 +479,14 @@ int run_processes_parallel_tr2(int n, get_next_task_fn, start_failure_fn, const char *tr2_category, const char *tr2_label);/** -* Convenience function which prepares env_array for a command to be run in a -* new repo. This adds all GIT_* environment variables to env_array with the +* Convenience function which prepares env for a command to be run in a +* new repo. This adds all GIT_* environment variables to env with the * exception of GIT_CONFIG_PARAMETERS and GIT_CONFIG_COUNT (which cause the * corresponding environment variables to be unset in the subprocess) and adds * an environment variable pointing to new_git_dir. See local_repo_env in * cache.h for more information. */ -void prepare_other_repo_env (struct strvec *env_array,const char *new_git_dir); +void prepare_other_repo_env (struct strvec *env,const char *new_git_dir);/** * Possible return values for start_bg_command().
sequencer.c +3 -3
@@ -919,7 +919,7 @@ static char *get_author(const char *message)return NULL ; } -static const char *author_date_from_env_array (const struct strvec *env) +static const char *author_date_from_env (const struct strvec *env) {int i;const char *date;
@@ -1011,7 +1011,7 @@ static int run_git_commit(const char *defmsg,strvec_pushf (&cmd.env,"GIT_COMMITTER_DATE=%s" , opts->ignore_date ?"" : -author_date_from_env_array (&cmd.env)); +author_date_from_env (&cmd.env));if (opts->ignore_date)strvec_push (&cmd.env,"GIT_AUTHOR_DATE=" );
@@ -3922,7 +3922,7 @@ static int do_merge(struct repository *r,strvec_pushf (&cmd.env,"GIT_COMMITTER_DATE=%s" , opts->ignore_date ?"" : -author_date_from_env_array (&cmd.env)); +author_date_from_env (&cmd.env));if (opts->ignore_date)strvec_push (&cmd.env,"GIT_AUTHOR_DATE=" );
submodule.h +2 -2
@@ -158,11 +158,11 @@ int submodule_move_head(const char *path,void submodule_unset_core_worktree (const struct submodule *sub);/* -* Prepare the "env_array" parameter of a "struct child_process" for executing +* Prepare the "env" parameter of a "struct child_process" for executing * a submodule by clearing any repo-specific environment variables, but * retaining any config in the environment. */ -void prepare_submodule_repo_env (struct strvec *out); +void prepare_submodule_repo_env (struct strvec *env);#define ABSORB_GITDIR_RECURSE_SUBMODULES (1<<0) void absorb_git_dir_into_superproject(const char *path,
Signature · 1 line
2.36.1.957.g2c13267e09b
Re: [PATCH v2 0/4] run-command.h: rename "env_array" to "env"
In reply to Ævar Arnfjörð BjarmasonQuoted 9 lines · Ævar Arnfjörð Bjarmason
Follow-up
32ec72c3e1(Merge branch 'ab/run-command', 2021-12-15) and rename the "env_array" member to simply "env" in the "structchild_process".Changes since v1:
* Added a commit to remove the coccinelle rule after its application, as suggested by Junio in
https://lore.kernel.org/git/[email protected]/
I actually think we do not even have to tentatively add one, only to remove it at the end.
Wouldn't a two-patch series whose
- first patch does the real damage to the codebase, with the coccinelle rule as part of the commit explanation in the proposed log message (e.g. "the patch was mechanically prepared with the help with this Coccinelle semantic patch"), and
- the second patch does the non-mechanical "comments and names"
work better than four patch series? A single patch that says "the code was mechanically updated with this s-patch, with names and comments that refer to env_array in the surrounding code manually adjusted" would also work well.
Re: [PATCH v2 0/4] run-command.h: rename "env_array" to "env"
Quoted 22 lines · Junio C Hamano
Quoted 9 lines · Ævar Arnfjörð Bjarmason
Follow-up
32ec72c3e1(Merge branch 'ab/run-command', 2021-12-15) and rename the "env_array" member to simply "env" in the "structchild_process".Changes since v1:
* Added a commit to remove the coccinelle rule after its application, as suggested by Junio in
https://lore.kernel.org/git/[email protected]/I actually think we do not even have to tentatively add one, only to remove it at the end.
Wouldn't a two-patch series whose
- first patch does the real damage to the codebase, with the coccinelle rule as part of the commit explanation in the proposed log message (e.g. "the patch was mechanically prepared with the help with this Coccinelle semantic patch"), and
Quoted 6 lines
- the second patch does the non-mechanical "comments and names"
work better than four patch series? A single patch that says "the code was mechanically updated with this s-patch, with names and comments that refer to
env_arrayin the surrounding code manually adjusted" would also work well.
I can re-roll it if you insist, but I think it's much more useful to have rules added to contrib/coccinelle, even if they're subsequently removed within the same series.
I've ofter paged through "git log -p -- contrib/coccinelle" to get inspiration from previous rules we used or see what's valid syntax. I think being able to do that consistently and not having to fish through log messages as well is more useful.
It also makes it easier for someone who needs to modify their code to just "git checkout" and run "spatch" on the rule, without copy/pasting from a log message.
But anyway, whatever you prefer. I see from the latest WC you're expecting a re-roll, maybe the above will convince you, and if not I can prepare a v3 with your suggested changes. Thanks.
v3 cover run-command.h: rename "env_array" to "env"
In reply to Ævar Arnfjörð BjarmasonFollow-up 32ec72c3e1 (Merge branch 'ab/run-command', 2021-12-15) and rename the "env_array" member to simply "env" in the "struct child_process".
Changes since v2[1]:
* Rebased on "master" (there was one small conflict).
* Squashed the first 3 commits into one. Now the coccinelle rule is mentionid in the 1/2 commit message, instead of adding & removing it before/after the change itself.
1. https://lore.kernel.org/git/[email protected]/
Ævar Arnfjörð Bjarmason (2):
run-command API: rename "env_array" to "env"
run-command API users: use "env" not "env_array" in comments & names
add-patch.c | 2 +- branch.c | 2 +- builtin/difftool.c | 6 ++--- builtin/receive-pack.c | 32 +++++++++++++-------------- builtin/stash.c | 16 +++++++------- builtin/submodule--helper.c | 44 ++++++++++++++++++------------------- builtin/worktree.c | 8 +++---- connect.c | 9 ++++---- connected.c | 2 +- daemon.c | 14 ++++++------ editor.c | 2 +- hook.c | 2 +- http-backend.c | 4 ++-- object-file.c | 2 +- pager.c | 4 ++-- promisor-remote.c | 2 +- run-command.c | 19 ++++++++-------- run-command.h | 14 ++++++------ sequencer.c | 18 +++++++-------- submodule.c | 38 ++++++++++++++++---------------- submodule.h | 4 ++-- t/helper/test-run-command.c | 2 +- trailer.c | 2 +- transport-helper.c | 2 +- wt-status.c | 2 +- 25 files changed, 127 insertions(+), 125 deletions(-)
Range-diff against v2:
1: e3f33fce566 < -: ----------- cocci: add a rename of "struct child_process"'s "env_array" to "env" 2: 5aeb6ec9117 ! 1: 80ef05d5b0a run-command API: rename "env_array" to "env"
@@ Metadata
## Commit message ##
run-command API: rename "env_array" to "env"
- As noted in the preceding commit it would be nice to not deal with the
- oddity of having an "_array" suffix for the "env" strvec, but not for
- its "args" sibling.
+ Start following-up on the rename mentioned in c7c4bdeccf3 (run-command
+ API: remove "env" member, always use "env_array", 2021-11-25) of
+ "env_array" to "env".
- We can do that with coccinelle in a way that's easy to review. The
- only manual changes in this commit are:
+ The "env_array" name was picked in 19a583dc39e (run-command: add
+ env_array, an optional argv_array for env, 2014-10-19) because "env"
+ was taken. Let's not forever keep the oddity of "*_array" for this
+ "struct strvec", but not for its "args" sibling.
- * git mv contrib/coccinelle/run_command{.pending,}.cocci
- * The change in run-command.h to rename the struct member itself, and
- to change its initializer.
+ This commit is almost entirely made with a coccinelle rule[1]. The
+ only manual change here is in run-command.h to rename the struct
+ member itself and to change "env_array" to "env" in the
+ CHILD_PROCESS_INIT initializer.
- The rest of this is all the result of a subsequent:
+ The rest of this is all a result of applying [1]:
* make contrib/coccinelle/run_command.cocci.patch
* patch -p1 <contrib/coccinelle/run_command.cocci.patch
* git add -u
+ 1. cat contrib/coccinelle/run_command.pending.cocci
+ @@
+ struct child_process E;
+ @@
+ - E.env_array
+ + E.env
+
+ @@
+ struct child_process *E;
+ @@
+ - E->env_array
+ + E->env
+
I've avoided changing any comments and derived variable names here, that will all be done in the next commit.
@@ builtin/receive-pack.c: static const char *push_to_deploy(unsigned char *sha1,
child.no_stdin = 1;
child.no_stdout = 1;
@@ builtin/receive-pack.c: static const char *unpack(int err_fd, struct shallow_info *si)
+ close(err_fd);
return "unable to create temporary object directory";
}
- if (tmp_objdir)
-- strvec_pushv(&child.env_array, tmp_objdir_env(tmp_objdir));
-+ strvec_pushv(&child.env, tmp_objdir_env(tmp_objdir));
+- strvec_pushv(&child.env_array, tmp_objdir_env(tmp_objdir));
++ strvec_pushv(&child.env, tmp_objdir_env(tmp_objdir));
/*
* Normally we just pass the tmp_objdir environment to the child
@@ connected.c: int check_connected(oid_iterate_fn fn, void *cb_data,
rev_list.no_stdout = 1;
if (opt->err_fd)
- ## contrib/coccinelle/run_command.pending.cocci => contrib/coccinelle/run_command.cocci ## -
## daemon.c ##
@@ daemon.c: static int upload_pack(const struct strvec *env)
strvec_pushl(&cld.args, "upload-pack", "--strict", NULL);
3: ca09da570ef < -: ----------- cocci: remove env_array -> env migration 4: 5419f839c74 = 2: 4039fec4f29 run-command API users: use "env" not "env_array" in comments & names
Signature · 1 line
2.36.1.1103.gb3ecdfb3e6a
PATCH v3 1/2 run-command API: rename "env_array" to "env"
Start following-up on the rename mentioned in c7c4bdeccf3 (run-command
API: remove "env" member, always use "env_array", 2021-11-25) of "env_array" to "env".
The "env_array" name was picked in 19a583dc39e (run-command: add env_array, an optional argv_array for env, 2014-10-19) because "env" was taken. Let's not forever keep the oddity of "*_array" for this "struct strvec", but not for its "args" sibling.
This commit is almost entirely made with a coccinelle rule[1]. The only manual change here is in run-command.h to rename the struct member itself and to change "env_array" to "env" in the CHILD_PROCESS_INIT initializer.
The rest of this is all a result of applying [1]:
* make contrib/coccinelle/run_command.cocci.patch
* patch -p1 <contrib/coccinelle/run_command.cocci.patch
* git add -u
1. cat contrib/coccinelle/run_command.pending.cocci @@
struct child_process E;
@@
- E.env_array
+ E.env
@@
struct child_process *E;
@@
- E->env_array
+ E->env
I've avoided changing any comments and derived variable names here, that will all be done in the next commit.
--- add-patch.c | 2 +- branch.c | 2 +- builtin/difftool.c | 6 +++--- builtin/receive-pack.c | 32 ++++++++++++++-------------- builtin/stash.c | 16 +++++++------- builtin/submodule--helper.c | 42 ++++++++++++++++++------------------- builtin/worktree.c | 8 +++---- connect.c | 9 ++++---- connected.c | 2 +- daemon.c | 14 ++++++------- editor.c | 2 +- hook.c | 2 +- http-backend.c | 4 ++-- object-file.c | 2 +- pager.c | 4 ++-- promisor-remote.c | 2 +- run-command.c | 13 ++++++------ run-command.h | 4 ++-- sequencer.c | 16 +++++++------- submodule.c | 38 ++++++++++++++++----------------- t/helper/test-run-command.c | 2 +- trailer.c | 2 +- transport-helper.c | 2 +- wt-status.c | 2 +- 24 files changed, 115 insertions(+), 113 deletions(-)
add-patch.c +1 -1
@@ -305,7 +305,7 @@ static void setup_child_process(struct add_p_state *s,va_end (ap); cp->git_cmd =1 ; -strvec_pushf (&cp->env_array, +strvec_pushf (&cp->env,INDEX_ENVIRONMENT "=%s" , s->s.r->index_file); }
branch.c +1 -1
@@ -587,7 +587,7 @@ static int submodule_create_branch(struct repository *r, child.err =-1 ; child.stdout_to_stderr =1 ; -prepare_other_repo_env (&child.env_array, r->gitdir); +prepare_other_repo_env (&child.env, r->gitdir);/* * submodule_create_branch() is indirectly invoked by "git * branch", but we cannot invoke "git branch" in the child
builtin/difftool.c +3 -3
@@ -217,7 +217,7 @@ static void changed_files(struct hashmap *result, const char *index_path, update_index.use_shell =0 ; update_index.clean_on_exit =1 ; update_index.dir = workdir; -strvec_pushf (&update_index.env_array,"GIT_INDEX_FILE=%s" , index_path); +strvec_pushf (&update_index.env,"GIT_INDEX_FILE=%s" , index_path);/* Ignore any errors of update-index */ run_command (&update_index);
@@ -230,7 +230,7 @@ static void changed_files(struct hashmap *result, const char *index_path, diff_files.clean_on_exit =1 ; diff_files.out =-1 ; diff_files.dir = workdir; -strvec_pushf (&diff_files.env_array,"GIT_INDEX_FILE=%s" , index_path); +strvec_pushf (&diff_files.env,"GIT_INDEX_FILE=%s" , index_path);if (start_command (&diff_files))die ("could not obtain raw diff" ); fp =xfdopen (diff_files.out,"r" );
@@ -675,7 +675,7 @@ static int run_file_diff(int prompt, const char *prefix, child->git_cmd =1 ; child->dir = prefix; -strvec_pushv (&child->env_array, env); +strvec_pushv (&child->env, env);return run_command (child); }
builtin/receive-pack.c +16 -16
@@ -764,23 +764,23 @@ static void prepare_push_cert_sha1(struct child_process *proc) nonce_status =check_nonce (push_cert.buf, bogs); }if (!is_null_oid (&push_cert_oid)) { -strvec_pushf (&proc->env_array,"GIT_PUSH_CERT=%s" , +strvec_pushf (&proc->env,"GIT_PUSH_CERT=%s" ,oid_to_hex (&push_cert_oid)); -strvec_pushf (&proc->env_array,"GIT_PUSH_CERT_SIGNER=%s" , +strvec_pushf (&proc->env,"GIT_PUSH_CERT_SIGNER=%s" , sigcheck.signer ? sigcheck.signer :"" ); -strvec_pushf (&proc->env_array,"GIT_PUSH_CERT_KEY=%s" , +strvec_pushf (&proc->env,"GIT_PUSH_CERT_KEY=%s" , sigcheck.key ? sigcheck.key :"" ); -strvec_pushf (&proc->env_array,"GIT_PUSH_CERT_STATUS=%c" , +strvec_pushf (&proc->env,"GIT_PUSH_CERT_STATUS=%c" , sigcheck.result);if (push_cert_nonce) { -strvec_pushf (&proc->env_array, +strvec_pushf (&proc->env,"GIT_PUSH_CERT_NONCE=%s" , push_cert_nonce); -strvec_pushf (&proc->env_array, +strvec_pushf (&proc->env,"GIT_PUSH_CERT_NONCE_STATUS=%s" , nonce_status);if (nonce_status ==NONCE_SLOP ) -strvec_pushf (&proc->env_array, +strvec_pushf (&proc->env,"GIT_PUSH_CERT_NONCE_SLOP=%ld" , nonce_stamp_slop); }
@@ -815,17 +815,17 @@ static int run_and_feed_hook(const char *hook_name, feed_fn feed,if (feed_state->push_options) {size_t i;for (i =0 ; i < feed_state->push_options->nr; i++) -strvec_pushf (&proc.env_array, +strvec_pushf (&proc.env,"GIT_PUSH_OPTION_%" PRIuMAX"=%s" , (uintmax_t )i, feed_state->push_options->items[i].string); -strvec_pushf (&proc.env_array,"GIT_PUSH_OPTION_COUNT=%" PRIuMAX"" , +strvec_pushf (&proc.env,"GIT_PUSH_OPTION_COUNT=%" PRIuMAX"" , (uintmax_t )feed_state->push_options->nr); }else -strvec_pushf (&proc.env_array,"GIT_PUSH_OPTION_COUNT" ); +strvec_pushf (&proc.env,"GIT_PUSH_OPTION_COUNT" );if (tmp_objdir) -strvec_pushv (&proc.env_array,tmp_objdir_env (tmp_objdir)); +strvec_pushv (&proc.env,tmp_objdir_env (tmp_objdir));if (use_sideband) {memset (&muxer,0 ,sizeof (muxer));
@@ -1357,7 +1357,7 @@ static const char *push_to_deploy(unsigned char *sha1,strvec_pushl (&child.args,"update-index" ,"-q" ,"--ignore-submodules" ,"--refresh" ,NULL ); -strvec_pushv (&child.env_array, env->v); +strvec_pushv (&child.env, env->v); child.dir = work_tree; child.no_stdin =1 ; child.stdout_to_stderr =1 ;
@@ -1369,7 +1369,7 @@ static const char *push_to_deploy(unsigned char *sha1,child_process_init (&child);strvec_pushl (&child.args,"diff-files" ,"--quiet" ,"--ignore-submodules" ,"--" ,NULL ); -strvec_pushv (&child.env_array, env->v); +strvec_pushv (&child.env, env->v); child.dir = work_tree; child.no_stdin =1 ; child.stdout_to_stderr =1 ;
@@ -1383,7 +1383,7 @@ static const char *push_to_deploy(unsigned char *sha1,/* diff-index with either HEAD or an empty tree */ head_has_history () ?"HEAD" :empty_tree_oid_hex (), "--", NULL); -strvec_pushv (&child.env_array, env->v); +strvec_pushv (&child.env, env->v); child.no_stdin =1 ; child.no_stdout =1 ; child.stdout_to_stderr =0 ;
@@ -1394,7 +1394,7 @@ static const char *push_to_deploy(unsigned char *sha1,child_process_init (&child);strvec_pushl (&child.args,"read-tree" ,"-u" ,"-m" ,hash_to_hex (sha1),NULL ); -strvec_pushv (&child.env_array, env->v); +strvec_pushv (&child.env, env->v); child.dir = work_tree; child.no_stdin =1 ; child.no_stdout =1 ;
@@ -2214,7 +2214,7 @@ static const char *unpack(int err_fd, struct shallow_info *si)close (err_fd);return "unable to create temporary object directory" ; } -strvec_pushv (&child.env_array,tmp_objdir_env (tmp_objdir)); +strvec_pushv (&child.env,tmp_objdir_env (tmp_objdir));/* * Normally we just pass the tmp_objdir environment to the child
builtin/stash.c +8 -8
@@ -357,7 +357,7 @@ static int restore_untracked(struct object_id *u_tree) cp.git_cmd =1 ;strvec_push (&cp.args,"read-tree" );strvec_push (&cp.args,oid_to_hex (u_tree)); -strvec_pushf (&cp.env_array,"GIT_INDEX_FILE=%s" , +strvec_pushf (&cp.env,"GIT_INDEX_FILE=%s" , stash_index_path.buf);if (run_command (&cp)) {remove_path (stash_index_path.buf);
@@ -367,7 +367,7 @@ static int restore_untracked(struct object_id *u_tree)child_process_init (&cp); cp.git_cmd =1 ;strvec_pushl (&cp.args,"checkout-index" ,"--all" ,NULL ); -strvec_pushf (&cp.env_array,"GIT_INDEX_FILE=%s" , +strvec_pushf (&cp.env,"GIT_INDEX_FILE=%s" , stash_index_path.buf); res =run_command (&cp);
@@ -603,9 +603,9 @@ static int do_apply_stash(const char *prefix, struct stash_info *info,*/ cp.git_cmd =1 ; cp.dir = prefix; -strvec_pushf (&cp.env_array,GIT_WORK_TREE_ENVIRONMENT "=%s" , +strvec_pushf (&cp.env,GIT_WORK_TREE_ENVIRONMENT "=%s" ,absolute_path (get_git_work_tree ())); -strvec_pushf (&cp.env_array,GIT_DIR_ENVIRONMENT "=%s" , +strvec_pushf (&cp.env,GIT_DIR_ENVIRONMENT "=%s" ,absolute_path (get_git_dir ()));strvec_push (&cp.args,"status" );run_command (&cp);
@@ -1106,7 +1106,7 @@ static int save_untracked_files(struct stash_info *info, struct strbuf *msg, cp_upd_index.git_cmd =1 ;strvec_pushl (&cp_upd_index.args,"update-index" ,"-z" ,"--add" ,"--remove" ,"--stdin" ,NULL ); -strvec_pushf (&cp_upd_index.env_array,"GIT_INDEX_FILE=%s" , +strvec_pushf (&cp_upd_index.env,"GIT_INDEX_FILE=%s" , stash_index_path.buf);strbuf_addf (&untracked_msg,"untracked files on %s\n" , msg->buf);
@@ -1180,7 +1180,7 @@ static int stash_patch(struct stash_info *info, const struct pathspec *ps, cp_read_tree.git_cmd =1 ;strvec_pushl (&cp_read_tree.args,"read-tree" ,"HEAD" ,NULL ); -strvec_pushf (&cp_read_tree.env_array,"GIT_INDEX_FILE=%s" , +strvec_pushf (&cp_read_tree.env,"GIT_INDEX_FILE=%s" , stash_index_path.buf);if (run_command (&cp_read_tree)) { ret =-1 ;
@@ -1267,7 +1267,7 @@ static int stash_working_tree(struct stash_info *info, const struct pathspec *psstrvec_pushl (&cp_upd_index.args,"update-index" ,"--ignore-skip-worktree-entries" ,"-z" ,"--add" ,"--remove" ,"--stdin" ,NULL ); -strvec_pushf (&cp_upd_index.env_array,"GIT_INDEX_FILE=%s" , +strvec_pushf (&cp_upd_index.env,"GIT_INDEX_FILE=%s" , stash_index_path.buf); if (pipe_command(&cp_upd_index, diff_output.buf, diff_output.len,
@@ -1543,7 +1543,7 @@ static int do_push_stash(const struct pathspec *ps, const char *stash_msg, int q cp.git_cmd =1 ;if (startup_info->original_cwd) { cp.dir = startup_info->original_cwd; -strvec_pushf (&cp.env_array,"%s=%s" , +strvec_pushf (&cp.env,"%s=%s" ,GIT_WORK_TREE_ENVIRONMENT , the_repository->worktree); }
builtin/submodule--helper.c +21 -21
140 lines not on this page · raw message
builtin/worktree.c +4 -4
@@ -301,7 +301,7 @@ static int checkout_worktree(const struct add_opts *opts,strvec_pushl (&cp.args,"reset" ,"--hard" ,"--no-recurse-submodules" ,NULL );if (opts->quiet)strvec_push (&cp.args,"--quiet" ); -strvec_pushv (&cp.env_array, child_env->v); +strvec_pushv (&cp.env, child_env->v);return run_command (&cp); }
@@ -433,7 +433,7 @@ static int add_worktree(const char *path, const char *refname,strvec_push (&cp.args,"--quiet" ); } -strvec_pushv (&cp.env_array, child_env.v); +strvec_pushv (&cp.env, child_env.v); ret =run_command (&cp);if (ret) goto done;
@@ -989,9 +989,9 @@ static void check_clean_worktree(struct worktree *wt,validate_no_submodules (wt);child_process_init (&cp); -strvec_pushf (&cp.env_array,"%s=%s/.git" , +strvec_pushf (&cp.env,"%s=%s/.git" ,GIT_DIR_ENVIRONMENT , wt->path); -strvec_pushf (&cp.env_array,"%s=%s" , +strvec_pushf (&cp.env,"%s=%s" ,GIT_WORK_TREE_ENVIRONMENT , wt->path); strvec_pushl(&cp.args, "status", "--porcelain", "--ignore-submodules=none",
connect.c +5 -4
@@ -1327,7 +1327,7 @@ static void fill_ssh_args(struct child_process *conn, const char *ssh_host,strvec_push (&detect.args, ssh);strvec_push (&detect.args,"-G" ); -push_ssh_options (&detect.args, &detect.env_array, +push_ssh_options (&detect.args, &detect.env,VARIANT_SSH , port, version, flags);strvec_push (&detect.args, ssh_host);
@@ -1335,7 +1335,8 @@ static void fill_ssh_args(struct child_process *conn, const char *ssh_host, }strvec_push (&conn->args, ssh); -push_ssh_options (&conn->args, &conn->env_array, variant, port, version, flags); +push_ssh_options (&conn->args, &conn->env, variant, port, version, + flags);strvec_push (&conn->args, ssh_host); }
@@ -1397,7 +1398,7 @@ struct child_process *git_connect(int fd[2], const char *url,/* remove repo-local variables from the environment */ for (var = local_repo_env; *var; var++) -strvec_push (&conn->env_array, *var); +strvec_push (&conn->env, *var); conn->use_shell =1 ; conn->in = conn->out =-1 ;
@@ -1429,7 +1430,7 @@ struct child_process *git_connect(int fd[2], const char *url,transport_check_allowed ("file" ); conn->trace2_child_class ="transport/file" ;if (version >0 ) { -strvec_pushf (&conn->env_array, +strvec_pushf (&conn->env,GIT_PROTOCOL_ENVIRONMENT "=version=%d" , version); }
connected.c +1 -1
@@ -110,7 +110,7 @@ int check_connected(oid_iterate_fn fn, void *cb_data, rev_list.git_cmd =1 ;if (opt->env) -strvec_pushv (&rev_list.env_array, opt->env); +strvec_pushv (&rev_list.env, opt->env); rev_list.in =-1 ; rev_list.no_stdout =1 ;if (opt->err_fd)
daemon.c +7 -7
@@ -484,7 +484,7 @@ static int upload_pack(const struct strvec *env)strvec_pushl (&cld.args,"upload-pack" ,"--strict" ,NULL );strvec_pushf (&cld.args,"--timeout=%u" , timeout); -strvec_pushv (&cld.env_array, env->v); +strvec_pushv (&cld.env, env->v);return run_service_command (&cld); }
@@ -494,7 +494,7 @@ static int upload_archive(const struct strvec *env)struct child_process cld =CHILD_PROCESS_INIT ;strvec_push (&cld.args,"upload-archive" ); -strvec_pushv (&cld.env_array, env->v); +strvec_pushv (&cld.env, env->v);return run_service_command (&cld); }
@@ -504,7 +504,7 @@ static int receive_pack(const struct strvec *env)struct child_process cld =CHILD_PROCESS_INIT ;strvec_push (&cld.args,"receive-pack" ); -strvec_pushv (&cld.env_array, env->v); +strvec_pushv (&cld.env, env->v);return run_service_command (&cld); }
@@ -904,16 +904,16 @@ static void handle(int incoming, struct sockaddr *addr, socklen_t addrlen)char buf[128 ] ="" ;struct sockaddr_in *sin_addr = (void *) addr;inet_ntop (addr->sa_family, &sin_addr->sin_addr, buf,sizeof (buf)); -strvec_pushf (&cld.env_array,"REMOTE_ADDR=%s" , buf); -strvec_pushf (&cld.env_array,"REMOTE_PORT=%d" , +strvec_pushf (&cld.env,"REMOTE_ADDR=%s" , buf); +strvec_pushf (&cld.env,"REMOTE_PORT=%d" ,ntohs (sin_addr->sin_port)); #ifndef NO_IPV6 }else if (addr->sa_family ==AF_INET6 ) {char buf[128 ] ="" ;struct sockaddr_in6 *sin6_addr = (void *) addr;inet_ntop (AF_INET6 , &sin6_addr->sin6_addr, buf,sizeof (buf)); -strvec_pushf (&cld.env_array,"REMOTE_ADDR=[%s]" , buf); -strvec_pushf (&cld.env_array,"REMOTE_PORT=%d" , +strvec_pushf (&cld.env,"REMOTE_ADDR=[%s]" , buf); +strvec_pushf (&cld.env,"REMOTE_PORT=%d" ,ntohs (sin6_addr->sin6_port));#endif }
editor.c +1 -1
@@ -80,7 +80,7 @@ static int launch_specified_editor(const char *editor, const char *path,strvec_pushl (&p.args, editor, realpath.buf,NULL );if (env) -strvec_pushv (&p.env_array, (const char **)env); +strvec_pushv (&p.env, (const char **)env); p.use_shell =1 ; p.trace2_child_class ="editor" ;if (start_command (&p) <0 ) {
hook.c +1 -1
@@ -54,7 +54,7 @@ static int pick_next_hook(struct child_process *cp,return 0 ; cp->no_stdin =1 ; -strvec_pushv (&cp->env_array, hook_cb->options->env.v); +strvec_pushv (&cp->env, hook_cb->options->env.v); cp->stdout_to_stderr =1 ; cp->trace2_hook_name = hook_cb->hook_name; cp->dir = hook_cb->options->dir;
http-backend.c +2 -2
@@ -476,9 +476,9 @@ static void run_service(const char **argv, int buffer_input) host ="(none)" ;if (!getenv ("GIT_COMMITTER_NAME" )) -strvec_pushf (&cld.env_array,"GIT_COMMITTER_NAME=%s" , user); +strvec_pushf (&cld.env,"GIT_COMMITTER_NAME=%s" , user);if (!getenv ("GIT_COMMITTER_EMAIL" )) -strvec_pushf (&cld.env_array, +strvec_pushf (&cld.env,"GIT_COMMITTER_EMAIL=%s@http.%s" , user, host);strvec_pushv (&cld.args, argv);
object-file.c +1 -1
@@ -838,7 +838,7 @@ static void fill_alternate_refs_command(struct child_process *cmd, } } -strvec_pushv (&cmd->env_array, (const char **)local_repo_env); +strvec_pushv (&cmd->env, (const char **)local_repo_env); cmd->out =-1 ; }
pager.c +2 -2
@@ -99,7 +99,7 @@ void prepare_pager_args(struct child_process *pager_process, const char *pager) {strvec_push (&pager_process->args, pager); pager_process->use_shell =1 ; -setup_pager_env (&pager_process->env_array); +setup_pager_env (&pager_process->env); pager_process->trace2_child_class ="pager" ; }
@@ -129,7 +129,7 @@ void setup_pager(void)/* spawn the pager */ prepare_pager_args (&pager_process, pager); pager_process.in =-1 ; -strvec_push (&pager_process.env_array,"GIT_PAGER_IN_USE" ); +strvec_push (&pager_process.env,"GIT_PAGER_IN_USE" );if (start_command (&pager_process))return ;
promisor-remote.c +1 -1
@@ -22,7 +22,7 @@ static int fetch_objects(struct repository *repo, child.git_cmd =1 ; child.in =-1 ;if (repo != the_repository) -prepare_other_repo_env (&child.env_array, repo->gitdir); +prepare_other_repo_env (&child.env, repo->gitdir); strvec_pushl(&child.args, "-c", "fetch.negotiationAlgorithm=noop", "fetch", remote_name, "--no-tags", "--no-write-fetch-head", "--recurse-submodules=no",
run-command.c +7 -6
@@ -20,7 +20,7 @@ void child_process_init(struct child_process *child)void child_process_clear (struct child_process *child) {strvec_clear (&child->args); -strvec_clear (&child->env_array); +strvec_clear (&child->env); }struct child_to_clean {
@@ -646,7 +646,7 @@ static void trace_run_command(const struct child_process *cp)sq_quote_buf_pretty (&buf, cp->dir);strbuf_addch (&buf,';' ); } -trace_add_env (&buf, cp->env_array.v); +trace_add_env (&buf, cp->env.v);if (cp->git_cmd)strbuf_addstr (&buf," git" );sq_quote_argv_pretty (&buf, cp->args.v);
@@ -751,7 +751,7 @@ int start_command(struct child_process *cmd)set_cloexec (null_fd); } - childenv =prep_childenv (cmd->env_array.v); + childenv =prep_childenv (cmd->env.v);atfork_prepare (&as);/*
@@ -914,8 +914,9 @@ int start_command(struct child_process *cmd)else if (cmd->use_shell) cmd->args.v =prepare_shell_cmd (&nargv, sargv); - cmd->pid =mingw_spawnvpe (cmd->args.v[0 ], cmd->args.v, (char **) cmd->env_array.v, - cmd->dir, fhin, fhout, fherr); + cmd->pid =mingw_spawnvpe (cmd->args.v[0 ], cmd->args.v, + (char **) cmd->env.v, + cmd->dir, fhin, fhout, fherr); failed_errno = errno;if (cmd->pid <0 && (!cmd->silent_exec_failure || errno !=ENOENT ))error_errno ("cannot spawn %s" , cmd->args.v[0 ]);
@@ -1031,7 +1032,7 @@ int run_command_v_opt_cd_env_tr2(const char **argv, int opt, const char *dir, cmd.close_object_store = opt &RUN_CLOSE_OBJECT_STORE ?1 :0 ; cmd.dir = dir;if (env) -strvec_pushv (&cmd.env_array, (const char **)env); +strvec_pushv (&cmd.env, (const char **)env); cmd.trace2_child_class = tr2_class;return run_command (&cmd); }
run-command.h +2 -2
@@ -73,7 +73,7 @@ struct child_process {* The memory in .env_array will be cleaned up automatically during * `finish_command` (or during `start_command` when it is unsuccessful). */ -struct strvec env_array; +struct strvec env;pid_t pid;int trace2_child_id;
@@ -146,7 +146,7 @@ struct child_process {#define CHILD_PROCESS_INIT { \ .args = STRVEC_INIT, \ - .env_array = STRVEC_INIT, \ + .env = STRVEC_INIT, \ }/**
sequencer.c +8 -8
@@ -1000,7 +1000,7 @@ static int run_git_commit(const char *defmsg,if (is_rebase_i (opts) && ((opts->committer_date_is_author_date && !opts->ignore_date) || !(!defmsg && (flags &AMEND_MSG ))) && -read_env_script (&cmd.env_array)) { +read_env_script (&cmd.env)) {const char *gpg_opt =gpg_sign_opt_quoted (opts); return error(_(staged_changes_advice),
@@ -1008,12 +1008,12 @@ static int run_git_commit(const char *defmsg, }if (opts->committer_date_is_author_date) -strvec_pushf (&cmd.env_array,"GIT_COMMITTER_DATE=%s" , +strvec_pushf (&cmd.env,"GIT_COMMITTER_DATE=%s" , opts->ignore_date ?"" : -author_date_from_env_array (&cmd.env_array)); +author_date_from_env_array (&cmd.env));if (opts->ignore_date) -strvec_push (&cmd.env_array,"GIT_AUTHOR_DATE=" ); +strvec_push (&cmd.env,"GIT_AUTHOR_DATE=" );strvec_push (&cmd.args,"commit" );
@@ -3911,7 +3911,7 @@ static int do_merge(struct repository *r,/* Octopus merge */ struct child_process cmd =CHILD_PROCESS_INIT ; -if (read_env_script (&cmd.env_array)) { +if (read_env_script (&cmd.env)) {const char *gpg_opt =gpg_sign_opt_quoted (opts); ret =error (_ (staged_changes_advice), gpg_opt, gpg_opt);
@@ -3919,12 +3919,12 @@ static int do_merge(struct repository *r, }if (opts->committer_date_is_author_date) -strvec_pushf (&cmd.env_array,"GIT_COMMITTER_DATE=%s" , +strvec_pushf (&cmd.env,"GIT_COMMITTER_DATE=%s" , opts->ignore_date ?"" : -author_date_from_env_array (&cmd.env_array)); +author_date_from_env_array (&cmd.env));if (opts->ignore_date) -strvec_push (&cmd.env_array,"GIT_AUTHOR_DATE=" ); +strvec_push (&cmd.env,"GIT_AUTHOR_DATE=" ); cmd.git_cmd =1 ;strvec_push (&cmd.args,"merge" );
submodule.c +19 -19
@@ -711,15 +711,15 @@ void show_submodule_inline_diff(struct diff_options *o, const char *path,if (!(dirty_submodule &DIRTY_SUBMODULE_MODIFIED ))strvec_push (&cp.args,oid_to_hex (new_oid)); -prepare_submodule_repo_env (&cp.env_array); +prepare_submodule_repo_env (&cp.env);if (!is_directory (path)) {/* fall back to absorbed git dir, if any */ if (!sub) goto done; cp.dir = sub->gitdir; -strvec_push (&cp.env_array,GIT_DIR_ENVIRONMENT "=." ); -strvec_push (&cp.env_array,GIT_WORK_TREE_ENVIRONMENT "=." ); +strvec_push (&cp.env,GIT_DIR_ENVIRONMENT "=." ); +strvec_push (&cp.env,GIT_WORK_TREE_ENVIRONMENT "=." ); }if (start_command (&cp)) {
@@ -1019,7 +1019,7 @@ static int submodule_has_commits(struct repository *r,oid_array_for_each_unique (commits, append_oid_to_argv, &cp.args);strvec_pushl (&cp.args,"--not" ,"--all" ,NULL ); -prepare_submodule_repo_env (&cp.env_array); +prepare_submodule_repo_env (&cp.env); cp.git_cmd =1 ; cp.no_stdin =1 ; cp.dir = path;
@@ -1060,7 +1060,7 @@ static int submodule_needs_pushing(struct repository *r,oid_array_for_each_unique (commits, append_oid_to_argv, &cp.args);strvec_pushl (&cp.args,"--not" ,"--remotes" ,"-n" ,"1" ,NULL ); -prepare_submodule_repo_env (&cp.env_array); +prepare_submodule_repo_env (&cp.env); cp.git_cmd =1 ; cp.no_stdin =1 ; cp.out =-1 ;
@@ -1146,7 +1146,7 @@ static int push_submodule(const char *path,strvec_push (&cp.args, rs->raw[i]); } -prepare_submodule_repo_env (&cp.env_array); +prepare_submodule_repo_env (&cp.env); cp.git_cmd =1 ; cp.no_stdin =1 ; cp.dir = path;
@@ -1177,7 +1177,7 @@ static void submodule_push_check(const char *path, const char *head,for (i =0 ; i < rs->raw_nr; i++)strvec_push (&cp.args, rs->raw[i]); -prepare_submodule_repo_env (&cp.env_array); +prepare_submodule_repo_env (&cp.env); cp.git_cmd =1 ; cp.no_stdin =1 ; cp.no_stdout =1 ;
@@ -1678,7 +1678,7 @@ static int get_next_submodule(struct child_process *cp, struct strbuf *err,child_process_init (cp); cp->dir = task->repo->gitdir; -prepare_submodule_repo_env_in_gitdir (&cp->env_array); +prepare_submodule_repo_env_in_gitdir (&cp->env); cp->git_cmd =1 ;strvec_init (&cp->args);if (task->git_args.nr)
@@ -1708,7 +1708,7 @@ static int get_next_submodule(struct child_process *cp, struct strbuf *err, spf->prefix, task->sub->path);child_process_init (cp); -prepare_submodule_repo_env_in_gitdir (&cp->env_array); +prepare_submodule_repo_env_in_gitdir (&cp->env); cp->git_cmd =1 ; cp->dir = task->repo->gitdir;
@@ -1882,7 +1882,7 @@ unsigned is_submodule_modified(const char *path, int ignore_untracked)if (ignore_untracked)strvec_push (&cp.args,"-uno" ); -prepare_submodule_repo_env (&cp.env_array); +prepare_submodule_repo_env (&cp.env); cp.git_cmd =1 ; cp.no_stdin =1 ; cp.out =-1 ;
@@ -1954,7 +1954,7 @@ int submodule_uses_gitfile(const char *path)"submodule" ,"foreach" ,"--quiet" ,"--recursive" , "test -f .git", NULL); -prepare_submodule_repo_env (&cp.env_array); +prepare_submodule_repo_env (&cp.env); cp.git_cmd =1 ; cp.no_stdin =1 ; cp.no_stderr =1 ;
@@ -1997,7 +1997,7 @@ int bad_to_remove_submodule(const char *path, unsigned flags)if (!(flags &SUBMODULE_REMOVAL_IGNORE_IGNORED_UNTRACKED ))strvec_push (&cp.args,"--ignored" ); -prepare_submodule_repo_env (&cp.env_array); +prepare_submodule_repo_env (&cp.env); cp.git_cmd =1 ; cp.no_stdin =1 ; cp.out =-1 ;
@@ -2052,7 +2052,7 @@ static int submodule_has_dirty_index(const struct submodule *sub) {struct child_process cp =CHILD_PROCESS_INIT ; -prepare_submodule_repo_env (&cp.env_array); +prepare_submodule_repo_env (&cp.env); cp.git_cmd =1 ; strvec_pushl(&cp.args, "diff-index", "--quiet",
@@ -2069,7 +2069,7 @@ static int submodule_has_dirty_index(const struct submodule *sub)static void submodule_reset_index (const char *path) {struct child_process cp =CHILD_PROCESS_INIT ; -prepare_submodule_repo_env (&cp.env_array); +prepare_submodule_repo_env (&cp.env); cp.git_cmd =1 ; cp.no_stdin =1 ;
@@ -2153,7 +2153,7 @@ int submodule_move_head(const char *path, } } -prepare_submodule_repo_env (&cp.env_array); +prepare_submodule_repo_env (&cp.env); cp.git_cmd =1 ; cp.no_stdin =1 ;
@@ -2191,7 +2191,7 @@ int submodule_move_head(const char *path, cp.no_stdin =1 ; cp.dir = path; -prepare_submodule_repo_env (&cp.env_array); +prepare_submodule_repo_env (&cp.env);strvec_pushl (&cp.args,"update-ref" ,"HEAD" ,"--no-deref" , new_head,NULL );
@@ -2374,7 +2374,7 @@ void absorb_git_dir_into_superproject(const char *path,strvec_pushl (&cp.args,"--super-prefix" , sb.buf,"submodule--helper" ,"absorb-git-dirs" ,NULL ); -prepare_submodule_repo_env (&cp.env_array); +prepare_submodule_repo_env (&cp.env);if (run_command (&cp))die (_ ("could not recurse into submodule '%s'" ), path);
@@ -2407,8 +2407,8 @@ int get_superproject_working_tree(struct strbuf *buf) subpath =relative_path (cwd, one_up.buf, &sb);strbuf_release (&one_up); -prepare_submodule_repo_env (&cp.env_array); -strvec_pop (&cp.env_array); +prepare_submodule_repo_env (&cp.env); +strvec_pop (&cp.env); strvec_pushl(&cp.args, "--literal-pathspecs", "-C", "..", "ls-files", "-z", "--stage", "--full-name", "--",
t/helper/test-run-command.c +1 -1
@@ -390,7 +390,7 @@ int cmd__run_command(int argc, const char **argv)while (!strcmp (argv[1 ],"env" )) {if (!argv[2 ])die ("env specifier without a value" ); -strvec_push (&proc.env_array, argv[2 ]); +strvec_push (&proc.env, argv[2 ]); argv +=2 ; argc -=2 ; }
trailer.c +1 -1
@@ -236,7 +236,7 @@ static char *apply_command(struct conf_info *conf, const char *arg)strbuf_replace (&cmd,TRAILER_ARG_STRING , arg);strvec_push (&cp.args, cmd.buf); } -strvec_pushv (&cp.env_array, (const char **)local_repo_env); +strvec_pushv (&cp.env, (const char **)local_repo_env); cp.no_stdin =1 ; cp.use_shell =1 ;
transport-helper.c +1 -1
@@ -135,7 +135,7 @@ static struct child_process *get_helper(struct transport *transport) helper->silent_exec_failure =1 ;if (have_git_dir ()) -strvec_pushf (&helper->env_array,"%s=%s" , +strvec_pushf (&helper->env,"%s=%s" ,GIT_DIR_ENVIRONMENT ,get_git_dir ()); helper->trace2_child_class = helper->args.v[0 ];/* "remote-<name>" */
wt-status.c +1 -1
@@ -982,7 +982,7 @@ static void wt_longstatus_print_submodule_summary(struct wt_status *s, int uncomstruct strbuf summary =STRBUF_INIT ;char *summary_content; -strvec_pushf (&sm_summary.env_array,"GIT_INDEX_FILE=%s" , s->index_file); +strvec_pushf (&sm_summary.env,"GIT_INDEX_FILE=%s" , s->index_file);strvec_push (&sm_summary.args,"submodule" );strvec_push (&sm_summary.args,"summary" );
Signature · 1 line
2.36.1.1103.gb3ecdfb3e6a
Re: [PATCH v3 1/2] run-command API: rename "env_array" to "env"
Quoted 13 lines · Ævar Arnfjörð Bjarmason
The rest of this is all a result of applying [1]:
* make
contrib/coccinelle/run_command.cocci.patch
* patch -p1 <contrib/coccinelle/run_command.cocci.patch
* git add -u1. cat
contrib/coccinelle/run_command.pending.cocci@@
structchild_processE;
@@
- E.env_array
+ E.env
Quoted 5 lines
@@ struct child_process *E; @@ - E->env_array + E->env
It makes sense to have this in the log message for documentation purposes. We have plenty of examples of renaming a symbol to another, like the simple ones in object_id.cocci, so adding this to the collection in contrib/coccinelle would not add much value.
Will replace. Thanks.
PATCH v3 2/2 run-command API users: use "env" not "env_array" in comments & names
In reply to Ævar Arnfjörð BjarmasonFollow-up on a preceding commit which changed all references to the "env_array" when referring to the "struct child_process" member. These changes are all unnecessary for the compiler, but help the code's human readers.
All the comments that referred to "env_array" have now been updated, as well as function names and variables that had "env_array" in their name, they now refer to "env".
In addition the "out" name for the submodule.h prototype was inconsistent with the function definition's use of "env_array" in submodule.c. Both of them use "env" now.
--- builtin/submodule--helper.c | 2 +- run-command.c | 6 +++--- run-command.h | 10 +++++----- sequencer.c | 6 +++--- submodule.h | 4 ++-- 5 files changed, 14 insertions(+), 14 deletions(-)
builtin/submodule--helper.c +1 -1
@@ -513,7 +513,7 @@ static void runcommand_in_submodule_cb(const struct cache_entry *list_item,* on windows. And since environment variables are * case-insensitive in windows, it interferes with the * existing PATH variable. Hence, to avoid that, we expose -* path via the args strvec and not via env_array. +* path via the args strvec and not via env. */ sq_quote_buf (&sb, path); strvec_pushf(&cp.args, "path=%s; %s",
run-command.c +3 -3
@@ -1816,16 +1816,16 @@ int run_auto_maintenance(int quiet)return run_command (&maint); } -void prepare_other_repo_env (struct strvec *env_array,const char *new_git_dir) +void prepare_other_repo_env (struct strvec *env,const char *new_git_dir) {const char *const *var;for (var = local_repo_env; *var; var++) {if (strcmp (*var,CONFIG_DATA_ENVIRONMENT ) &&strcmp (*var,CONFIG_COUNT_ENVIRONMENT )) -strvec_push (env_array, *var); +strvec_push (env, *var); } -strvec_pushf (env_array,"%s=%s" ,GIT_DIR_ENVIRONMENT , new_git_dir); +strvec_pushf (env,"%s=%s" ,GIT_DIR_ENVIRONMENT , new_git_dir); } enum start_bg_result start_bg_command(struct child_process *cmd,
run-command.h +5 -5
@@ -58,7 +58,7 @@ struct child_process {struct strvec args;/** -* Like .args the .env_array is a `struct strvec'. +* Like .args the .env is a `struct strvec'. * * To modify the environment of the sub-process, specify an array of * environment settings. Each string in the array manipulates the
@@ -70,7 +70,7 @@ struct child_process {* - If the string does not contain '=', it names an environment * variable that will be removed from the child process's environment. * -* The memory in .env_array will be cleaned up automatically during +* The memory in .env will be cleaned up automatically during * `finish_command` (or during `start_command` when it is unsuccessful). */ struct strvec env;
@@ -479,14 +479,14 @@ int run_processes_parallel_tr2(int n, get_next_task_fn, start_failure_fn, const char *tr2_category, const char *tr2_label);/** -* Convenience function which prepares env_array for a command to be run in a -* new repo. This adds all GIT_* environment variables to env_array with the +* Convenience function which prepares env for a command to be run in a +* new repo. This adds all GIT_* environment variables to env with the * exception of GIT_CONFIG_PARAMETERS and GIT_CONFIG_COUNT (which cause the * corresponding environment variables to be unset in the subprocess) and adds * an environment variable pointing to new_git_dir. See local_repo_env in * cache.h for more information. */ -void prepare_other_repo_env (struct strvec *env_array,const char *new_git_dir); +void prepare_other_repo_env (struct strvec *env,const char *new_git_dir);/** * Possible return values for start_bg_command().
sequencer.c +3 -3
@@ -919,7 +919,7 @@ static char *get_author(const char *message)return NULL ; } -static const char *author_date_from_env_array (const struct strvec *env) +static const char *author_date_from_env (const struct strvec *env) {int i;const char *date;
@@ -1011,7 +1011,7 @@ static int run_git_commit(const char *defmsg,strvec_pushf (&cmd.env,"GIT_COMMITTER_DATE=%s" , opts->ignore_date ?"" : -author_date_from_env_array (&cmd.env)); +author_date_from_env (&cmd.env));if (opts->ignore_date)strvec_push (&cmd.env,"GIT_AUTHOR_DATE=" );
@@ -3922,7 +3922,7 @@ static int do_merge(struct repository *r,strvec_pushf (&cmd.env,"GIT_COMMITTER_DATE=%s" , opts->ignore_date ?"" : -author_date_from_env_array (&cmd.env)); +author_date_from_env (&cmd.env));if (opts->ignore_date)strvec_push (&cmd.env,"GIT_AUTHOR_DATE=" );
submodule.h +2 -2
@@ -158,11 +158,11 @@ int submodule_move_head(const char *path,void submodule_unset_core_worktree (const struct submodule *sub);/* -* Prepare the "env_array" parameter of a "struct child_process" for executing +* Prepare the "env" parameter of a "struct child_process" for executing * a submodule by clearing any repo-specific environment variables, but * retaining any config in the environment. */ -void prepare_submodule_repo_env (struct strvec *out); +void prepare_submodule_repo_env (struct strvec *env);#define ABSORB_GITDIR_RECURSE_SUBMODULES (1<<0) void absorb_git_dir_into_superproject(const char *path,
Signature · 1 line
2.36.1.1103.gb3ecdfb3e6a
ab/make-dependency (was: What's cooking in git.git (Dec 2021, #04; Wed, 15))
In reply to Junio C HamanoQuoted 26 lines · Junio C Hamano
* ab/make-dependency (2021-11-18) 24 commits
-Makefile: move ".SUFFIXES" rule to shared.mak
-Makefile: define $(LIB_H) in terms of $(FIND_SOURCE_FILES)
-Makefile: disable GNU make built-in wildcard rules
-Makefile: use $(file) I/O instead of "FORCE" when possible
-Makefile: correct the dependency graph ofhook-list.h
- Makefiles: add and use wildcard "mkdir -p" template
-Makefile: use $(wspfx) for $(QUIET...) in shared.mak
-Makefile: add "$(QUIET)" boilerplate to shared.mak
-Makefile: add a "TRACK_template" for GIT-*{FLAGS,DEFINES,...}
-Makefile: re-add and use the "shellquote" macros
-Makefile: move $(comma), $(empty) and $(space) to shared.mak
- Makefiles: add "shared.mak", move ".DELETE_ON_ERROR" to it
-Makefile: stop needing @@GIT_VERSION@@ in *.perl scripts
-Makefile: create a GIT-PYTHON-DEFINES, like "PERL"
-Makefile: correct "GIT-PERL-{DEFINES,HEADER}" dependency graph
-Makefile: adjust Perl-related comments & whitespace
-Makefile: change "ifndefNO_PERL" to "ifdefNO_PERL"
-Makefile: guard Perl-only variable assignments
-Makefile: remove "mv $@ $@+" dance redundant to .DELETE_ON_ERROR
-Makefile: clean perl/build/ even with NO_PERL=Y
-Makefile: use "=" not ":=" for po/* and perl/*
-Makefile: don't set up "perl/build" rules under NO_PERL=Y
-Makefile: don't invoke msgfmt with --statistics
- Merge branch 'ab/sh-retire-helper-functions' into ab/make-dependency
Quoted 6 lines
Dependency clean-up.
Needs review.
There are some comments on earlier rounds; the latest one needs a serious review or at least Acks from past commentors.
source: <[email protected]>
I think it's best to drop this rather large topic for now.
I started re-rolling it with improvements to address your shell escaping comments, and ended up with a much better end-state, but it's now at north of 30 commits locally.
So I've split it up and have some incoming patches. Not for all of it, just starting with some of the more urgent than not fixes & more trivial & easy to review changes, or around 1/2 of what's quoted above.
I'll then submit the rest sometime after that lands.
Quoted 1 line
* xw/am-empty (2021-12-07) 3 commits
The alias of my name should be "pwxu" but not "xw".
Quoted 5 lines
- am: support --allow-empty to record specific empty patches
- am: support --empty=<option> to handle empty patches
- doc: git-format-patch: describe the option --always"git am" learns "--empty=(die|drop|keep)" option to tweak what is
This should be 'learns "--empty=(stop|drop|keep)"'
Quoted 4 lines
done to a piece of e-mail without a patch in it.
Almost there.
source: <[email protected]>
Quoted 4 lines · Aleen 徐沛文
Quoted 2 lines
* xw/am-empty (2021-12-07) 3 commits
The alias of my name should be "pwxu" but not "xw".
This isn't an alias. These are the initials of the first and last name, so only 2 ascii characters.
Maybe "px" or something else are better initials though. Your suggestions are welcome!