]> git.ipfire.org Git - thirdparty/git.git/log
thirdparty/git.git
13 months agoMerge branch 'jc/retire-get-sha1-hex'
Junio C Hamano [Fri, 4 Aug 2023 17:52:30 +0000 (10:52 -0700)] 
Merge branch 'jc/retire-get-sha1-hex'

The implementation of "get_sha1_hex()" that reads a hexadecimal
string that spells a full object name has been extended to cope
with any hash function used in the repository, but the "sha1" in
its name survived.  Rename it to get_hash_hex(), a name that is
more consistent within its friends like get_hash_hex_algop().

* jc/retire-get-sha1-hex:
  hex: retire get_sha1_hex()

13 months agoMerge branch 'la/doc-choose-starting-point'
Junio C Hamano [Fri, 4 Aug 2023 17:52:29 +0000 (10:52 -0700)] 
Merge branch 'la/doc-choose-starting-point'

Clarify how to choose the starting point for a new topic in
developer guidance document.

* la/doc-choose-starting-point:
  SubmittingPatches: simplify guidance for choosing a starting point
  SubmittingPatches: emphasize need to communicate non-default starting points
  SubmittingPatches: de-emphasize branches as starting points
  SubmittingPatches: discuss subsystems separately from git.git
  SubmittingPatches: reword awkward phrasing

13 months agoThe eighteenth batch
Junio C Hamano [Wed, 2 Aug 2023 15:44:02 +0000 (08:44 -0700)] 
The eighteenth batch

Signed-off-by: Junio C Hamano <gitster@pobox.com>
13 months agoDocumentation/RelNotes/2.42.0.txt: typofix
Taylor Blau [Tue, 1 Aug 2023 18:20:18 +0000 (14:20 -0400)] 
Documentation/RelNotes/2.42.0.txt: typofix

Fix a typo introduced in aa9166bcc0 (The ninth batch, 2023-07-08).

Signed-off-by: Taylor Blau <me@ttaylorr.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
13 months agoMerge branch 'ks/ref-filter-describe'
Junio C Hamano [Wed, 2 Aug 2023 16:37:24 +0000 (09:37 -0700)] 
Merge branch 'ks/ref-filter-describe'

"git branch --list --format=<format>" and friends are taught
a new "%(describe)" placeholder.

* ks/ref-filter-describe:
  ref-filter: add new "describe" atom
  ref-filter: add multiple-option parsing functions

13 months agoMerge branch 'ah/sequencer-rewrite-todo-fix'
Junio C Hamano [Wed, 2 Aug 2023 16:37:23 +0000 (09:37 -0700)] 
Merge branch 'ah/sequencer-rewrite-todo-fix'

When the user edits "rebase -i" todo file so that it starts with a
"fixup", which would make it invalid, the command truncated the
rest of the file before giving an error and returning the control
back to the user.  Stop truncating to make it easier to correct
such a malformed todo file.

* ah/sequencer-rewrite-todo-fix:
  sequencer: finish parsing the todo list despite an invalid first line

13 months agoMerge branch 'bb/use-trace2-counters-for-fsync-stats'
Junio C Hamano [Wed, 2 Aug 2023 16:37:23 +0000 (09:37 -0700)] 
Merge branch 'bb/use-trace2-counters-for-fsync-stats'

Instead of inventing a custom counter variables for debugging,
use existing trace2 facility in the fsync customization codepath.

* bb/use-trace2-counters-for-fsync-stats:
  wrapper: use trace2 counters to collect fsync stats

13 months agoMerge branch 'ah/autoconf-fixes'
Junio C Hamano [Wed, 2 Aug 2023 16:37:23 +0000 (09:37 -0700)] 
Merge branch 'ah/autoconf-fixes'

"./configure --with-expat=no" did not work as a way to refuse use
of the expat library on a system with the library installed, which
has been corrected.

* ah/autoconf-fixes:
  configure.ac: always save NO_ICONV to config.status
  configure.ac: don't overwrite NO_CURL option
  configure.ac: don't overwrite NO_EXPAT option

13 months agoMerge branch 'jc/tree-walk-drop-base-offset'
Junio C Hamano [Wed, 2 Aug 2023 16:37:23 +0000 (09:37 -0700)] 
Merge branch 'jc/tree-walk-drop-base-offset'

Code simplification.

* jc/tree-walk-drop-base-offset:
  tree-walk: drop unused base_offset from do_match()
  tree-walk: lose base_offset that is never used in tree_entry_interesting

13 months agoThe seventeenth batch
Junio C Hamano [Fri, 28 Jul 2023 16:17:53 +0000 (09:17 -0700)] 
The seventeenth batch

Signed-off-by: Junio C Hamano <gitster@pobox.com>
13 months agoMerge branch 'rs/pack-objects-parseopt-fix'
Junio C Hamano [Fri, 28 Jul 2023 16:45:22 +0000 (09:45 -0700)] 
Merge branch 'rs/pack-objects-parseopt-fix'

Command line parser fix.

* rs/pack-objects-parseopt-fix:
  pack-objects: fix --no-quiet
  pack-objects: fix --no-keep-true-parents

13 months agoMerge branch 'rs/describe-parseopt-fix'
Junio C Hamano [Fri, 28 Jul 2023 16:45:21 +0000 (09:45 -0700)] 
Merge branch 'rs/describe-parseopt-fix'

Command line parser fix.

* rs/describe-parseopt-fix:
  describe: fix --no-exact-match

13 months agoMerge branch 'bb/trace2-comment-fix'
Junio C Hamano [Fri, 28 Jul 2023 16:45:21 +0000 (09:45 -0700)] 
Merge branch 'bb/trace2-comment-fix'

In-code comment fix.

* bb/trace2-comment-fix:
  trace2: fix a comment

13 months agoThe sixteenth batch
Junio C Hamano [Thu, 27 Jul 2023 22:02:38 +0000 (15:02 -0700)] 
The sixteenth batch

Signed-off-by: Junio C Hamano <gitster@pobox.com>
13 months agoMerge branch 'jc/parse-options-reset'
Junio C Hamano [Thu, 27 Jul 2023 22:26:37 +0000 (15:26 -0700)] 
Merge branch 'jc/parse-options-reset'

Command line parser fix.

* jc/parse-options-reset:
  reset: reject --no-(mixed|soft|hard|merge|keep) option

13 months agoMerge branch 'jc/parse-options-show-branch'
Junio C Hamano [Thu, 27 Jul 2023 22:26:37 +0000 (15:26 -0700)] 
Merge branch 'jc/parse-options-show-branch'

Command line parser fixes.

* jc/parse-options-show-branch:
  show-branch: reject --[no-](topo|date)-order
  show-branch: --no-sparse should give dense output

13 months agoMerge branch 'jc/transport-parseopt-fix'
Junio C Hamano [Thu, 27 Jul 2023 22:26:37 +0000 (15:26 -0700)] 
Merge branch 'jc/transport-parseopt-fix'

Command line parser fixes.

* jc/transport-parseopt-fix:
  fetch: reject --no-ipv[46]
  parse-options: introduce OPT_IPVERSION()

13 months agoMerge branch 'jc/gitignore-doc-pattern-markup'
Junio C Hamano [Thu, 27 Jul 2023 22:26:36 +0000 (15:26 -0700)] 
Merge branch 'jc/gitignore-doc-pattern-markup'

Doc mark-up update.

* jc/gitignore-doc-pattern-markup:
  gitignore.txt: mark up explanation of patterns consistently

13 months agoThe fifteenth batch
Junio C Hamano [Wed, 26 Jul 2023 20:40:42 +0000 (13:40 -0700)] 
The fifteenth batch

Signed-off-by: Junio C Hamano <gitster@pobox.com>
13 months agoMerge branch 'jc/branch-parseopt-fix'
Junio C Hamano [Wed, 26 Jul 2023 21:13:15 +0000 (14:13 -0700)] 
Merge branch 'jc/branch-parseopt-fix'

Command line parser fixes.

* jc/branch-parseopt-fix:
  branch: reject "--no-all" and "--no-remotes" early

13 months agoMerge branch 'jc/am-parseopt-fix'
Junio C Hamano [Wed, 26 Jul 2023 21:13:15 +0000 (14:13 -0700)] 
Merge branch 'jc/am-parseopt-fix'

Code simplification.

* jc/am-parseopt-fix:
  am: simplify parsing of "--[no-]keep-cr"

13 months agoMerge branch 'rs/ls-tree-no-full-name-fix'
Junio C Hamano [Wed, 26 Jul 2023 21:13:15 +0000 (14:13 -0700)] 
Merge branch 'rs/ls-tree-no-full-name-fix'

Command line parser fix.

* rs/ls-tree-no-full-name-fix:
  ls-tree: fix --no-full-name

13 months agoMerge branch 'jr/gitignore-doc-example-markup'
Junio C Hamano [Wed, 26 Jul 2023 21:13:15 +0000 (14:13 -0700)] 
Merge branch 'jr/gitignore-doc-example-markup'

Doc update.

* jr/gitignore-doc-example-markup:
  gitignore.txt: use backticks instead of double quotes

13 months agoThe fourteenth batch
Junio C Hamano [Tue, 25 Jul 2023 19:05:40 +0000 (12:05 -0700)] 
The fourteenth batch

Signed-off-by: Junio C Hamano <gitster@pobox.com>
13 months agoMerge branch 'jk/nested-points-at'
Junio C Hamano [Tue, 25 Jul 2023 19:05:24 +0000 (12:05 -0700)] 
Merge branch 'jk/nested-points-at'

"git tag --list --points-at X" showed tags that directly refers to
object X, but did not list a tag that points at such a tag, which
has been corrected.

* jk/nested-points-at:
  ref-filter: simplify return type of match_points_at
  ref-filter: avoid parsing non-tags in match_points_at()
  ref-filter: avoid parsing tagged objects in match_points_at()
  ref-filter: handle nested tags in --points-at option

13 months agoMerge branch 'rs/strbuf-addftime-simplify'
Junio C Hamano [Tue, 25 Jul 2023 19:05:24 +0000 (12:05 -0700)] 
Merge branch 'rs/strbuf-addftime-simplify'

Code clean-up.

* rs/strbuf-addftime-simplify:
  strbuf: use skip_prefix() in strbuf_addftime()

13 months agoMerge branch 'rs/ref-filter-signature-fix'
Junio C Hamano [Tue, 25 Jul 2023 19:05:24 +0000 (12:05 -0700)] 
Merge branch 'rs/ref-filter-signature-fix'

Test fix.

* rs/ref-filter-signature-fix:
  t6300: fix setup with GPGSSH but without GPG

13 months agoMerge branch 'jk/unused-parameter'
Junio C Hamano [Tue, 25 Jul 2023 19:05:24 +0000 (12:05 -0700)] 
Merge branch 'jk/unused-parameter'

Mark-up unused parameters in the code so that we can eventually
enable -Wunused-parameter by default.

* jk/unused-parameter:
  t/helper: mark unused callback void data parameters
  tag: mark unused parameters in each_tag_name_fn callbacks
  rev-parse: mark unused parameter in for_each_abbrev callback
  replace: mark unused parameter in each_mergetag_fn callback
  replace: mark unused parameter in ref callback
  merge-tree: mark unused parameter in traverse callback
  fsck: mark unused parameters in various fsck callbacks
  revisions: drop unused "opt" parameter in "tweak" callbacks
  count-objects: mark unused parameter in alternates callback
  am: mark unused keep_cr parameters
  http-push: mark unused parameter in xml callback
  http: mark unused parameters in curl callbacks
  do_for_each_ref_helper(): mark unused repository parameter
  test-ref-store: drop unimplemented reflog-expire command

13 months agoMerge branch 'dk/bundle-i18n-more'
Junio C Hamano [Tue, 25 Jul 2023 19:05:24 +0000 (12:05 -0700)] 
Merge branch 'dk/bundle-i18n-more'

Update message mark-up for i18n in "git bundle".

* dk/bundle-i18n-more:
  i18n: mark more bundle.c strings for translation

13 months agoMerge branch 'mh/mingw-case-sensitive-build'
Junio C Hamano [Tue, 25 Jul 2023 19:05:23 +0000 (12:05 -0700)] 
Merge branch 'mh/mingw-case-sensitive-build'

Names of MinGW header files are spelled in mixed case in some
source files, but the build host can be using case sensitive
filesystem with header files with their name spelled in all
lowercase.

* mh/mingw-case-sensitive-build:
  mingw: use lowercase includes for some Windows headers

13 months agoMerge branch 'dk/t4002-syntaxo-fix'
Junio C Hamano [Tue, 25 Jul 2023 19:05:23 +0000 (12:05 -0700)] 
Merge branch 'dk/t4002-syntaxo-fix'

Test fix.

* dk/t4002-syntaxo-fix:
  t4002: fix "diff can read from stdin" syntax

13 months agoMerge branch 'tb/object-access-overflow-protection'
Junio C Hamano [Tue, 25 Jul 2023 19:05:23 +0000 (12:05 -0700)] 
Merge branch 'tb/object-access-overflow-protection'

Various offset computation in the code that accesses the packfiles
and other data in the object layer has been hardened against
arithmetic overflow, especially on 32-bit systems.

* tb/object-access-overflow-protection:
  commit-graph.c: prevent overflow in `verify_commit_graph()`
  commit-graph.c: prevent overflow in `write_commit_graph()`
  commit-graph.c: prevent overflow in `merge_commit_graph()`
  commit-graph.c: prevent overflow in `split_graph_merge_strategy()`
  commit-graph.c: prevent overflow in `load_tree_for_commit()`
  commit-graph.c: prevent overflow in `fill_commit_in_graph()`
  commit-graph.c: prevent overflow in `fill_commit_graph_info()`
  commit-graph.c: prevent overflow in `load_oid_from_graph()`
  commit-graph.c: prevent overflow in add_graph_to_chain()
  commit-graph.c: prevent overflow in `write_commit_graph_file()`
  pack-bitmap.c: ensure that eindex lookups don't overflow
  midx.c: prevent overflow in `fill_included_packs_batch()`
  midx.c: prevent overflow in `write_midx_internal()`
  midx.c: store `nr`, `alloc` variables as `size_t`'s
  midx.c: prevent overflow in `nth_midxed_offset()`
  midx.c: prevent overflow in `nth_midxed_object_oid()`
  midx.c: use `size_t`'s for fanout nr and alloc
  packfile.c: use checked arithmetic in `nth_packed_object_offset()`
  packfile.c: prevent overflow in `load_idx()`
  packfile.c: prevent overflow in `nth_packed_object_id()`

13 months agoMerge branch 'ah/advise-force-pushing'
Junio C Hamano [Tue, 25 Jul 2023 19:05:23 +0000 (12:05 -0700)] 
Merge branch 'ah/advise-force-pushing'

Help newbies by suggesting that there are cases where force-pushing
is a valid and sensible thing to update a branch at a remote
repository, rather than reconciling with merge/rebase.

* ah/advise-force-pushing:
  push: don't imply that integration is always required before pushing
  remote: don't imply that integration is always required before pushing
  wt-status: don't show divergence advice when committing

14 months agohex: retire get_sha1_hex()
Junio C Hamano [Mon, 24 Jul 2023 23:11:03 +0000 (16:11 -0700)] 
hex: retire get_sha1_hex()

The naming convention around get_sha1_hex() and its friends is
awkward these days, after "struct object_id" was introduced.

There are three public functions around this area:

 * get_sha1_hex()       - use the implied the_hash_algo, fill uchar *
 * get_oid_hex()        - use the implied the_hash_algo, fill oid *
 * get_oid_hex_algop()  - use the passed algop, fill oid *

Between the latter two, the "_algop" suffix signals whether the
the_hash_algo is used as the implied algorithm or the caller should
pass an algorithm explicitly.  That is very much understandable and
is a good convention.

Between the former two, however, the "SHA1" vs "OID" in the names
differentiate in what type of variable the result is stored.

We could argue that it makes sense to use "SHA1" to mean "flat byte
buffer" to honor the historical practice in the days before "struct
object_id" was invented, but the natural fourth friend of the above
group would take an algop and fill a flat byte buffer, and it would
be strange to name it get_sha1_hex_algop().  Do we use the passed in
algo, or are we limited to SHA-1 ;-)?

In fact, such a function exists, albeit as a private helper function
used by the implementation of these functions, and is named a lot
more sensibly: get_hash_hex_algop().

Correct the misnomer of get_sha1_hex() and use "hash", instead of
"sha1", as "flat byte buffer that stores binary (as opposed to
hexadecimal) representation of the hash".

The four (2x2) friends now become:

 * get_hash_hex()       - use the implied the_hash_algo, fill uchar *
 * get_oid_hex()        - use the implied the_hash_algo, fill oid *
 * get_hash_hex_algop() - use the passed algop, fill uchar *
 * get_oid_hex_algop()  - use the passed algop, fill oid *

As there are only two remaining calls to get_sha1_hex() in the
codebase right now, the blast radious of this change is fairly
small.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
14 months agoref-filter: add new "describe" atom
Kousik Sanagavarapu [Sun, 23 Jul 2023 16:19:59 +0000 (21:49 +0530)] 
ref-filter: add new "describe" atom

Duplicate the logic of %(describe) and friends from pretty to
ref-filter. In the future, this change helps in unifying both the
formats as ref-filter will be able to do everything that pretty is doing
and we can have a single interface.

The new atom "describe" and its friends are equivalent to the existing
pretty formats with the same name.

Helped-by: Junio C Hamano <gitster@pobox.com>
Mentored-by: Christian Couder <christian.couder@gmail.com>
Mentored-by: Hariom Verma <hariom18599@gmail.com>
Signed-off-by: Kousik Sanagavarapu <five231003@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
14 months agoref-filter: add multiple-option parsing functions
Kousik Sanagavarapu [Sun, 23 Jul 2023 16:19:58 +0000 (21:49 +0530)] 
ref-filter: add multiple-option parsing functions

The functions

match_placeholder_arg_value()
match_placeholder_bool_arg()

were added in pretty 4f732e0fd7 (pretty: allow %(trailers) options
with explicit value, 2019-01-29) to parse multiple options in an
argument to --pretty. For example,

git log --pretty="%(trailers:key=Signed-Off-By,separator=%x2C )"

will output all the trailers matching the key and seperates them by
a comma followed by a space per commit.

Add similar functions,

match_atom_arg_value()
match_atom_bool_arg()

in ref-filter.

There is no atom yet that can use these functions in ref-filter, but we
are going to add a new %(describe) atom in a subsequent commit where we
parse options like tags=<bool-value> or match=<pattern> given to it.

Helped-by: Junio C Hamano <gitster@pobox.com>
Mentored-by: Christian Couder <christian.couder@gmail.com>
Mentored-by: Hariom Verma <hariom18599@gmail.com>
Signed-off-by: Kousik Sanagavarapu <five231003@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
14 months agosequencer: finish parsing the todo list despite an invalid first line
Alex Henrie [Sat, 22 Jul 2023 21:28:25 +0000 (15:28 -0600)] 
sequencer: finish parsing the todo list despite an invalid first line

Before the todo list is edited it is rewritten to shorten the OIDs of
the commits being picked and to append advice about editing the list.
The exact advice depends on whether the todo list is being edited for
the first time or not. After the todo list has been edited it is
rewritten to lengthen the OIDs of the commits being picked and to remove
the advice. If the edited list cannot be parsed then this last step is
skipped.

Prior to db81e50724 (rebase-interactive: use todo_list_write_to_file()
in edit_todo_list(), 2019-03-05) if the existing todo list could not be
parsed then the initial rewrite was skipped as well. This had the
unfortunate consequence that if the list could not be parsed after the
initial edit the advice given to the user was wrong when they re-edited
the list. This change relied on todo_list_parse_insn_buffer() returning
the whole todo list even when it cannot be parsed. Unfortunately if the
list starts with a "fixup" command then it will be truncated and the
remaining lines are lost. Fix this by continuing to parse after an
initial "fixup" commit as we do when we see any other invalid line.

Signed-off-by: Alex Henrie <alexhenrie24@gmail.com>
[jc: removed an apparently unneeded subshell around the test body]
Signed-off-by: Junio C Hamano <gitster@pobox.com>
14 months agoThe thirteenth batch
Junio C Hamano [Fri, 21 Jul 2023 20:47:13 +0000 (13:47 -0700)] 
The thirteenth batch

Signed-off-by: Junio C Hamano <gitster@pobox.com>
14 months agoMerge branch 'tb/refs-exclusion-and-packed-refs'
Junio C Hamano [Fri, 21 Jul 2023 20:47:26 +0000 (13:47 -0700)] 
Merge branch 'tb/refs-exclusion-and-packed-refs'

Enumerating refs in the packed-refs file, while excluding refs that
match certain patterns, has been optimized.

* tb/refs-exclusion-and-packed-refs:
  ls-refs.c: avoid enumerating hidden refs where possible
  upload-pack.c: avoid enumerating hidden refs where possible
  builtin/receive-pack.c: avoid enumerating hidden references
  refs.h: implement `hidden_refs_to_excludes()`
  refs.h: let `for_each_namespaced_ref()` take excluded patterns
  revision.h: store hidden refs in a `strvec`
  refs/packed-backend.c: add trace2 counters for jump list
  refs/packed-backend.c: implement jump lists to avoid excluded pattern(s)
  refs/packed-backend.c: refactor `find_reference_location()`
  refs: plumb `exclude_patterns` argument throughout
  builtin/for-each-ref.c: add `--exclude` option
  ref-filter.c: parameterize match functions over patterns
  ref-filter: add `ref_filter_clear()`
  ref-filter: clear reachable list pointers after freeing
  ref-filter.h: provide `REF_FILTER_INIT`
  refs.c: rename `ref_filter`

14 months agopack-objects: fix --no-quiet
René Scharfe [Fri, 21 Jul 2023 12:41:53 +0000 (14:41 +0200)] 
pack-objects: fix --no-quiet

Since 99fb6e04cb (pack-objects: convert to use parse_options(),
2012-02-01) git pack-objects has accepted the option --no-quiet, but it
does the same as --quiet.  That's because it's defined using OPT_SET_INT
with a value of 0, which sets 0 when negated, too.

Make --no-quiet equivalent to --progress and ignore it if --all-progress
was given.

Signed-off-by: René Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
14 months agopack-objects: fix --no-keep-true-parents
René Scharfe [Fri, 21 Jul 2023 12:41:56 +0000 (14:41 +0200)] 
pack-objects: fix --no-keep-true-parents

Since 99fb6e04cb (pack-objects: convert to use parse_options(),
2012-02-01) git pack-objects has accepted --no-keep-true-parents, but
this option does the same as --keep-true-parents.  That's because it's
defined using OPT_SET_INT with a value of 0, which sets 0 when negated
as well.

Turn --no-keep-true-parents into the opposite of --keep-true-parents by
using OPT_BOOL and storing the option's status directly in a variable
named "grafts_keep_true_parents" instead of in negative form in
"grafts_replace_parents".

Signed-off-by: René Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
14 months agodescribe: fix --no-exact-match
René Scharfe [Fri, 21 Jul 2023 13:41:33 +0000 (15:41 +0200)] 
describe: fix --no-exact-match

Since 2c33f75754 (Teach git-describe --exact-match to avoid expensive
tag searches, 2008-02-24) git describe accepts --no-exact-match, but it
does the same as --exact-match, an alias for --candidates=0.  That's
because it's defined using OPT_SET_INT with a value of 0, which sets 0
when negated as well.

Let --no-exact-match set the number of candidates to the default value
instead.  Users that need a more specific lack of exactitude can specify
their preferred value using --candidates, as before.

The "--no-exact-match" option was not covered in the tests, so let's
add a few.  Also add a case where --exact-match option is used on a
commit that cannot be described without distance from tags and make
sure the command fails.

Signed-off-by: René Scharfe <l.s.r@web.de>
[jc: added trivial tests]
Signed-off-by: Junio C Hamano <gitster@pobox.com>
14 months agowrapper: use trace2 counters to collect fsync stats
Beat Bolli [Thu, 20 Jul 2023 16:48:23 +0000 (18:48 +0200)] 
wrapper: use trace2 counters to collect fsync stats

As mentioned in the thread starting at [1], trace2 counters should be
used to count events instead of ad-hoc static variables.

Convert the two fsync static variables to trace2 counters, reducing the
coupling between wrapper.c and the trace2 subsystem. Adjust t/t5351 to
match the trace2 counter output format.

The counters are not per-thread because the ones being replaced also
were not.

[1] https://lore.kernel.org/git/20230627195251.1973421-2-calvinwan@google.com/

Signed-off-by: Beat Bolli <dev+git@drbeat.li>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
14 months agoreset: reject --no-(mixed|soft|hard|merge|keep) option
Junio C Hamano [Wed, 19 Jul 2023 13:37:39 +0000 (06:37 -0700)] 
reset: reject --no-(mixed|soft|hard|merge|keep) option

"git reset --no-mixed" behaved exactly like "git reset --mixed",
which was nonsense.

If there were only two kinds, e.g. "mixed" vs "separate", it might
have made sense to make "git reset --no-mixed" behave identically to
"git reset --separate" and vice-versa, but because we have many
types of reset, let's just forbid "--no-mixed" and negated form of
other types.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
14 months agoshow-branch: reject --[no-](topo|date)-order
Junio C Hamano [Wed, 19 Jul 2023 16:32:36 +0000 (09:32 -0700)] 
show-branch: reject --[no-](topo|date)-order

"git show-branch --no-topo-order" behaved exactly the same way as
"git show-branch --topo-order" did, which was nonsense.  This was
because we choose between topo- and date- by setting a variable to
either REV_SORT_IN_GRAPH_ORDER or REV_SORT_BY_COMMIT_DATE with
OPT_SET_INT() and REV_SORT_IN_GRAPH_ORDER happens to be 0.  The
OPT_SET_INT() macro assigns 0 to the target variable in respose to
the negated form of its option.

"--no-date-order" by luck behaves identically to "--topo-order"
exactly for the same reason, and it sort-of makes sense right now,
but the "sort-of makes sense" will quickly break down once we add a
third way to sort.  Not-A may be B when there are only two choices
between A and B, but once your choices become among A, B, and C,
not-A does not mean B.

Just mark these two ordering options to reject negation, and add a
test, which was missing.  "git show-branch --no-reflog" is also
unnegatable, so throw in a test for that while we are at it.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
14 months agotrace2: fix a comment
Beat Bolli [Wed, 19 Jul 2023 23:24:43 +0000 (01:24 +0200)] 
trace2: fix a comment

When the trace2 counter mechanism was added in 81071626ba (trace2: add
global counter mechanism, 2022-10-24), the name of the file where new
counters are added was misspelled in a comment.

Use the correct file name.

Signed-off-by: Beat Bolli <dev+git@drbeat.li>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
14 months agoconfigure.ac: always save NO_ICONV to config.status
Andreas Herrmann [Wed, 19 Jul 2023 14:29:58 +0000 (16:29 +0200)] 
configure.ac: always save NO_ICONV to config.status

In case 'configure --with-iconv=no' is used, NO_ICONV is not saved to
config.status and thus git is built with iconv support.

Always save NO_ICONV to config.status to honor what user selected
during configure step.

Signed-off-by: Andreas Herrmann <aherrmann@suse.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
14 months agoconfigure.ac: don't overwrite NO_CURL option
Andreas Herrmann [Wed, 19 Jul 2023 14:29:56 +0000 (16:29 +0200)] 
configure.ac: don't overwrite NO_CURL option

Even if 'configure --with-curl=no' was run, curl support is used,
because library detection overwrites it. Avoid this overwrite.
Configure should obey what the user has specified.

Signed-off-by: Andreas Herrmann <aherrmann@suse.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
14 months agoconfigure.ac: don't overwrite NO_EXPAT option
Andreas Herrmann [Wed, 19 Jul 2023 14:29:54 +0000 (16:29 +0200)] 
configure.ac: don't overwrite NO_EXPAT option

Even if 'configure --with-expat=no' was run, expat support is used,
because library detection overwrites it. Avoid this overwrite.
Configure should obey what the user has specified.

Signed-off-by: Andreas Herrmann <aherrmann@suse.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
14 months agoshow-branch: --no-sparse should give dense output
Junio C Hamano [Wed, 19 Jul 2023 11:37:39 +0000 (04:37 -0700)] 
show-branch: --no-sparse should give dense output

"git show-branch --no-sparse" behaved exactly the same way as "git
show-branch --sparse", which did not make any sense.  This was
because it used a variable "dense" initialized to 1 by default to
give "non sparse" behaviour, and OPT_SET_INT() to set the varilable
to 0 in response to the "--sparse" option.  Unfortunately,
OPT_SET_INT() sets 0 to the given variable when the option is
negated.

Flip the polarity of the variable "dense" by renaming it to "sparse"
and initializing it to 0, and have OPT_SET_INT() set the variable to
1 when "--sparse" is given.  This way, "--no-sparse" would set 0 to
the variable and would give us the "dense" behaviour.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
14 months agofetch: reject --no-ipv[46]
Junio C Hamano [Tue, 18 Jul 2023 21:45:59 +0000 (14:45 -0700)] 
fetch: reject --no-ipv[46]

Now we have introduced OPT_IPVERSION(), tweak its implementation so
that "git clone", "git fetch", and "git push" reject the negated
form of "Use only IP version N" options.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
14 months agoparse-options: introduce OPT_IPVERSION()
Junio C Hamano [Tue, 18 Jul 2023 21:34:33 +0000 (14:34 -0700)] 
parse-options: introduce OPT_IPVERSION()

The command line option parsing for "git clone", "git fetch", and
"git push" have duplicated implementations of parsing "--ipv4" and
"--ipv6" options, by having two OPT_SET_INT() for "ipv4" and "ipv6".

Introduce a new OPT_IPVERSION() macro and use it in these three
commands.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
14 months agobranch: reject "--no-all" and "--no-remotes" early
Junio C Hamano [Tue, 18 Jul 2023 18:27:49 +0000 (11:27 -0700)] 
branch: reject "--no-all" and "--no-remotes" early

As the command line parser for "git branch --all" forgets to use
PARSE_OPT_NONEG, it accepted "git branch --no-all", and then passed
a nonsense value to the underlying machinery, leading to a fatal
error "filter_refs: invalid type".  The "--remotes" option had
exactly the same issue.

Catch the unsupported options early in the option parser.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
14 months agoam: simplify parsing of "--[no-]keep-cr"
Junio C Hamano [Tue, 18 Jul 2023 18:22:40 +0000 (11:22 -0700)] 
am: simplify parsing of "--[no-]keep-cr"

Command line options "--keep-cr" and its negation trigger
OPT_SET_INT_F(PARSE_OPT_NONEG) to set a variable to 1 and 0
respectively.  Using OPT_SET_INT() to implement the positive variant
that sets the variable to 1 without specifying PARSE_OPT_NONEG gives
us the negative variant to set it to 0 for free.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
14 months agogitignore.txt: mark up explanation of patterns consistently
Junio C Hamano [Tue, 18 Jul 2023 17:47:39 +0000 (10:47 -0700)] 
gitignore.txt: mark up explanation of patterns consistently

In the "PATTERN FORMAT" section, all the other pattern elements are
shown as `monospace` literals inside "double quoted" strings.  Do
the same for the explanation of a slash to make it consistent.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
14 months agols-tree: fix --no-full-name
René Scharfe [Tue, 18 Jul 2023 15:44:13 +0000 (17:44 +0200)] 
ls-tree: fix --no-full-name

Since 61fdbcf98b (ls-tree: migrate to parse-options, 2009-11-13) git
ls-tree has accepted the option --no-full-name, but it does the same
as --full-name, contrary to convention.  That's because it's defined
using OPT_SET_INT with a value of 0, where the negative variant sets
0 as well.

Turn --no-full-name into the opposite of --full-name by using OPT_BOOL
instead and storing the option's status directly in a variable named
"full_name" instead of in negated form in "chomp_prefix".

Signed-off-by: René Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
14 months agoThe twelfth batch
Junio C Hamano [Tue, 18 Jul 2023 14:29:00 +0000 (07:29 -0700)] 
The twelfth batch

Signed-off-by: Junio C Hamano <gitster@pobox.com>
14 months agoMerge branch 'tb/repack-cleanup'
Junio C Hamano [Tue, 18 Jul 2023 14:28:53 +0000 (07:28 -0700)] 
Merge branch 'tb/repack-cleanup'

The recent change to "git repack" made it react less nicely when a
leftover .idx file that no longer has the corresponding .pack file
in the repository, which has been corrected.

* tb/repack-cleanup:
  builtin/repack.c: avoid dir traversal in `collect_pack_filenames()`
  builtin/repack.c: only repack `.pack`s that exist

14 months agoMerge branch 'tb/fsck-no-progress'
Junio C Hamano [Tue, 18 Jul 2023 14:28:52 +0000 (07:28 -0700)] 
Merge branch 'tb/fsck-no-progress'

"git fsck --no-progress" still spewed noise from the commit-graph
subsystem, which has been corrected.

* tb/fsck-no-progress:
  commit-graph.c: avoid duplicated progress output during `verify`
  commit-graph.c: pass progress to `verify_one_commit_graph()`
  commit-graph.c: iteratively verify commit-graph chains
  commit-graph.c: extract `verify_one_commit_graph()`
  fsck: suppress MIDX output with `--no-progress`
  fsck: suppress commit-graph output with `--no-progress`

14 months agoMerge branch 'mh/doc-credential-helpers'
Junio C Hamano [Tue, 18 Jul 2023 14:28:52 +0000 (07:28 -0700)] 
Merge branch 'mh/doc-credential-helpers'

Doc update.

* mh/doc-credential-helpers:
  doc: gitcredentials: link to helper list

14 months agogitignore.txt: use backticks instead of double quotes
Johan Ruokangas [Tue, 18 Jul 2023 13:13:01 +0000 (13:13 +0000)] 
gitignore.txt: use backticks instead of double quotes

Among four examples, only this one used "double quoted" sample
patterns, but all others marked up the patterns in `monospace`.

Signed-off-by: Johan Ruokangas <johan@latehours.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
14 months agoref-filter: simplify return type of match_points_at
Jeff King [Sun, 2 Jul 2023 22:38:29 +0000 (18:38 -0400)] 
ref-filter: simplify return type of match_points_at

We return the oid that matched, but the sole caller only cares whether
we matched anything at all. This is mostly academic, since there's only
one caller, but the lifetime of the returned pointer is not immediately
clear. Sometimes it points to an oid in a tag struct, which should live
forever. And sometimes to the oid passed in, which only lives as long as
the each_ref_fn callback we're called from.

Simplify this to a boolean return which is more direct and obvious. As a
bonus, this lets us avoid the weird pattern of overwriting our "oid"
parameter in the loop (since we now only refer to the tagged oid one
time, and can just inline the call to get it).

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
14 months agoref-filter: avoid parsing non-tags in match_points_at()
Jeff King [Sun, 2 Jul 2023 22:37:47 +0000 (18:37 -0400)] 
ref-filter: avoid parsing non-tags in match_points_at()

When handling --points-at, we have to try to peel each ref to see if
it's a tag that points at a requested oid. We start this process by
calling parse_object() on the oid pointed to by each ref.

The cost of parsing each object adds up, especially in an output that
doesn't otherwise need to open the objects at all. Ideally we'd use
peel_iterated_oid() here, which uses the cached information in the
packed-refs file. But we can't, because our --points-at must match not
only the fully peeled value, but any interim values (so if tag A points
to tag B which points to commit C, we should match --points-at=B, but
peel_iterated_oid() will only tell us about C).

So the best we can do (absent changes to the packed-refs peel traits) is
to avoid parsing non-tags. The obvious way to do that is to call
oid_object_info() to check the type before parsing. But there are a few
gotchas there, like checking if the object has already been parsed.

Instead we can just tell parse_object() that we are OK skipping the hash
check, which lets it turn on several optimizations. Commits can be
loaded via the commit graph (so it's both fast and we have the benefit
of the parsed data if we need it later at the output stage). Blobs are
not loaded at all. Trees are still loaded, but it's rather rare to have
a ref point directly to a tree (and since this is just an optimization,
kicking in 99% of the time is OK).

Even though we're paying for an extra lookup, the cost to avoid parsing
the non-tags is a net benefit. In my git.git repository with 941 tags
and 1440 other refs pointing to commits, this significantly cuts the
runtime:

  Benchmark 1: ./git.old for-each-ref --points-at=HEAD
    Time (mean ± σ):      26.8 ms ±   0.5 ms    [User: 24.5 ms, System: 2.2 ms]
    Range (min … max):    25.9 ms …  29.2 ms    107 runs

  Benchmark 2: ./git.new for-each-ref --points-at=HEAD
    Time (mean ± σ):       9.1 ms ±   0.3 ms    [User: 6.8 ms, System: 2.2 ms]
    Range (min … max):     8.6 ms …  10.2 ms    308 runs

  Summary
    './git.new for-each-ref --points-at=HEAD' ran
      2.96 ± 0.10 times faster than './git.old for-each-ref --points-at=HEAD'

In a repository that is mostly annotated tags, we'd expect less
improvement (we might still skip a few object loads, but that's balanced
by the extra lookups). In my clone of linux.git, which has 782 tags and
3 branches, the run-time is about the same (it's actually ~1% faster on
average after this patch, but that's within the run-to-run noise).

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
14 months agoref-filter: avoid parsing tagged objects in match_points_at()
Jeff King [Sun, 2 Jul 2023 22:35:40 +0000 (18:35 -0400)] 
ref-filter: avoid parsing tagged objects in match_points_at()

When we peel tags to check if they match a --points-at oid, we
recursively parse the tagged object to see if it is also a tag. But
since the tag itself tells us the type of the object it points to (and
even gives us the appropriate object struct via its "tagged" member), we
can use that directly.

We do still have to make sure to call parse_tag() before looking at each
tag. This is redundant for the outermost tag (since we did call
parse_object() to find its type), but that's OK; parse_tag() is smart
enough to make this a noop when the tag has already been parsed.

In my clone of linux.git, with 782 tags (and only 3 non-tags), this
yields a significant speedup (bringing us back where we were before the
commit before this one started recursively dereferencing tags):

  Benchmark 1: ./git.old for-each-ref --points-at=HEAD --format="%(refname)"
    Time (mean ± σ):      20.3 ms ±   0.5 ms    [User: 11.1 ms, System: 9.1 ms]
    Range (min … max):    19.6 ms …  21.5 ms    141 runs

  Benchmark 2: ./git.new for-each-ref --points-at=HEAD --format="%(refname)"
    Time (mean ± σ):      11.4 ms ±   0.2 ms    [User: 6.3 ms, System: 5.0 ms]
    Range (min … max):    11.0 ms …  12.2 ms    250 runs

  Summary
    './git.new for-each-ref --points-at=HEAD --format="%(refname)"' ran
      1.79 ± 0.05 times faster than './git.old for-each-ref --points-at=HEAD --format="%(refname)"'

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
14 months agoref-filter: handle nested tags in --points-at option
Jan Klötzke [Sat, 1 Jul 2023 20:57:02 +0000 (22:57 +0200)] 
ref-filter: handle nested tags in --points-at option

Tags are dereferenced until reaching a different object type to handle
nested tags, e.g. on checkout. In contrast, "git tag --points-at=..."
fails to list such nested tags because only one level of indirection is
obtained in filter_refs(). Implement the recursive dereferencing for the
"--points-at" option when filtering refs to unify the behaviour.

Signed-off-by: Jan Klötzke <jan@kloetzke.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
14 months agoThe eleventh batch
Junio C Hamano [Mon, 17 Jul 2023 17:06:52 +0000 (10:06 -0700)] 
The eleventh batch

Signed-off-by: Junio C Hamano <gitster@pobox.com>
14 months agoMerge branch 'jc/pathspec-match-with-common-prefix'
Junio C Hamano [Mon, 17 Jul 2023 18:30:42 +0000 (11:30 -0700)] 
Merge branch 'jc/pathspec-match-with-common-prefix'

"git ls-files '(attr:X)D/'" that triggers the common prefix
optimization codepath failed to read from "D/.gitattributes",
which has been corrected.

* jc/pathspec-match-with-common-prefix:
  dir: match "attr" pathspec magic with correct paths
  t6135: attr magic with path pattern

14 months agoMerge branch 'cw/compat-util-header-cleanup'
Junio C Hamano [Mon, 17 Jul 2023 18:30:42 +0000 (11:30 -0700)] 
Merge branch 'cw/compat-util-header-cleanup'

Further shuffling of declarations across header files to streamline
file dependencies.

* cw/compat-util-header-cleanup:
  git-compat-util: move alloc macros to git-compat-util.h
  treewide: remove unnecessary includes for wrapper.h
  kwset: move translation table from ctype
  sane-ctype.h: create header for sane-ctype macros
  git-compat-util: move wrapper.c funcs to its header
  git-compat-util: move strbuf.c funcs to its header

14 months agoMerge branch 'vd/adjust-mfow-doc-to-updated-headers'
Junio C Hamano [Mon, 17 Jul 2023 18:30:42 +0000 (11:30 -0700)] 
Merge branch 'vd/adjust-mfow-doc-to-updated-headers'

Code snippets in a tutorial document no longer compiled after
recent header shuffling, which have been corrected.

* vd/adjust-mfow-doc-to-updated-headers:
  docs: add necessary headers to Documentation/MFOW.txt

14 months agoMerge branch 'rs/ls-tree-prefix-simplify'
Junio C Hamano [Mon, 17 Jul 2023 18:30:41 +0000 (11:30 -0700)] 
Merge branch 'rs/ls-tree-prefix-simplify'

Code simplification.

* rs/ls-tree-prefix-simplify:
  ls-tree: simplify prefix handling

14 months agoMerge branch 'rs/userformat-find-requirements-simplify'
Junio C Hamano [Mon, 17 Jul 2023 18:30:41 +0000 (11:30 -0700)] 
Merge branch 'rs/userformat-find-requirements-simplify'

Code simplification.

* rs/userformat-find-requirements-simplify:
  pretty: use strchr(3) in userformat_find_requirements()

14 months agoMerge branch 'rs/pretty-format-double-negation-fix'
Junio C Hamano [Mon, 17 Jul 2023 18:30:41 +0000 (11:30 -0700)] 
Merge branch 'rs/pretty-format-double-negation-fix'

Code clarification.

* rs/pretty-format-double-negation-fix:
  pretty: avoid double negative in format_commit_item()

14 months agoMerge branch 'rs/packet-length-simplify'
Junio C Hamano [Mon, 17 Jul 2023 18:30:41 +0000 (11:30 -0700)] 
Merge branch 'rs/packet-length-simplify'

Code simplification.

* rs/packet-length-simplify:
  pkt-line: add size parameter to packet_length()

14 months agoMerge branch 'pw/diff-no-index-from-named-pipes'
Junio C Hamano [Mon, 17 Jul 2023 18:30:41 +0000 (11:30 -0700)] 
Merge branch 'pw/diff-no-index-from-named-pipes'

"git diff --no-index" learned to read from named pipes as if they
were regular files, to allow "git diff <(process) <(substitution)"
some shells support.

* pw/diff-no-index-from-named-pipes:
  diff --no-index: support reading from named pipes
  t4054: test diff --no-index with stdin
  diff --no-index: die on error reading stdin
  diff --no-index: refuse to compare stdin to a directory

14 months agostrbuf: use skip_prefix() in strbuf_addftime()
René Scharfe [Sun, 16 Jul 2023 08:52:33 +0000 (10:52 +0200)] 
strbuf: use skip_prefix() in strbuf_addftime()

Use the now common skip_prefix() cascade instead of a case statement to
parse the strftime(3) format in strbuf_addftime().  skip_prefix() parses
the "fmt" pointer and advances it appropriately, making additional
pointer arithmetic unnecessary.  The resulting code is more compact and
consistent with most other strbuf_expand_step() loops.

Signed-off-by: René Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
14 months agot6300: fix setup with GPGSSH but without GPG
René Scharfe [Sun, 16 Jul 2023 08:17:35 +0000 (10:17 +0200)] 
t6300: fix setup with GPGSSH but without GPG

In a test introduced by 26c9c03f0a (ref-filter: add new "signature"
atom, 2023-06-04) the file named "file" is added by a setup step that
requires GPG and modified by a second setup step that requires GPGSSH.
Systems lacking the first prerequisite skip the initial setup step and
then "git commit -a" in the second one doesn't find the modified file.
Add it explicitly.

Signed-off-by: René Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
14 months agoThe tenth batch
Junio C Hamano [Fri, 14 Jul 2023 17:45:39 +0000 (10:45 -0700)] 
The tenth batch

Signed-off-by: Junio C Hamano <gitster@pobox.com>
14 months agoMerge branch 'jk/imap-send-unused-variable-cleanup'
Junio C Hamano [Fri, 14 Jul 2023 17:46:07 +0000 (10:46 -0700)] 
Merge branch 'jk/imap-send-unused-variable-cleanup'

"imap-send" codepaths got cleaned up to get rid of unused
parameters.

* jk/imap-send-unused-variable-cleanup:
  imap-send: drop unused fields from imap_cmd_cb
  imap-send: drop unused parameter from imap_cmd_cb callback
  imap-send: use server conf argument in setup_curl()

14 months agoMerge branch 'ma/t0091-fixup'
Junio C Hamano [Fri, 14 Jul 2023 17:46:07 +0000 (10:46 -0700)] 
Merge branch 'ma/t0091-fixup'

"git bugreport" tests did not test what it wanted to test, which
has been corrected.

* ma/t0091-fixup:
  t0091-bugreport.sh: actually verify some content of report

14 months agoMerge branch 'ks/ref-filter-signature'
Junio C Hamano [Fri, 14 Jul 2023 17:46:07 +0000 (10:46 -0700)] 
Merge branch 'ks/ref-filter-signature'

The "git for-each-ref" family of commands learned placeholders
related to GPG signature verification.

* ks/ref-filter-signature:
  ref-filter: add new "signature" atom
  t/lib-gpg: introduce new prereq GPG2

14 months agoSubmittingPatches: simplify guidance for choosing a starting point
Linus Arver [Fri, 14 Jul 2023 06:01:33 +0000 (06:01 +0000)] 
SubmittingPatches: simplify guidance for choosing a starting point

Background: The guidance to "base your work on the oldest branch that
your change is relevant to" was added in d0c26f0f56 (SubmittingPatches:
Add new section about what to base work on, 2010-04-19). That commit
also added the bullet points which describe the scenarios where one
would use one of the following named branches: "maint", "master",
"next", and "seen" ("pu" in the original as that was the name of this
branch before it was renamed, per 828197de8f (docs: adjust for the
recent rename of `pu` to `seen`, 2020-06-25)). The guidance was probably
taken from existing similar language introduced in the "Merge upwards"
section of gitworkflows in f948dd8992 (Documentation: add manpage about
workflows, 2008-10-19).

Summary: This change simplifies the guidance by pointing users to just
"maint" or "master". But it also gives an explanation of why that is
preferred and what is meant by preferring "older" branches (which might
be confusing to some because "old" here is meant in relative terms
between these named branches, not in terms of the age of the branches
themselves). We also add an example to illustrate why it would be a bad
idea to use "next" as a starting point, which may not be so obvious to
new contributors.

Helped-by: Jonathan Nieder <jrnieder@gmail.com>
Helped-by: Junio C Hamano <gitster@pobox.com>
Signed-off-by: Linus Arver <linusa@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
14 months agoSubmittingPatches: emphasize need to communicate non-default starting points
Linus Arver [Fri, 14 Jul 2023 06:01:32 +0000 (06:01 +0000)] 
SubmittingPatches: emphasize need to communicate non-default starting points

The phrase

    and unless it targets the `master` branch (which is the default),
    mark your patches as such.

is tightly packed with several things happening in just two lines of
text. It also feels like it is not that important because of the terse
treatment. This is a problem because (1) it has the potential to confuse
new contributors, and (2) it may be glossed over for those skimming the
docs.

Emphasize and elaborate on this guidance by promoting it to its own
separate paragraph.

Signed-off-by: Linus Arver <linusa@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
14 months agoSubmittingPatches: de-emphasize branches as starting points
Linus Arver [Fri, 14 Jul 2023 06:01:31 +0000 (06:01 +0000)] 
SubmittingPatches: de-emphasize branches as starting points

It could be that a suitable branch does not exist, so instead just use
the phrase "starting point". Technically speaking the starting point
would be a commit (not a branch) anyway.

Helped-by: Junio C Hamano <gitster@pobox.com>
Signed-off-by: Linus Arver <linusa@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
14 months agoSubmittingPatches: discuss subsystems separately from git.git
Linus Arver [Fri, 14 Jul 2023 06:01:30 +0000 (06:01 +0000)] 
SubmittingPatches: discuss subsystems separately from git.git

The discussion around subsystems disrupts the flow of discussion in the
surrounding area, which only deals with starting points used for the
git.git project. So move this bullet point out to the end.

Signed-off-by: Linus Arver <linusa@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
14 months agoSubmittingPatches: reword awkward phrasing
Linus Arver [Fri, 14 Jul 2023 06:01:29 +0000 (06:01 +0000)] 
SubmittingPatches: reword awkward phrasing

Signed-off-by: Linus Arver <linusa@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
14 months agot4002: fix "diff can read from stdin" syntax
D. Ben Knoble [Fri, 14 Jul 2023 13:30:10 +0000 (13:30 +0000)] 
t4002: fix "diff can read from stdin" syntax

I noticed this test was producing output like

```
t4002-diff-basic.sh: test_expect_successdiff can read from stdin: not found
```

which is rather odd. Investigation shows an error of shell syntax:
foo'abc' is the same as fooabc to the shell. Perhaps obviously, this is
not a valid command for the test.

I am surprised this doesn't count as an error in the test, but that
accounts for it going unnoticed.

Signed-off-by: D. Ben Knoble <ben.knoble+github@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
14 months agocommit-graph.c: prevent overflow in `verify_commit_graph()`
Taylor Blau [Wed, 12 Jul 2023 23:38:19 +0000 (19:38 -0400)] 
commit-graph.c: prevent overflow in `verify_commit_graph()`

In a similar spirit as previous commits, ensure that we don't overflow
when trying to read an OID out of an existing commit-graph during
verification.

Signed-off-by: Taylor Blau <me@ttaylorr.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
14 months agocommit-graph.c: prevent overflow in `write_commit_graph()`
Taylor Blau [Wed, 12 Jul 2023 23:38:16 +0000 (19:38 -0400)] 
commit-graph.c: prevent overflow in `write_commit_graph()`

In a similar spirit as previous commits, ensure that we don't overflow
when trying to read an existing OID while writing a new commit-graph.

Signed-off-by: Taylor Blau <me@ttaylorr.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
14 months agocommit-graph.c: prevent overflow in `merge_commit_graph()`
Taylor Blau [Wed, 12 Jul 2023 23:38:13 +0000 (19:38 -0400)] 
commit-graph.c: prevent overflow in `merge_commit_graph()`

When merging two commit graphs, ensure that we don't attempt to merge
two graphs which, when combined, have more total commits than the 32-bit
unsigned maximum.

Signed-off-by: Taylor Blau <me@ttaylorr.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
14 months agocommit-graph.c: prevent overflow in `split_graph_merge_strategy()`
Taylor Blau [Wed, 12 Jul 2023 23:38:11 +0000 (19:38 -0400)] 
commit-graph.c: prevent overflow in `split_graph_merge_strategy()`

In a similar spirit as previous commits, ensure that we don't overflow
when choosing how to split and merge different layers of the
commit-graph.

In particular, avoid a potential overflow between `size_mult` and
`num_commits`, as well as a potential overflow between the number of
commits currently in the merged graph, and the number of commits in the
graph about to be merged.

Signed-off-by: Taylor Blau <me@ttaylorr.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
14 months agocommit-graph.c: prevent overflow in `load_tree_for_commit()`
Taylor Blau [Wed, 12 Jul 2023 23:38:08 +0000 (19:38 -0400)] 
commit-graph.c: prevent overflow in `load_tree_for_commit()`

In a similar spirit as previous commits, ensure that we don't overflow
when computing an offset into the commit_data chunk when the (relative)
graph position exceeds 2^32-1/GRAPH_DATA_WIDTH.

Signed-off-by: Taylor Blau <me@ttaylorr.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
14 months agocommit-graph.c: prevent overflow in `fill_commit_in_graph()`
Taylor Blau [Wed, 12 Jul 2023 23:38:05 +0000 (19:38 -0400)] 
commit-graph.c: prevent overflow in `fill_commit_in_graph()`

In a similar spirit as previous commits, ensure that we don't overflow
when the lex_index of the commit we are trying to fill out exceeds
2^32-1/(g->hash_len+16).

The other hunk touched in this patch is not susceptible to overflow,
since an explicit cast is made to a 64-bit unsigned value. For clarity
and consistency with the rest of the commits in this series, avoid a
tricky to reason about cast, and use `st_mult()` directly.

Signed-off-by: Taylor Blau <me@ttaylorr.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
14 months agocommit-graph.c: prevent overflow in `fill_commit_graph_info()`
Taylor Blau [Wed, 12 Jul 2023 23:38:03 +0000 (19:38 -0400)] 
commit-graph.c: prevent overflow in `fill_commit_graph_info()`

In a similar spirit as previous commits, ensure that we don't overflow
in a few spots within `fill_commit_graph_info()`:

  - First, when computing an offset into the commit data chunk, which
    can occur when the `lex_index` of the item we're looking up exceeds
    2^32-1/GRAPH_DATA_WIDTH.

  - A similar issue when computing the generation date offset for
    commits with `lex_index` greater than 2^32-1/4. Note that in
    practice this will never overflow, since the left-hand operand is
    from calling `sizeof(...)` and is thus already a `size_t`. But wrap
    that in an `st_mult()` to make it clear that we intend to perform
    this computation using 64-bit operands.

  - Finally, a nearly identical issue as above when computing an offset
    into the `generation_data_overflow` chunk.

Signed-off-by: Taylor Blau <me@ttaylorr.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
14 months agocommit-graph.c: prevent overflow in `load_oid_from_graph()`
Taylor Blau [Wed, 12 Jul 2023 23:38:00 +0000 (19:38 -0400)] 
commit-graph.c: prevent overflow in `load_oid_from_graph()`

In a similar spirit as previous commits, ensure that we don't overflow
when trying to compute an offset into the `chunk_oid_lookup` table when
the `lex_index` of the item we're trying to look up exceeds
`2^32-1/g->hash_len`.

Signed-off-by: Taylor Blau <me@ttaylorr.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
14 months agocommit-graph.c: prevent overflow in add_graph_to_chain()
Taylor Blau [Wed, 12 Jul 2023 23:37:57 +0000 (19:37 -0400)] 
commit-graph.c: prevent overflow in add_graph_to_chain()

The commit-graph uses a fanout table with 4-byte entries to store the
number of commits at each shard of the commit-graph. So it is OK to have
a commit graph with as many as 2^32-1 stored commits. But we risk
overflowing any computation which may exceed the 32-bit (unsigned)
maximum when those computations are (incorrectly) performed using 32-bit
operands.

There are a couple of spots in `add_graph_to_chain()` where we could
potentially overflow the result:

  - First, when comparing the list of existing entries in the
    commit-graph chain. It is unlikely that this should ever overflow,
    since it would require having roughly 2^32-1/g->hash_len
    commit-graphs in the chain. But let's guard that computation with a
    `st_mult()` just to be safe.

  - Second, when computing the number of commits in the graph added to
    the front of the chain. This value is also a 32-bit unsigned, but we
    should make sure that it does not grow beyond the maximum value.

Signed-off-by: Taylor Blau <me@ttaylorr.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
14 months agocommit-graph.c: prevent overflow in `write_commit_graph_file()`
Taylor Blau [Wed, 12 Jul 2023 23:37:54 +0000 (19:37 -0400)] 
commit-graph.c: prevent overflow in `write_commit_graph_file()`

When writing a commit-graph, we use the chunk-format API to write out
each individual chunk of the commit-graph. Each chunk of the
commit-graph is tracked via a call to `add_chunk()`, along with the
expected size of that chunk.

Similar to an earlier commit which handled the identical issue in the
MIDX machinery, guard against overflow when dealing with a commit-graph
with a large number of entries to avoid corrupting the contents of the
commit-graph itself.

Signed-off-by: Taylor Blau <me@ttaylorr.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
14 months agopack-bitmap.c: ensure that eindex lookups don't overflow
Taylor Blau [Wed, 12 Jul 2023 23:37:52 +0000 (19:37 -0400)] 
pack-bitmap.c: ensure that eindex lookups don't overflow

When a bitmap is used to answer some reachability query, it creates a
pseudo-bitmap called the "extended index" on top of any existing bitmaps
to store objects that are relevant to the query, but not mentioned in
the bitmap.

When looking up the ith object in the extended index in a bitmap, it is
common to write something like:

    bitmap_get(result, i + bitmap_num_objects(bitmap_git))

, indicating that we want the ith object following all other objects
mentioned in the bitmap_git.

Since the type of `i` and the return type of `bitmap_num_objects()` are
both `uint32_t`s,  But if there are either a large number of objects in
the bitmap, or a large number of objects in the extended index (or
both), this addition can overflow when the sum is greater than 2^32-1.

Having that large of a bitmap position is entirely acceptable, but we
need to ensure that the computed bitmap position for that object is
performed using 64-bits and doesn't overflow.

Signed-off-by: Taylor Blau <me@ttaylorr.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
14 months agomidx.c: prevent overflow in `fill_included_packs_batch()`
Taylor Blau [Wed, 12 Jul 2023 23:37:49 +0000 (19:37 -0400)] 
midx.c: prevent overflow in `fill_included_packs_batch()`

In a similar spirit as in previous commits, avoid an integer overflow
when computing the expected size of a MIDX.

(Note that this is also OK as-is, since `p->pack_size` is an `off_t`, so
this computation should already be done as 64-bit integers. But again,
let's use `st_mult()` to make this fact clear).

Signed-off-by: Taylor Blau <me@ttaylorr.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
14 months agomidx.c: prevent overflow in `write_midx_internal()`
Taylor Blau [Wed, 12 Jul 2023 23:37:46 +0000 (19:37 -0400)] 
midx.c: prevent overflow in `write_midx_internal()`

When writing a MIDX, we use the chunk-format API to write out each
individual chunk of the MIDX. Each chunk of the MIDX is tracked via a
call to `add_chunk()`, along with the expected size of that chunk.

Guard against overflow when dealing with a MIDX with a large number of
entries (and consequently, large chunks within the MIDX file itself) to
avoid corrupting the contents of the MIDX itself.

Signed-off-by: Taylor Blau <me@ttaylorr.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
14 months agomidx.c: store `nr`, `alloc` variables as `size_t`'s
Taylor Blau [Wed, 12 Jul 2023 23:37:44 +0000 (19:37 -0400)] 
midx.c: store `nr`, `alloc` variables as `size_t`'s

In the `write_midx_context` structure, we use two `uint32_t`'s to track
the length and allocated size of the packs, and one `uint32_t` to track
the number of objects in the MIDX.

In practice, having these be 32-bit unsigned values shouldn't cause any
problems since we are unlikely to have that many objects or packs in any
real-world repository. But these values should be `size_t`'s, so change
their type to reflect that.

Signed-off-by: Taylor Blau <me@ttaylorr.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>