]> git.ipfire.org Git - thirdparty/git.git/log
thirdparty/git.git
3 years agowrapper.c: add x{un,}setenv(), and use xsetenv() in environment.c
Ævar Arnfjörð Bjarmason [Tue, 21 Sep 2021 13:12:59 +0000 (15:12 +0200)] 
wrapper.c: add x{un,}setenv(), and use xsetenv() in environment.c

Add fatal wrappers for setenv() and unsetenv(). In d7ac12b25d3 (Add
set_git_dir() function, 2007-08-01) we started checking its return
value, and since 48988c4d0c3 (set_git_dir: die when setenv() fails,
2018-03-30) we've had set_git_dir_1() die if we couldn't set it.

Let's provide a wrapper for both, this will be useful in many other
places, a subsequent patch will make another use of xsetenv().

The checking of the return value here is over-eager according to
setenv(3) and POSIX. It's documented as returning just -1 or 0, so
perhaps we should be checking -1 explicitly.

Let's just instead die on any non-zero, if our C library is so broken
as to return something else than -1 on error (and perhaps not set
errno?) the worst we'll do is die with a nonsensical errno value, but
we'll want to die in either case.

Let's make these return "void" instead of "int". As far as I can tell
there's no other x*() wrappers that needed to make the decision of
deviating from the signature in the C library, but since their return
value is only used to indicate errors (so we'd die here), we can catch
unreachable code such as

    if (xsetenv(...) < 0)
        [...];

I think it would be OK skip the NULL check of the "name" here for the
calls to die_errno(). Almost all of our setenv() callers are taking a
constant string hardcoded in the source as the first argument, and for
the rest we can probably assume they've done the NULL check
themselves. Even if they didn't, modern C libraries are forgiving
about it (e.g. glibc formatting it as "(null)"), on those that aren't,
well, we were about to die anyway. But let's include the check anyway
for good measure.

1. https://pubs.opengroup.org/onlinepubs/009604499/functions/setenv.html

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agoThe sixth batch
Junio C Hamano [Wed, 15 Sep 2021 20:15:09 +0000 (13:15 -0700)] 
The sixth batch

Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agoMerge branch 'jc/prefix-filename-allocates'
Junio C Hamano [Wed, 15 Sep 2021 20:15:28 +0000 (13:15 -0700)] 
Merge branch 'jc/prefix-filename-allocates'

Leakfix.

* jc/prefix-filename-allocates:
  hash-object: prefix_filename() returns allocated memory these days

3 years agoMerge branch 'rs/range-diff-avoid-segfault-with-I'
Junio C Hamano [Wed, 15 Sep 2021 20:15:27 +0000 (13:15 -0700)] 
Merge branch 'rs/range-diff-avoid-segfault-with-I'

"git range-diff -I... <range> <range>" segfaulted, which has been
corrected.

* rs/range-diff-avoid-segfault-with-I:
  range-diff: avoid segfault with -I

3 years agoMerge branch 'ab/reverse-midx-optim'
Junio C Hamano [Wed, 15 Sep 2021 20:15:27 +0000 (13:15 -0700)] 
Merge branch 'ab/reverse-midx-optim'

The code that optionally creates the *.rev reverse index file has
been optimized to avoid needless computation when it is not writing
the file out.

* ab/reverse-midx-optim:
  pack-write: skip *.rev work when not writing *.rev

3 years agoMerge branch 'bs/install-strip'
Junio C Hamano [Wed, 15 Sep 2021 20:15:26 +0000 (13:15 -0700)] 
Merge branch 'bs/install-strip'

"make INSTALL_STRIP=-s install" allows the installation step to use
"install -s" to strip the binaries as they get installed.

* bs/install-strip:
  make: add INSTALL_STRIP option variable

3 years agoMerge branch 'pb/test-use-user-env'
Junio C Hamano [Wed, 15 Sep 2021 20:15:26 +0000 (13:15 -0700)] 
Merge branch 'pb/test-use-user-env'

Teach "test_pause" and "debug" helpers to allow using the HOME and
TERM environment variables the user usually uses.

* pb/test-use-user-env:
  test-lib-functions: keep user's debugger config files and TERM in 'debug'
  test-lib-functions: optionally keep HOME, TERM and SHELL in 'test_pause'
  test-lib-functions: use 'TEST_SHELL_PATH' in 'test_pause'

3 years agoMerge branch 'jc/trivial-threeway-binary-merge'
Junio C Hamano [Wed, 15 Sep 2021 20:15:26 +0000 (13:15 -0700)] 
Merge branch 'jc/trivial-threeway-binary-merge'

The "git apply -3" code path learned not to bother the lower level
merge machinery when the three-way merge can be trivially resolved
without the content level merge.

* jc/trivial-threeway-binary-merge:
  apply: resolve trivial merge without hitting ll-merge with "--3way"

3 years agoMerge branch 'bs/doc-bugreport-outdir'
Junio C Hamano [Wed, 15 Sep 2021 20:15:25 +0000 (13:15 -0700)] 
Merge branch 'bs/doc-bugreport-outdir'

Docfix.

* bs/doc-bugreport-outdir:
  Documentation: fix default directory of git bugreport -o

3 years agoMerge branch 'ab/no-more-check-bindir'
Junio C Hamano [Wed, 15 Sep 2021 20:15:25 +0000 (13:15 -0700)] 
Merge branch 'ab/no-more-check-bindir'

Build simplification.

* ab/no-more-check-bindir:
  Makefile: remove the check_bindir script

3 years agoMerge branch 'ab/send-email-config-fix'
Junio C Hamano [Wed, 15 Sep 2021 20:15:24 +0000 (13:15 -0700)] 
Merge branch 'ab/send-email-config-fix'

Regression fix.

* ab/send-email-config-fix:
  send-email: fix a "first config key wins" regression in v2.33.0

3 years agoMerge branch 'so/diff-index-regression-fix'
Junio C Hamano [Wed, 15 Sep 2021 20:15:24 +0000 (13:15 -0700)] 
Merge branch 'so/diff-index-regression-fix'

Recent "diff -m" changes broke "gitk", which has been corrected.

* so/diff-index-regression-fix:
  diff-index: restore -c/--cc options handling

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 agopack-write: skip *.rev work when not writing *.rev
Ævar Arnfjörð Bjarmason [Wed, 8 Sep 2021 01:08:03 +0000 (03:08 +0200)] 
pack-write: skip *.rev work when not writing *.rev

Fix a performance regression introduced in a587b5a786 (pack-write.c:
extract 'write_rev_file_order', 2021-03-30) and stop needlessly
allocating the "pack_order" array and sorting it with
"pack_order_cmp()", only to throw that work away when we discover that
we're not writing *.rev files after all.

This redundant work was not present in the original version of this
code added in 8ef50d9958 (pack-write.c: prepare to write 'pack-*.rev'
files, 2021-01-25). There we'd call write_rev_file() from
e.g. finish_tmp_packfile(), but we'd "return NULL" early in
write_rev_file() if not doing a "WRITE_REV" or "WRITE_REV_VERIFY".

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agohash-object: prefix_filename() returns allocated memory these days
Junio C Hamano [Tue, 7 Sep 2021 22:10:22 +0000 (15:10 -0700)] 
hash-object: prefix_filename() returns allocated memory these days

Back when a1be47e4 (hash-object: fix buffer reuse with --path in a
subdirectory, 2017-03-20) was written, the prefix_filename() helper
used a static piece of memory to the caller, making the caller
responsible for copying it, if it wants to keep it across another
call to the same function.  Two callers of the prefix_filename() in
hash-object were made to xstrdup() the value obtained from it.

But in the same series, when e4da43b1 (prefix_filename: return newly
allocated string, 2017-03-20) changed the rule to gave the caller
possession of the memory, we forgot to revert one of the xstrdup()
changes, allowing the returned value to leak.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agoDocumentation: fix default directory of git bugreport -o
Bagas Sanjaya [Fri, 3 Sep 2021 11:59:34 +0000 (18:59 +0700)] 
Documentation: fix default directory of git bugreport -o

git bugreport writes bug report to the current directory by default,
instead of repository root.

Fix the documentation.

Signed-off-by: Bagas Sanjaya <bagasdotme@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agoMakefile: remove the check_bindir script
Ævar Arnfjörð Bjarmason [Mon, 6 Sep 2021 07:55:33 +0000 (09:55 +0200)] 
Makefile: remove the check_bindir script

This script was added in f28ac70f48 (Move all dashed-form commands to
libexecdir, 2007-11-28) when commands such as "git-add" lived in the
bin directory, instead of the git exec directory.

This notice helped someone incorrectly installing version v1.6.0 and
later into a directory built for a pre-v1.6.0 git version.

We're now long past the point where anyone who'd be helped by this
warning is likely to be doing that, so let's just remove this check
and warning to simplify the Makefile.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agosend-email: fix a "first config key wins" regression in v2.33.0
Ævar Arnfjörð Bjarmason [Mon, 6 Sep 2021 07:33:29 +0000 (09:33 +0200)] 
send-email: fix a "first config key wins" regression in v2.33.0

Fix a regression in my c95e3a3f0b8 (send-email: move trivial config
handling to Perl, 2021-05-28) where we'd pick the first config key out
of multiple defined ones, instead of using the normal "last key wins"
semantics of "git config --get".

This broke e.g. cases where a .git/config would have a different
sendemail.smtpServer than ~/.gitconfig. We'd pick the ~/.gitconfig
over .git/config, instead of preferring the repository-local
version. The same would go for /etc/gitconfig etc.

The full list of impacted config keys (the %config_settings values
which are references to scalars, not arrays) is:

    sendemail.smtpencryption
    sendemail.smtpserver
    sendemail.smtpserverport
    sendemail.smtpuser
    sendemail.smtppass
    sendemail.smtpdomain
    sendemail.smtpauth
    sendemail.smtpbatchsize
    sendemail.smtprelogindelay
    sendemail.tocmd
    sendemail.cccmd
    sendemail.aliasfiletype
    sendemail.envelopesender
    sendemail.confirm
    sendemail.from
    sendemail.assume8bitencoding
    sendemail.composeencoding
    sendemail.transferencoding
    sendemail.sendmailcmd

I.e. having any of these set in say ~/.gitconfig and in-repo
.git/config regressed in v2.33.0 to prefer the --global one over the
--local.

To test this add a test of config priority to one of these config
variables, most don't have tests at all, but there was an existing one
for sendemail.8bitEncoding.

The "git config" (instead of "test_config") is somewhat of an
anti-pattern, but follows established conventions in
t9001-send-email.sh, likewise with any other pattern or idiom in this
test.

The populating of home/.gitconfig and setting of HOME= is copied from
a test in t0017-env-helper.sh added in 1ff750b128e (tests: make
GIT_TEST_GETTEXT_POISON a boolean, 2019-06-21). This test fails
without this bugfix, but now it works.

Reported-by: Eli Schwartz <eschwartz@archlinux.org>
Tested-by: Eli Schwartz <eschwartz@archlinux.org>
Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agorange-diff: avoid segfault with -I
René Scharfe [Sat, 4 Sep 2021 07:50:58 +0000 (09:50 +0200)] 
range-diff: avoid segfault with -I

output() reuses the same struct diff_options for multiple calls of
diff_flush().  Set the option no_free to instruct it to keep the
ignore regexes between calls and release them explicitly at the end.

Signed-off-by: René Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agodiff-index: restore -c/--cc options handling
Sergey Organov [Wed, 1 Sep 2021 16:52:20 +0000 (19:52 +0300)] 
diff-index: restore -c/--cc options handling

This fixes 19b2517f (diff-merges: move specific diff-index "-m"
handling to diff-index, 2021-05-21).

That commit disabled handling of all diff for merges options in
diff-index on an assumption that they are unused. However, it later
appeared that -c and --cc, even though undocumented and not being
covered by tests, happen to have had particular effect on diff-index
output.

Restore original -c/--cc options handling by diff-index.

Signed-off-by: Sergey Organov <sorganov@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agotest-lib-functions: keep user's debugger config files and TERM in 'debug'
Philippe Blain [Mon, 6 Sep 2021 04:39:00 +0000 (04:39 +0000)] 
test-lib-functions: keep user's debugger config files and TERM in 'debug'

The 'debug' function in test-lib-functions.sh is used to invoke a
debugger at a specific line in a test. It inherits the value of HOME and
TERM set by 'test-lib.sh': HOME="$TRASH_DIRECTORY" and TERM=dumb.

Changing the value of HOME means that any customization configured in a
developers' debugger configuration file (like $HOME/.gdbinit or
$HOME/.lldbinit) are not available in the debugger invoked by
'test_pause'.

Changing the value of TERM to 'dumb' means that colored output
is disabled in the debugger.

To make the debugging experience with 'debug' more pleasant, leverage
the variable USER_HOME, added in the previous commit, to copy a
developer's ~/.gdbinit and ~/.lldbinit to the test HOME. We do not set
HOME to USER_HOME as in 'test_pause' to avoid user configuration in
$USER_HOME/.gitconfig from interfering with the command being debugged.

Also, add a flag to launch the debugger with the original value of
TERM, and add the same warning as for 'test_pause'.

Helped-by: Carlo Marcelo Arenas Belón <carenas@gmail.com>
Signed-off-by: Philippe Blain <levraiphilippeblain@gmail.com>
Acked-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agotest-lib-functions: optionally keep HOME, TERM and SHELL in 'test_pause'
Philippe Blain [Mon, 6 Sep 2021 04:38:59 +0000 (04:38 +0000)] 
test-lib-functions: optionally keep HOME, TERM and SHELL in 'test_pause'

The 'test_pause' function, which is designed to help interactive
debugging and exploration of tests, currently inherits the value of HOME
and TERM set by 'test-lib.sh': HOME="$TRASH_DIRECTORY" and TERM=dumb. It
also invokes the shell defined by TEST_SHELL_PATH, which defaults to
/bin/sh (through SHELL_PATH).

Changing the value of HOME means that any customization configured in a
developers' shell startup files and any Git aliases defined in their
global Git configuration file are not available in the shell invoked by
'test_pause'.

Changing the value of TERM to 'dumb' means that colored output
is disabled for all commands in that shell.

Using /bin/sh as the shell invoked by 'test_pause' is not ideal since
some platforms (i.e. Debian and derivatives) use Dash as /bin/sh, and
this shell is usually compiled without readline support, which makes for
a poor interactive command line experience.

To make the interactive command line experience in the shell invoked by
'test_pause' more pleasant, save the values of HOME and TERM in
USER_HOME and USER_TERM before changing them in test-lib.sh, and add
options to 'test_pause' to optionally use these variables to invoke the
shell. Also add an option to invoke SHELL instead of TEST_SHELL_PATH, so
that developer's interactive shell is used.

We use options instead of changing the behaviour unconditionally since
these three variables can slightly change command behaviour. Moreover,
using the original HOME means commands could overwrite files in a user's
home directory. Be explicit about these caveats in the new 'Usage'
section in test-lib-functions.sh.

Finally, add '[options]' to the test_pause synopsys in t/README, and
mention that the full list of helper functions and their options can be
found in test-lib-functions.sh.

Helped-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Philippe Blain <levraiphilippeblain@gmail.com>
Acked-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agotest-lib-functions: use 'TEST_SHELL_PATH' in 'test_pause'
Philippe Blain [Mon, 6 Sep 2021 04:38:58 +0000 (04:38 +0000)] 
test-lib-functions: use 'TEST_SHELL_PATH' in 'test_pause'

3f824e91c8 (t/Makefile: introduce TEST_SHELL_PATH, 2017-12-08)
made it easy to use a different shell for the tests than 'SHELL_PATH'
used at compile time. But 'test_pause' still invokes 'SHELL_PATH'.

If TEST_SHELL_PATH is set, invoke that shell in 'test_pause' for
consistency.

Suggested-by: Carlo Marcelo Arenas Belón <carenas@gmail.com>
Signed-off-by: Philippe Blain <levraiphilippeblain@gmail.com>
Acked-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agomake: add INSTALL_STRIP option variable
Bagas Sanjaya [Sun, 5 Sep 2021 19:17:56 +0000 (12:17 -0700)] 
make: add INSTALL_STRIP option variable

Add $(INSTALL_STRIP), which allows passing stripping options to
$(INSTALL).

For this to work, installing executables must be split to installing
compiled binaries and scripts portions, since $(INSTALL_STRIP) is only
meaningful to the former.

Users can set this variable depending on their system. For example,
Linux users can use `-s --strip-program=strip`, while FreeBSD users can
simply set to `-s` and choose strip program with $STRIPBIN.

[original outline by Đoàn Trần Công Danh]

Signed-off-by: Đoàn Trần Công Danh <congdanhqx@gmail.com>
Helped-by: Junio C Hamano <gitster@pobox.com>
Signed-off-by: Bagas Sanjaya <bagasdotme@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agoapply: resolve trivial merge without hitting ll-merge with "--3way"
Junio C Hamano [Sun, 5 Sep 2021 19:06:57 +0000 (12:06 -0700)] 
apply: resolve trivial merge without hitting ll-merge with "--3way"

The ll_binary_merge() function assumes that the ancestor blob is
different from either side of the new versions, and always fails
the merge in conflict, unless -Xours or -Xtheirs is in effect.

The normal "merge" machineries all resolve the trivial cases
(e.g. if our side changed while their side did not, the result
is ours) without triggering the file-level merge drivers, so the
assumption is warranted.

The code path in "git apply --3way", however, does not check for
the trivial three-way merge situation and always calls the
file-level merge drivers.  This used to be perfectly OK back
when we always first attempted a straight patch application and
used the three-way code path only as a fallback.  Any binary
patch that can be applied as a trivial three-way merge (e.g. the
patch is based exactly on the version we happen to have) would
always cleanly apply, so the ll_binary_merge() that is not
prepared to see the trivial case would not have to handle such a
case.

This no longer is true after we made "--3way" to mean "first try
three-way and then fall back to straight application", and made
"git apply -3" on a binary patch that is based on the current
version no longer apply.

Teach "git apply -3" to first check for the trivial merge cases
and resolve them without hitting the file-level merge drivers.

Signed-off-by: Jerry Zhang <jerry@skydio.com>
[jc: stolen tests from Jerry's patch]
Signed-off-by: Junio C Hamano <gitster@pobox.com>
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