Commit graph

61816 commits

Author SHA1 Message Date
Martin Ågren 7b77f5a13e pack-format.txt: document sizes at start of delta data
We document the delta data as a set of instructions, but forget to
document the two sizes that precede those instructions: the size of the
base object and the size of the object to be reconstructed. Fix this
omission.

Rather than cramming all the details about the encoding into the running
text, introduce a separate section detailing our "size encoding" and
refer to it.

Reported-by: Ross Light <ross@zombiezen.com>
Signed-off-by: Martin Ågren <martin.agren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2021-01-04 13:00:28 -08:00
Elijah Newren 350410f6b1 diffcore-rename: remove unnecessary duplicate entry checks
Commit 25d5ea410f ("[PATCH] Redo rename/copy detection logic.",
2005-05-24) added a duplicate entry check on rename_src in order to
avoid segfaults; the code at the time was prone to double free()s and an
easy way to avoid it was just to turn off rename detection for any
duplicate entries.  Note that the form of the check was modified two
commits ago in this series.

Similarly, commit 4d6be03b95 ("diffcore-rename: avoid processing
duplicate destinations", 2015-02-26) added a duplicate entry check
on rename_dst for the exact same reason -- the code was prone to double
free()s, and an easy way to avoid it was just to turn off rename
detection entirely.  Note that the form of the check was modified in the
commit just before this one.

In the original code in both places, the code was dealing with
individual diff_filespecs and trying to match things up, instead of just
keeping the original diff_filepairs around as we do now.  The
intervening change in structure has fixed the accounting problems and
the associated double free()s that used to occur, and thus we already
have a better fix.  As such, we can remove the band-aid checks for
duplicate entries.

Due to the last two patches, the diffcore_rename() setup is no longer a
sizeable chunk of overall runtime.  Thus, in a large rebase of many
commits with lots of renames and several optimizations to inexact rename
detection, this patch only speeds up the overall code by about half a
percent or so and is pretty close to the run-to-run variability making
it hard to get an exact measurement.  However, with some trace2 regions
around the setup code in diffcore_rename() so that I can focus on just
it, I measure that this patch consistently saves almost a third of the
remaining time spent in diffcore_rename() setup.

Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2021-01-04 12:59:34 -08:00
Antonio Russo c8302c6c00 t6016: move to lib-log-graph.sh framework
t6016 manually reconstructs git log --graph output by using the reported
commit hashes from `git rev-parse`.  Each tag is converted into an
environment variable manually, and then `echo`-ed to an expected output
file, which is in turn compared to the actual output.

The expected output is difficult to read and write, because, e.g.,
each line of output must be prefaced with echo, quoted, and properly
escaped.  Additionally, the test is sensitive to trailing whitespace,
which may potentially be removed from graph log output in the future.

In order to reduce duplication, ease troubleshooting of failed tests by
improving readability, and ease the addition of more tests to this file,
port the operations to `lib-log-graph.sh`, which is already used in
several other tests, e.g., t4215.  Give all merges a simple commit
message, and use a common `check_graph` macro taking a heredoc of the
expected output which does not required extensive escaping.

Signed-off-by: Antonio Russo <aerusso@aerusso.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2021-01-04 12:20:49 -08:00
Martin Ågren 04f6b0a192 t1300: don't needlessly work with core.foo configs
We use various made-up config keys in the "core" section for no real
reason. Change them to work in the "section" section instead and be
careful to also change "cores" to "sections". Make sure to also catch
"Core", "CoReS" and similar.

There are a few instances that actually want to work with a real "core"
config such as `core.bare` or `core.editor`. After this, it's clearer
that they work with "core" for a reason.

Reported-by: Junio C Hamano <gitster@pobox.com>
Signed-off-by: Martin Ågren <martin.agren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2021-01-04 11:31:25 -08:00
Martin Ågren 34479d7177 t1300: remove duplicate test for --file no-such-file
We test that we can handle `git config --file symlink` and the error
case of `git config --file symlink-to-missing-file`. For good measure,
we also throw in a test to check that we correctly handle referencing a
missing regular file. But we have such a test earlier in this script.
They both check that we fail to use `--file no-such-file --list`.

Drop the latter of these and keep the one that is in the general area
where we test `--file` and `GIT_CONFIG`. The one we're dropping also
checks that we can't even get a specific key from the missing file --
let's make sure we check that in the test we keep.

Signed-off-by: Martin Ågren <martin.agren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2021-01-04 11:31:25 -08:00
Martin Ågren b832abb63d t1300: remove duplicate test for --file ../foo
We have two tests for checking that we can handle `git config --file
../other-config ...`. One, using `--file`, was introduced in 65807ee697
("builtin-config: Fix crash when using "-f <relative path>" from
non-root dir", 2010-01-26), then another, using `GIT_CONFIG`, came about
in 270a34438b ("config: stop using config_exclusive_filename",
2012-02-16).

The latter of these was then converted to use `--file` in f7e8714101
("t: prefer "git config --file" to GIT_CONFIG", 2014-03-20). Both where
then simplified in a5db0b77b9 ("t1300: extract and use
test_cmp_config()", 2018-10-21).

These two tests differ slightly in the order of the options used, but
other than that, they are identical. Let's drop one. As noted in
f7e8714101, we do still have a test for `GIT_CONFIG` and it shares the
implementation with `--file`.

Signed-off-by: Martin Ågren <martin.agren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2021-01-04 11:31:24 -08:00
Philippe Blain 1f4e9319c7 gitmodules.txt: fix 'GIT_WORK_TREE' variable name
'gitmodules.txt' is a guide about the '.gitmodules' file that describes
submodule properties, and that file must exist at the root of the
repository. This was clarified in e5b5c1d2cf (Document clarification:
gitmodules, gitattributes, 2008-08-31).

However, that commit mistakenly uses the non-existing environment
variable 'GIT_WORK_DIR' to refer to the root of the repository.

Fix that by using the correct variable, 'GIT_WORK_TREE'. Take the
opportunity to modernize and improve the formatting of that guide,
and fix a grammar mistake.

Signed-off-by: Philippe Blain <levraiphilippeblain@gmail.com>
Acked-by: Martin Ågren <martin.agren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2021-01-04 11:29:36 -08:00
Thomas Ackermann 7efc378205 doc: fix some typos
Signed-off-by: Thomas Ackermann <th.acker@arcor.de>
Acked-by: Martin Ågren <martin.agren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2021-01-04 11:27:48 -08:00
Junio C Hamano ffd27e6cb2 CoC: explicitly take any whitespace breakage
We'll keep this document mostly in sync with the upstream; let's
help "git am" and "git show" by telling them that they may introduce
what we may consider whitespace errors.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
2021-01-04 09:44:49 -08:00
Ævar Arnfjörð Bjarmason cb50786f49 CoC: Update word-wrapping to match upstream
When the CoC document was added in 5cdf2301d4 (add a Code of Conduct
document, 2019-09-24) it was added from some 1.4 version of the
document whose word wrapping doesn't match what's currently at [1],
which matches content/version/1/4/code-of-conduct.md in the CoC
repository[2].

Let's update our version to match that, to make reading subsequent
diffs easier. There are no non-whitespace changes here.

1. https://www.contributor-covenant.org/version/1/4/code-of-conduct/
2. https://github.com/ContributorCovenant/contributor_covenant

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2021-01-04 09:14:38 -08:00
Junio C Hamano 71ca53e812 Git 2.30
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2020-12-27 15:15:23 -08:00
Junio C Hamano f6bf36dc9c Merge branch 'pb/doc-git-linkit-fix'
Docfix.

* pb/doc-git-linkit-fix:
  git.txt: fix typos in 'linkgit' macro invocation
2020-12-27 15:14:32 -08:00
Junio C Hamano 371065cc22 l10n for Git 2.30.0 round 2
-----BEGIN PGP SIGNATURE-----
 
 iQIzBAABCAAdFiEE37vMEzKDqYvVxs51k24VDd1FMtUFAl/omoIACgkQk24VDd1F
 MtV1nw/9FJKiNTB4Qi7mX1uNSYMr3RxtSSq0w6SsPpXyv/CBRwa4ZLWe8KT5g8JA
 hPOn8XAPFwM5BL+4A62toqZi/758XBTLJNUL8iohfVSt2UeDpRDdC1nq7ufJU+Mm
 9ij0wmzor6KSLLUfor8B5eKf1mCtsoj20SpZcLzLqYMPsCrVePng+nLKb7HBiCpZ
 UUdLYhFN8UYcFaUXqNT/runcZbHEJCk+5G+3wGvKpWhA0ppthD0TTHRTnfvamotb
 q/w47/fFMfkB+7uCvB4ysctCFmhjqdRKVGDV8ZCCTxMURnQ3p1MC9IWTxkFfaWgN
 9ZwcEUYhKByhGNU1M4lcr7pWGfdXULa8/kIuXg2rHRKUeGQPmREKE8hOmOadFzlX
 vBlHKbKC0oZ8xVHY8IxkaKhEdUJ4q4WW6CYF1VCfbcEXWP4Y6/FTqG2ok2YgofNz
 DjB/jvLO9kqD1THLYY4aOOm1z6citLSMMrUG0TsVgJenb4bywZPEFuj1OzOZgaOF
 l/FfQqJVI9kqS8J17QLsrevItEwRnnFihLPg5Oh4MIp0MNmGNpnfiZwKT7/QjSEm
 bxtmNv3QFNlfie1Wvoq5L/cpmvdTsJHExfZAvhq3h2GYRXvB62uxaLI81Uz/VZZ4
 +SwGtoFeiqO2HWI0Iivx9NCMWfaj7vQiJMnohJViET+wLuXSDxY=
 =W3Ab
 -----END PGP SIGNATURE-----

Merge tag 'l10n-2.30.0-rnd2' of https://github.com/git-l10n/git-po

l10n for Git 2.30.0 round 2

* tag 'l10n-2.30.0-rnd2' of https://github.com/git-l10n/git-po:
  l10n: zh_CN: for git v2.30.0 l10n round 1 and 2
  l10n: zh_TW.po: v2.30.0 round 2 (1 untranslated)
  l10n: pl.po: add translation and set team leader
  l10n: pl.po: started Polish translation
  l10n: de.po: Update German translation for Git 2.30.0
  l10n: Update Catalan translation
  l10n: bg.po: Updated Bulgarian translation (5037t)
  l10n: fr.po v2.30.0 rnd 2
  l10n: tr: v2.30.0-r2
  l10n: sv.po: Update Swedish translation (5037t0f0u)
  l10n: vi.po(5037t): v2.30.0 rnd 2
  l10n: git.pot: v2.30.0 round 2 (1 new, 2 removed)
  l10n: Update Catalan translation
  l10n: fr.po: v2.30.0 rnd 1
  l10n: fr.po Fix a typo
  l10n: fr fix misleading message
  l10n: tr: v2.30.0-r1
  l10n: sv.po: Update Swedish translation (5038t0f0u)
  l10n: git.pot: v2.30.0 round 1 (70 new, 45 removed)
2020-12-27 15:01:16 -08:00
Jiang Xin d13389bf27 l10n: zh_CN: for git v2.30.0 l10n round 1 and 2
Translate 71 new messages (5037t0f0u) for git 2.30.0.

Reviewed-by: 依云 <lilydjwg@gmail.com>
Signed-off-by: Jiang Xin <worldhello.net@gmail.com>
2020-12-27 19:23:27 +08:00
Jiang Xin ecc0c5841b Merge branch 'l10n/zh_TW/201223' of github.com:l10n-tw/git-po
* 'l10n/zh_TW/201223' of github.com:l10n-tw/git-po:
  l10n: zh_TW.po: v2.30.0 round 2 (1 untranslated)
2020-12-25 15:12:02 +08:00
pan93412 6806dd88f3 l10n: zh_TW.po: v2.30.0 round 2 (1 untranslated)
Signed-off-by: pan93412 <pan93412@gmail.com>
2020-12-25 12:16:13 +08:00
Arusekk b77b318bd2 l10n: pl.po: add translation and set team leader
Signed-off-by: Arusekk <arek_koz@o2.pl>
2020-12-23 23:51:43 +01:00
Junio C Hamano 4a0de43f49 Git 2.30-rc2
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2020-12-23 13:59:46 -08:00
Junio C Hamano 73583204d9 Merge branch 'nk/refspecs-negative-fix'
Hotfix for recent regression.

* nk/refspecs-negative-fix:
  negative-refspec: improve comment on query_matches_negative_refspec
  negative-refspec: fix segfault on : refspec
2020-12-23 13:59:46 -08:00
Junio C Hamano 7a50265295 Merge branch 'ma/maintenance-crontab-fix'
Hotfix for a topic of this cycle.

* ma/maintenance-crontab-fix:
  t7900-maintenance: test for magic markers
  gc: fix handling of crontab magic markers
  git-maintenance.txt: add missing word
2020-12-23 13:59:46 -08:00
Junio C Hamano 04cd999638 Merge branch 'dl/checkout-p-merge-base'
Fix to a regression introduced during this cycle.

* dl/checkout-p-merge-base:
  checkout -p: handle tree arguments correctly again
2020-12-23 13:59:46 -08:00
Junio C Hamano d076224363 Merge branch 'js/no-more-prepare-for-main-in-test'
Test coverage fix.

* js/no-more-prepare-for-main-in-test:
  tests: drop the `PREPARE_FOR_MAIN_BRANCH` prereq
  t9902: use `main` as initial branch name
  t6302: use `main` as initial branch name
  t5703: use `main` as initial branch name
  t5510: use `main` as initial branch name
  t5505: finalize transitioning to using the branch name `main`
  t3205: finalize transitioning to using the branch name `main`
  t3203: complete the transition to using the branch name `main`
  t3201: finalize transitioning to using the branch name `main`
  t3200: finish transitioning to the initial branch name `main`
  t1400: use `main` as initial branch name
2020-12-23 13:59:46 -08:00
Junio C Hamano c46f849f8a Merge branch 'jx/pack-redundant-on-single-pack'
"git pack-redandant" when there is only one packfile used to crash,
which has been corrected.

* jx/pack-redundant-on-single-pack:
  pack-redundant: fix crash when one packfile in repo
2020-12-23 13:59:46 -08:00
m4sk1n f6d254c157 l10n: pl.po: started Polish translation
Signed-off-by: Arusekk <arek_koz@o2.pl>
2020-12-23 22:51:30 +01:00
Daniel Levin 52fc4f195c git-p4: fix syncing file types with pattern
Example of pattern file type: text+k

Text filtered through the p4 pattern regexp must be converted from
string back to bytes, otherwise 'data' command for the fast-import
will receive extra invalid characters, followed by the fast-import
process error.

CC: Yang Zhao <yang.zhao@skyboxlabs.com>
Signed-off-by: Daniel Levin <dendy.ua@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2020-12-23 13:49:40 -08:00
Eric Wong a9ecaa06a7 core.abbrev=no disables abbreviations
This allows users to write hash-agnostic scripts and configs by
disabling abbreviations.  Using "-c core.abbrev=40" will be
insufficient with SHA-256, and "-c core.abbrev=64" won't work with
SHA-1 repos today.

Signed-off-by: Eric Wong <e@80x24.org>
[jc: tweaked implementation, added doc and a test]
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2020-12-23 13:40:09 -08:00
Matthias Rüster 6fe3d27d00 l10n: de.po: Update German translation for Git 2.30.0
Reviewed-by: Ralf Thielow <ralf.thielow@gmail.com>
Reviewed-by: Phillip Szelat <phillip.szelat@gmail.com>
Signed-off-by: Matthias Rüster <matthias.ruester@gmail.com>
2020-12-23 13:41:53 +01:00
Ævar Arnfjörð Bjarmason 9ce0fc3311 mktag doc: grammar fix, when exists -> when it exists
Amend the wording of documentation added in 6cfec03680 (mktag:
minimally update the description., 2007-06-10). It makes more sense to
say "when it exists" here, as we're referring to "the message".

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2020-12-22 17:49:05 -08:00
Ævar Arnfjörð Bjarmason f59b61dc4d mktag doc: say <hash> not <sha1>
Change the "mktag" documentation to refer to the input hash as just
"hash", not "sha1". This command has supported SHA-256 for a while
now.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2020-12-22 17:49:05 -08:00
Jiang Xin 4953317e6b Merge branch 'master' of github.com:Softcatala/git-po
* 'master' of github.com:Softcatala/git-po:
  l10n: Update Catalan translation
2020-12-23 08:44:44 +08:00
Eric Sunshine 5bc12c11cc t/perf: avoid unnecessary test_export() recursion
test_export() has been self-recursive since its inception even though a
simple for-loop would have served just as well to append its arguments
to the `test_export_` variable separated by the pipe character "|".
Recently `test_export_` was changed instead to a space-separated list of
tokens to be exported, an operation which can be accomplished via a
single simple assignment, with no need for looping or recursion.
Therefore, simplify the implementation.

While at it, take advantage of the fact that variable names to be
exported are shell identifiers, thus won't be composed of special
characters or whitespace, thus simple a `$*` can be used rather than
magical `"$@"`.

Signed-off-by: Eric Sunshine <sunshine@sunshineco.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2020-12-22 13:45:36 -08:00
Philippe Blain 5bed7f66c4 git.txt: fix typos in 'linkgit' macro invocation
The 'linkgit' Asciidoc macro is misspelled as 'linkit' in the
description of 'GIT_SEQUENCE_EDITOR' since the addition of that variable
to git(1) in 902a126eca (doc: mention GIT_SEQUENCE_EDITOR and
'sequence.editor' more, 2020-08-31). Also, it uses two colons instead of
one.

Fix that.

Signed-off-by: Philippe Blain <levraiphilippeblain@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2020-12-22 12:02:29 -08:00
Jordi Mas 9d82565c2e l10n: Update Catalan translation
Signed-off-by: Jordi Mas <jmas@softcatala.org>
2020-12-22 18:04:53 +01:00
Alexander Shopov da0e79d6fa l10n: bg.po: Updated Bulgarian translation (5037t)
Signed-off-by: Alexander Shopov <ash@kambanaria.org>
2020-12-22 17:49:18 +01:00
Nipunn Koorapati 773c694142 negative-refspec: improve comment on query_matches_negative_refspec
Comment did not adequately explain how the two loops work
together to achieve the goal of querying for matching of any
negative refspec.

Signed-off-by: Nipunn Koorapati <nipunn@dropbox.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2020-12-21 22:49:36 -08:00
Nipunn Koorapati 18f9c98845 negative-refspec: fix segfault on : refspec
The logic added to check for negative pathspec match by c0192df630
(refspec: add support for negative refspecs, 2020-09-30) looks at
refspec->src assuming it is never NULL, however when
remote.origin.push is set to ":", then refspec->src is NULL,
causing a segfault within strcmp.

Tell git to handle matching refspec by adding the needle to the
set of positively matched refspecs, since matching ":" refspecs
match anything as src.

Add test for matching refspec pushes fetch-negative-refspec
both individually and in combination with a negative refspec.

Signed-off-by: Nipunn Koorapati <nipunn@dropbox.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2020-12-21 22:49:36 -08:00
Jiang Xin 44840426ec Merge branch 'fr_2.30_rnd2' of github.com:jnavila/git
* 'fr_2.30_rnd2' of github.com:jnavila/git:
  l10n: fr.po v2.30.0 rnd 2
2020-12-22 08:46:17 +08:00
Martin Ågren a52df25a54 t7900-maintenance: test for magic markers
When we insert our "BEGIN" and "END" markers into the cron table, it's
so that a Git version from many years into the future would be able to
identify this region in the cron table. Let's add a test to make sure
that these markers don't ever change.

Signed-off-by: Martin Ågren <martin.agren@gmail.com>
Acked-by: Derrick Stolee <dstolee@microsoft.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2020-12-21 14:33:09 -08:00
Martin Ågren 66dc0a3625 gc: fix handling of crontab magic markers
On `git maintenance start`, we add a few entries to the user's cron
table. We wrap our entries using two magic markers, "# BEGIN GIT
MAINTENANCE SCHEDULE" and "# END GIT MAINTENANCE SCHEDULE". At a later
`git maintenance stop`, we will go through the table and remove these
lines. Or rather, we will remove the "BEGIN" marker, the "END" marker
and everything between them.

Alas, we have a bug in how we detect the "END" marker: we don't. As we
loop through all the lines of the crontab, if we are in the "old
region", i.e., the region we're aiming to remove, we make an early
`continue` and don't get as far as checking for the "END" marker. Thus,
once we've seen our "BEGIN", we remove everything until the end of the
file.

Rewrite the logic for identifying these markers. There are four cases
that are mutually exclusive: The current line starts a region or it ends
it, or it's firmly within the region, or it's outside of it (and should
be printed).

Signed-off-by: Martin Ågren <martin.agren@gmail.com>
Acked-by: Derrick Stolee <dstolee@microsoft.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2020-12-21 14:33:08 -08:00
Martin Ågren 83fcadd636 git-maintenance.txt: add missing word
Add a missing "a" before "bunch".

Signed-off-by: Martin Ågren <martin.agren@gmail.com>
Acked-by: Derrick Stolee <dstolee@microsoft.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2020-12-21 14:33:08 -08:00
Johannes Schindelin 5c29f19cda checkout -p: handle tree arguments correctly again
This fixes a segmentation fault.

The bug is caused by dereferencing `new_branch_info->commit` when it is
`NULL`, which is the case when the tree-ish argument is actually a tree,
not a commit-ish. This was introduced in 5602b500c3 (builtin/checkout:
fix `git checkout -p HEAD...` bug, 2020-10-07), where we tried to ensure
that the special tree-ish `HEAD...` is handled correctly.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2020-12-21 14:06:09 -08:00
Eric Sunshine cf76baea41 worktree: teach repair to fix multi-directional breakage
`git worktree repair` knows how to repair the two-way links between the
repository and a worktree as long as a link in one or the other
direction is sound. For instance, if a linked worktree is moved (without
using `git worktree move`), repair is possible because the worktree
still knows the location of the repository even though the repository no
longer knows where the worktree is. Similarly, if the repository is
moved, repair is possible since the repository still knows the locations
of the worktrees even though the worktrees no longer know where the
repository is.

However, if both the repository and the worktrees are moved, then links
are severed in both directions, and no repair is possible. This is the
case even when the new worktree locations are specified as arguments to
`git worktree repair`. The reason for this limitation is twofold. First,
when `repair` consults the worktree's gitfile (/path/to/worktree/.git)
to determine the corresponding <repo>/worktrees/<id>/gitdir file to fix,
<repo> is the old path to the repository, thus it is unable to fix the
`gitdir` file at its new location since it doesn't know where it is.
Second, when `repair` consults <repo>/worktrees/<id>/gitdir to find the
location of the worktree's gitfile (/path/to/worktree/.git), the path
recorded in `gitdir` is the old location of the worktree's gitfile, thus
it is unable to repair the gitfile since it doesn't know where it is.

Fix these shortcomings by teaching `repair` to attempt to infer the new
location of the <repo>/worktrees/<id>/gitdir file when the location
recorded in the worktree's gitfile has become stale but the file is
otherwise well-formed. The inference is intentionally simple-minded.
For each worktree path specified as an argument, `git worktree repair`
manually reads the ".git" gitfile at that location and, if it is
well-formed, extracts the <id>. It then searches for a corresponding
<id> in <repo>/worktrees/ and, if found, concludes that there is a
reasonable match and updates <repo>/worktrees/<id>/gitdir to point at
the specified worktree path. In order for <repo> to be known, `git
worktree repair` must be run in the main worktree or bare repository.

`git worktree repair` first attempts to repair each incoming
/path/to/worktree/.git gitfile to point at the repository, and then
attempts to repair outgoing <repo>/worktrees/<id>/gitdir files to point
at the worktrees. This sequence was chosen arbitrarily when originally
implemented since the order of fixes is immaterial as long as one side
of the two-way link between the repository and a worktree is sound.
However, for this new repair technique to work, the order must be
reversed. This is because the new inference mechanism, when it is
successful, allows the outgoing <repo>/worktrees/<id>/gitdir file to be
repaired, thus fixing one side of the two-way link. Once that side is
fixed, the other side can be fixed by the existing repair mechanism,
hence the order of repairs is now significant.

Two safeguards are employed to avoid hijacking a worktree from a
different repository if the user accidentally specifies a foreign
worktree as an argument. The first, as described above, is that it
requires an <id> match between the repository and the worktree. That
itself is not foolproof for preventing hijack, so the second safeguard
is that the inference will only kick in if the worktree's
/path/to/worktree/.git gitfile does not point at a repository.

Signed-off-by: Eric Sunshine <sunshine@sunshineco.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2020-12-21 13:44:28 -08:00
Felipe Contreras 33fc56253b test: bisect-porcelain: fix location of files
Commit ba7eafe146 (t6030: explicitly test for bisection cleanup,
2017-09-29) introduced checks for files in the $GIT_DIR directory, but
that variable is not always defined, and in this test file it's not.

Therefore these checks always passed regardless of the presence of these
files (unless the user has some /BISECT_LOG file, for some reason).

Let's check the files in the correct location.

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2020-12-21 13:08:39 -08:00
Jean-Noël Avila aa13df664e l10n: fr.po v2.30.0 rnd 2
Signed-off-by: Jean-Noël Avila <jn.avila@free.fr>
2020-12-21 18:53:19 +01:00
Emir Sarı cc2a21c415 l10n: tr: v2.30.0-r2
Signed-off-by: Emir Sarı <bitigchi@me.com>
2020-12-21 12:32:52 +03:00
Peter Krefting 035b991fae l10n: sv.po: Update Swedish translation (5037t0f0u)
Signed-off-by: Peter Krefting <peter@softwolves.pp.se>
2020-12-21 08:10:43 +01:00
Tran Ngoc Quan 2a48769ec2 l10n: vi.po(5037t): v2.30.0 rnd 2
Signed-off-by: Tran Ngoc Quan <vnwildman@gmail.com>
2020-12-21 08:45:38 +07:00
Jiang Xin d0b62a5259 l10n: git.pot: v2.30.0 round 2 (1 new, 2 removed)
Generate po/git.pot from v2.30.0-rc1 for git v2.30.0 l10n round 2.

Signed-off-by: Jiang Xin <worldhello.net@gmail.com>
2020-12-21 07:11:59 +08:00
Jiang Xin 3104153d5e Merge remote-tracking branch 'github/master' into git-po-master
* github/master: (42 commits)
  Git 2.30-rc1
  git-gui: use gray background for inactive text widgets
  Another batch before 2.30-rc1
  git-gui: Fix selected text colors
  Makefile: conditionally include GIT-VERSION-FILE
  git-gui: fix colored label backgrounds when using themed widgets
  config.mak.uname: remove old NonStop compatibility settings
  diff: correct interaction between --exit-code and -I<pattern>
  t/perf: fix test_export() failure with BSD `sed`
  style: do not "break" in switch() after "return"
  compat-util: pretend that stub setitimer() always succeeds
  strmap: make callers of strmap_remove() to call it in void context
  doc: mention Python 3.x supports
  index-format.txt: document v2 format of file system monitor extension
  docs: multi-pack-index: remove note about future 'verify' work
  init: provide useful advice about init.defaultBranch
  get_default_branch_name(): prepare for showing some advice
  branch -m: allow renaming a yet-unborn branch
  init: document `init.defaultBranch` better
  t7900: use --fixed-value in git-maintenance tests
  ...
2020-12-21 07:10:19 +08:00
Jordi Mas da5bf7b515 l10n: Update Catalan translation
Signed-off-by: Jordi Mas <jmas@softcatala.org>
2020-12-19 23:52:12 +01:00