summaryrefslogtreecommitdiff
path: root/builtin
AgeCommit message (Collapse)Author
2024-02-14Merge branch 'js/check-null-from-read-object-file'Junio C Hamano
The code paths that call repo_read_object_file() have been tightened to react to errors. * js/check-null-from-read-object-file: Always check the return value of `repo_read_object_file()`
2024-02-14Merge branch 'rs/receive-pack-remove-find-header'Junio C Hamano
Code simplification. * rs/receive-pack-remove-find-header: receive-pack: use find_commit_header() in check_nonce() receive-pack: use find_commit_header() in check_cert_push_options()
2024-02-12Merge branch 'tb/multi-pack-reuse-experiment'Junio C Hamano
Setting `feature.experimental` opts the user into multi-pack reuse experiment * tb/multi-pack-reuse-experiment: pack-objects: enable multi-pack reuse via `feature.experimental` t5332-multi-pack-reuse.sh: extract pack-objects helper functions
2024-02-12Merge branch 'pw/show-ref-pseudorefs'Junio C Hamano
"git show-ref --verify" did not show things like "CHERRY_PICK_HEAD", which has been corrected. * pw/show-ref-pseudorefs: t1400: use show-ref to check pseudorefs show-ref --verify: accept pseudorefs
2024-02-12Merge branch 'ps/report-failure-from-git-stash'Junio C Hamano
"git stash" sometimes was silent even when it failed due to unwritable index file, which has been corrected. * ps/report-failure-from-git-stash: builtin/stash: report failure to write to index
2024-02-12Merge branch 'jc/sign-buffer-failure-propagation-fix'Junio C Hamano
A failed "git tag -s" did not necessarily result in an error depending on the crypto backend, which has been corrected. * jc/sign-buffer-failure-propagation-fix: ssh signing: signal an error with a negative return value tag: fix sign_buffer() call to create a signed tag
2024-02-12receive-pack: use find_commit_header() in check_nonce()René Scharfe
Use the public function find_commit_header() and remove find_header(), as it becomes unused. This is safe and appropriate because we pass the NUL-terminated payload buffer to check_nonce() instead of its start and length. The underlying strbuf push_cert cannot contain NULs, as it is built using strbuf_addstr(), only. We no longer need to call strlen(), as find_commit_header() returns the length of nonce already. Signed-off-by: René Scharfe <l.s.r@web.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2024-02-09receive-pack: use find_commit_header() in check_cert_push_options()René Scharfe
Use the public function find_commit_header() instead of find_header() to simplify the code. This is possible and safe because we're operating on a strbuf, which is always NUL-terminated, so there is no risk of running over the end of the buffer. It cannot contain NUL within the buffer, as it is built using strbuf_addstr(), only. The string comparison becomes more complicated because we need to check for NUL explicitly after comparing the length-limited option, but on the flip side we don't need to clean up allocations or track the remaining buffer length. Signed-off-by: René Scharfe <l.s.r@web.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2024-02-08Merge branch 'jk/index-pack-lsan-false-positive-fix' into maint-2.43Junio C Hamano
Fix false positive reported by leak sanitizer. * jk/index-pack-lsan-false-positive-fix: index-pack: spawn threads atomically
2024-02-08Merge branch 'rs/fast-import-simplify-mempool-allocation' into maint-2.43Junio C Hamano
Code simplification. * rs/fast-import-simplify-mempool-allocation: fast-import: use mem_pool_calloc()
2024-02-08Merge branch 'en/header-cleanup' into maint-2.43Junio C Hamano
Remove unused header "#include". * en/header-cleanup: treewide: remove unnecessary includes in source files treewide: add direct includes currently only pulled in transitively trace2/tr2_tls.h: remove unnecessary include submodule-config.h: remove unnecessary include pkt-line.h: remove unnecessary include line-log.h: remove unnecessary include http.h: remove unnecessary include fsmonitor--daemon.h: remove unnecessary includes blame.h: remove unnecessary includes archive.h: remove unnecessary include treewide: remove unnecessary includes in source files treewide: remove unnecessary includes from header files
2024-02-08Merge branch 'jc/orphan-unborn' into maint-2.43Junio C Hamano
Doc updates to clarify what an "unborn branch" means. * jc/orphan-unborn: orphan/unborn: fix use of 'orphan' in end-user facing messages orphan/unborn: add to the glossary and use them consistently
2024-02-08Merge branch 'la/trailer-cleanups' into maint-2.43Junio C Hamano
Code clean-up. * la/trailer-cleanups: trailer: use offsets for trailer_start/trailer_end trailer: find the end of the log message commit: ignore_non_trailer computes number of bytes to ignore
2024-02-08Merge branch 'jc/retire-cas-opt-name-constant' into maint-2.43Junio C Hamano
Code clean-up. * jc/retire-cas-opt-name-constant: remote.h: retire CAS_OPT_NAME
2024-02-08Merge branch 'rs/rebase-use-strvec-pushf' into maint-2.43Junio C Hamano
Code clean-up. * rs/rebase-use-strvec-pushf: rebase: use strvec_pushf() for format-patch revisions
2024-02-08Merge branch 'jk/config-cleanup' into maint-2.43Junio C Hamano
Code clean-up around use of configuration variables. * jk/config-cleanup: sequencer: simplify away extra git_config_string() call gpg-interface: drop pointless config_error_nonbool() checks push: drop confusing configset/callback redundancy config: use git_config_string() for core.checkRoundTripEncoding diff: give more detailed messages for bogus diff.* config config: use config_error_nonbool() instead of custom messages imap-send: don't use git_die_config() inside callback git_xmerge_config(): prefer error() to die() config: reject bogus values for core.checkstat
2024-02-08Merge branch 'rs/incompatible-options-messages' into maint-2.43Junio C Hamano
Clean-up code that handles combinations of incompatible options. * rs/incompatible-options-messages: worktree: simplify incompatibility message for --orphan and commit-ish worktree: standardize incompatibility messages clean: factorize incompatibility message revision, rev-parse: factorize incompatibility messages about - -exclude-hidden revision: use die_for_incompatible_opt3() for - -graph/--reverse/--walk-reflogs repack: use die_for_incompatible_opt3() for -A/-k/--cruft push: use die_for_incompatible_opt4() for - -delete/--tags/--all/--mirror
2024-02-08Merge branch 'rs/column-leakfix' into maint-2.43Junio C Hamano
Leakfix. * rs/column-leakfix: column: release strbuf and string_list after use
2024-02-08Merge branch 'rs/i18n-cannot-be-used-together' into maint-2.43Junio C Hamano
Clean-up code that handles combinations of incompatible options. * rs/i18n-cannot-be-used-together: i18n: factorize even more 'incompatible options' messages
2024-02-08Merge branch 'jb/reflog-expire-delete-dry-run-options' into maint-2.43Junio C Hamano
Command line parsing fix for "git reflog". * jb/reflog-expire-delete-dry-run-options: builtin/reflog.c: fix dry-run option short name
2024-02-08Merge branch 'jc/sparse-checkout-set-default-fix' into maint-2.43Junio C Hamano
"git sparse-checkout set" added default patterns even when the patterns are being fed from the standard input, which has been corrected. * jc/sparse-checkout-set-default-fix: sparse-checkout: use default patterns for 'set' only !stdin
2024-02-08Merge branch 'jx/fetch-atomic-error-message-fix' into maint-2.43Junio C Hamano
"git fetch --atomic" issued an unnecessary empty error message, which has been corrected. cf. <ZX__e7VjyLXIl-uV@tanuki> * jx/fetch-atomic-error-message-fix: fetch: no redundant error message for atomic fetch t5574: test porcelain output of atomic fetch
2024-02-08Merge branch 'rs/show-ref-incompatible-options' into maint-2.43Junio C Hamano
Code clean-up for sanity checking of command line options for "git show-ref". * rs/show-ref-incompatible-options: show-ref: use die_for_incompatible_opt3()
2024-02-08Merge branch 'jk/implicit-true' into maint-2.43Junio C Hamano
Some codepaths did not correctly parse configuration variables specified with valueless "true", which has been corrected. * jk/implicit-true: fsck: handle NULL value when parsing message config trailer: handle NULL value when parsing trailer-specific config submodule: handle NULL value when parsing submodule.*.branch help: handle NULL value for alias.* config trace2: handle NULL values in tr2_sysenv config callback setup: handle NULL value when parsing extensions config: handle NULL value when parsing non-bools
2024-02-08Merge branch 'jk/bisect-reset-fix' into maint-2.43Junio C Hamano
"git bisect reset" has been taught to clean up state files and refs even when BISECT_START file is gone. * jk/bisect-reset-fix: bisect: always clean on reset
2024-02-08Merge branch 'ja/doc-placeholders-fix'Junio C Hamano
Docfix. * ja/doc-placeholders-fix: doc: enforce placeholders in documentation doc: enforce dashes in placeholders
2024-02-08Merge branch 'jc/index-pack-fsck-levels'Junio C Hamano
The "--fsck-objects" option of "git index-pack" now can take the optional parameter to tweak severity of different fsck errors. * jc/index-pack-fsck-levels: index-pack: --fsck-objects to take an optional argument for fsck msgs index-pack: test and document --strict=<msg-id>=<severity>...
2024-02-07tag: fix sign_buffer() call to create a signed tagJunio C Hamano
The command "git tag -s" internally calls sign_buffer() to make a cryptographic signature using the chosen backend like GPG and SSH. The internal helper functions used by "git tag" implementation seem to use a "negative return values are errors, zero or positive return values are not" convention, and there are places (e.g., verify_tag() that calls gpg_verify_tag()) that these internal helper functions translate return values that signal errors to conform to this convention, but do_sign() that calls sign_buffer() forgets to do so. Fix it, so that a failed call to sign_buffer() that can return the exit status from pipe_command() will not be overlooked. Reported-by: Sergey Kosukhin <skosukhin@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2024-02-07show-ref --verify: accept pseudorefsPhillip Wood
"git show-ref --verify" is useful for scripts that want to look up a fully qualified refname without falling back to the DWIM rules used by "git rev-parse" rules when the ref does not exist. Currently it will only accept "HEAD" or a refname beginning with "refs/". Running git show-ref --verify CHERRY_PICK_HEAD will always result in fatal: 'CHERRY_PICK_HEAD' - not a valid ref even when CHERRY_PICK_HEAD exists. By calling refname_is_safe() instead of comparing the refname to "HEAD" we can accept all one-level refs that contain only uppercase ascii letters and underscores. Signed-off-by: Phillip Wood <phillip.wood@dunelm.org.uk> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2024-02-06Merge branch 'jc/comment-style-fixes'Junio C Hamano
Rewrite //-comments to /* comments */ in files whose comments prevalently use the latter. * jc/comment-style-fixes: reftable/pq_test: comment style fix merge-ort.c: comment style fix builtin/worktree: comment style fixes
2024-02-06Merge branch 'kh/maintenance-use-xdg-when-it-should'Junio C Hamano
Comment fix. * kh/maintenance-use-xdg-when-it-should: config: add back code comment
2024-02-06builtin/stash: report failure to write to indexPatrick Steinhardt
The git-stash(1) command needs to write to the index for many of its operations. When the index is locked by a concurrent writer it will thus fail to operate, which is expected. What is not expected though is that we do not print any error message at all in this case. The user can thus easily miss the fact that the command didn't do what they expected it to do and would be left wondering why that is. Fix this bug and report failures to write to the index. Add tests for the subcommands which hit the respective code paths. While at it, unify error messages when writing to the index fails. The chosen error message is already used in "builtin/stash.c". Reported-by: moti sd <motisd8@gmail.com> Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2024-02-06Always check the return value of `repo_read_object_file()`Johannes Schindelin
There are a couple of places in Git's source code where the return value is not checked. As a consequence, they are susceptible to segmentation faults. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2024-02-05pack-objects: enable multi-pack reuse via `feature.experimental`Taylor Blau
Now that multi-pack reuse is supported, enable it via the feature.experimental configuration in addition to the classic `pack.allowPackReuse`. This will allow more users to experiment with the new behavior who might not otherwise be aware of the existing `pack.allowPackReuse` configuration option. The enum with values NO_PACK_REUSE, SINGLE_PACK_REUSE, and MULTI_PACK_REUSE is defined statically in builtin/pack-objects.c's compilation unit. We could hoist that enum into a scope visible from the repository_settings struct, and then use that enum value in pack-objects. Instead, define a single int that indicates what pack-objects's default value should be to avoid additional unnecessary code movement. Though `feature.experimental` implies `pack.allowPackReuse=multi`, this can still be overridden by explicitly setting the latter configuration to either "single" or "false". Tests covering all of these cases are showin t5332. Signed-off-by: Taylor Blau <me@ttaylorr.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2024-02-01index-pack: --fsck-objects to take an optional argument for fsck msgsJohn Cai
git-index-pack has a --strict option that can take an optional argument to provide a list of fsck issues to change their severity. --fsck-objects does not have such a utility, which would be useful if one would like to be more lenient or strict on data integrity in a repository. Like --strict, allow --fsck-objects to also take a list of fsck msgs to change the severity. Remove the "For internal use only" note for --fsck-objects, and document the option. This won't often be used by the normal end user, but it turns out it is useful for Git forges like GitLab. Reviewed-by: Christian Couder <christian.couder@gmail.com> Signed-off-by: John Cai <johncai86@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2024-02-01index-pack: test and document --strict=<msg-id>=<severity>...John Cai
5d477a334a (fsck (receive-pack): allow demoting errors to warnings, 2015-06-22) allowed a list of fsck msg to downgrade to be passed to --strict. However this is a hidden argument that was not documented nor tested. Though it is true that most users would not call this option directly, (nor use index-pack for that matter) it is still useful to document and test this feature. Reviewed-by: Christian Couder <christian.couder@gmail.com> Signed-off-by: John Cai <johncai86@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2024-01-29Merge branch 'ps/not-so-many-refs-are-special'Junio C Hamano
Define "special ref" as a very narrow set that consists of FETCH_HEAD and MERGE_HEAD, and clarify everything else that used to be classified as such are actually just pseudorefs. * ps/not-so-many-refs-are-special: Documentation: add "special refs" to the glossary refs: redefine special refs refs: convert MERGE_AUTOSTASH to become a normal pseudo-ref sequencer: introduce functions to handle autostashes via refs refs: convert AUTO_MERGE to become a normal pseudo-ref sequencer: delete REBASE_HEAD in correct repo when picking commits sequencer: clean up pseudo refs with REF_NO_DEREF
2024-01-29Merge branch 'tc/show-ref-exists-fix'Junio C Hamano
Update to a new feature recently added, "git show-ref --exists". * tc/show-ref-exists-fix: builtin/show-ref: treat directory as non-existing in --exists
2024-01-29builtin/worktree: comment style fixesJunio C Hamano
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2024-01-29config: add back code commentKristoffer Haugsbakk
c15129b699 (config: factor out global config file retrieval, 2024-01-18) was a refactor that moved some of the code in this function to `config.c`. However, in the process I managed to drop this code comment which explains `$HOME not set`. Signed-off-by: Kristoffer Haugsbakk <code@khaugsbakk.name> Acked-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2024-01-26Merge branch 'kh/maintenance-use-xdg-when-it-should'Junio C Hamano
When $HOME/.gitignore is missing but XDG config file available, we should write into the latter, not former. "git gc" and "git maintenance" wrote into a wrong "global config" file, which have been corrected. * kh/maintenance-use-xdg-when-it-should: maintenance: use XDG config if it exists config: factor out global config file retrieval config: rename global config function config: format newlines
2024-01-26Merge branch 'ps/worktree-refdb-initialization'Junio C Hamano
Instead of manually creating refs/ hierarchy on disk upon a creation of a secondary worktree, which is only usable via the files backend, use the refs API to populate it. * ps/worktree-refdb-initialization: builtin/worktree: create refdb via ref backend worktree: expose interface to look up worktree by name builtin/worktree: move setup of commondir file earlier refs/files: skip creation of "refs/{heads,tags}" for worktrees setup: move creation of "refs/" into the files backend refs: prepare `refs_init_db()` for initializing worktree refs
2024-01-26Merge branch 'rj/advice-delete-branch-not-fully-merged'Junio C Hamano
The error message given when "git branch -d branch" fails due to commits unique to the branch has been split into an error and a new conditional advice message. * rj/advice-delete-branch-not-fully-merged: branch: make the advice to force-deleting a conditional one advice: fix an unexpected leading space advice: sort the advice related lists
2024-01-26Merge branch 'es/some-up-to-date-messages-must-stay'Junio C Hamano
Comment updates to help developers not to attempt to modify messages from plumbing commands that must stay constant. It might make sense to reassess the plumbing needs every few years, but that should be done as a separate effort. * es/some-up-to-date-messages-must-stay: messages: mark some strings with "up-to-date" not to touch
2024-01-19Merge branch 'tb/fetch-all-configuration'Junio C Hamano
"git fetch" learned to pay attention to "fetch.all" configuration variable, which pretends as if "--all" was passed from the command line when no remote parameter was given. * tb/fetch-all-configuration: fetch: add new config option fetch.all
2024-01-19refs: convert MERGE_AUTOSTASH to become a normal pseudo-refPatrick Steinhardt
Similar to the preceding conversion of the AUTO_MERGE pseudo-ref, let's convert the MERGE_AUTOSTASH ref to become a normal pseudo-ref as well. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2024-01-19refs: convert AUTO_MERGE to become a normal pseudo-refPatrick Steinhardt
In 70c70de616 (refs: complete list of special refs, 2023-12-14) we have inrtoduced a new `is_special_ref()` function that classifies some refs as being special. The rule is that special refs are exclusively read and written via the filesystem directly, whereas normal refs exclucsively go via the refs API. The intent of that commit was to record the status quo so that we know to route reads of such special refs consistently. Eventually, the list should be reduced to its bare minimum of refs which really are special, namely FETCH_HEAD and MERGE_HEAD. Follow up on this promise and convert the AUTO_MERGE ref to become a normal pseudo-ref by using the refs API to both read and write it instead of accessing the filesystem directly. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2024-01-18maintenance: use XDG config if it existsKristoffer Haugsbakk
`git maintenance register` registers the repository in the user's global config. `$XDG_CONFIG_HOME/git/config` is supposed to be used if `~/.gitconfig` does not exist. However, this command creates a `~/.gitconfig` file and writes to that one even though the XDG variant exists. This used to work correctly until 50a044f1e4 (gc: replace config subprocesses with API calls, 2022-09-27), when the command started calling the config API instead of git-config(1). Also change `unregister` accordingly. Signed-off-by: Kristoffer Haugsbakk <code@khaugsbakk.name> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2024-01-18config: factor out global config file retrievalKristoffer Haugsbakk
Factor out code that retrieves the global config file so that we can use it in `gc.c` as well. Use the old name from the previous commit since this function acts functionally the same as `git_system_config` but for “global”. Signed-off-by: Kristoffer Haugsbakk <code@khaugsbakk.name> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2024-01-18config: rename global config functionKristoffer Haugsbakk
Rename this function to a more descriptive name since we want to use the existing name for a new function. Signed-off-by: Kristoffer Haugsbakk <code@khaugsbakk.name> Signed-off-by: Junio C Hamano <gitster@pobox.com>