]> git.ipfire.org Git - thirdparty/git.git/log
thirdparty/git.git
3 years agotests: remove leftover untracked files
Elijah Newren [Sat, 11 Sep 2021 17:08:42 +0000 (17:08 +0000)] 
tests: remove leftover untracked files

Remove untracked files that are unwanted after they are done being used.

While the set of cases in this patch is certainly far from
comprehensive, it was motivated by some work to see what the fallout
would be if we were to make the removal of untracked files as a side
effect of other commands into an error.  Some cases were a bit more
involved than the testcase changes included in this patch, but the ones
included here represent the simple cases.  While this patch is not that
important since we are not changing the behavior of those other commands
into an error in the near term, I thought these changes were useful
anyway as an explicit documentation of the intent that these untracked
files are no longer useful.

Acked-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>
Acked-by: Derrick Stolee <stolee@gmail.com>
Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agoThe fifth batch
Junio C Hamano [Fri, 10 Sep 2021 18:47:10 +0000 (11:47 -0700)] 
The fifth batch

Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agoMerge branch 'ab/help-autocorrect-prompt'
Junio C Hamano [Fri, 10 Sep 2021 18:46:33 +0000 (11:46 -0700)] 
Merge branch 'ab/help-autocorrect-prompt'

The logic for auto-correction of misspelt subcommands learned to go
interactive when the help.autocorrect configuration variable is set
to 'prompt'.

* ab/help-autocorrect-prompt:
  help.c: help.autocorrect=prompt waits for user action

3 years agoMerge branch 'cb/ci-build-pedantic'
Junio C Hamano [Fri, 10 Sep 2021 18:46:32 +0000 (11:46 -0700)] 
Merge branch 'cb/ci-build-pedantic'

CI update.

* cb/ci-build-pedantic:
  ci: run a pedantic build as part of the GitHub workflow

3 years agoMerge branch 'gh/gitweb-branch-sort'
Junio C Hamano [Fri, 10 Sep 2021 18:46:31 +0000 (11:46 -0700)] 
Merge branch 'gh/gitweb-branch-sort'

Tie-break branches that point at the same object in the list of
branches on GitWeb to show the one pointed at by HEAD early.

* gh/gitweb-branch-sort:
  gitweb: use HEAD as secondary sort key in git_get_heads_list()

3 years agoMerge branch 'rs/archive-use-object-id'
Junio C Hamano [Fri, 10 Sep 2021 18:46:31 +0000 (11:46 -0700)] 
Merge branch 'rs/archive-use-object-id'

Code cleanup.

* rs/archive-use-object-id:
  archive: convert queue_directory to struct object_id

3 years agoMerge branch 'rs/show-branch-simplify'
Junio C Hamano [Fri, 10 Sep 2021 18:46:30 +0000 (11:46 -0700)] 
Merge branch 'rs/show-branch-simplify'

Code cleanup.

* rs/show-branch-simplify:
  show-branch: simplify rev_is_head()

3 years agoMerge branch 'jk/log-warn-on-bogus-encoding'
Junio C Hamano [Fri, 10 Sep 2021 18:46:30 +0000 (11:46 -0700)] 
Merge branch 'jk/log-warn-on-bogus-encoding'

Doc update plus improved error reporting.

* jk/log-warn-on-bogus-encoding:
  docs: use "character encoding" to refer to commit-object encoding
  logmsg_reencode(): warn when iconv() fails

3 years agoMerge branch 'cb/remote-ndebug-fix'
Junio C Hamano [Fri, 10 Sep 2021 18:46:30 +0000 (11:46 -0700)] 
Merge branch 'cb/remote-ndebug-fix'

Build fix.

* cb/remote-ndebug-fix:
  remote: avoid -Wunused-but-set-variable in gcc with -DNDEBUG

3 years agoMerge branch 'ab/retire-advice-config'
Junio C Hamano [Fri, 10 Sep 2021 18:46:29 +0000 (11:46 -0700)] 
Merge branch 'ab/retire-advice-config'

Code clean up to migrate callers from older advice_config[] based
API to newer advice_if_enabled() and advice_enabled() API.

* ab/retire-advice-config:
  advice: move advice.graftFileDeprecated squashing to commit.[ch]
  advice: remove use of global advice_add_embedded_repo
  advice: remove read uses of most global `advice_` variables
  advice: add enum variants for missing advice variables

3 years agoMerge branch 'mk/clone-recurse-submodules'
Junio C Hamano [Fri, 10 Sep 2021 18:46:29 +0000 (11:46 -0700)] 
Merge branch 'mk/clone-recurse-submodules'

After "git clone --recurse-submodules", all submodules are cloned
but they are not by default recursed into by other commands.  With
submodule.stickyRecursiveClone configuration set, submodule.recurse
configuration is set to true in a repository created by "clone"
with "--recurse-submodules" option.

* mk/clone-recurse-submodules:
  clone: set submodule.recurse=true if submodule.stickyRecursiveClone enabled

3 years agoMerge branch 'ab/mailmap-leakfix'
Junio C Hamano [Fri, 10 Sep 2021 18:46:28 +0000 (11:46 -0700)] 
Merge branch 'ab/mailmap-leakfix'

Leakfix.

* ab/mailmap-leakfix:
  mailmap.c: fix a memory leak in free_mailap_{info,entry}()

3 years agoMerge branch 'ab/gc-log-rephrase'
Junio C Hamano [Fri, 10 Sep 2021 18:46:28 +0000 (11:46 -0700)] 
Merge branch 'ab/gc-log-rephrase'

A pathname in an advice message has been made cut-and-paste ready.

* ab/gc-log-rephrase:
  gc: remove trailing dot from "gc.log" line

3 years agoMerge branch 'uk/userdiff-php-enum'
Junio C Hamano [Fri, 10 Sep 2021 18:46:27 +0000 (11:46 -0700)] 
Merge branch 'uk/userdiff-php-enum'

Update the userdiff pattern for PHP.

* uk/userdiff-php-enum:
  userdiff: support enum keyword in PHP hunk header

3 years agoMerge branch 'tk/fast-export-anonymized-tag-fix'
Junio C Hamano [Fri, 10 Sep 2021 18:46:27 +0000 (11:46 -0700)] 
Merge branch 'tk/fast-export-anonymized-tag-fix'

The output from "git fast-export", when its anonymization feature
is in use, showed an annotated tag incorrectly.

* tk/fast-export-anonymized-tag-fix:
  fast-export: fix anonymized tag using original length

3 years agoMerge branch 'ba/object-info'
Junio C Hamano [Fri, 10 Sep 2021 18:46:26 +0000 (11:46 -0700)] 
Merge branch 'ba/object-info'

Leakfix.

* ba/object-info:
  protocol-caps.c: fix memory leak in send_info()

3 years agoMerge branch 'ab/commit-graph-usage'
Junio C Hamano [Fri, 10 Sep 2021 18:46:25 +0000 (11:46 -0700)] 
Merge branch 'ab/commit-graph-usage'

Fixes on usage message from "git commit-graph".

* ab/commit-graph-usage:
  commit-graph: show "unexpected subcommand" error
  commit-graph: show usage on "commit-graph [write|verify] garbage"
  commit-graph: early exit to "usage" on !argc
  multi-pack-index: refactor "goto usage" pattern
  commit-graph: use parse_options_concat()
  commit-graph: remove redundant handling of -h
  commit-graph: define common usage with a macro

3 years agoMerge branch 'mh/send-email-reset-in-reply-to'
Junio C Hamano [Fri, 10 Sep 2021 18:46:25 +0000 (11:46 -0700)] 
Merge branch 'mh/send-email-reset-in-reply-to'

Even when running "git send-email" without its own threaded
discussion support, a threading related header in one message is
carried over to the subsequent message to result in an unwanted
threading, which has been corrected.

* mh/send-email-reset-in-reply-to:
  send-email: avoid incorrect header propagation

3 years agoMerge branch 'rs/more-fspathcmp'
Junio C Hamano [Fri, 10 Sep 2021 18:46:24 +0000 (11:46 -0700)] 
Merge branch 'rs/more-fspathcmp'

Code simplification.

* rs/more-fspathcmp:
  merge-recursive: use fspathcmp() in path_hashmap_cmp()

3 years agoMerge branch 'sg/set-ceiling-during-tests'
Junio C Hamano [Fri, 10 Sep 2021 18:46:23 +0000 (11:46 -0700)] 
Merge branch 'sg/set-ceiling-during-tests'

Buggy tests could damage repositories outside the throw-away test
area we created.  We now by default export GIT_CEILING_DIRECTORIES
to limit the damage from such a stray test.

* sg/set-ceiling-during-tests:
  test-lib: set GIT_CEILING_DIRECTORIES to protect the surrounding repository

3 years agoMerge branch 'jh/sparse-index-resize-fix'
Junio C Hamano [Fri, 10 Sep 2021 18:46:23 +0000 (11:46 -0700)] 
Merge branch 'jh/sparse-index-resize-fix'

The sparse-index support can corrupt the index structure by storing
a stale and/or uninitialized data, which has been corrected.

* jh/sparse-index-resize-fix:
  sparse-index: copy dir_hash in ensure_full_index()

3 years agoMerge branch 'es/walken-tutorial-fix'
Junio C Hamano [Fri, 10 Sep 2021 18:46:23 +0000 (11:46 -0700)] 
Merge branch 'es/walken-tutorial-fix'

Typofix.

* es/walken-tutorial-fix:
  doc: fix syntax error and the format of printf

3 years agoMerge branch 'tb/add-objects-in-unpacked-packs-simplify'
Junio C Hamano [Fri, 10 Sep 2021 18:46:21 +0000 (11:46 -0700)] 
Merge branch 'tb/add-objects-in-unpacked-packs-simplify'

Code simplification with reduced memory usage.

* tb/add-objects-in-unpacked-packs-simplify:
  builtin/pack-objects.c: remove duplicate hash lookup
  builtin/pack-objects.c: simplify add_objects_in_unpacked_packs()
  object-store.h: teach for_each_packed_object to ignore kept packs

3 years agoMerge branch 'ps/fetch-omit-formatting-under-quiet'
Junio C Hamano [Fri, 10 Sep 2021 18:46:20 +0000 (11:46 -0700)] 
Merge branch 'ps/fetch-omit-formatting-under-quiet'

"git fetch --quiet" optimization to avoid useless computation of
info that will never be displayed.

* ps/fetch-omit-formatting-under-quiet:
  fetch: skip formatting updated refs with `--quiet`

3 years agoMerge branch 'ka/want-ref-in-namespace'
Junio C Hamano [Fri, 10 Sep 2021 18:46:20 +0000 (11:46 -0700)] 
Merge branch 'ka/want-ref-in-namespace'

"git upload-pack" which runs on the other side of "git fetch"
forgot to take the ref namespaces into account when handling
want-ref requests.

* ka/want-ref-in-namespace:
  docs: clarify the interaction of transfer.hideRefs and namespaces
  upload-pack.c: treat want-ref relative to namespace
  t5730: introduce fetch command helper

3 years agoMerge branch 'zh/cherry-pick-advice'
Junio C Hamano [Fri, 10 Sep 2021 18:46:19 +0000 (11:46 -0700)] 
Merge branch 'zh/cherry-pick-advice'

The advice message that "git cherry-pick" gives when it asks
conflicted replay of a commit to be resolved by the end user has
been updated.

* zh/cherry-pick-advice:
  cherry-pick: use better advice message

3 years agoMerge branch 'js/advise-when-skipping-cherry-picked'
Junio C Hamano [Fri, 10 Sep 2021 18:46:19 +0000 (11:46 -0700)] 
Merge branch 'js/advise-when-skipping-cherry-picked'

"git rebase" by default skips changes that are equivalent to
commits that are already in the history the branch is rebased onto;
give messages when this happens to let the users be aware of
skipped commits, and also teach them how to tell "rebase" to keep
duplicated changes.

* js/advise-when-skipping-cherry-picked:
  sequencer: advise if skipping cherry-picked commit

3 years agoThe fourth batch
Junio C Hamano [Wed, 8 Sep 2021 00:47:04 +0000 (17:47 -0700)] 
The fourth batch

Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agoMerge branch 'sg/column-nl'
Junio C Hamano [Wed, 8 Sep 2021 20:30:34 +0000 (13:30 -0700)] 
Merge branch 'sg/column-nl'

The parser for the "--nl" option of "git column" has been
corrected.

* sg/column-nl:
  column: fix parsing of the '--nl' option

3 years agoMerge branch 'cb/makefile-apple-clang'
Junio C Hamano [Wed, 8 Sep 2021 20:30:33 +0000 (13:30 -0700)] 
Merge branch 'cb/makefile-apple-clang'

Build update for Apple clang.

* cb/makefile-apple-clang:
  build: catch clang that identifies itself as "$VENDOR clang"
  build: clang version may not be followed by extra words
  build: update detect-compiler for newer Xcode version

3 years agoMerge branch 'ps/ls-refs-strbuf-optim'
Junio C Hamano [Wed, 8 Sep 2021 20:30:33 +0000 (13:30 -0700)] 
Merge branch 'ps/ls-refs-strbuf-optim'

Micro-optimization for the wire protocol driver.

* ps/ls-refs-strbuf-optim:
  ls-refs: reuse buffer when sending refs

3 years agoMerge branch 'rs/branch-allow-deleting-dangling'
Junio C Hamano [Wed, 8 Sep 2021 20:30:32 +0000 (13:30 -0700)] 
Merge branch 'rs/branch-allow-deleting-dangling'

"git branch -D <branch>" used to refuse to remove a broken branch
ref that points at a missing commit, which has been corrected.

* rs/branch-allow-deleting-dangling:
  branch: allow deleting dangling branches with --force

3 years agoMerge branch 'mt/quiet-with-delayed-checkout'
Junio C Hamano [Wed, 8 Sep 2021 20:30:32 +0000 (13:30 -0700)] 
Merge branch 'mt/quiet-with-delayed-checkout'

The delayed checkout code path in "git checkout" etc. were chatty
even when --quiet and/or --no-progress options were given.

* mt/quiet-with-delayed-checkout:
  checkout: make delayed checkout respect --quiet and --no-progress

3 years agoMerge branch 'rs/xopen-reports-open-failures'
Junio C Hamano [Wed, 8 Sep 2021 20:30:32 +0000 (13:30 -0700)] 
Merge branch 'rs/xopen-reports-open-failures'

Error diagnostics improvement.

* rs/xopen-reports-open-failures:
  use xopen() to handle fatal open(2) failures
  xopen: explicitly report creation failures

3 years agoMerge branch 'dd/diff-files-unmerged-fix'
Junio C Hamano [Wed, 8 Sep 2021 20:30:31 +0000 (13:30 -0700)] 
Merge branch 'dd/diff-files-unmerged-fix'

"git diff --relative" segfaulted and/or produced incorrect result
when there are unmerged paths.

* dd/diff-files-unmerged-fix:
  diff-lib: ignore paths that are outside $cwd if --relative asked

3 years agoMerge branch 'dd/t6300-wo-gpg-fix'
Junio C Hamano [Wed, 8 Sep 2021 20:30:31 +0000 (13:30 -0700)] 
Merge branch 'dd/t6300-wo-gpg-fix'

Test fix.

* dd/t6300-wo-gpg-fix:
  t6300: check for cat-file exit status code
  t6300: don't run cat-file on non-existent object

3 years agoMerge branch 'mh/credential-leakfix'
Junio C Hamano [Wed, 8 Sep 2021 20:30:30 +0000 (13:30 -0700)] 
Merge branch 'mh/credential-leakfix'

Leak fix.

* mh/credential-leakfix:
  credential: fix leak in credential_apply_config()

3 years agoMerge branch 'jk/t5323-no-pack-test-fix'
Junio C Hamano [Wed, 8 Sep 2021 20:30:30 +0000 (13:30 -0700)] 
Merge branch 'jk/t5323-no-pack-test-fix'

Test fix.

* jk/t5323-no-pack-test-fix:
  t5323: drop mentions of "master"

3 years agoMerge branch 'js/maintenance-launchctl-fix'
Junio C Hamano [Wed, 8 Sep 2021 20:30:29 +0000 (13:30 -0700)] 
Merge branch 'js/maintenance-launchctl-fix'

"git maintenance" scheduler fix for macOS.

* js/maintenance-launchctl-fix:
  maintenance: skip bootout/bootstrap when plist is registered
  maintenance: create `launchctl` configuration using a lock file

3 years agoMerge branch 'ab/rebase-fatal-fatal-fix'
Junio C Hamano [Wed, 8 Sep 2021 20:30:29 +0000 (13:30 -0700)] 
Merge branch 'ab/rebase-fatal-fatal-fix'

Error message fix.

* ab/rebase-fatal-fatal-fix:
  rebase: emit one "fatal" in "fatal: fatal: <error>"

3 years agoMerge branch 'ab/ls-remote-packet-trace'
Junio C Hamano [Wed, 8 Sep 2021 20:30:28 +0000 (13:30 -0700)] 
Merge branch 'ab/ls-remote-packet-trace'

Debugging aid fix.

* ab/ls-remote-packet-trace:
  ls-remote: set packet_trace_identity(<name>)

3 years agoMerge branch 'rs/git-mmap-uses-malloc'
Junio C Hamano [Wed, 8 Sep 2021 20:30:27 +0000 (13:30 -0700)] 
Merge branch 'rs/git-mmap-uses-malloc'

mmap() imitation used to call xmalloc() that dies upon malloc()
failure, which has been corrected to just return an error to the
caller to be handled.

* rs/git-mmap-uses-malloc:
  compat: let git_mmap use malloc(3) directly

3 years agoMerge branch 'ga/send-email-sendmail-cmd'
Junio C Hamano [Wed, 8 Sep 2021 20:30:27 +0000 (13:30 -0700)] 
Merge branch 'ga/send-email-sendmail-cmd'

Test fix.

* ga/send-email-sendmail-cmd:
  t9001: PATH must not use Windows-style paths

3 years agoMerge branch 'me/t5582-cleanup'
Junio C Hamano [Wed, 8 Sep 2021 20:30:26 +0000 (13:30 -0700)] 
Merge branch 'me/t5582-cleanup'

Test fix.

* me/t5582-cleanup:
  t5582: remove spurious 'cd "$D"' line

3 years agoThe third batch
Junio C Hamano [Fri, 3 Sep 2021 20:37:47 +0000 (13:37 -0700)] 
The third batch

Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agoMerge branch 'sg/make-fix-ar-invocation'
Junio C Hamano [Fri, 3 Sep 2021 20:49:30 +0000 (13:49 -0700)] 
Merge branch 'sg/make-fix-ar-invocation'

Build fix.

* sg/make-fix-ar-invocation:
  Makefile: remove archives before manipulating them with 'ar'

3 years agoMerge branch 'ti/tcsh-completion-regression-fix'
Junio C Hamano [Fri, 3 Sep 2021 20:49:29 +0000 (13:49 -0700)] 
Merge branch 'ti/tcsh-completion-regression-fix'

Update to the command line completion (in contrib/) for tcsh.

* ti/tcsh-completion-regression-fix:
  completion: tcsh: Fix regression by drop of wrapper functions

3 years agoMerge branch 'fc/completion-updates'
Junio C Hamano [Fri, 3 Sep 2021 20:49:29 +0000 (13:49 -0700)] 
Merge branch 'fc/completion-updates'

Command line completion updates.

* fc/completion-updates:
  completion: bash: add correct suffix in variables
  completion: bash: fix for multiple dash commands
  completion: bash: fix for suboptions with value
  completion: bash: fix prefix detection in branch.*

3 years agoMerge branch 'pw/rebase-r-fixes'
Junio C Hamano [Fri, 3 Sep 2021 20:49:28 +0000 (13:49 -0700)] 
Merge branch 'pw/rebase-r-fixes'

Various bugs in "git rebase -r" have been fixed.

* pw/rebase-r-fixes:
  rebase -r: fix merge -c with a merge strategy
  rebase -r: don't write .git/MERGE_MSG when fast-forwarding
  rebase -i: add another reword test
  rebase -r: make 'merge -c' behave like reword

3 years agoMerge branch 'pw/rebase-skip-final-fix'
Junio C Hamano [Fri, 3 Sep 2021 20:49:28 +0000 (13:49 -0700)] 
Merge branch 'pw/rebase-skip-final-fix'

Checking out all the paths from HEAD during the last conflicted
step in "git rebase" and continuing would cause the step to be
skipped (which is expected), but leaves MERGE_MSG file behind in
$GIT_DIR and confuses the next "git commit", which has been
corrected.

* pw/rebase-skip-final-fix:
  rebase --continue: remove .git/MERGE_MSG
  rebase --apply: restore some tests
  t3403: fix commit authorship

3 years agoMerge branch 'cb/ci-use-upload-artifacts-v1'
Junio C Hamano [Fri, 3 Sep 2021 20:49:28 +0000 (13:49 -0700)] 
Merge branch 'cb/ci-use-upload-artifacts-v1'

Use upload-artifacts v1 (instead of v2) for 32-bit linux, as the
new version has a blocker bug for that architecture.

* cb/ci-use-upload-artifacts-v1:
  ci: use upload-artifacts v1 for dockerized jobs

3 years agoMerge branch 'jk/commit-edit-fixup-fix'
Junio C Hamano [Fri, 3 Sep 2021 20:49:27 +0000 (13:49 -0700)] 
Merge branch 'jk/commit-edit-fixup-fix'

"git commit --fixup" now works with "--edit" again, after it was
broken in v2.32.

* jk/commit-edit-fixup-fix:
  commit: restore --edit when combined with --fixup

3 years agoMerge branch 'ps/connectivity-optim'
Junio C Hamano [Fri, 3 Sep 2021 20:49:27 +0000 (13:49 -0700)] 
Merge branch 'ps/connectivity-optim'

The revision traversal API has been optimized by taking advantage
of the commit-graph, when available, to determine if a commit is
reachable from any of the existing refs.

* ps/connectivity-optim:
  revision: avoid hitting packfiles when commits are in commit-graph
  commit-graph: split out function to search commit position
  revision: stop retrieving reference twice
  connected: do not sort input revisions
  revision: separate walk and unsorted flags

3 years agoremote: avoid -Wunused-but-set-variable in gcc with -DNDEBUG
Carlo Marcelo Arenas Belón [Thu, 2 Sep 2021 08:52:53 +0000 (04:52 -0400)] 
remote: avoid -Wunused-but-set-variable in gcc with -DNDEBUG

In make_remote(), we store the return value of hashmap_put() and check
it using assert(), but don't otherwise use it. If Git is compiled with
NDEBUG, then the assert() becomes a noop, and nobody looks at the
variable at all. This causes some compilers to produce warnings.

Let's switch it instead to a BUG(). This accomplishes the same thing,
but is always compiled in (and we don't have to worry about the cost;
the check is cheap, and this is not a hot code path).

Signed-off-by: Carlo Marcelo Arenas Belón <carenas@gmail.com>
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agogc: remove trailing dot from "gc.log" line
Ævar Arnfjörð Bjarmason [Tue, 31 Aug 2021 14:37:29 +0000 (16:37 +0200)] 
gc: remove trailing dot from "gc.log" line

Remove the trailing dot from the warning we emit about gc.log. It's
common for various terminal UX's to allow the user to select "words",
and by including the trailing dot a user wanting to select the path to
gc.log will need to manually remove the trailing dot.

Such a user would also probably need to adjust the path if it e.g. had
spaces in it, but this should address this very common case.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Suggested-by: Jan Judas <snugar.i@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agodocs: clarify the interaction of transfer.hideRefs and namespaces
Kim Altintop [Fri, 13 Aug 2021 06:23:54 +0000 (06:23 +0000)] 
docs: clarify the interaction of transfer.hideRefs and namespaces

Expand the section about namespaces in the documentation of
`transfer.hideRefs` to point out the subtle differences between
`upload-pack` and `receive-pack`.

ffcfb68176 (upload-pack.c: treat want-ref relative to namespace,
2021-07-30) taught `upload-pack` to reject `want-ref`s for hidden refs,
which is now mentioned. It is clarified that at no point the name of a
hidden ref is revealed, but the object id it points to may.

Signed-off-by: Kim Altintop <kim@eagain.st>
Reviewed-by: Jonathan Tan <jonathantanmy@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agoupload-pack.c: treat want-ref relative to namespace
Kim Altintop [Fri, 13 Aug 2021 06:23:50 +0000 (06:23 +0000)] 
upload-pack.c: treat want-ref relative to namespace

When 'upload-pack' runs within the context of a git namespace, treat any
'want-ref' lines the client sends as relative to that namespace.

Also check if the wanted ref is hidden via 'hideRefs'. If it is hidden,
respond with an error as if the ref didn't exist.

Helped-by: Jonathan Tan <jonathantanmy@google.com>
Signed-off-by: Kim Altintop <kim@eagain.st>
Reviewed-by: Jonathan Tan <jonathantanmy@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agot5730: introduce fetch command helper
Kim Altintop [Fri, 13 Aug 2021 06:23:40 +0000 (06:23 +0000)] 
t5730: introduce fetch command helper

Assembling a "raw" fetch command to be fed directly to "test-tool serve-v2"
is extracted into a test helper.

Suggested-by: Junio C Hamano <gitster@pobox.com>
Signed-off-by: Kim Altintop <kim@eagain.st>
Reviewed-by: Jonathan Tan <jonathantanmy@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agomailmap.c: fix a memory leak in free_mailap_{info,entry}()
Ævar Arnfjörð Bjarmason [Tue, 31 Aug 2021 13:42:52 +0000 (15:42 +0200)] 
mailmap.c: fix a memory leak in free_mailap_{info,entry}()

In the free_mailmap_entry() code added in 0925ce4d49 (Add map_user()
and clear_mailmap() to mailmap, 2009-02-08) the intent was clearly to
clear the "me" structure, but while we freed parts of the
mailmap_entry structure, we didn't free the structure itself. The same
goes for the "mailmap_info" structure.

This brings the number of SANITIZE=leak failures in t4203-mailmap.sh
down from 50 to 49. Not really progress as far as the number of
failures is concerned, but as far as I can tell this fixes all leaks
in mailmap.c itself. There's still users of it such as builtin/log.c
that call read_mailmap() without a clear_mailmap(), but that's on
them.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agouserdiff: support enum keyword in PHP hunk header
USAMI Kenta [Tue, 31 Aug 2021 06:01:25 +0000 (06:01 +0000)] 
userdiff: support enum keyword in PHP hunk header

"enum" keyword will be introduced in PHP 8.1.
https://wiki.php.net/rfc/enumerations

Signed-off-by: USAMI Kenta <tadsan@zonu.me>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agofast-export: fix anonymized tag using original length
Tal Kelrich [Tue, 31 Aug 2021 15:55:54 +0000 (15:55 +0000)] 
fast-export: fix anonymized tag using original length

Commit 7f4075949686 (fast-export: tighten anonymize_mem() interface to
handle only strings, 2020-06-23) changed the interface used in anonymizing
strings, but failed to update the size of annotated tag messages to match
the new anonymized string.

As a result, exporting tags having messages longer than 13 characters
would create output that couldn't be parsed by fast-import,
as the data length indicated was larger than the data output.

Reset the message size when anonymizing, and add a tag with a "long"
message to the test.

Signed-off-by: Tal Kelrich <hasturkun@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agoprotocol-caps.c: fix memory leak in send_info()
Ævar Arnfjörð Bjarmason [Tue, 31 Aug 2021 13:46:42 +0000 (15:46 +0200)] 
protocol-caps.c: fix memory leak in send_info()

Fix a memory leak in a2ba162cda (object-info: support for retrieving
object info, 2021-04-20) which appears to have been based on a
misunderstanding of how the pkt-line.c API works. There is no need to
strdup() input to packet_writer_write(), it's just a printf()-like
format function.

This fixes a potentially large memory leak, since the number of OID
lines the "object-info" call can be arbitrarily large (or a small one
if the request is small).

This makes t5701-git-serve.sh pass again under SANITIZE=leak, as it
did before a2ba162cda2.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Acked-by: Bruno Albuquerque <bga@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agocommit-graph: show "unexpected subcommand" error
Ævar Arnfjörð Bjarmason [Mon, 23 Aug 2021 12:30:21 +0000 (14:30 +0200)] 
commit-graph: show "unexpected subcommand" error

Bring the "commit-graph" command in line with the error output and
general pattern in cmd_multi_pack_index().

Let's test for that output, and also cover the same potential bug as
was fixed in the multi-pack-index command in
88617d11f9d (multi-pack-index: fix potential segfault without
sub-command, 2021-07-19).

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Reviewed-by: Taylor Blau <me@ttaylorr.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agocommit-graph: show usage on "commit-graph [write|verify] garbage"
Ævar Arnfjörð Bjarmason [Mon, 23 Aug 2021 12:30:20 +0000 (14:30 +0200)] 
commit-graph: show usage on "commit-graph [write|verify] garbage"

Change the parse_options() invocation in the commit-graph code to
error on unknown leftover argv elements, in addition to the existing
and implicit erroring via parse_options() on unknown options.

We'd already error in cmd_commit_graph() on e.g.:

    git commit-graph unknown verify
    git commit-graph --unknown verify

But here we're calling parse_options() twice more for the "write" and
"verify" subcommands. We did not do the same checking for leftover
argv elements there. As a result we'd silently accept garbage in these
subcommands, let's not do that.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Reviewed-by: Taylor Blau <me@ttaylorr.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agocommit-graph: early exit to "usage" on !argc
Ævar Arnfjörð Bjarmason [Mon, 23 Aug 2021 12:30:19 +0000 (14:30 +0200)] 
commit-graph: early exit to "usage" on !argc

Rather than guarding all of the !argc with an additional "if" arm
let's do an early goto to "usage". This also makes it clear that
"save_commit_buffer" is not needed in this case.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Reviewed-by: Taylor Blau <me@ttaylorr.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agomulti-pack-index: refactor "goto usage" pattern
Ævar Arnfjörð Bjarmason [Mon, 23 Aug 2021 12:30:18 +0000 (14:30 +0200)] 
multi-pack-index: refactor "goto usage" pattern

Refactor the "goto usage" pattern added in
cd57bc41bbc (builtin/multi-pack-index.c: display usage on unrecognized
command, 2021-03-30) and 88617d11f9d (multi-pack-index: fix potential
segfault without sub-command, 2021-07-19) to maintain the same
brevity, but in a form that doesn't run afoul of the recommendation in
CodingGuidelines about braces:

    When there are multiple arms to a conditional and some of them
    require braces, enclose even a single line block in braces for
    consistency[...]

Let's also change "argv == 0" to juts "!argv", per:

    Do not explicitly compare an integral value with constant 0 or
    '\0', or a pointer value with constant NULL[...]

I'm changing this because in a subsequent commit I'll make
builtin/commit-graph.c use the same pattern, having the two similarly
structured commands match aids readability.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Reviewed-by: Taylor Blau <me@ttaylorr.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agocommit-graph: use parse_options_concat()
Ævar Arnfjörð Bjarmason [Mon, 23 Aug 2021 12:30:17 +0000 (14:30 +0200)] 
commit-graph: use parse_options_concat()

Make use of the parse_options_concat() so we don't need to copy/paste
common options like --object-dir.

This is inspired by a similar change to "checkout" in 2087182272
(checkout: split options[] array in three pieces, 2019-03-29), and the
same pattern in the multi-pack-index command, see
60ca94769ce (builtin/multi-pack-index.c: split sub-commands,
2021-03-30).

A minor behavior change here is that now we're going to list both
--object-dir and --progress first, before we'd list --progress along
with other options.

Co-authored-by: Taylor Blau <me@ttaylorr.com>
Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Reviewed-by: Taylor Blau <me@ttaylorr.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agocommit-graph: remove redundant handling of -h
Ævar Arnfjörð Bjarmason [Mon, 23 Aug 2021 12:30:16 +0000 (14:30 +0200)] 
commit-graph: remove redundant handling of -h

If we don't handle the -h option here like most parse_options() users
we'll fall through and it'll do the right thing for us.

I think this code added in 4ce58ee38d (commit-graph: create
git-commit-graph builtin, 2018-04-02) was always redundant,
parse_options() did this at the time, and the commit-graph code never
used PARSE_OPT_NO_INTERNAL_HELP.

We don't need a test for this, it's tested by the t0012-help.sh test
added in d691551192a (t0012: test "-h" with builtins, 2017-05-30).

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Reviewed-by: Taylor Blau <me@ttaylorr.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agocommit-graph: define common usage with a macro
Ævar Arnfjörð Bjarmason [Mon, 23 Aug 2021 12:30:15 +0000 (14:30 +0200)] 
commit-graph: define common usage with a macro

Share the usage message between these three variables by using a
macro. Before this new options needed to copy/paste the usage
information, see e.g. 809e0327f5 (builtin/commit-graph.c: introduce
'--max-new-filters=<n>', 2020-09-18).

See b25b727494f (builtin/multi-pack-index.c: define common usage with
a macro, 2021-03-30) for another use of this pattern (but on-list this
one came first).

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Reviewed-by: Taylor Blau <me@ttaylorr.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agosequencer: advise if skipping cherry-picked commit
Josh Steadmon [Mon, 30 Aug 2021 21:46:02 +0000 (14:46 -0700)] 
sequencer: advise if skipping cherry-picked commit

Silently skipping commits when rebasing with --no-reapply-cherry-picks
(currently the default behavior) can cause user confusion. Issue
warnings when this happens, as well as advice on how to preserve the
skipped commits.

These warnings and advice are displayed only when using the (default)
"merge" rebase backend.

Update the git-rebase docs to mention the warnings and advice.

Signed-off-by: Josh Steadmon <steadmon@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agoThe second batch
Junio C Hamano [Mon, 30 Aug 2021 23:06:22 +0000 (16:06 -0700)] 
The second batch

The most significant of this batch is of course "merge -sort".
Thanks, Elijah and everybody who helped the topic.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agoMerge branch 'cb/ci-freebsd-update'
Junio C Hamano [Mon, 30 Aug 2021 23:06:06 +0000 (16:06 -0700)] 
Merge branch 'cb/ci-freebsd-update'

Update FreeBSD CI job

* cb/ci-freebsd-update:
  ci: update freebsd 12 cirrus job

3 years agoMerge branch 'tl/traverse-non-commits-rename'
Junio C Hamano [Mon, 30 Aug 2021 23:06:06 +0000 (16:06 -0700)] 
Merge branch 'tl/traverse-non-commits-rename'

Meh.

* tl/traverse-non-commits-rename:
  list-objects.c: rename "traverse_trees_and_blobs" to "traverse_non_commits"

3 years agoMerge branch 'bc/t5607-avoid-broken-test-fail-prereqs'
Junio C Hamano [Mon, 30 Aug 2021 23:06:05 +0000 (16:06 -0700)] 
Merge branch 'bc/t5607-avoid-broken-test-fail-prereqs'

The current implementation of GIT_TEST_FAIL_PREREQS is broken in
that checking for the lack of a prerequisite would not work.  Avoid
the use of "if ! test_have_prereq X" in a test script.

* bc/t5607-avoid-broken-test-fail-prereqs:
  t5607: avoid using prerequisites to select algorithm

3 years agoMerge branch 'th/userdiff-more-java'
Junio C Hamano [Mon, 30 Aug 2021 23:06:05 +0000 (16:06 -0700)] 
Merge branch 'th/userdiff-more-java'

The userdiff pattern for "java" language has been updated.

* th/userdiff-more-java:
  userdiff: improve java hunk header regex

3 years agoMerge branch 'jk/range-diff-fixes'
Junio C Hamano [Mon, 30 Aug 2021 23:06:05 +0000 (16:06 -0700)] 
Merge branch 'jk/range-diff-fixes'

"git range-diff" code clean-up.

* jk/range-diff-fixes:
  range-diff: use ssize_t for parsed "len" in read_patches()
  range-diff: handle unterminated lines in read_patches()
  range-diff: drop useless "offset" variable from read_patches()

3 years agoMerge branch 'jk/apply-binary-hunk-parsing-fix'
Junio C Hamano [Mon, 30 Aug 2021 23:06:04 +0000 (16:06 -0700)] 
Merge branch 'jk/apply-binary-hunk-parsing-fix'

"git apply" miscounted the bytes and failed to read to the end of
binary hunks.

* jk/apply-binary-hunk-parsing-fix:
  apply: keep buffer/size pair in sync when parsing binary hunks

3 years agoMerge branch 'jc/userdiff-pattern-hint'
Junio C Hamano [Mon, 30 Aug 2021 23:06:03 +0000 (16:06 -0700)] 
Merge branch 'jc/userdiff-pattern-hint'

Remind developers that the userdiff patterns should be kept simple
and permissive, assuming that the contents they apply are always
syntactically correct.

* jc/userdiff-pattern-hint:
  userdiff: comment on the builtin patterns

3 years agoMerge branch 'cb/builtin-merge-format-string-fix'
Junio C Hamano [Mon, 30 Aug 2021 23:06:02 +0000 (16:06 -0700)] 
Merge branch 'cb/builtin-merge-format-string-fix'

Code clean-up.

* cb/builtin-merge-format-string-fix:
  builtin/merge: avoid -Wformat-extra-args from ancient Xcode

3 years agoMerge branch 'js/log-protocol-version'
Junio C Hamano [Mon, 30 Aug 2021 23:06:02 +0000 (16:06 -0700)] 
Merge branch 'js/log-protocol-version'

Debugging aid.

* js/log-protocol-version:
  connect, protocol: log negotiated protocol version

3 years agoMerge branch 'en/ort-becomes-the-default'
Junio C Hamano [Mon, 30 Aug 2021 23:06:01 +0000 (16:06 -0700)] 
Merge branch 'en/ort-becomes-the-default'

Use `ort` instead of `recursive` as the default merge strategy.

* en/ort-becomes-the-default:
  Update docs for change of default merge backend
  Change default merge backend from recursive to ort

3 years agoMerge branch 'en/merge-strategy-docs'
Junio C Hamano [Mon, 30 Aug 2021 23:06:01 +0000 (16:06 -0700)] 
Merge branch 'en/merge-strategy-docs'

Documentation updates.

* en/merge-strategy-docs:
  Update error message and code comment
  merge-strategies.txt: add coverage of the `ort` merge strategy
  git-rebase.txt: correct out-of-date and misleading text about renames
  merge-strategies.txt: fix simple capitalization error
  merge-strategies.txt: avoid giving special preference to patience algorithm
  merge-strategies.txt: do not imply using copy detection is desired
  merge-strategies.txt: update wording for the resolve strategy
  Documentation: edit awkward references to `git merge-recursive`
  directory-rename-detection.txt: small updates due to merge-ort optimizations
  git-rebase.txt: correct antiquated claims about --rebase-merges

3 years agoMerge branch 'en/pull-conflicting-options'
Junio C Hamano [Mon, 30 Aug 2021 23:06:01 +0000 (16:06 -0700)] 
Merge branch 'en/pull-conflicting-options'

"git pull" had various corner cases that were not well thought out
around its --rebase backend, e.g. "git pull --ff-only" did not stop
but went ahead and rebased when the history on other side is not a
descendant of our history.  The series tries to fix them up.

* en/pull-conflicting-options:
  pull: fix handling of multiple heads
  pull: update docs & code for option compatibility with rebasing
  pull: abort by default when fast-forwarding is not possible
  pull: make --rebase and --no-rebase override pull.ff=only
  pull: since --ff-only overrides, handle it first
  pull: abort if --ff-only is given and fast-forwarding is impossible
  t7601: add tests of interactions with multiple merge heads and config
  t7601: test interaction of merge/rebase/fast-forward flags and options

3 years agoclone: set submodule.recurse=true if submodule.stickyRecursiveClone enabled
Mahi Kolla [Sat, 14 Aug 2021 01:09:56 +0000 (01:09 +0000)] 
clone: set submodule.recurse=true if submodule.stickyRecursiveClone enabled

Based on current experience, when running git clone --recurse-submodules,
developers do not expect other commands such as pull or checkout to run
recursively into active submodules. However, setting submodule.recurse=true
at this step could make for a simpler workflow by eliminating the need for
the --recurse-submodules option in subsequent commands. To collect more
data on developers' preference in regards to making submodule.recurse=true
a default config value in the future, deploy this feature under the opt in
submodule.stickyRecursiveClone flag.

Signed-off-by: Mahi Kolla <mkolla2@illinois.edu>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agosend-email: avoid incorrect header propagation
Marvin Häuser [Mon, 30 Aug 2021 15:30:01 +0000 (15:30 +0000)] 
send-email: avoid incorrect header propagation

If multiple independent patches are sent with send-email, even if the
"In-Reply-To" and "References" headers are not managed by --thread or
--in-reply-to, their values may be propagated from prior patches to
subsequent patches with no such headers defined.

To mitigate this and potential future issues, make sure all global
patch-specific variables are always either handled by
command-specific code (e.g. threading), or are reset to their default
values for every iteration.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Marvin Häuser <mhaeuser@posteo.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agofetch: skip formatting updated refs with `--quiet`
Patrick Steinhardt [Mon, 30 Aug 2021 10:54:26 +0000 (12:54 +0200)] 
fetch: skip formatting updated refs with `--quiet`

When fetching, Git will by default print a list of all updated refs in a
nicely formatted table. In order to come up with this table, Git needs
to iterate refs twice: first to determine the maximum column width, and
a second time to actually format these changed refs.

While this table will not be printed in case the user passes `--quiet`,
we still go out of our way and do all these steps. In fact, we even do
more work compared to not passing `--quiet`: without the flag, we will
skip all references in the column width computation which have not been
updated, but if it is set we will now compute widths for all refs.

Fix this issue by completely skipping both preparation of the format and
formatting data for display in case the user passes `--quiet`, improving
performance especially with many refs. The following benchmark shows a
nice speedup for a quiet mirror-fetch in a repository with 2.3M refs:

    Benchmark #1: HEAD~: git-fetch
      Time (mean ± σ):     26.929 s ±  0.145 s    [User: 24.194 s, System: 4.656 s]
      Range (min … max):   26.692 s … 27.068 s    5 runs

    Benchmark #2: HEAD: git-fetch
      Time (mean ± σ):     25.189 s ±  0.094 s    [User: 22.556 s, System: 4.606 s]
      Range (min … max):   25.070 s … 25.314 s    5 runs

    Summary
      'HEAD: git-fetch' ran
        1.07 ± 0.01 times faster than 'HEAD~: git-fetch'

While at it, this patch also fixes `adjust_refcol_width()` such that it
skips unchanged refs in case the user passed `--quiet`, where verbosity
will be negative. While this function won't be called anymore if so,
this brings the comment in line with actual code. Furthermore, needless
`verbosity >= 0` checks are now removed in `store_updated_refs()`: we
never print to the `note` buffer anymore in case `verbosity < 0`, so we
won't end up in that code block anyway.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agomerge-recursive: use fspathcmp() in path_hashmap_cmp()
René Scharfe [Sat, 28 Aug 2021 21:30:49 +0000 (23:30 +0200)] 
merge-recursive: use fspathcmp() in path_hashmap_cmp()

Call fspathcmp() instead of open-coding it.  This shortens the code and
makes it less repetitive.

Signed-off-by: René Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agotest-lib: set GIT_CEILING_DIRECTORIES to protect the surrounding repository
SZEDER Gábor [Sun, 29 Aug 2021 09:25:36 +0000 (11:25 +0200)] 
test-lib: set GIT_CEILING_DIRECTORIES to protect the surrounding repository

Every once in a while a test somehow manages to escape from its trash
directory and modifies the surrounding repository, whether because of
a bug in git itself, a bug in a test [1], or e.g. when trying to run
tests with a shell that is, in general, unable to run our tests [2].

Set GIT_CEILING_DIRECTORIES="$TRASH_DIRECTORY/.." as an additional
safety measure to protect the surrounding repository at least from
modifications by git commands executed in the tests (assuming that
handling of ceiling directories during repository discovery is not
broken, and, of course, it won't save us from regular shell commands,
e.g. 'cd .. && rm -f ...').

[1] e.g. https://public-inbox.org/git/20210423051255.GD2947267@szeder.dev
[2] $ git symbolic-ref HEAD
    refs/heads/master
    $ ksh ./t2011-checkout-invalid-head.sh
    [... a lot of "not ok" ...]
    $ git symbolic-ref HEAD
    refs/heads/other

    (In short: 'ksh' doesn't support the 'local' builtin command,
    which is used by 'test_oid', causing it to return with error
    whenever it's called, leaving ZERO_OID set to empty, so when the
    test 'checkout main from invalid HEAD' runs 'echo $ZERO_OID
    >.git/HEAD' it writes a corrupt (not invalid) HEAD, and subsequent
    git commands don't recognize the repository in the trash directory
    anymore, but operate on the surrounding repo.)

Signed-off-by: SZEDER Gábor <szeder.dev@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agodoc: fix syntax error and the format of printf
Zoker [Sat, 28 Aug 2021 09:02:12 +0000 (09:02 +0000)] 
doc: fix syntax error and the format of printf

Fix syntax and correct the format of printf in MyFirstObjectWalk.txt

Signed-off-by: Zoker <kaixuanguiqu@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agosparse-index: copy dir_hash in ensure_full_index()
Jeff Hostetler [Mon, 16 Aug 2021 17:48:55 +0000 (17:48 +0000)] 
sparse-index: copy dir_hash in ensure_full_index()

Copy the 'index_state->dir_hash' back to the real istate after expanding
a sparse index.

A crash was observed in 'git status' during some hashmap lookups with
corrupted hashmap entries.  During an index expansion, new cache-entries
are added to the 'index_state->name_hash' and the 'dir_hash' in a
temporary 'index_state' variable 'full'.  However, only the 'name_hash'
hashmap from this temp variable was copied back into the real 'istate'
variable.  The original copy of the 'dir_hash' was incorrectly
preserved.  If the table in the 'full->dir_hash' hashmap were realloced,
the stale version (in 'istate') would be corrupted.

The test suite does not operate on index sizes sufficiently large to
trigger this reallocation, so they do not cover this behavior.
Increasing the test suite to cover such scale is fragile and likely
wasteful.

Signed-off-by: Jeff Hostetler <jeffhost@microsoft.com>
Signed-off-by: Derrick Stolee <dstolee@microsoft.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agobuiltin/pack-objects.c: remove duplicate hash lookup
Taylor Blau [Mon, 30 Aug 2021 02:48:57 +0000 (22:48 -0400)] 
builtin/pack-objects.c: remove duplicate hash lookup

In the original code from 08cdfb1337 (pack-objects --keep-unreachable,
2007-09-16), we add each object to the packing list with type
`obj->type`, where `obj` comes from `lookup_unknown_object()`. Unless we
had already looked up and parsed the object, this will be `OBJ_NONE`.
That's fine, since oe_set_type() sets the type_valid bit to '0', and we
determine the real type later on.

So the only thing we need from the object lookup is access to the
`flags` field so that we can mark that we've added the object with
`OBJECT_ADDED` to avoid adding it again (we can just pass `OBJ_NONE`
directly instead of grabbing it from the object).

But add_object_entry() already rejects duplicates! This has been the
behavior since 7a979d99ba (Thin pack - create packfile with missing
delta base., 2006-02-19), but 08cdfb1337 didn't take advantage of it.
Moreover, to do the OBJECT_ADDED check, we have to do a hash lookup in
`obj_hash`.

So we can drop the lookup_unknown_object() call completely, *and* the
OBJECT_ADDED flag, too, since the spot we're touching here is the only
location that checks it.

In the end, we perform the same number of hash lookups, but with the
added bonus that we don't waste memory allocating an OBJ_NONE object (if
we were traversing, we'd need it eventually, but the whole point of this
code path is not to traverse).

Signed-off-by: Taylor Blau <me@ttaylorr.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agobuiltin/pack-objects.c: simplify add_objects_in_unpacked_packs()
Taylor Blau [Mon, 30 Aug 2021 02:48:54 +0000 (22:48 -0400)] 
builtin/pack-objects.c: simplify add_objects_in_unpacked_packs()

This function is used to implement `pack-objects`'s `--keep-unreachable`
option, but can be simplified in a couple of ways:

  - add_objects_in_unpacked_packs() iterates over all packs (and then
    all packed objects) itself, but could use for_each_packed_object()
    instead since the missing flags necessary were added in the previous
    commit

  - objects are added to an in_pack array which store (off_t, object)
    tuples, and then sorted in offset order when we could iterate
    objects in offset order.

    There is a slight behavior change here: before we would have added
    objects in sorted offset order among _all_ packs. Handing objects to
    create_object_entry() in pack order for each pack (instead of
    feeding objects from all packs simultaneously their offset relative
    to different packs) is much more reasonable, if different than how
    the code currently works.

  - objects in a single pack are iterated in index order and searched
    for in order to discover their offsets, which is much less efficient
    than using the on-disk reverse index

Simplify the function by addressing each of the above and moving the
core of the loop into a callback function that we then pass to
for_each_packed_object() instead of open-coding the latter function
ourselves.

Signed-off-by: Taylor Blau <me@ttaylorr.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agoobject-store.h: teach for_each_packed_object to ignore kept packs
Taylor Blau [Mon, 30 Aug 2021 02:48:52 +0000 (22:48 -0400)] 
object-store.h: teach for_each_packed_object to ignore kept packs

The next patch will reimplement a function that wants to iterate over
packed objects while ignoring packs which are marked as kept (either
in-core or on-disk).

Teach for_each_packed_object() to ignore all objects from those packs by
adding a new flag for each of the "kept" states that a pack can be in.

Signed-off-by: Taylor Blau <me@ttaylorr.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agobranch: allow deleting dangling branches with --force
René Scharfe [Fri, 27 Aug 2021 18:35:35 +0000 (20:35 +0200)] 
branch: allow deleting dangling branches with --force

git branch only allows deleting branches that point to valid commits.
Skip that check if --force is given, as the caller is indicating with
it that they know what they are doing and accept the consequences.
This allows deleting dangling branches, which previously had to be
reset to a valid start-point using --force first.

Reported-by: Ulrich Windl <Ulrich.Windl@rz.uni-regensburg.de>
Helped-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Helped-by: Junio C Hamano <gitster@pobox.com>
Signed-off-by: René Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agoarchive: convert queue_directory to struct object_id
René Scharfe [Fri, 27 Aug 2021 19:59:16 +0000 (21:59 +0200)] 
archive: convert queue_directory to struct object_id

Pass the struct object_id on instead of just its hash member.
This is simpler and avoids the need to guess the algorithm.

Signed-off-by: René Scharfe <l.s.r@web.de>
Acked-by: brian m. carlson <sandals@crustytoothpaste.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agoshow-branch: simplify rev_is_head()
René Scharfe [Fri, 27 Aug 2021 19:20:27 +0000 (21:20 +0200)] 
show-branch: simplify rev_is_head()

Only one of the callers of rev_is_head() provides two hashes to compare.
Move that check there and convert it to struct object_id.

Signed-off-by: René Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agodocs: use "character encoding" to refer to commit-object encoding
Jeff King [Fri, 27 Aug 2021 18:32:06 +0000 (14:32 -0400)] 
docs: use "character encoding" to refer to commit-object encoding

The word "encoding" can mean a lot of things (e.g., base64 or
quoted-printable encoding in emails, HTML entities, URL encoding, and so
on). The documentation for i18n.commitEncoding and i18n.logOutputEncoding
uses the phrase "character encoding" to make this more clear.

Let's use that phrase in other places to make it clear what kind of
encoding we are talking about. This patch covers the gui.encoding
option, as well as the --encoding option for git-log, etc (in this
latter case, I word-smithed the sentence a little at the same time).
That, coupled with the mention of iconv in the --encoding description,
should make this more clear.

The other spot I looked at is the working-tree-encoding section of
gitattributes(5). But it gives specific examples of encodings that I
think make the meaning pretty clear already.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agologmsg_reencode(): warn when iconv() fails
Jeff King [Fri, 27 Aug 2021 18:30:15 +0000 (14:30 -0400)] 
logmsg_reencode(): warn when iconv() fails

If the user asks for a pretty-printed commit to be converted (either
explicitly with --encoding=foo, or implicitly because the commit is
non-utf8 and we want to convert it), we pass it through iconv(). If that
fails, we fall back to showing the input verbatim, but don't tell the
user that the output may be bogus.

Let's add a warning to do so, along with a mention in the documentation
for --encoding. Two things to note about the implementation:

  - we could produce the warning closer to the call to iconv() in
    reencode_string_len(), which would let us relay the value of errno.
    But this is not actually very helpful. reencode_string_len() does
    not know we are operating on a commit, and indeed does not know that
    the caller won't produce an error of its own. And the errno values
    from iconv() are seldom helpful (iconv_open() only ever produces
    EINVAL; perhaps EILSEQ from iconv() might be illuminating, but it
    can also return EINVAL for incomplete sequences).

  - if the reason for the failure is that the output charset is not
    supported, then the user will see this warning for every commit we
    try to display. That might be ugly and overwhelming, but on the
    other hand it is making it clear that every one of them has not been
    converted (and the likely outcome anyway is to re-try the command
    with a supported output encoding).

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agocheckout: make delayed checkout respect --quiet and --no-progress
Matheus Tavares [Thu, 26 Aug 2021 19:10:06 +0000 (16:10 -0300)] 
checkout: make delayed checkout respect --quiet and --no-progress

The 'Filtering contents...' progress report from delayed checkout is
displayed even when checkout and clone are invoked with --quiet or
--no-progress. Furthermore, it is displayed unconditionally, without
first checking whether stdout is a tty. Let's fix these issues and also
add some regression tests for the two code paths that currently use
delayed checkout: unpack_trees.c:check_updates() and
builtin/checkout.c:checkout_worktree().

Signed-off-by: Matheus Tavares <matheus.bernardino@usp.br>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agocolumn: fix parsing of the '--nl' option
SZEDER Gábor [Wed, 18 Aug 2021 09:24:56 +0000 (11:24 +0200)] 
column: fix parsing of the '--nl' option

'git column's '--nl' option can be used to specify a "string to be
printed at the end of each line" (quoting the man page), but this
option and its mandatory argument has been parsed as OPT_INTEGER since
the introduction of the command in 7e29b8254f (Add column layout
skeleton and git-column, 2012-04-21).  Consequently, any non-number
argument is rejected by parse-options, and any number other than 0
leads to segfault:

  $ printf "%s\n" one two |git column --mode=plain --nl=foo
  error: option `nl' expects a numerical value
  $ printf "%s\n" one two |git column --mode=plain --nl=42
  Segmentation fault (core dumped)
  $ printf "%s\n" one two |git column --mode=plain --nl=0
  one
  two

Parse this option as OPT_STRING.

Signed-off-by: SZEDER Gábor <szeder.dev@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>