]> git.ipfire.org Git - thirdparty/git.git/log
thirdparty/git.git
17 months agoMerge branch 'pe/time-use-gettimeofday'
Junio C Hamano [Tue, 28 Mar 2023 17:51:52 +0000 (10:51 -0700)] 
Merge branch 'pe/time-use-gettimeofday'

time(2) on glib 2.31+, especially on Linux, goes out of sync with
higher resolution timers used for gettimeofday(2) and by the
filesystem.  Replace all calls to it with a git_time() wrapper and
use gettimeofday(2) in its implementation.

* pe/time-use-gettimeofday:
  git-compat-util: use gettimeofday(2) for time(2)

17 months agoMerge branch 'jk/fix-proto-downgrade-to-v0'
Junio C Hamano [Tue, 28 Mar 2023 17:51:52 +0000 (10:51 -0700)] 
Merge branch 'jk/fix-proto-downgrade-to-v0'

Transports that do not support protocol v2 did not correctly fall
back to protocol v0 under certain conditions, which has been
corrected.

* jk/fix-proto-downgrade-to-v0:
  git_connect(): fix corner cases in downgrading v2 to v0

17 months agoMerge branch 'fc/oid-quietly-parse-upstream'
Junio C Hamano [Tue, 28 Mar 2023 17:51:52 +0000 (10:51 -0700)] 
Merge branch 'fc/oid-quietly-parse-upstream'

"git rev-parse --quiet foo@{u}", or anything that asks @{u} to be
parsed with GET_OID_QUIETLY option, did not quietly fail, which has
been corrected.

* fc/oid-quietly-parse-upstream:
  object-name: fix quiet @{u} parsing

17 months agoMerge branch 'fc/completion-colors-do-not-need-prompt-command'
Junio C Hamano [Tue, 28 Mar 2023 17:51:52 +0000 (10:51 -0700)] 
Merge branch 'fc/completion-colors-do-not-need-prompt-command'

Lift the limitation that colored prompts can only be used with
PROMPT_COMMAND mode.

* fc/completion-colors-do-not-need-prompt-command:
  completion: prompt: use generic colors

18 months agoThe third batch
Junio C Hamano [Tue, 21 Mar 2023 21:19:03 +0000 (14:19 -0700)] 
The third batch

Signed-off-by: Junio C Hamano <gitster@pobox.com>
18 months agoMerge branch 'fc/test-aggregation-clean-up'
Junio C Hamano [Tue, 21 Mar 2023 21:18:56 +0000 (14:18 -0700)] 
Merge branch 'fc/test-aggregation-clean-up'

Code clean-up for test framework.

* fc/test-aggregation-clean-up:
  test: don't print aggregate-results command
  test: simplify counts aggregation

18 months agoMerge branch 'ps/receive-pack-unlock-before-die'
Junio C Hamano [Tue, 21 Mar 2023 21:18:55 +0000 (14:18 -0700)] 
Merge branch 'ps/receive-pack-unlock-before-die'

"git receive-pack" that responds to "git push" requests failed to
clean a stale lockfile when killed in the middle, which has been
corrected.

* ps/receive-pack-unlock-before-die:
  receive-pack: fix stale packfile locks when dying

18 months agoMerge branch 'aj/ls-files-format-fix'
Junio C Hamano [Tue, 21 Mar 2023 21:18:55 +0000 (14:18 -0700)] 
Merge branch 'aj/ls-files-format-fix'

Fix for a "ls-files --format="%(path)" that produced nonsense
output, which was a bug in 2.38.

* aj/ls-files-format-fix:
  ls-files: fix "--format" output of relative paths

18 months agoMerge branch 'jk/format-patch-ignore-noprefix'
Junio C Hamano [Tue, 21 Mar 2023 21:18:55 +0000 (14:18 -0700)] 
Merge branch 'jk/format-patch-ignore-noprefix'

"git format-patch" honors the src/dst prefixes set to nonstandard
values with configuration variables like "diff.noprefix", causing
receiving end of the patch that expects the standard -p1 format to
break.  Teach "format-patch" to ignore end-user configuration and
always use the standard prefixes.

This is a backward compatibility breaking change.

* jk/format-patch-ignore-noprefix:
  rebase: prefer --default-prefix to --{src,dst}-prefix for format-patch
  format-patch: add format.noprefix option
  format-patch: do not respect diff.noprefix
  diff: add --default-prefix option
  t4013: add tests for diff prefix options
  diff: factor out src/dst prefix setup

18 months agogit-compat-util: use gettimeofday(2) for time(2)
Paul Eggert [Mon, 20 Mar 2023 23:05:07 +0000 (16:05 -0700)] 
git-compat-util: use gettimeofday(2) for time(2)

Use gettimeofday instead of time(NULL) to get current time.
This avoids clock skew on glibc 2.31+ on Linux, where in the
first 1 to 2.5 ms of every second, time(NULL) returns a
value that is one less than the tv_sec part of
higher-resolution timestamps such as those returned by
gettimeofday or timespec_get, or those in the file system.
There are similar clock skew problems on AIX and MS-Windows,
which have problems in the first 5 ms of every second.

Without this patch, users can observe Git issuing a
timestamp T+1 before it issues timestamp T, because Git
sometimes uses time(NULL) or time(&t) and sometimes uses
higher-res methods like gettimeofday.  Although strictly
speaking users should tolerate this behavior because a
superuser can always change the clock back, this is a
quality of implementation issue and users naturally expect
Git to issue timestamps in increasing order unless the
superuser has fiddled with the system clock.

This patch always uses gettimeofday(...) instead of time(...),
and I have verified that the resulting .o files never refer
to the name 'time'.  A trickier patch would change only
those calls for which timestamp monotonicity is user-visible.
Such a patch would require more expertise about Git internals,
though, and would be harder to maintain later.

Another possibility would be to change Git's documentation
to warn users that Git does not always issue timestamps in
increasing order.  However, Git users would likely be either
dismayed by this possibility, or confused by the level of
detail that any such documentation would require.

Yet another possibility would be to fix the Linux kernel so
that the time syscall is consistent with the other timestamp
syscalls.  I suppose this has not been done due to
performance implications.  (Git's use of timestamps is rare
enough that performance is not a significant consideration
for git.)  However, this wouldn't fix Git's problem on older
Linux kernels, or on AIX or MS-Windows.

Signed-off-by: Paul Eggert <eggert@cs.ucla.edu>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
18 months agoThe second batch
Junio C Hamano [Sun, 19 Mar 2023 22:03:22 +0000 (15:03 -0700)] 
The second batch

Signed-off-by: Junio C Hamano <gitster@pobox.com>
18 months agoMerge branch 'jk/add-p-unmerged-fix'
Junio C Hamano [Sun, 19 Mar 2023 22:03:13 +0000 (15:03 -0700)] 
Merge branch 'jk/add-p-unmerged-fix'

"git add -p" while the index is unmerged sometimes failed to parse
the diff output it internally produces and died, which has been
corrected.

* jk/add-p-unmerged-fix:
  add-patch: handle "* Unmerged path" lines

18 months agoMerge branch 'ew/fetch-no-write-fetch-head-fix'
Junio C Hamano [Sun, 19 Mar 2023 22:03:13 +0000 (15:03 -0700)] 
Merge branch 'ew/fetch-no-write-fetch-head-fix'

* ew/fetch-no-write-fetch-head-fix:
  fetch: pass --no-write-fetch-head to subprocesses

18 months agoMerge branch 'fc/advice-diverged-history'
Junio C Hamano [Sun, 19 Mar 2023 22:03:12 +0000 (15:03 -0700)] 
Merge branch 'fc/advice-diverged-history'

After "git pull" that is configured with pull.rebase=false
merge.ff=only fails due to our end having our own development, give
advice messages to get out of the "Not possible to fast-forward"
state.

* fc/advice-diverged-history:
  advice: add diverging advice for novices

18 months agoMerge branch 'ab/fix-strategy-opts-parsing'
Junio C Hamano [Sun, 19 Mar 2023 22:03:12 +0000 (15:03 -0700)] 
Merge branch 'ab/fix-strategy-opts-parsing'

The code to parse "git rebase -X<opt>" was not prepared to see an
unparsable option string, which has been corrected.

* ab/fix-strategy-opts-parsing:
  sequencer.c: fix overflow & segfault in parse_strategy_opts()

18 months agoMerge branch 'ds/reprepare-alternates-when-repreparing-packfiles'
Junio C Hamano [Sun, 19 Mar 2023 22:03:12 +0000 (15:03 -0700)] 
Merge branch 'ds/reprepare-alternates-when-repreparing-packfiles'

Once we start running, we assumed that the list of alternate object
databases would never change.  Hook into the machinery used to
update the list of packfiles during runtime to update this list as
well.

* ds/reprepare-alternates-when-repreparing-packfiles:
  object-file: reprepare alternates when necessary

18 months agoMerge branch 'jk/format-patch-change-format-for-empty-commits'
Junio C Hamano [Sun, 19 Mar 2023 22:03:12 +0000 (15:03 -0700)] 
Merge branch 'jk/format-patch-change-format-for-empty-commits'

"git format-patch" learned to write a log-message only output file
for empty commits.

* jk/format-patch-change-format-for-empty-commits:
  format-patch: output header for empty commits

18 months agoMerge branch 'jk/bundle-use-dash-for-stdfiles'
Junio C Hamano [Sun, 19 Mar 2023 22:03:12 +0000 (15:03 -0700)] 
Merge branch 'jk/bundle-use-dash-for-stdfiles'

"git bundle" learned that "-" is a common way to say that the input
comes from the standard input and/or the output goes to the
standard output.  It used to work only for output and only from the
root level of the working tree.

* jk/bundle-use-dash-for-stdfiles:
  parse-options: use prefix_filename_except_for_dash() helper
  parse-options: consistently allocate memory in fix_filename()
  bundle: don't blindly apply prefix_filename() to "-"
  bundle: document handling of "-" as stdin
  bundle: let "-" mean stdin for reading operations

18 months agoMerge branch 'jk/bundle-progress'
Junio C Hamano [Sun, 19 Mar 2023 22:03:11 +0000 (15:03 -0700)] 
Merge branch 'jk/bundle-progress'

Simplify UI to control progress meter given by "git bundle" command.

* jk/bundle-progress:
  bundle: turn on --all-progress-implied by default

18 months agoMerge branch 'as/doc-markup-fix'
Junio C Hamano [Sun, 19 Mar 2023 22:03:11 +0000 (15:03 -0700)] 
Merge branch 'as/doc-markup-fix'

Fix for a mis-mark-up in doc made in Git 2.39 days.

* as/doc-markup-fix:
  git-merge-tree.txt: replace spurious HTML entity

18 months agoMerge branch 'rj/avoid-switching-to-already-used-branch'
Junio C Hamano [Sun, 19 Mar 2023 22:03:11 +0000 (15:03 -0700)] 
Merge branch 'rj/avoid-switching-to-already-used-branch'

A few subcommands have been taught to stop users from working on a
branch that is being used in another worktree linked to the same
repository.

* rj/avoid-switching-to-already-used-branch:
  switch: reject if the branch is already checked out elsewhere (test)
  rebase: refuse to switch to a branch already checked out elsewhere (test)
  branch: fix die_if_checked_out() when ignore_current_worktree
  worktree: introduce is_shared_symref()

18 months agoMerge branch 'rj/bisect-already-used-branch'
Junio C Hamano [Sun, 19 Mar 2023 22:03:11 +0000 (15:03 -0700)] 
Merge branch 'rj/bisect-already-used-branch'

Allow "git bisect reset" to check out the original branch when the
branch is already checked out in a different worktree linked to the
same repository.

* rj/bisect-already-used-branch:
  bisect: fix "reset" when branch is checked out elsewhere

18 months agoMerge branch 'zh/push-to-delete-onelevel-ref'
Junio C Hamano [Sun, 19 Mar 2023 22:03:10 +0000 (15:03 -0700)] 
Merge branch 'zh/push-to-delete-onelevel-ref'

"git push" has been taught to allow deletion of refs with one-level
names to help repairing a repository who acquired such a ref by
mistake.  In general, we don't encourage use of such a ref, and
creation or update to such a ref is rejected as before.

* zh/push-to-delete-onelevel-ref:
  push: allow delete single-level ref
  receive-pack: fix funny ref error messsage

18 months agoMerge branch 'ak/restore-both-incompatible-with-conflicts'
Junio C Hamano [Sun, 19 Mar 2023 22:03:10 +0000 (15:03 -0700)] 
Merge branch 'ak/restore-both-incompatible-with-conflicts'

"git restore" supports options like "--ours" that are only
meaningful during a conflicted merge, but these options are only
meaningful when updating the working tree files.  These options are
marked to be incompatible when both "--staged" and "--worktree" are
in effect.

* ak/restore-both-incompatible-with-conflicts:
  restore: fault --staged --worktree with merge opts

18 months agoMerge branch 'ew/commit-reach-clean-up-flags-fix'
Junio C Hamano [Sun, 19 Mar 2023 22:03:10 +0000 (15:03 -0700)] 
Merge branch 'ew/commit-reach-clean-up-flags-fix'

Fix a segfaulting loop.  The function and its caller may need
further clean-up.

* ew/commit-reach-clean-up-flags-fix:
  commit-reach: avoid NULL dereference

18 months agoMerge branch 'ab/avoid-losing-exit-codes-in-tests'
Junio C Hamano [Sun, 19 Mar 2023 22:03:10 +0000 (15:03 -0700)] 
Merge branch 'ab/avoid-losing-exit-codes-in-tests'

Test clean-up.

* ab/avoid-losing-exit-codes-in-tests:
  tests: don't lose misc "git" exit codes
  tests: don't lose exit status with "test <op> $(git ...)"
  tests: don't lose "git" exit codes in "! ( git ... | grep )"
  tests: don't lose exit status with "(cd ...; test <op> $(git ...))"
  t/lib-patch-mode.sh: fix ignored exit codes
  auto-crlf tests: don't lose exit code in loops and outside tests

18 months agogit_connect(): fix corner cases in downgrading v2 to v0
Jeff King [Fri, 17 Mar 2023 19:08:51 +0000 (15:08 -0400)] 
git_connect(): fix corner cases in downgrading v2 to v0

There's code in git_connect() that checks whether we are doing a push
with protocol_v2, and if so, drops us to protocol_v0 (since we know
how to do v2 only for fetches). But it misses some corner cases:

  1. it checks the "prog" variable, which is actually the path to
     receive-pack on the remote side. By default this is just
     "git-receive-pack", but it could be an arbitrary string (like
     "/path/to/git receive-pack", etc). We'd accidentally stay in v2
     mode in this case.

  2. besides "receive-pack" and "upload-pack", there's one other value
     we'd expect: "upload-archive" for handling "git archive --remote".
     Like receive-pack, this doesn't understand v2, and should use the
     v0 protocol.

In practice, neither of these causes bugs in the real world so far. We
do send a "we understand v2" probe to the server, but since no server
implements v2 for anything but upload-pack, it's simply ignored. But
this would eventually become a problem if we do implement v2 for those
endpoints, as older clients would falsely claim to understand it,
leading to a server response they can't parse.

We can fix (1) by passing in both the program path and the "name" of the
operation. I treat the name as a string here, because that's the pattern
set in transport_connect(), which is one of our callers (we were simply
throwing away the "name" value there before).

We can fix (2) by allowing only known-v2 protocols ("upload-pack"),
rather than blocking unknown ones ("receive-pack" and "upload-archive").
That will mean whoever eventually implements v2 push will have to adjust
this list, but that's reasonable. We'll do the safe, conservative thing
(sticking to v0) by default, and anybody working on v2 will quickly
realize this spot needs to be updated.

The new tests cover the receive-pack and upload-archive cases above, and
re-confirm that we allow v2 with an arbitrary "--upload-pack" path (that
already worked before this patch, of course, but it would be an easy
thing to break if we flipped the allow/block logic without also handling
"name" separately).

Here are a few miscellaneous implementation notes, since I had to do a
little head-scratching to understand who calls what:

  - transport_connect() is called only for git-upload-archive. For
    non-http git remotes, that resolves to the virtual connect_git()
    function (which then calls git_connect(); confused yet?). So
    plumbing through "name" in connect_git() covers that.

  - for regular fetches and pushes, callers use higher-level functions
    like transport_fetch_refs(). For non-http git remotes, that means
    calling git_connect() under the hood via connect_setup(). And that
    uses the "for_push" flag to decide which name to use.

  - likewise, plumbing like fetch-pack and send-pack may call
    git_connect() directly; they each know which name to use.

  - for remote helpers (including http), we already have separate
    parameters for "name" and "exec" (another name for "prog"). In
    process_connect_service(), we feed the "name" to the helper via
    "connect" or "stateless-connect" directives.

    There's also a "servpath" option, which can be used to tell the
    helper about the "exec" path. But no helpers we implement support
    it! For http it would be useless anyway (no reasonable server
    implementation will allow you to send a shell command to run the
    server). In theory it would be useful for more obscure helpers like
    remote-ext, but even there it is not implemented.

    It's tempting to get rid of it simply to reduce confusion, but we
    have publicly documented it since it was added in fa8c097cc9
    (Support remote helpers implementing smart transports, 2009-12-09),
    so it's possible some helper in the wild is using it.

  - So for v2, helpers (again, including http) are mainly used via
    stateless-connect, driven by the main program. But they do still
    need to decide whether to do a v2 probe. And so there's similar
    logic in remote-curl.c's discover_refs() that looks for
    "git-receive-pack". But it's not buggy in the same way. Since it
    doesn't support servpath, it is always dealing with a "service"
    string like "git-receive-pack". And since it doesn't support
    straight "connect", it can't be used for "upload-archive".

    So we could leave that spot alone. But I've updated it here to match
    the logic we're changing in connect_git(). That seems like the least
    confusing thing for somebody who has to touch both of these spots
    later (say, to add v2 push support). I didn't add a new test to make
    sure this doesn't break anything; we already have several tests (in
    t5551 and elsewhere) that make sure we are using v2 over http.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
18 months agoStart the 2.41 cycle
Junio C Hamano [Fri, 17 Mar 2023 21:03:20 +0000 (14:03 -0700)] 
Start the 2.41 cycle

Signed-off-by: Junio C Hamano <gitster@pobox.com>
18 months agoMerge branch 'fz/rebase-msg-update'
Junio C Hamano [Fri, 17 Mar 2023 21:03:10 +0000 (14:03 -0700)] 
Merge branch 'fz/rebase-msg-update'

Message update.

* fz/rebase-msg-update:
  rebase: fix capitalisation autoSquash in i18n string

18 months agoMerge branch 'ew/fetch-hiderefs'
Junio C Hamano [Fri, 17 Mar 2023 21:03:10 +0000 (14:03 -0700)] 
Merge branch 'ew/fetch-hiderefs'

A new "fetch.hideRefs" option can be used to exclude specified refs
from "rev-list --objects --stdin --not --all" traversal for
checking object connectivity, most useful when there are many
unrelated histories in a single repository.

* ew/fetch-hiderefs:
  fetch: support hideRefs to speed up connectivity checks

18 months agoMerge branch 'mc/credential-helper-www-authenticate'
Junio C Hamano [Fri, 17 Mar 2023 21:03:10 +0000 (14:03 -0700)] 
Merge branch 'mc/credential-helper-www-authenticate'

Allow information carried on the WWW-AUthenticate header to be
passed to the credential helpers.

* mc/credential-helper-www-authenticate:
  credential: add WWW-Authenticate header to cred requests
  http: read HTTP WWW-Authenticate response headers
  t5563: add tests for basic and anoymous HTTP access

18 months agoMerge branch 'jc/gpg-lazy-init'
Junio C Hamano [Fri, 17 Mar 2023 21:03:10 +0000 (14:03 -0700)] 
Merge branch 'jc/gpg-lazy-init'

Instead of forcing each command to choose to honor GPG related
configuration variables, make the subsystem lazily initialize
itself.

* jc/gpg-lazy-init:
  drop pure pass-through config callbacks
  gpg-interface: lazily initialize and read the configuration

18 months agoMerge branch 'jk/unused-post-2.39-part2'
Junio C Hamano [Fri, 17 Mar 2023 21:03:09 +0000 (14:03 -0700)] 
Merge branch 'jk/unused-post-2.39-part2'

More work towards -Wunused.

* jk/unused-post-2.39-part2: (21 commits)
  help: mark unused parameter in git_unknown_cmd_config()
  run_processes_parallel: mark unused callback parameters
  userformat_want_item(): mark unused parameter
  for_each_commit_graft(): mark unused callback parameter
  rewrite_parents(): mark unused callback parameter
  fetch-pack: mark unused parameter in callback function
  notes: mark unused callback parameters
  prio-queue: mark unused parameters in comparison functions
  for_each_object: mark unused callback parameters
  list-objects: mark unused callback parameters
  mark unused parameters in signal handlers
  run-command: mark error routine parameters as unused
  mark "pointless" data pointers in callbacks
  ref-filter: mark unused callback parameters
  http-backend: mark unused parameters in virtual functions
  http-backend: mark argc/argv unused
  object-name: mark unused parameters in disambiguate callbacks
  serve: mark unused parameters in virtual functions
  serve: use repository pointer to get config
  ls-refs: drop config caching
  ...

18 months agoMerge branch 'en/header-cleanup'
Junio C Hamano [Fri, 17 Mar 2023 21:03:08 +0000 (14:03 -0700)] 
Merge branch 'en/header-cleanup'

Code clean-up to clarify the rule that "git-compat-util.h" must be
the first to be included.

* en/header-cleanup:
  diff.h: remove unnecessary include of object.h
  Remove unnecessary includes of builtin.h
  treewide: replace cache.h with more direct headers, where possible
  replace-object.h: move read_replace_refs declaration from cache.h to here
  object-store.h: move struct object_info from cache.h
  dir.h: refactor to no longer need to include cache.h
  object.h: stop depending on cache.h; make cache.h depend on object.h
  ident.h: move ident-related declarations out of cache.h
  pretty.h: move has_non_ascii() declaration from commit.h
  cache.h: remove dependence on hex.h; make other files include it explicitly
  hex.h: move some hex-related declarations from cache.h
  hash.h: move some oid-related declarations from cache.h
  alloc.h: move ALLOC_GROW() functions from cache.h
  treewide: remove unnecessary cache.h includes in source files
  treewide: remove unnecessary cache.h includes
  treewide: remove unnecessary git-compat-util.h includes in headers
  treewide: ensure one of the appropriate headers is sourced first

18 months agoMerge branch 'en/dir-api-cleanup'
Junio C Hamano [Fri, 17 Mar 2023 21:03:08 +0000 (14:03 -0700)] 
Merge branch 'en/dir-api-cleanup'

Code clean-up to clarify directory traversal API.

* en/dir-api-cleanup:
  unpack-trees: add usage notices around df_conflict_entry
  unpack-trees: special case read-tree debugging as internal usage
  unpack-trees: rewrap a few overlong lines from previous patch
  unpack-trees: mark fields only used internally as internal
  unpack_trees: start splitting internal fields from public API
  sparse-checkout: avoid using internal API of unpack-trees, take 2
  sparse-checkout: avoid using internal API of unpack-trees
  unpack-trees: clean up some flow control
  dir: mark output only fields of dir_struct as such
  dir: add a usage note to exclude_per_dir
  dir: separate public from internal portion of dir_struct
  unpack-trees: heed requests to overwrite ignored files
  t2021: fix platform-specific leftover cruft

18 months agoMerge branch 'jk/fsck-indices-in-worktrees'
Junio C Hamano [Fri, 17 Mar 2023 21:03:08 +0000 (14:03 -0700)] 
Merge branch 'jk/fsck-indices-in-worktrees'

"git fsck" learned to check the index files in other worktrees,
just like "git gc" honors them as anchoring points.

* jk/fsck-indices-in-worktrees:
  fsck: check even zero-entry index files
  fsck: mention file path for index errors
  fsck: check index files in all worktrees
  fsck: factor out index fsck

18 months agocompletion: prompt: use generic colors
Felipe Contreras [Tue, 28 Feb 2023 14:59:34 +0000 (08:59 -0600)] 
completion: prompt: use generic colors

When the prompt command mode was introduced in 1bfc51ac81 (Allow
__git_ps1 to be used in PROMPT_COMMAND, 2012-10-10), the assumption was
that it was necessary in order to properly add colors to PS1 in bash,
but this wasn't true.

It's true that the \[ \] markers add the information needed to properly
calculate the width of the prompt, and they have to be added directly to
PS1, a function returning them doesn't work.

But that is because bash coverts the \[ \] markers in PS1 to \001 \002,
which is what readline ultimately needs in order to calculate the width.

We don't need bash to do this conversion, we can use \001 \002
ourselves, and then the prompt command mode is not necessary to display
colors.

This is what functions returning colors are supposed to do [1].

[1] http://mywiki.wooledge.org/BashFAQ/053

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
Tested-by: Joakim Petersen <joak-pet@online.no>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
18 months agoobject-name: fix quiet @{u} parsing
Felipe Contreras [Thu, 16 Mar 2023 17:15:14 +0000 (11:15 -0600)] 
object-name: fix quiet @{u} parsing

Currently `git rev-parse --quiet @{u}` is not actually quiet when
upstream isn't configured:

  fatal: no upstream configured for branch 'foo'

Make it so.

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
18 months agorebase: prefer --default-prefix to --{src,dst}-prefix for format-patch
Jeff King [Mon, 13 Mar 2023 19:54:11 +0000 (15:54 -0400)] 
rebase: prefer --default-prefix to --{src,dst}-prefix for format-patch

When git-rebase invokes format-patch, it wants to make sure we use the
normal prefixes, and are not confused by diff.noprefix or similar. When
this was added in 5b220a6876f (Add --src/dst-prefix to git-formt-patch
in git-rebase.sh, 2010-09-09), we only had --src-prefix and --dst-prefix
to do so, which requires re-specifying the prefixes we expect to see.
These days we can say what we want more directly: just use the defaults.

This is a minor cleanup that should have no behavior change, but
hopefully the result expresses more clearly what the code is trying to
accomplish.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
18 months agoGit 2.40 v2.40.0
Junio C Hamano [Sun, 12 Mar 2023 21:34:41 +0000 (14:34 -0700)] 
Git 2.40

Signed-off-by: Junio C Hamano <gitster@pobox.com>
18 months agoMerge tag 'l10n-2.40.0-rnd1' of https://github.com/git-l10n/git-po
Junio C Hamano [Sun, 12 Mar 2023 21:33:14 +0000 (14:33 -0700)] 
Merge tag 'l10n-2.40.0-rnd1' of https://github.com/git-l10n/git-po

l10n-2.40.0-rnd1

* tag 'l10n-2.40.0-rnd1' of https://github.com/git-l10n/git-po:
  l10n: zh_CN v2.40.0 round 1
  l10n: update German translation
  l10n: tr: Update Turkish translations for v.2.40.0
  l10n: fr: v2.40.0 rnd 2
  l10n: fr: v2.40.0 rnd 1
  l10n: fr: fix some typos
  l10n: po-id for 2.40 (round 1)
  l10n: sv.po: Update Swedish translation (5490t0f0u)
  l10n: bg.po: Updated Bulgarian translation (5490t)
  l10n: Update Catalan translation

18 months agols-files: fix "--format" output of relative paths
Adam Johnson [Fri, 10 Mar 2023 13:04:33 +0000 (13:04 +0000)] 
ls-files: fix "--format" output of relative paths

Fix a bug introduced with the "--format" option in
ce74de93 (ls-files: introduce "--format" option, 2022-07-23),
where relative paths were computed using the output buffer,
which could lead to random garbage data in the output.

Signed-off-by: Adam Johnson <me@adamj.eu>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
18 months agoreceive-pack: fix stale packfile locks when dying
Patrick Steinhardt [Fri, 10 Mar 2023 06:52:10 +0000 (07:52 +0100)] 
receive-pack: fix stale packfile locks when dying

When accepting a packfile in git-receive-pack(1), we feed that packfile
into git-index-pack(1) to generate the packfile index. As the packfile
would often only contain unreachable objects until the references have
been updated, concurrently running garbage collection might be tempted
to delete the packfile right away and thus cause corruption. To fix
this, we ask git-index-pack(1) to create a `.keep` file before moving
the packfile into place, which is getting deleted again once all of the
reference updates have been processed.

Now in production systems we have observed that those `.keep` files are
sometimes not getting deleted as expected, where the result is that
repositories tend to grow packfiles that are never deleted over time.
This seems to be caused by a race when git-receive-pack(1) is killed
after we have migrated the kept packfile from the quarantine directory
into the main object database. While this race window is typically small
it can be extended for example by installing a `proc-receive` hook.

Fix this race by registering the lockfile as a tempfile so that it will
automatically be removed at exit or when receiving a signal.

Helped-by: Jeff King <peff@peff.net>
Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
18 months agoMerge branch 'fz/po-zh_CN' of github.com:fangyi-zhou/git-po
Jiang Xin [Fri, 10 Mar 2023 14:50:14 +0000 (22:50 +0800)] 
Merge branch 'fz/po-zh_CN' of github.com:fangyi-zhou/git-po

* 'fz/po-zh_CN' of github.com:fangyi-zhou/git-po:
  l10n: zh_CN v2.40.0 round 1

18 months agotest: don't print aggregate-results command
Felipe Contreras [Thu, 9 Mar 2023 17:30:32 +0000 (11:30 -0600)] 
test: don't print aggregate-results command

There's no value in it.

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
18 months agotest: simplify counts aggregation
Felipe Contreras [Thu, 9 Mar 2023 17:30:31 +0000 (11:30 -0600)] 
test: simplify counts aggregation

When the list of files as input was implemented in 6508eedf67
(t/aggregate-results: accomodate systems with small max argument list
length, 2010-06-01), a much simpler solution wasn't considered.

Let's just pass the directory as an argument.

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
18 months agoobject-file: reprepare alternates when necessary
Derrick Stolee [Wed, 8 Mar 2023 18:47:32 +0000 (18:47 +0000)] 
object-file: reprepare alternates when necessary

When an object is not found in a repository's object store, we sometimes
call reprepare_packed_git() to see if the object was temporarily moved
into a new pack-file (and its old pack-file or loose object was
deleted). This process does a scan of each pack directory within each
odb, but does not reevaluate if the odb list needs updating.

Extend reprepare_packed_git() to also reprepare the alternate odb list
by setting loaded_alternates to zero and calling prepare_alt_odb(). This
will add newly-discoverd odbs to the linked list, but will not duplicate
existing ones nor will it remove existing ones that are no longer listed
in the alternates file. Do this under the object read lock to avoid
readers from interacting with a potentially incomplete odb being added
to the odb list.

If the alternates file was edited to _remove_ some alternates during the
course of the Git process, Git will continue to see alternates that were
ever valid for that repository. ODBs are not removed from the list, the
same as the existing behavior before this change. Git already has
protections against an alternate directory disappearing from the
filesystem during the lifetime of a process, and those are still in
effect.

This change is specifically for concurrent changes to the repository, so
it is difficult to create a test that guarantees this behavior is
correct. I manually verified by introducing a reprepare_packed_git() call
into get_revision() and stepped into that call in a debugger with a
parent 'git log' process. Multiple runs of prepare_alt_odb() kept
the_repository->objects->odb as a single-item chain until I added a
.git/objects/info/alternates file in a different process. The next run
added the new odb to the chain and subsequent runs did not add to the
chain.

Signed-off-by: Derrick Stolee <derrickstolee@github.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
18 months agofetch: pass --no-write-fetch-head to subprocesses
Eric Wong [Wed, 8 Mar 2023 22:22:05 +0000 (22:22 +0000)] 
fetch: pass --no-write-fetch-head to subprocesses

It seems a user would expect this option would work regardless
of whether it's fetching from a single remote, many remotes,
or recursing into submodules.

Signed-off-by: Eric Wong <e@80x24.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
18 months agoadd-patch: handle "* Unmerged path" lines
Jeff King [Thu, 9 Mar 2023 08:58:16 +0000 (03:58 -0500)] 
add-patch: handle "* Unmerged path" lines

When we generate a diff with --cached, unmerged entries have no oid for
their index entry:

  $ git diff-index --abbrev --cached HEAD
  :100644 000000 f719efd 0000000 U my-conflict

So when we are asked to produce a patch, since we only have one side, we
just emit a special message:

  $ git diff-index --cached -p HEAD
  * Unmerged path my-conflict

This confuses interactive-patch modes that look at cached diffs. For
example:

  $ git reset -p
  BUG: add-patch.c:498: diff starts with unexpected line:
  * Unmerged path my-conflict

Making things even more confusing, you'll get that error only if the
unmerged entry is alphabetically the first changed file. Otherwise, we
simply stick the unrecognized line to the end of the previous hunk.
There it's mostly harmless, as it eventually gets fed back to "git
apply", which happily ignores it. But it's still shown to the user
attached to the hunk, which is wrong.

So let's handle these lines as a noop. There's not really anything
useful to do with a conflicted merge in this case, and that's what we do
for other cases like "add -p". There we get a "diff --cc" line, which we
accept as starting a new file, but we refuse to use any of its hunks
(their headers start with "@@@" and not "@@ ", so we silently ignore
them).

It seems like simply recognizing the line and continuing in our parsing
loop would work. But we actually need to run the rest of the loop body
to handle matching up our colored/filtered output. But that code assumes
that we have some active file_diff we're working on. So instead, we'll
just insert a dummy entry into our array. This ends up the same as if we
saw a "diff --cc" line (a file with no hunks).

Reported-by: Philippe Blain <levraiphilippeblain@gmail.com>
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
18 months agoformat-patch: add format.noprefix option
Jeff King [Thu, 9 Mar 2023 06:12:37 +0000 (01:12 -0500)] 
format-patch: add format.noprefix option

The previous commit dropped support for diff.noprefix in format-patch.
While this will do the right thing in most cases (where sending patches
without a prefix was an accidental side effect of the sender preferring
to see their local patches without prefixes), it left no good option for
a project or workflow where you really do want to send patches without
prefixes. You'd be stuck using "--no-prefix" for every invocation.

So let's add a config option specific to format-patch that enables this
behavior. That gives people who have such a workflow a way to get what
they want, but makes it hard to accidentally trigger it.

A more backwards-compatible way of doing the transition would be to have
format.noprefix default to diff.noprefix when it's not set. But that
doesn't really help the "accidental" problem; people would have to
manually set format.noprefix=false. And it's unlikely that anybody
really wants format.noprefix=true in the first place. I'm adding it here
mostly as an escape hatch, not because anybody has expressed any
interest in it.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
18 months agoformat-patch: do not respect diff.noprefix
Jeff King [Thu, 9 Mar 2023 06:11:49 +0000 (01:11 -0500)] 
format-patch: do not respect diff.noprefix

The output of format-patch respects diff.noprefix, but this usually ends
up being a hassle for people receiving the patch, as they have to
manually specify "-p0" in order to apply it.

I don't think there was any specific intention for it to behave this
way. The noprefix option is handled by git_diff_ui_config(), and
format-patch exists in a gray area between plumbing and porcelain.
People do look at the output, and we'd expect it to colorize things,
respect their choice of algorithm, and so on. But this particular option
creates problems for the receiver (in theory so does diff.mnemonicprefix,
but since we are always formatting commits, the mnemonic prefixes will
always be "a/" and "b/").

So let's disable it. The slight downsides are:

  - people who have set diff.noprefix presumably like to see their
    patches without prefixes. If they use format-patch to review their
    series, they'll see prefixes. On the other hand, it is probably a
    good idea for them to look at what will actually get sent out.

    We could try to play games here with "is stdout a tty", as we do for
    color. But that's not a completely reliable signal, and it's
    probably not worth the trouble. If you want to see the patch with
    the usual bells and whistles, then you are better off using "git
    log" or "git show".

  - if a project really does have a workflow that likes prefix-less
    patches, and the receiver is prepared to use "-p0", then the sender
    now has to manually say "--no-prefix" for each format-patch
    invocation. That doesn't seem _too_ terrible given that the receiver
    has to manually say "-p0" for each git-am invocation.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
18 months agodiff: add --default-prefix option
Jeff King [Thu, 9 Mar 2023 06:09:54 +0000 (01:09 -0500)] 
diff: add --default-prefix option

You can change the output of prefixes with diff.noprefix and
diff.mnemonicprefix, but there's no easy way to override them from the
command-line. We do have "--no-prefix", but there's no way to get back
to the default prefix. So let's add an option to do that.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
18 months agot4013: add tests for diff prefix options
Jeff King [Thu, 9 Mar 2023 06:07:45 +0000 (01:07 -0500)] 
t4013: add tests for diff prefix options

We don't have any specific test coverage of diff's various prefix
options. We do incidentally invoke them in a few places, but it's worth
having a more thorough set of tests that covers all of the effects we
expect to see, and that the options kick in at the appropriate times.

This will be especially useful as the next patch adds more options.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
18 months agodiff: factor out src/dst prefix setup
Jeff King [Thu, 9 Mar 2023 06:07:06 +0000 (01:07 -0500)] 
diff: factor out src/dst prefix setup

We directly manipulate diffopt's a_prefix and b_prefix to set up either
the default "a/foo" prefix or the "--no-prefix" variant. Although this
is only a few lines, it's worth pulling these into their own functions.
That lets us avoid one repetition already in this patch, but will also
give us a cleaner interface for callers which want to tweak this
setting.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
18 months agosequencer.c: fix overflow & segfault in parse_strategy_opts()
Ævar Arnfjörð Bjarmason [Tue, 7 Mar 2023 18:21:59 +0000 (19:21 +0100)] 
sequencer.c: fix overflow & segfault in parse_strategy_opts()

The split_cmdline() function introduced in [1] returns an "int". If
it's negative it signifies an error. The option parsing in [2] didn't
account for this, and assigned the value directly to the "size_t
xopts_nr". We'd then attempt to loop over all of these elements, and
access uninitialized memory.

There's a few things that use this for option parsing, but one way to
trigger it is with a bad value to "-X <strategy-option>", e.g:

git rebase -X"bad argument\""

In another context this might be a security issue, but in this case
someone who's already able to inject arguments directly to our
commands would be past other defenses, making this potential
escalation a moot point.

As the example above & test case shows the error reporting leaves
something to be desired. The function will loop over the
whitespace-split values, but when it encounters an error we'll only
report the first element, which is OK, not the second "argument\""
whose quote is unbalanced.

This is an inherent limitation of the current API, and the issue
affects other API users. Let's not attempt to fix that now. If and
when that happens these tests will need to be adjusted to assert the
new output.

1. 2b11e3170e9 (If you have a config containing something like this:,
   2006-06-05)
2. ca6c6b45dd9 (sequencer (rebase -i): respect strategy/strategy_opts
   settings, 2017-01-02)

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
18 months agoadvice: add diverging advice for novices
Felipe Contreras [Wed, 8 Mar 2023 02:48:33 +0000 (20:48 -0600)] 
advice: add diverging advice for novices

The user might not necessarily know why ff only was configured, maybe an
admin did it, or the installer (Git for Windows), or perhaps they just
followed some online advice.

This can happen not only on pull.ff=only, but merge.ff=only too.

Even worse if the user has configured pull.rebase=false and
merge.ff=only, because in those cases a diverging merge will constantly
keep failing. There's no trivial way to get out of this other than
`git merge --no-ff`.

Let's not assume our users are experts in git who completely understand
all their configurations.

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
Acked-by: Taylor Blau <me@ttaylorr.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
18 months agoMerge branch 'l10n-de-2.40' of github.com:ralfth/git
Jiang Xin [Wed, 8 Mar 2023 01:10:20 +0000 (09:10 +0800)] 
Merge branch 'l10n-de-2.40' of github.com:ralfth/git

* 'l10n-de-2.40' of github.com:ralfth/git:
  l10n: update German translation

18 months agoMerge branch 'po-id' of github.com:bagasme/git-po
Jiang Xin [Wed, 8 Mar 2023 00:28:02 +0000 (08:28 +0800)] 
Merge branch 'po-id' of github.com:bagasme/git-po

* 'po-id' of github.com:bagasme/git-po:
  l10n: po-id for 2.40 (round 1)

18 months agoMerge branch 'catalan' of github.com:Softcatala/git-po
Jiang Xin [Wed, 8 Mar 2023 00:27:07 +0000 (08:27 +0800)] 
Merge branch 'catalan' of github.com:Softcatala/git-po

* 'catalan' of github.com:Softcatala/git-po:
  l10n: Update Catalan translation

18 months agoMerge branch 'fr_2.40.0_rnd1' of github.com:jnavila/git
Jiang Xin [Wed, 8 Mar 2023 00:26:00 +0000 (08:26 +0800)] 
Merge branch 'fr_2.40.0_rnd1' of github.com:jnavila/git

* 'fr_2.40.0_rnd1' of github.com:jnavila/git:
  l10n: fr: v2.40.0 rnd 2
  l10n: fr: v2.40.0 rnd 1
  l10n: fr: fix some typos

18 months agoMerge branch 'master' of github.com:nafmo/git-l10n-sv
Jiang Xin [Wed, 8 Mar 2023 00:25:07 +0000 (08:25 +0800)] 
Merge branch 'master' of github.com:nafmo/git-l10n-sv

* 'master' of github.com:nafmo/git-l10n-sv:
  l10n: sv.po: Update Swedish translation (5490t0f0u)

18 months agoMerge branch 'master' of github.com:alshopov/git-po
Jiang Xin [Wed, 8 Mar 2023 00:23:16 +0000 (08:23 +0800)] 
Merge branch 'master' of github.com:alshopov/git-po

* 'master' of github.com:alshopov/git-po:
  l10n: bg.po: Updated Bulgarian translation (5490t)

18 months agoMerge branch 'turkish' of github.com:bitigchi/git-po
Jiang Xin [Wed, 8 Mar 2023 00:22:01 +0000 (08:22 +0800)] 
Merge branch 'turkish' of github.com:bitigchi/git-po

* 'turkish' of github.com:bitigchi/git-po:
  l10n: tr: Update Turkish translations for v.2.40.0

18 months agol10n: zh_CN v2.40.0 round 1
Fangyi Zhou [Tue, 7 Mar 2023 23:42:30 +0000 (23:42 +0000)] 
l10n: zh_CN v2.40.0 round 1

Reviewed-by: 依云 <lilydjwg@gmail.com>
Signed-off-by: Fangyi Zhou <me@fangyi.io>
18 months agoGit 2.40-rc2 v2.40.0-rc2
Junio C Hamano [Tue, 7 Mar 2023 05:53:11 +0000 (21:53 -0800)] 
Git 2.40-rc2

Signed-off-by: Junio C Hamano <gitster@pobox.com>
18 months agoMerge branch 'gm/signature-format-doc'
Junio C Hamano [Tue, 7 Mar 2023 05:51:56 +0000 (21:51 -0800)] 
Merge branch 'gm/signature-format-doc'

Doc update.

* gm/signature-format-doc:
  signature-format.txt: note SSH and X.509 signature delimiters

18 months agoparse-options: use prefix_filename_except_for_dash() helper
Jeff King [Sat, 4 Mar 2023 10:31:47 +0000 (05:31 -0500)] 
parse-options: use prefix_filename_except_for_dash() helper

Since our fix_filename()'s only remaining special case is handling "-",
we can use the newly-minted helper function that handles this already.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
18 months agoparse-options: consistently allocate memory in fix_filename()
Jeff King [Sat, 4 Mar 2023 10:31:22 +0000 (05:31 -0500)] 
parse-options: consistently allocate memory in fix_filename()

When handling OPT_FILENAME(), we have to stick the "prefix" (if any) in
front of the filename to make up for the fact that Git has chdir()'d to
the top of the repository. We can do this with prefix_filename(), but
there are a few special cases we handle ourselves.

Unfortunately the memory allocation is inconsistent here; if we do make
it to prefix_filename(), we'll allocate a string which the caller must
free to avoid a leak. But if we hit our special cases, we'll return the
string as-is, and a caller which tries to free it will crash. So there's
no way to win.

Let's consistently allocate, so that callers can do the right thing.

There are now three cases to care about in the function (and hence a
three-armed if/else):

  1. we got a NULL input (and should leave it as NULL, though arguably
     this is the sign of a bug; let's keep the status quo for now and we
     can pick at that scab later)

  2. we hit a special case that means we leave the name intact; we
     should duplicate the string. This includes our special "-"
     matching. Prior to this patch, it also included empty prefixes and
     absolute filenames. But we can observe that prefix_filename()
     already handles these, so we don't need to detect them.

  3. everything else goes to prefix_filename()

I've dropped the "const" from the "char **file" parameter to indicate
that we're allocating, though in practice it's not really important.
This is all being shuffled through a void pointer via opt->value before
it hits code which ever looks at the string. And it's even a bit weird,
because we are really taking _in_ a const string and using the same
out-parameter for a non-const string. A better function signature would
be:

  static char *fix_filename(const char *prefix, const char *file);

but that would mean the caller dereferences the double-pointer (and the
NULL check is currently handled inside this function). So I took the
path of least-change here.

Note that we have to fix several callers in this commit, too, or we'll
break the leak-checking tests. These are "new" leaks in the sense that
they are now triggered by the test suite, but these spots have always
been leaky when Git is run in a subdirectory of the repository. I fixed
all of the cases that trigger with GIT_TEST_PASSING_SANITIZE_LEAK. There
may be others in scripts that have other leaks, but we can fix them
later along with those other leaks (and again, you _couldn't_ fix them
before this patch, so this is the necessary first step).

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
18 months agobundle: don't blindly apply prefix_filename() to "-"
Junio C Hamano [Sat, 4 Mar 2023 10:27:56 +0000 (05:27 -0500)] 
bundle: don't blindly apply prefix_filename() to "-"

A user can specify a filename to a command from the command line,
either as the value given to a command line option, or a command
line argument.  When it is given as a relative filename, in the
user's mind, it is relative to the directory "git" was started from,
but by the time the filename is used, "git" would almost always have
chdir()'ed up to the root level of the working tree.

The given filename, if it is relative, needs to be prefixed with the
path to the current directory, and it typically is done by calling
prefix_filename() helper function.  For commands that can also take
"-" to use the standard input or the standard output, however, this
needs to be done with care.

"git bundle create" uses the next word on the command line as the
output filename, and can take "-" to mean "write to the standard
output".  It blindly called prefix_filename(), so running it in a
subdirectory did not quite work as expected.

Introduce a new helper, prefix_filename_except_for_dash(), and use
it to help "git bundle create" codepath.

Reported-by: Michael Henry
Helped-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
18 months agobundle: document handling of "-" as stdin
Jeff King [Sat, 4 Mar 2023 10:26:40 +0000 (05:26 -0500)] 
bundle: document handling of "-" as stdin

We have always allowed "bundle create -" to write to stdout, but it was
never documented. And a recent patch let reading operations like "bundle
list-heads -" read from stdin.

Let's document all of these cases.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
18 months agobundle: let "-" mean stdin for reading operations
Jeff King [Sat, 4 Mar 2023 10:26:14 +0000 (05:26 -0500)] 
bundle: let "-" mean stdin for reading operations

For writing, "bundle create -" indicates that the bundle should be
written to stdout. But there's no matching handling of "-" for reading
operations. This is inconsistent, and a little inflexible (though one
can always use "/dev/stdin" on systems that support it).

However, it's easy to change. Once upon a time, the bundle-reading code
required a seekable descriptor, but that was fixed long ago in
e9ee84cf28b (bundle: allowing to read from an unseekable fd,
2011-10-13). So we just need to handle "-" explicitly when opening the
file.

We _could_ do this by handling "-" in read_bundle_header(), which the
reading functions all call already. But that is probably a bad idea.
It's also used by low-level code like the transport functions, and we
may want to be more careful there. We do not know that stdin is even
available to us, and certainly we would not want to get confused by a
configured URL that happens to point to "-".

So instead, let's add a helper to builtin/bundle.c. Since both the
bundle code and some of the callers refer to the bundle by name for
error messages, let's use the string "<stdin>" to make the output a bit
nicer to read.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
18 months agogit-merge-tree.txt: replace spurious HTML entity
Andreas Schwab [Sat, 4 Mar 2023 17:00:46 +0000 (18:00 +0100)] 
git-merge-tree.txt: replace spurious HTML entity

Signed-off-by: Andreas Schwab <schwab@linux-m68k.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
18 months agobundle: turn on --all-progress-implied by default
Jeff King [Sat, 4 Mar 2023 10:55:13 +0000 (05:55 -0500)] 
bundle: turn on --all-progress-implied by default

In 79862b6b77c (bundle-create: progress output control, 2019-11-10),
"bundle create" learned about the --all-progress and
--all-progress-implied options, which were copied from pack-objects.
I think these were a mistake.

In pack-objects, "all-progress-implied" is about switching the behavior
between a regular on-disk "git repack" and the use of pack-objects for
push/fetch (where a fetch does not want progress from the server during
the write stage; the client will print progress as it receives the
data). But there's no such distinction for bundles. Prior to
79862b6b77c, we always printed the write stage. Afterwards, a vanilla:

  git bundle create foo.bundle

omits the write progress, appearing to hang (especially if your
repository is large or your disk is slow). That seems like a regression.

It's possible that the flexibility to disable the write-phase progress
_could_ be useful for bundle. E.g., if you did something like:

  ssh some-host git bundle create foo.bundle |
  git bundle unbundle

But if you are running both in real-time, why are you using bundles in
the first place? You're better off doing a real fetch.

But even if we did want to support that, it should be the exception, and
vanilla "bundle create" should display the full progress. So we'd want
to name the option "--no-write-progress" or something.

The "--all-progress" option itself is even worse. It exists in
pack-objects only for historical reasons. It's a mistake because it
implies "--progress", and we added "--all-progress-implied" to fix that.
There is no reason to propagate that mistake to new commands.

Likewise, the documentation for these options was pulled from
pack-objects. But it doesn't make any sense in this context. It talks
about "--stdout", but that is not even an option that git-bundle
supports.

This patch flips the default for "--all-progress-implied" back to
"true", fixing the regression in 79862b6b77c. This turns that option
into a noop, and means that "--all-progress" is really the same as
"--progress". We _could_ drop them completely, but since they've been
shipped with Git since v2.25.0, it's polite to continue accepting them.

I didn't implement any sort of "--no-write-progress" here. I'm not at
all convinced it's necessary, and the discussion from the original
thread:

  https://lore.kernel.org/git/20191110204126.30553-2-robbat2@gentoo.org/

shows that that the main focus was on getting --progress and --quiet
support, and not any kind of clever "real-time bundle over the network"
feature. But technically this patch is making it impossible to do
something that you _could_ do post-79862b6b77c.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
18 months agol10n: update German translation
Ralf Thielow [Fri, 3 Mar 2023 16:23:10 +0000 (17:23 +0100)] 
l10n: update German translation

Reviewed-by: Matthias Rüster <matthias.ruester@gmail.com>
Signed-off-by: Ralf Thielow <ralf.thielow@gmail.com>
18 months agoformat-patch: output header for empty commits
John Keeping [Fri, 3 Mar 2023 16:03:01 +0000 (16:03 +0000)] 
format-patch: output header for empty commits

When formatting an empty commit, it is surprising that a totally empty
file is generated.  Set the flag to always print the header, matching
the behaviour of git-log.

Signed-off-by: John Keeping <john@keeping.me.uk>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
18 months agol10n: tr: Update Turkish translations for v.2.40.0
Emir SARI [Sat, 25 Feb 2023 10:53:07 +0000 (13:53 +0300)] 
l10n: tr: Update Turkish translations for v.2.40.0

Signed-off-by: Emir SARI <emir_sari@icloud.com>
18 months agol10n: fr: v2.40.0 rnd 2
Jean-Noël Avila [Thu, 2 Mar 2023 17:45:05 +0000 (18:45 +0100)] 
l10n: fr: v2.40.0 rnd 2

Signed-off-by: Jean-Noël Avila <jn.avila@free.fr>
18 months agol10n: fr: v2.40.0 rnd 1
Jean-Noël Avila [Mon, 27 Feb 2023 19:58:56 +0000 (20:58 +0100)] 
l10n: fr: v2.40.0 rnd 1

Signed-off-by: Jean-Noël Avila <jn.avila@free.fr>
18 months agol10n: fr: fix some typos
Jean-Noël Avila [Sat, 31 Dec 2022 15:37:33 +0000 (16:37 +0100)] 
l10n: fr: fix some typos

Signed-off-by: Jean-Noël Avila <jn.avila@free.fr>
Reported-by: Andrei Rybak <rybak.a.v@gmail.com>
18 months agol10n: po-id for 2.40 (round 1)
Bagas Sanjaya [Wed, 1 Mar 2023 09:00:12 +0000 (16:00 +0700)] 
l10n: po-id for 2.40 (round 1)

Update following components:

  * archive.c
  * attr.c
  * builtin/add.c
  * builtin/rebase.c
  * bundle.c
  * connect.c
  * sequencer.c
  * t/helper/test-bundle-uri.c
  * transport.c
  * wt-status.c

Signed-off-by: Bagas Sanjaya <bagasdotme@gmail.com>
18 months agol10n: sv.po: Update Swedish translation (5490t0f0u)
Peter Krefting [Thu, 2 Mar 2023 08:35:41 +0000 (09:35 +0100)] 
l10n: sv.po: Update Swedish translation (5490t0f0u)

Signed-off-by: Peter Krefting <peter@softwolves.pp.se>
18 months agol10n: bg.po: Updated Bulgarian translation (5490t)
Alexander Shopov [Sat, 25 Feb 2023 15:14:56 +0000 (16:14 +0100)] 
l10n: bg.po: Updated Bulgarian translation (5490t)

Signed-off-by: Alexander Shopov <ash@kambanaria.org>
18 months agoMerge branch 'rs/range-diff-custom-abbrev-fix'
Junio C Hamano [Wed, 1 Mar 2023 21:25:24 +0000 (13:25 -0800)] 
Merge branch 'rs/range-diff-custom-abbrev-fix'

Hotfix for a topic that is already in 'master'.

* rs/range-diff-custom-abbrev-fix:
  range-diff: avoid compiler warning when char is unsigned

18 months agol10n: Update Catalan translation
Jordi Mas [Wed, 1 Mar 2023 21:07:24 +0000 (22:07 +0100)] 
l10n: Update Catalan translation

Signed-off-by: Jordi Mas <jmas@softcatala.org>
18 months agoGit 2.40-rc1 v2.40.0-rc1
Junio C Hamano [Wed, 1 Mar 2023 16:13:35 +0000 (08:13 -0800)] 
Git 2.40-rc1

Signed-off-by: Junio C Hamano <gitster@pobox.com>
18 months agopush: allow delete single-level ref
ZheNing Hu [Wed, 1 Mar 2023 10:20:29 +0000 (10:20 +0000)] 
push: allow delete single-level ref

We discourage the creation/update of single-level refs
because some upper-layer applications only work in specified
reference namespaces, such as "refs/heads/*" or "refs/tags/*",
these single-level refnames may not be recognized. However,
we still hope users can delete them which have been created
by mistake.

Therefore, when updating branches on the server with
"git receive-pack", by checking whether it is a branch deletion
operation, it will determine whether to allow the update of
a single-level refs. This avoids creating/updating such
single-level refs, but allows them to be deleted.

On the client side, "git push" also does not properly fill in
the old-oid of single-level refs, which causes the server-side
"git receive-pack" to think that the ref's old-oid has changed
when deleting single-level refs, this causes the push to be
rejected. So the solution is to fix the client to be able to
delete single-level refs by properly filling old-oid.

Signed-off-by: ZheNing Hu <adlternative@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
18 months agoreceive-pack: fix funny ref error messsage
ZheNing Hu [Wed, 1 Mar 2023 10:20:28 +0000 (10:20 +0000)] 
receive-pack: fix funny ref error messsage

When the user deletes the remote one level branch through
"git push origin -d refs/foo", remote will return an error:
"refusing to create funny ref 'refs/foo' remotely", here we
are not creating "refs/foo" instead wants to delete it, so a
better error description here would be: "refusing to update
funny ref 'refs/foo' remotely".

Signed-off-by: ZheNing Hu <adlternative@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
18 months agoA bit more before 2.40-rc1
Junio C Hamano [Tue, 28 Feb 2023 23:42:20 +0000 (15:42 -0800)] 
A bit more before 2.40-rc1

Signed-off-by: Junio C Hamano <gitster@pobox.com>
18 months agoMerge branch 'ar/test-lib-remove-stale-comment'
Junio C Hamano [Wed, 1 Mar 2023 00:38:47 +0000 (16:38 -0800)] 
Merge branch 'ar/test-lib-remove-stale-comment'

Test library clean-up.

* ar/test-lib-remove-stale-comment:
  test-lib: drop comment about test_description

18 months agoMerge branch 'zy/t9700-style'
Junio C Hamano [Wed, 1 Mar 2023 00:38:47 +0000 (16:38 -0800)] 
Merge branch 'zy/t9700-style'

Test style fixes.

* zy/t9700-style:
  t9700: modernize test scripts

18 months agoMerge branch 'pw/rebase-i-parse-fix'
Junio C Hamano [Wed, 1 Mar 2023 00:38:47 +0000 (16:38 -0800)] 
Merge branch 'pw/rebase-i-parse-fix'

Fixes to code that parses the todo file used in "rebase -i".

* pw/rebase-i-parse-fix:
  rebase -i: fix parsing of "fixup -C<commit>"
  rebase -i: match whole word in is_command()

18 months agoMerge branch 'jk/http-test-fixes'
Junio C Hamano [Wed, 1 Mar 2023 00:38:47 +0000 (16:38 -0800)] 
Merge branch 'jk/http-test-fixes'

Various fix-ups on HTTP tests.

* jk/http-test-fixes:
  t5559: make SSL/TLS the default
  t5559: fix test failures with LIB_HTTPD_SSL
  t/lib-httpd: enable HTTP/2 "h2" protocol, not just h2c
  t/lib-httpd: respect $HTTPD_PROTO in expect_askpass()
  t5551: drop curl trace lines without headers
  t5551: handle v2 protocol in cookie test
  t5551: simplify expected cookie file
  t5551: handle v2 protocol in upload-pack service test
  t5551: handle v2 protocol when checking curl trace
  t5551: stop forcing clone to run with v0 protocol
  t5551: handle HTTP/2 when checking curl trace
  t5551: lower-case headers in expected curl trace
  t5551: drop redundant grep for Accept-Language
  t5541: simplify and move "no empty path components" test
  t5541: stop marking "used receive-pack service" test as v0 only
  t5541: run "used receive-pack service" test earlier

18 months agorange-diff: avoid compiler warning when char is unsigned
René Scharfe [Tue, 28 Feb 2023 16:13:27 +0000 (17:13 +0100)] 
range-diff: avoid compiler warning when char is unsigned

Since 2b15969f61 (range-diff: let '--abbrev' option takes effect,
2023-02-20), GCC 11.3 on Ubuntu 22.04 on aarch64 warns (and errors
out if the make variable DEVELOPER is set):

range-diff.c: In function ‘output_pair_header’:
range-diff.c:388:20: error: comparison is always false due to limited range of data type [-Werror=type-limits]
  388 |         if (abbrev < 0)
      |                    ^
cc1: all warnings being treated as errors

That's because char is unsigned on that platform.  Use int instead, just
like in struct diff_options, to copy the value faithfully.

Signed-off-by: René Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
18 months agosignature-format.txt: note SSH and X.509 signature delimiters
Gwyneth Morgan [Mon, 27 Feb 2023 20:27:18 +0000 (20:27 +0000)] 
signature-format.txt: note SSH and X.509 signature delimiters

This document only explains PGP signatures, but Git now supports X.509
signatures as of 1e7adb9756 (gpg-interface: introduce new signature
format "x509" using gpgsm, 2018-07-17), and SSH signatures as of
29b315778e (ssh signing: add ssh key format and signing code,
2021-09-10).

Additionally, explain that these signature formats are controlled
`gpg.format`, linking to its documentation, and explain in said
`gpg.format` documentation that the underlying signature format is
documented in signature-format.txt.

Signed-off-by: Gwyneth Morgan <gwymor@tilde.club>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
18 months agorebase: fix capitalisation autoSquash in i18n string
Fangyi Zhou [Sun, 26 Feb 2023 18:00:29 +0000 (18:00 +0000)] 
rebase: fix capitalisation autoSquash in i18n string

The config option (as documented) for rebase.autoSquash has a capital S,
whereas the command line option has a small case s.

Cf. <20220617100309.3224-1-worldhello.net@gmail.com>

Signed-off-by: Fangyi Zhou <me@fangyi.io>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
18 months agocredential: add WWW-Authenticate header to cred requests
Matthew John Cheetham [Mon, 27 Feb 2023 17:20:20 +0000 (17:20 +0000)] 
credential: add WWW-Authenticate header to cred requests

Add the value of the WWW-Authenticate response header to credential
requests. Credential helpers that understand and support HTTP
authentication and authorization can use this standard header (RFC 2616
Section 14.47 [1]) to generate valid credentials.

WWW-Authenticate headers can contain information pertaining to the
authority, authentication mechanism, or extra parameters/scopes that are
required.

The current I/O format for credential helpers only allows for unique
names for properties/attributes, so in order to transmit multiple header
values (with a specific order) we introduce a new convention whereby a
C-style array syntax is used in the property name to denote multiple
ordered values for the same property.

In this case we send multiple `wwwauth[]` properties where the order
that the repeated attributes appear in the conversation reflects the
order that the WWW-Authenticate headers appeared in the HTTP response.

Add a set of tests to exercise the HTTP authentication header parsing
and the interop with credential helpers. Credential helpers will receive
WWW-Authenticate information in credential requests.

[1] https://datatracker.ietf.org/doc/html/rfc2616#section-14.47

Signed-off-by: Matthew John Cheetham <mjcheetham@outlook.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
18 months agohttp: read HTTP WWW-Authenticate response headers
Matthew John Cheetham [Mon, 27 Feb 2023 17:20:19 +0000 (17:20 +0000)] 
http: read HTTP WWW-Authenticate response headers

Read and store the HTTP WWW-Authenticate response headers made for
a particular request.

This will allow us to pass important authentication challenge
information to credential helpers or others that would otherwise have
been lost.

libcurl only provides us with the ability to read all headers recieved
for a particular request, including any intermediate redirect requests
or proxies. The lines returned by libcurl include HTTP status lines
delinating any intermediate requests such as "HTTP/1.1 200". We use
these lines to reset the strvec of WWW-Authenticate header values as
we encounter them in order to only capture the final response headers.

The collection of all header values matching the WWW-Authenticate
header is complicated by the fact that it is legal for header fields to
be continued over multiple lines, but libcurl only gives us each
physical line a time, not each logical header. This line folding feature
is deprecated in RFC 7230 [1] but older servers may still emit them, so
we need to handle them.

In the future [2] we may be able to leverage functions to read headers
from libcurl itself, but as of today we must do this ourselves.

[1] https://www.rfc-editor.org/rfc/rfc7230#section-3.2
[2] https://daniel.haxx.se/blog/2022/03/22/a-headers-api-for-libcurl/

Signed-off-by: Matthew John Cheetham <mjcheetham@outlook.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
18 months agot5563: add tests for basic and anoymous HTTP access
Matthew John Cheetham [Mon, 27 Feb 2023 17:20:18 +0000 (17:20 +0000)] 
t5563: add tests for basic and anoymous HTTP access

Add a test showing simple anoymous HTTP access to an unprotected
repository, that results in no credential helper invocations.
Also add a test demonstrating simple basic authentication with
simple credential helper support.

Leverage a no-parsed headers (NPH) CGI script so that we can directly
control the HTTP responses to simulate a multitude of good, bad and ugly
remote server implementations around auth.

Signed-off-by: Matthew John Cheetham <mjcheetham@outlook.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
18 months agoA bit more before 2.40-rc1
Junio C Hamano [Mon, 27 Feb 2023 18:06:20 +0000 (10:06 -0800)] 
A bit more before 2.40-rc1

Signed-off-by: Junio C Hamano <gitster@pobox.com>
18 months agoMerge branch 'if/simplify-trace-setup'
Junio C Hamano [Mon, 27 Feb 2023 18:08:57 +0000 (10:08 -0800)] 
Merge branch 'if/simplify-trace-setup'

Code clean-up.

* if/simplify-trace-setup:
  trace.c, git.c: remove unnecessary parameter to trace_repo_setup()