summaryrefslogtreecommitdiff
path: root/Documentation
AgeCommit message (Collapse)Author
2024-03-29add-patch: introduce 'p' in interactive-patchRubén Justo
Shortly we're going make interactive-patch stop printing automatically the hunk under certain circumstances. Let's introduce a new option to allow the user to explicitly request the printing. Signed-off-by: Rubén Justo <rjusto@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2024-03-28The twelfth batchJunio C Hamano
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2024-03-28Merge branch 'jc/show-untracked-false'Junio C Hamano
The status.showUntrackedFiles configuration variable had a name that tempts users to set a Boolean value expressed in our usual "false", "off", and "0", but it only took "no". This has been corrected so "true" and its synonyms are taken as "normal", while "false" and its synonyms are taken as "no". * jc/show-untracked-false: status: allow --untracked=false and friends status: unify parsing of --untracked= and status.showUntrackedFiles
2024-03-28Merge branch 'ph/diff-src-dst-prefix-config'Junio C Hamano
"git diff" and friends learned two extra configuration variables, diff.srcPrefix and diff.dstPrefix. * ph/diff-src-dst-prefix-config: diff.*Prefix: use camelCase in the doc and test titles diff: add diff.srcPrefix and diff.dstPrefix configuration variables
2024-03-28Merge branch 'eb/hash-transition'Junio C Hamano
Work to support a repository that work with both SHA-1 and SHA-256 hash algorithms has started. * eb/hash-transition: (30 commits) t1016-compatObjectFormat: add tests to verify the conversion between objects t1006: test oid compatibility with cat-file t1006: rename sha1 to oid test-lib: compute the compatibility hash so tests may use it builtin/ls-tree: let the oid determine the output algorithm object-file: handle compat objects in check_object_signature tree-walk: init_tree_desc take an oid to get the hash algorithm builtin/cat-file: let the oid determine the output algorithm rev-parse: add an --output-object-format parameter repository: implement extensions.compatObjectFormat object-file: update object_info_extended to reencode objects object-file-convert: convert commits that embed signed tags object-file-convert: convert commit objects when writing object-file-convert: don't leak when converting tag objects object-file-convert: convert tag objects when writing object-file-convert: add a function to convert trees between algorithms object: factor out parse_mode out of fast-import and tree-walk into in object.h cache: add a function to read an OID of a specific algorithm tag: sign both hashes commit: export add_header_signature to support handling signatures on tags ...
2024-03-27MyFirstObjectWalk: add stderr to pipe processingDirk Gouders
In the last chapter of this document, pipes are used in commands to filter out the first/last trace messages. But according to git(1), trace messages are sent to stderr if GIT_TRACE is set to '1', so those commands do not produce the described results. Fix this by redirecting stderr to stdout prior to the pipe operator to additionally connect stderr to stdin of the latter command. Further, while reviewing the above fix, Kyle Lippincott noticed a second issue with the second of the examples: a missing slash in the executable path "./bin-wrappers git". Add the missing slash. Helped-by: Kyle Lippincott <spectral@google.com> Signed-off-by: Dirk Gouders <dirk@gouders.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2024-03-27MyFirstObjectWalk: fix description for counting omitted objectsDirk Gouders
Before the changes to count omitted objects, the function traverse_commit_list() was used and its call cannot be changed to pass a pointer to an oidset to record omitted objects. Fix the text to clarify that we now use another traversal function to be able to pass the pointer to the introduced oidset. Helped-by: Kyle Lippincott <spectral@google.com> Signed-off-by: Dirk Gouders <dirk@gouders.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2024-03-27MyFirstObjectWalk: fix filtered object walkDirk Gouders
Commit f0d2f84919 (MyFirstObjectWalk: update recommended usage, 2022-03-09) changed a call of parse_list_objects_filter() in a way that probably never worked: parse_list_objects_filter() always needed a pointer as its first argument. Fix this by removing the CALLOC_ARRAY and passing the address of rev->filter to parse_list_objects_filter() in accordance to such a call in revisions.c, for example. Signed-off-by: Dirk Gouders <dirk@gouders.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2024-03-27MyFirstObjectWalk: fix misspelled "builtins/"Dirk Gouders
pack-objects.c resides in builtin/ (not builtins/). Fix the misspelled directory name. Signed-off-by: Dirk Gouders <dirk@gouders.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2024-03-27MyFirstObjectWalk: use additional arg in config_fn_tDirk Gouders
Commit a4e7e317f8 (config: add ctx arg to config_fn_t, 2023-06-28) added a fourth argument to config_fn_t but did not change relevant function calls in Documentation/MyFirstObjectWalk.txt. Fix those calls and the example git_walken_config() to use that additional argument. Signed-off-by: Dirk Gouders <dirk@gouders.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2024-03-27config: add core.commentStringJeff King
The core.commentChar code recently learned to accept more than a single ASCII character. But using it is annoying with multiple versions of Git, since older ones will reject it outright: $ git.v2.44.0 -c core.commentchar=foo stripspace -s error: core.commentChar should only be one ASCII character fatal: unable to parse 'core.commentchar' from command-line config Let's add an alias core.commentString. That's arguably a better name anyway, since we now can handle strings, and it makes it possible to have a config that works reasonably with both old and new versions of Git (see the example in the documentation). This is strictly an alias, so there's not much point in adding duplicate tests; I added a single one to t0030 that exercises the alias code. Note also that the error messages for invalid values will now show the variable the config parser handed us, and thus will be normalized to lowercase (rather than camelcase). A few tests in t0030 are adjusted to match. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2024-03-26SubmittingPatches: release-notes entry experimentJunio C Hamano
The "What's cooking" report lists the topics in flight, with a short paragraph descibing what they are about. Once written, the description is automatically picked up from the "What's cooking" report and used in the commit log message of the merge commit when the topic is merged into integration branches. These commit log messges of the merge commits are then propagated to the release notes. It has been the maintainer's task to prepare these entries in the "What's cooking" report. Even though the original author of a topic may be in the best position to write the initial description of a topic, we so far lacked a formal channel for the author to suggest what description to use. The usual procedure has been for the author to see the topic described in "What's cooking" report, and then either complain about inaccurate explanation and/or offer a rewrite. Let's try an experiment to optionally let the author propose the one paragraph description when the topic is submitted. Pick the cover letter as the logical place to do so, and describe an experimental workflow in the SubmittingPatches document. Signed-off-by: Junio C Hamano <gitster@pobox.com>
2024-03-25cherry-pick: add `--empty` for more robust redundant commit handlingBrian Lyles
As with git-rebase(1) and git-am(1), git-cherry-pick(1) can result in a commit being made redundant if the content from the picked commit is already present in the target history. However, git-cherry-pick(1) does not have the same options available that git-rebase(1) and git-am(1) have. There are three things that can be done with these redundant commits: drop them, keep them, or have the cherry-pick stop and wait for the user to take an action. git-rebase(1) has the `--empty` option added in commit e98c4269c8 (rebase (interactive-backend): fix handling of commits that become empty, 2020-02-15), which handles all three of these scenarios. Similarly, git-am(1) got its own `--empty` in 7c096b8d61 (am: support --empty=<option> to handle empty patches, 2021-12-09). git-cherry-pick(1), on the other hand, only supports two of the three possiblities: Keep the redundant commits via `--keep-redundant-commits`, or have the cherry-pick fail by not specifying that option. There is no way to automatically drop redundant commits. In order to bring git-cherry-pick(1) more in-line with git-rebase(1) and git-am(1), this commit adds an `--empty` option to git-cherry-pick(1). It has the same three options (keep, drop, and stop), and largely behaves the same. The notable difference is that for git-cherry-pick(1), the default will be `stop`, which maintains the current behavior when the option is not specified. Like the existing `--keep-redundant-commits`, `--empty=keep` will imply `--allow-empty`. The `--keep-redundant-commits` option will be documented as a deprecated synonym of `--empty=keep`, and will be supported for backwards compatibility for the time being. Signed-off-by: Brian Lyles <brianmlyles@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2024-03-25rebase: update `--empty=ask` to `--empty=stop`Brian Lyles
When git-am(1) got its own `--empty` option in 7c096b8d61 (am: support --empty=<option> to handle empty patches, 2021-12-09), `stop` was used instead of `ask`. `stop` is a more accurate term for describing what really happens, and consistency is good. Update git-rebase(1) to also use `stop`, while keeping `ask` as a deprecated synonym. Update the tests to primarily use `stop`, but also ensure that `ask` is still allowed. In a future commit, we'll be adding a new `--empty` option for git-cherry-pick(1) as well, making the consistency even more relevant. Reported-by: Elijah Newren <newren@gmail.com> Signed-off-by: Brian Lyles <brianmlyles@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2024-03-25docs: clean up `--empty` formatting in git-rebase(1) and git-am(1)Brian Lyles
Both of these pages document very similar `--empty` options, but with different styles. The exact behavior of these `--empty` options differs somewhat, but consistent styling in the docs is still beneficial. This commit aims to make them more consistent. Break the possible values for `--empty` into separate sections for readability. Alphabetical order is chosen for consistency. In a future commit, we'll be documenting a new `--empty` option for git-cherry-pick(1), making the consistency even more relevant. Signed-off-by: Brian Lyles <brianmlyles@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2024-03-25docs: address inaccurate `--empty` default with `--exec`Brian Lyles
The documentation for git-rebase(1) indicates that using the `--exec` option will use `--empty=drop`. This is inaccurate: when `--interactive` is not explicitly provided, `--exec` results in `--empty=keep` behaviors. Correctly indicate the behavior of `--exec` using `--empty=keep` when `--interactive` is not specified. Reported-by: Phillip Wood <phillip.wood@dunelm.org.uk> Signed-off-by: Brian Lyles <brianmlyles@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2024-03-25The eleventh batchJunio C Hamano
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2024-03-25Merge branch 'bl/doc-key-val-sep-fix'Junio C Hamano
The documentation for "%(trailers[:options])" placeholder in the "--pretty" option of commands in the "git log" family has been updated. * bl/doc-key-val-sep-fix: docs: adjust trailer `separator` and `key_value_separator` language docs: correct trailer `key_value_separator` description
2024-03-25Merge branch 'bl/doc-config-fixes'Junio C Hamano
A few typoes in "git config --help" have been corrected. * bl/doc-config-fixes: docs: fix typo in git-config `--default` docs: clarify file options in git-config `--edit`
2024-03-25Merge branch 'ja/doc-formatting-fix'Junio C Hamano
Documentation mark-up fix. * ja/doc-formatting-fix: doc: fix some placeholders formating doc: format alternatives in synopsis
2024-03-25Merge branch 'bb/sh-scripts-cleanup'Junio C Hamano
Shell scripts clean-up. * bb/sh-scripts-cleanup: (22 commits) git-quiltimport: avoid an unnecessary subshell contrib/coverage-diff: avoid redundant pipelines t/t9*: merge "grep | sed" pipelines t/t8*: merge "grep | sed" pipelines t/t5*: merge a "grep | sed" pipeline t/t4*: merge a "grep | sed" pipeline t/t3*: merge a "grep | awk" pipeline t/t1*: merge a "grep | sed" pipeline t/t9*: avoid redundant uses of cat t/t8*: avoid redundant use of cat t/t7*: avoid redundant use of cat t/t6*: avoid redundant uses of cat t/t5*: avoid redundant uses of cat t/t4*: avoid redundant uses of cat t/t3*: avoid redundant uses of cat t/t1*: avoid redundant uses of cat t/t0*: avoid redundant uses of cat t/perf: avoid redundant use of cat t/annotate-tests.sh: avoid redundant use of cat t/lib-cvs.sh: avoid redundant use of cat ...
2024-03-25Merge branch 'js/bugreport-no-suffix-fix'Junio C Hamano
"git bugreport --no-suffix" was not supported and instead segfaulted, which has been corrected. * js/bugreport-no-suffix-fix: bugreport.c: fix a crash in `git bugreport` with `--no-suffix` option
2024-03-25grep docs: describe --no-index further and improve formatting a bitDragan Simic
Improve the description of --no-index, to make it more clear to the users what this option actually does under the hood, and what's its purpose. Describe the dependency between --no-index and either of the --cached and --untracked options, which cannot be used together. As part of that, shuffle a couple of the options, to make the documentation flow a bit better, because it makes more sense to describe first the options that have something in common, and to after that describe an option that does something differently. In more detail, --cached and --untracked both leave git-grep(1) in the usual state, in which it treats the directory as a local git repository, unlike --no-index that makes git-grep(1) treat the directory not as a git repository. While there, improve the descriptions of grep worker threads a bit, to give them better context. Adjust the language a bit, to avoid addressing the reader directly, which is in general preferred in technical documentation, because it eliminates the possible element of persuading the user to do something. In other words, we should be telling the user what our software can do, instead of telling the user what to do. Also perform some minor formatting improvements, to make it clear it's the git commands, command parameters, and configuration option names. Signed-off-by: Dragan Simic <dsimic@manjaro.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2024-03-25grep docs: describe --recurse-submodules further and improve formatting a bitDragan Simic
Clarify that --recurse-submodules cannot be used together with --untracked, and improve the formatting in a couple of places, to make it visually clear that those are the commands or the names of configuration options. While there, change a couple of "<tree>" placeholders to "_<tree>_", to help with an ongoing translation improvement effort. [1] [1] https://lore.kernel.org/git/CAPig+cQc8W4JOpB+TMP=czketU1U7wcY_x9bsP5T=3-XjGLhRQ@mail.gmail.com/ Signed-off-by: Dragan Simic <dsimic@manjaro.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2024-03-25builtin/pack-refs: introduce new "--auto" flagPatrick Steinhardt
Calling git-pack-refs(1) will unconditionally cause it to pack all requested refs regardless of the current state of the ref database. For example: - With the "files" backend we will end up rewriting the complete "packed-refs" file even if only a single ref would require compaction. - With the "reftable" backend we will end up always compacting all tables into a single table. This behaviour can be completely unnecessary depending on the backend and is thus wasteful. With the introduction of the `PACK_REFS_AUTO` flag in the preceding commit we can improve this and let the backends decide for themselves whether to pack refs in the first place. Expose this functionality via a new "--auto" flag in git-pack-refs(1), which mirrors the same flag in both git-gc(1) and git-maintenance(1). Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2024-03-21config.txt: describe handling of whitespace furtherDragan Simic
Make it more clear what the whitespace characters are in the context of git configuration files, and significantly improve the description of the leading and trailing whitespace handling, especially how it works out together with the presence of inline comments. Helped-by: Junio C Hamano <gitster@pobox.com> Helped-by: Eric Sunshine <sunshine@sunshineco.com> Signed-off-by: Dragan Simic <dsimic@manjaro.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2024-03-21The tenth batchJunio C Hamano
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2024-03-21Merge branch 'jw/doc-show-untracked-files-fix'Junio C Hamano
The status.showUntrackedFiles configuration variable was incorrectly documented to accept "false", which has been corrected. * jw/doc-show-untracked-files-fix: doc: status.showUntrackedFiles does not take "false"
2024-03-21Merge branch 'dg/user-manual-hash-example'Junio C Hamano
User manual (the original one) update. * dg/user-manual-hash-example: Documentation/user-manual.txt: example for generating object hashes
2024-03-21Merge branch 'ja/doc-markup-fixes'Junio C Hamano
Mark-ups used in the documentation has been improved for consistency. * ja/doc-markup-fixes: doc: git-clone: format placeholders doc: git-clone: format verbatim words doc: git-init: rework config item init.templateDir doc: git-init: rework definition lists doc: git-init: format placeholders doc: git-init: format verbatim parts
2024-03-20transport-helper: drop "object-format <algo>" optionJeff King
The documentation in gitremote-helpers.txt claims that helpers should accept an object-format option from Git whose value is either: 1. "true", in which case the helper is merely told that Git understands the special ":object-format" response, and will send it 2. an algorithm name that the helper should use However, Git has never sent the second form, and it's not clear if it would ever be useful. When interacting with a remote Git repository, we generally discover what _their_ object format is, and then decide what to do with a mismatch (where that is currently just "bail out", but could eventually be on-the-fly conversion and interop). And that is true for native protocols, but also for transport helpers like remote-curl that talk to remote Git repositories. There we send back an ":object-format" line telling Git what remote-curl detected on the other side. And this is true even for pushes (since we get it via receive-pack's advertisement). And it is even true for dumb-http, as we guess at the algorithm based on the hash size, due to ac093d0790 (remote-curl: detect algorithm for dumb HTTP by size, 2020-06-19). The one case where it _isn't_ true is dumb-http talking to an empty repository. There we have no clue what the remote hash is, so remote-curl just sends back its default. If we kept the "object-format <algo>" form then in theory Git could say "object-format sha256" to change that default. But it doesn't really accomplish anything. We still may or may not be mis-matched with the other side. For a fetch that's OK, since it's by definition a noop. For a push into an empty repository, it might matter (though the dumb http-push DAV code seems happy to clobber a remote sha256 info/refs and corrupt the repository). If we want to pursue making this work, I think we'd be better off improving detection of the object format of empty repositories over dumb-http (e.g., an "info/object-format" file). But what about helpers that _aren't_ talking to another Git repo? Consider something like git-cinnabar, which is converting on the fly to/from hg. Most of the heavy lifting is done by fast-import/export, but some oids may still pass between Git and the helper. Could "object-format <algo>" be useful to tell the helper what oids we expect to see? Possibly, but in practice this isn't necessary. Git-cinnabar for example already peeks at the local-repo .git/config to check its object-format (and currently just bails if it is sha256). So I think the "object-format" extension really is only useful for the helper telling Git what object-format it found, and not the other way around. Note that this patch can't break any remote helpers; we're not changing the code on the Git side at all, but just bringing the documentation in line with what Git has always done. It does remove the receiving support in remote-curl.c, but that code was never actually triggered. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2024-03-20doc/gitremote-helpers: fix more missing single-quotesJeff King
There are a few cases left in gitremote-helpers.txt that are missing a closing quote, so you end up with: 'option deepen-since <timestamp> with a stray opening quote instead of rendering correctly in italics. These should have been part of 51d41dc243 (doc/gitremote-helpers: fix missing single-quote, 2024-03-07), but apparently my eyesight is not what it once was. Hopefully this is now all of them. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2024-03-18The ninth batchJunio C Hamano
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2024-03-18Merge branch 'jk/doc-remote-helpers-markup-fix'Junio C Hamano
Doc mark-up fix. * jk/doc-remote-helpers-markup-fix: doc/gitremote-helpers: fix missing single-quote
2024-03-18docs: adjust trailer `separator` and `key_value_separator` languageBrian Lyles
The language describing the trailer separator and key-value separator default value is overly complicated. Indicate the default with simpler "Defaults to ..." language. Suggested-by: Linus Arver <linusa@google.com> Signed-off-by: Brian Lyles <brianmlyles@gmail.com> Acked-by: Linus Arver <linusa@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2024-03-18docs: correct trailer `key_value_separator` descriptionBrian Lyles
The description for `key_value_separator` incorrectly states that this separator is inserted between trailer lines, which appears likely to have been incorrectly copied from `separator` when this option was added. Update the description to correctly indicate that it is a separator that appears between the key and the value of each trailer. Signed-off-by: Brian Lyles <brianmlyles@gmail.com> Acked-by: Linus Arver <linusa@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2024-03-18sequencer: allow disabling conflict advicePhilippe Blain
Allow disabling the advice shown when a squencer operation results in a merge conflict through a new config 'advice.mergeConflict', which is named generically such that it can be used by other commands eventually. Remove that final '\n' in the first hunk in sequencer.c to avoid an otherwise empty 'hint: ' line before the line 'hint: Disable this message with "git config advice.mergeConflict false"' which is automatically added by 'advise_if_enabled'. Note that we use 'advise_if_enabled' for each message in the second hunk in sequencer.c, instead of using 'if (show_hints && advice_enabled(...)', because the former instructs the user how to disable the advice, which is more user-friendly. Update the tests accordingly. Note that the body of the second test in t3507-cherry-pick-conflict.sh is enclosed in double quotes, so we must escape them in the added line. Note that t5520-pull.sh, which checks that we display the advice for 'git rebase' (via 'git pull --rebase') does not have to be updated because it only greps for a specific line in the advice message. Signed-off-by: Philippe Blain <levraiphilippeblain@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2024-03-18diff.*Prefix: use camelCase in the doc and test titlesJunio C Hamano
We added documentation for diff.srcPrefix and diff.dstPrefix with their names properly camelCased, but the diff.noPrefix is listed there in all lowercase. Also these configuration variables, both existing ones and the {src,dst}Prefix we recently added, were spelled in all lowercase in the tests in t4013. Now we are done with the main change, clean these up. Signed-off-by: Junio C Hamano <gitster@pobox.com> Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2024-03-16doc: avoid redundant use of catBeat Bolli
The update-hook-example.txt script uses this anti-pattern twice. Call grep with the input file name directy. While at it, merge the two consecutive grep calls. Signed-off-by: Beat Bolli <dev+git@drbeat.li> Acked-by: Taylor Blau <me@ttaylorr.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2024-03-16doc: fix some placeholders formatingJean-Noël Avila
Signed-off-by: Jean-Noël Avila <jn.avila@free.fr> Acked-by: Taylor Blau <me@ttaylorr.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2024-03-16doc: format alternatives in synopsisJean-Noël Avila
This is a list of various fixes on malformed alternative in commands and option syntax. Signed-off-by: Jean-Noël Avila <jn.avila@free.fr> Acked-by: Taylor Blau <me@ttaylorr.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2024-03-16docs: fix typo in git-config `--default`Brian Lyles
Signed-off-by: Brian Lyles <brianmlyles@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2024-03-16docs: clarify file options in git-config `--edit`Brian Lyles
The description for the `-e`/`--edit` option references scopes inconsistently: system and global are referenced by their option name (`--system`/`--global`), but repository (`--local` is not. Additionally, neither `--worktree` nor `--file` are referenced at all, despite also being a valid options. Update the description to mention all four available scopes as well as `--file`, referencing each consistently by their option name. Signed-off-by: Brian Lyles <brianmlyles@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2024-03-16bugreport.c: fix a crash in `git bugreport` with `--no-suffix` optionJiamu Sun
`git bugreport` does not complain when `--no-suffix` is given, but it leads to a segmentation fault as the it is not prepared to see a NULL assigned to the option_suffix variable. Signed-off-by: Jiamu Sun <barroit@linux.com> Acked-by: Taylor Blau <me@ttaylorr.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2024-03-15config: allow tweaking whitespace between value and commentJunio C Hamano
Extending the previous step, this allows the whitespace placed after the value before the "# comment message" to be tweaked by tweaking the preprocessing rule to: * If the given comment string begins with one or more whitespace characters followed by '#', it is passed intact. * If the given comment string begins with '#', a Space is prepended. * Otherwise, " # " (Space, '#', Space) is prefixed. * A string with LF in it cannot be used as a comment string. Unlike the previous step, which unconditionally added a space after the value before writing the "# comment string", because the above preprocessing already gives a whitespace before the '#', the resulting string is written immediately after copying the value. And the sanity checking rule becomes * comment string after the above massaging that comes into git_config_set_multivar_in_file_gently() must - begin with zero or more whitespace characters followed by '#'. - not have a LF in it. I personally think this is over-engineered, but since I thought things through anyway, here it is in the patch form. The logic to tweak end-user supplied comment string is encapsulated in a new helper function, git_config_prepare_comment_string(), so if new front-end callers would want to use the same massaging rules, it is easily reused. Unfortunately I do not think of a way to tweak the preprocessing rules further to optionally allow having no blank after the value, i.e. to produce [section] variable = value#comment (which is a valid way to say section.variable=value, by the way) without sacrificing the ergonomics for the more usual case, so this time I really stop here. Signed-off-by: Junio C Hamano <gitster@pobox.com>
2024-03-15config: fix --comment formattingJunio C Hamano
When git adds comments itself (like "rebase -i" todo list and "commit -e" log message editor), it always gives a comment introducer "#" followed by a Space before the message, except for the recently introduced "git config --comment", where the users are forced to say " this is my comment" if they want to add their comment in this usual format; otherwise their comment string will end up without a space after the "#". Make it more ergonomic, while keeping it possible to also use this unusual style, by massaging the comment string at the UI layer with a set of simple rules: * If the given comment string begins with '#', it is passed intact. * Otherwise, "# " is prefixed. * A string with LF in it cannot be used as a comment string. Right now there is only one "front-end" that accepts end-user comment string and calls the underlying machinery to add or modify configuration file with comments, but to make sure that the future callers perform similar massaging as they see fit, add a sanity check logic in git_config_set_multivar_in_file_gently(), which is the single choke point in the codepaths that consumes the comment string. Signed-off-by: Junio C Hamano <gitster@pobox.com>
2024-03-15The eighth batchJunio C Hamano
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2024-03-15Merge branch 'kh/branch-ref-syntax-advice'Junio C Hamano
When git refuses to create a branch because the proposed branch name is not a valid refname, an advice message is given to refer the user to exact naming rules. * kh/branch-ref-syntax-advice: branch: advise about ref syntax rules advice: use double quotes for regular quoting advice: use backticks for verbatim advice: make all entries stylistically consistent t3200: improve test style
2024-03-15config: add --comment option to add a commentRalph Seichter
Introduce the ability to append comments to modifications made using git-config. Example usage: git config --comment "changed via script" \ --add safe.directory /home/alice/repo.git based on the proposed patch, the output produced is: [safe] directory = /home/alice/repo.git #changed via script Users need to be able to distinguish between config entries made using automation and entries made by a human. Automation can add comments containing a URL pointing to explanations for the change made, avoiding questions from users as to why their config file was changed by a third party. The implementation ensures that a # character is unconditionally prepended to the provided comment string, and that the comment text is appended as a suffix to the changed key-value-pair in the same line of text. Multi-line comments (i.e. comments containing linefeed) are rejected as errors, causing Git to exit without making changes. Comments are aimed at humans who inspect or change their Git config using a pager or editor. Comments are not meant to be read or displayed by git-config at a later time. Signed-off-by: Ralph Seichter <github@seichter.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2024-03-15diff: add diff.srcPrefix and diff.dstPrefix configuration variablesPeter Hutterer
Allow the default prefixes "a/" and "b/" to be tweaked by the diff.srcPrefix and diff.dstPrefix configuration variables. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>