summaryrefslogtreecommitdiff
AgeCommit message (Collapse)AuthorFilesLines
2019-08-19merge-recursive: remove useless parameter in merge_trees()Libravatar Elijah Newren4-12/+22
merge_trees() took a results parameter that would only be written when opt->call_depth was positive, which is never the case now that merge_trees_internal() has been split from merge_trees(). Remove the misleading and unused parameter from merge_trees(). While at it, add some comments explaining how the output of merge_trees() and merge_recursive() differ. Signed-off-by: Elijah Newren <newren@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2019-08-19merge-recursive: exit early if index != headLibravatar Elijah Newren1-29/+72
We had a rule to enforce that the index matches head, but it was found at the beginning of merge_trees() and would only trigger when opt->call_depth was 0. Since merge_recursive() doesn't call merge_trees() until after returning from recursing, this meant that the check wasn't triggered by merge_recursive() until it had first finished all the intermediate merges to create virtual merge bases. That is a potentially huge amount of computation (and writing of intermediate merge results into the .git/objects directory) before it errors out and says, in effect, "Sorry, I can't do any merging because you have some local changes that would be overwritten." Further, not enforcing this requirement earlier allowed other bugs (such as an unintentional unconditional dropping and reloading of the index in merge_recursive() even when no recursion was necessary), to mask bugs in other callers (which were fixed in the commit prior to this one). Make sure we do the index == head check at the beginning of the merge, and error out immediately if it fails. While we're at it, fix a small leak in the show-the-error codepath. Signed-off-by: Elijah Newren <newren@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2019-08-19Ensure index matches head before invoking merge machinery, round NLibravatar Elijah Newren3-1/+14
This is the bug that just won't die; there always seems to be another form of it somewhere. See the commit message of 55f39cf7551b ("merge: fix misleading pre-merge check documentation", 2018-06-30) for a more detailed explanation), but in short: <quick summary> builtin/merge.c contains this important requirement for merge strategies: ...the index must be in sync with the head commit. The strategies are responsible to ensure this. This condition is important to enforce because there are two likely failure cases when the index isn't in sync with the head commit: * we silently throw away changes the user had staged before the merge * we accidentally (and silently) include changes in the merge that were not part of either of the branches/trees being merged Discarding users' work and mis-merging are both bad outcomes, especially when done silently, so naturally this rule was stated sternly -- but, unfortunately totally ignored in practice unless and until actual bugs were found. But, fear not: the bugs from this were fixed in commit ee6566e8d70d ("[PATCH] Rewrite read-tree", 2005-09-05) through a rewrite of read-tree (again, commit 55f39cf7551b has a more detailed explanation of how this affected merge). And it was fixed again in commit 160252f81626 ("git-merge-ours: make sure our index matches HEAD", 2005-11-03) ...and it was fixed again in commit 3ec62ad9ffba ("merge-octopus: abort if index does not match HEAD", 2016-04-09) ...and again in commit 65170c07d466 ("merge-recursive: avoid incorporating uncommitted changes in a merge", 2017-12-21) ...and again in commit eddd1a411d93 ("merge-recursive: enforce rule that index matches head before merging", 2018-06-30) ...with multiple testcases added to the testsuite that could be enumerated in even more commits. Then, finally, in a patch in the same series as the last fix above, the documentation about this requirement was fixed in commit 55f39cf7551b ("merge: fix misleading pre-merge check documentation", 2018-06-30), and we all lived happily ever after... </quick summary> Unfortunately, "ever after" apparently denotes a limited time and it expired today. The merge-recursive rule to enforce that index matches head was at the beginning of merge_trees() and would only trigger when opt->call_depth was 0. Since merge_recursive() doesn't call merge_trees() until after returning from recursing, this meant that the check wasn't triggered by merge_recursive() until it had first finished all the intermediate merges to create virtual merge bases. That is a potentially HUGE amount of computation (and writing of intermediate merge results into the .git/objects directory) before it errors out and says, in effect, "Sorry, I can't do any merging because you have some local changes that would be overwritten." Trying to enforce that all of merge_trees(), merge_recursive(), and merge_recursive_generic() checked the index == head condition earlier resulted in a bunch of broken tests. It turns out that merge_recursive() has code to drop and reload the cache while recursing to create intermediate virtual merge bases, but unfortunately that code runs even when no recursion is necessary. This unconditional dropping and reloading of the cache masked a few bugs: * builtin/merge-recursive.c: didn't even bother loading the index. * builtin/stash.c: feels like a fake 'builtin' because it repeatedly invokes git subprocesses all over the place, mixed with other operations. In particular, invoking "git reset" will reset the index on disk, but the parent process that invoked it won't automatically have its in-memory index updated. * t3030-merge-recursive.h: this test has always been broken in that it didn't make sure to make index match head before running. But, it didn't care about the index or even the merge result, just the verbose output while running. While commit eddd1a411d93 ("merge-recursive: enforce rule that index matches head before merging", 2018-06-30) should have uncovered this broken test, it used a test_must_fail wrapper around the merge-recursive call because it was known that the merge resulted in a rename/rename conflict. Thus, that fix only made this test fail for a different reason, and since the index == head check didn't happen until after coming all the way back out of the recursion, the testcase had enough information to pass the one check that it did perform. So, load the index in builtin/merge-recursive.c, reload the in-memory index in builtin/stash.c, and modify the t3030 testcase to correctly setup the index and make sure that the test fails in the expected way (meaning it reports a rename/rename conflict). This makes sure that all callers actually make the index match head. The next commit will then enforce the condition that index matches head earlier so this problem doesn't return in the future. Signed-off-by: Elijah Newren <newren@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2019-08-19merge-recursive: remove another implicit dependency on the_repositoryLibravatar Elijah Newren1-2/+5
Commit d7cf3a96e9a0 ("merge-recursive.c: remove implicit dependency on the_repository", 2019-01-12) and follow-ups like commit 34e7771bc644 ("Use the right 'struct repository' instead of the_repository", 2019-06-27), removed most implicit uses of the_repository. Convert calls to get_commit_tree() to instead use repo_get_commit_tree() to get rid of another. Signed-off-by: Elijah Newren <newren@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2019-08-19merge-recursive: future-proof update_file_flags() against memory leaksLibravatar Elijah Newren1-3/+5
There is a 'free_buf' label to which all but one of the error paths in update_file_flags() jump; that error case involves a NULL buf and is thus not a memory leak. However, make that error case execute the same deallocation code anyway so that if anyone adds any additional memory allocations or deallocations, then all error paths correctly deallocate resources. Signed-off-by: Elijah Newren <newren@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2019-08-19merge-recursive: introduce an enum for detect_directory_renames valuesLibravatar Derrick Stolee3-11/+21
Improve code readability by introducing an enum to replace the not-quite-boolean values taken on by detect_directory_renames. Signed-off-by: Derrick Stolee <dstolee@microsoft.com> Signed-off-by: Elijah Newren <newren@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2019-08-19merge-recursive: provide a better label for diff3 common ancestorLibravatar Elijah Newren3-4/+209
In commit 7ca56aa07619 ("merge-recursive: add a label for ancestor", 2010-03-20), a label was added for the '||||||' line to make it have the more informative heading '|||||| merged common ancestors', with the statement: It would be nicer to use a more informative label. Perhaps someone will provide one some day. This chosen label was perfectly reasonable when recursiveness kicks in, i.e. when there are multiple merge bases. (I can't think of a better label in such cases.) But it is actually somewhat misleading when there is a unique merge base or no merge base. Change this based on the number of merge bases: >=2: "merged common ancestors" 1: <abbreviated commit hash> 0: "<empty tree>" Tests have also been added to check that we get the right ancestor name for each of the three cases. Also, since merge_recursive() and merge_trees() have polar opposite pre-conditions for opt->ancestor, document merge_recursive()'s pre-condition with an assertion. (An assertion was added to merge_trees() already a few commits ago.) The differences in pre-conditions stem from two factors: (1) merge_trees() does not recurse and thus does not have multiple sub-merges to worry about -- each of which would require a different value for opt->ancestor, (2) merge_trees() is only passed trees rather than commits and thus cannot internally guess as good of a label. Thus, while external callers of merge_trees() are required to provide a non-NULL opt->ancestor, merge_recursive() expects to set this value itself. Signed-off-by: Elijah Newren <newren@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2019-08-16merge-recursive: enforce opt->ancestor != NULL when calling merge_trees()Libravatar Elijah Newren1-10/+9
We always want our conflict hunks to be labelled so that users can know where each came from. The previous commit fixed the one caller in the codebase which was not setting opt->ancestor (and thus not providing a label for the "merge base" conflict hunk in diff3-style conflict markers); add an assertion to prevent future codepaths from also overlooking this requirement. Enforcing this requirement also allows us to simplify the code for labelling the conflict hunks by no longer checking if the ancestor label is NULL. Signed-off-by: Elijah Newren <newren@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2019-08-16checkout: provide better conflict hunk description with detached HEADLibravatar Elijah Newren1-0/+8
When running 'git checkout -m' and using diff3 style conflict markers, we want all the conflict hunks (left-side, "common" or "merge base", and right-side) to have label markers letting the user know where each came from. The "common" hunk label (o.ancestor) came from old_branch_info->name, but that is NULL when HEAD is detached, which resulted in a blank label. Check for that case and provide an abbreviated commit hash instead. (Incidentally, this was the only case in the git codebase where merge_trees() was called with opt->ancestor being NULL. A subsequent commit will prevent similar problems by enforcing that merge_trees() always be called with opt->ancestor != NULL.) Signed-off-by: Elijah Newren <newren@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2019-08-16merge-recursive: be consistent with assertLibravatar Elijah Newren1-1/+1
In commit 8daec1df03de ("merge-recursive: switch from (oid,mode) pairs to a diff_filespec", 2019-04-05), an assertion on a->path && b->path was added for code readability to document that these both needed to be non-NULL at this point in the code. However, the subsequent lines also read o->path, so it should be included in the assert. Signed-off-by: Elijah Newren <newren@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2019-08-16Git 2.23Libravatar Junio C Hamano1-1/+1
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2019-08-16Merge tag 'l10n-2.23.0-rnd2' of git://github.com/git-l10n/git-poLibravatar Junio C Hamano11-36251/+46987
l10n-2.23.0-rnd2
2019-08-16l10n: zh_CN: for git v2.23.0 l10n round 1~2Libravatar Jiang Xin1-2910/+3413
Translate 128 new messages (4674t0f0u) for git 2.23.0. Signed-off-by: Jiang Xin <worldhello.net@gmail.com>
2019-08-12l10n: de.po: Update German translationLibravatar Matthias Ruester1-2910/+3533
Signed-off-by: Matthias Rüster <matthias.ruester@gmail.com> Reviewed-by: Ralf Thielow <ralf.thielow@gmail.com> Reviewed-by: Phillip Szelat <phillip.szelat@gmail.com>
2019-08-12Merge branch 'master' of https://github.com/vnwildman/gitLibravatar Jiang Xin1-585/+595
* 'master' of https://github.com/vnwildman/git: l10n: vi(4674t): Updated translation for Vietnamese
2019-08-12Merge branch 'update-italian-translation' of github.com:AlessandroMenti/git-poLibravatar Jiang Xin1-522/+531
* 'update-italian-translation' of github.com:AlessandroMenti/git-po: l10n: it.po: update the Italian localization for v2.23.0 round 2
2019-08-12Merge branch 'next' of https://github.com/ChrisADR/git-poLibravatar Jiang Xin1-3030/+3598
* 'next' of https://github.com/ChrisADR/git-po: l10n: es: 2.23.0 round 2
2019-08-11Sync with Git 2.22.1Libravatar Junio C Hamano2-0/+4
2019-08-11doc: fix repeated wordsLibravatar Mark Rushakoff9-9/+9
Inspired by 21416f0a07 ("restore: fix typo in docs", 2019-08-03), I ran "git grep -E '(\b[a-zA-Z]+) \1\b' -- Documentation/" to find other cases where words were duplicated, e.g. "the the", and in most cases removed one of the repeated words. There were many false positives by this grep command, including deliberate repeated words like "really really" or valid uses of "that that" which I left alone, of course. I also did not correct any of the legitimate, accidentally repeated words in old RelNotes. Signed-off-by: Mark Rushakoff <mark.rushakoff@gmail.com> Acked-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2019-08-11Git 2.22.1Libravatar Junio C Hamano2-1/+4
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2019-08-11.mailmap: update email address of Philip OakleyLibravatar Philip Oakley1-0/+1
My IEE 'home for life' email service is being withdrawn on 30 Sept 2019. Replace with my new email domain. I also have a secondary (backup) 'home for life' through <philipoakley@dunelm.org.uk>. Signed-off-by: Philip Oakley <philipoakley@iee.email> Signed-off-by: Philip Oakley <philipoakley@iee.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2019-08-11l10n: it.po: update the Italian localization for v2.23.0 round 2Libravatar Alessandro Menti1-522/+531
Signed-off-by: Alessandro Menti <alessandro.menti@alessandromenti.it>
2019-08-11l10n: vi(4674t): Updated translation for VietnameseLibravatar Tran Ngoc Quan1-585/+595
Signed-off-by: Tran Ngoc Quan <vnwildman@gmail.com>
2019-08-10l10n: es: 2.23.0 round 2Libravatar Christopher Diaz Riveros1-3030/+3598
Signed-off-by: Christopher Diaz Riveros <chrisadr@gentoo.org>
2019-08-10l10n: fr v2.23.0 round 2Libravatar Jean-Noël Avila1-2904/+3429
Signed-off-by: Jean-Noël Avila <jn.avila@free.fr>
2019-08-10l10n: git.pot: v2.23.0 round 2 (4 new, 6 removed)Libravatar Jiang Xin1-477/+461
Generate po/git.pot from v2.23.0-rc2 for git v2.23.0 l10n round 2. Signed-off-by: Jiang Xin <worldhello.net@gmail.com>
2019-08-10Merge tag 'v2.23.0-rc2' of git://git.kernel.org/pub/scm/git/gitLibravatar Jiang Xin59-396/+1041
Git 2.23-rc2 * tag 'v2.23.0-rc2' of git://git.kernel.org/pub/scm/git/git: (63 commits) Git 2.23-rc2 t0000: reword comments for "local" test t: decrease nesting in test_oid_to_path sha1-file: release strbuf after use test-dir-iterator: use path argument directly dir-iterator: release strbuf after use commit-graph: release strbufs after use l10n: reformat some localized strings for v2.23.0 merge-recursive: avoid directory rename detection in recursive case commit-graph: fix bug around octopus merges restore: fix typo in docs doc: typo: s/can not/cannot/ and s/is does/does/ Git 2.23-rc1 log: really flip the --mailmap default RelNotes/2.23.0: fix a few typos and other minor issues RelNotes/2.21.1: typofix log: flip the --mailmap default unconditionally config: work around bug with includeif:onbranch and early config A few more last-minute fixes repack: simplify handling of auto-bitmaps and .keep files ...
2019-08-10l10n: bg.po: Updated Bulgarian translation (4674t)Libravatar Alexander Shopov1-2937/+3481
Signed-off-by: Alexander Shopov <ash@kambanaria.org>
2019-08-09Merge branch 'cb/xdiff-no-system-includes-in-dot-c' into maintLibravatar Junio C Hamano3-8/+0
Compilation fix. * cb/xdiff-no-system-includes-in-dot-c: xdiff: remove duplicate headers from xpatience.c xdiff: remove duplicate headers from xhistogram.c xdiff: drop system includes in xutils.c
2019-08-09Merge branch 'jk/no-system-includes-in-dot-c' into maintLibravatar Junio C Hamano3-3/+0
Compilation fix. * jk/no-system-includes-in-dot-c: wt-status.h: drop stdio.h include verify-tag: drop signal.h include
2019-08-09Merge branch 'sg/fsck-config-in-doc' into maintLibravatar Junio C Hamano1-0/+5
Doc update. * sg/fsck-config-in-doc: Documentation/git-fsck.txt: include fsck.* config variables
2019-08-09Merge branch 'jk/xdiff-clamp-funcname-context-index' into maintLibravatar Junio C Hamano2-2/+24
The internal diff machinery can be made to read out of bounds while looking for --funcion-context line in a corner case, which has been corrected. * jk/xdiff-clamp-funcname-context-index: xdiff: clamp function context indices in post-image
2019-08-09Git 2.23-rc2Libravatar Junio C Hamano1-1/+1
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2019-08-09Merge branch 'bc/hash-independent-tests-part-4'Libravatar Junio C Hamano2-9/+8
Test fix. * bc/hash-independent-tests-part-4: t0000: reword comments for "local" test t: decrease nesting in test_oid_to_path
2019-08-09Merge branch 'rs/plug-strbuf-reak-in-read-alt-refs'Libravatar Junio C Hamano1-0/+1
Leakfix. * rs/plug-strbuf-reak-in-read-alt-refs: sha1-file: release strbuf after use
2019-08-09Merge branch 'mt/dir-iterator-updates'Libravatar Junio C Hamano2-4/+4
Leakfix. * mt/dir-iterator-updates: test-dir-iterator: use path argument directly dir-iterator: release strbuf after use
2019-08-09Merge branch 'ds/commit-graph-incremental'Libravatar Junio C Hamano1-5/+7
Leakfix. * ds/commit-graph-incremental: commit-graph: release strbufs after use
2019-08-08Merge branch 'ja/l10n-fixes'Libravatar Junio C Hamano2-5/+12
A few messages have been updated to help localization better. * ja/l10n-fixes: l10n: reformat some localized strings for v2.23.0
2019-08-08Merge branch 'en/disable-dir-rename-in-recursive-merge'Libravatar Junio C Hamano2-1/+113
"merge-recursive" hit a BUG() when building a virtual merge base detected a directory rename. * en/disable-dir-rename-in-recursive-merge: merge-recursive: avoid directory rename detection in recursive case
2019-08-08Merge branch 'nd/switch-and-restore'Libravatar Junio C Hamano1-1/+1
Docfix. * nd/switch-and-restore: restore: fix typo in docs
2019-08-08Merge branch 'mr/doc-can-not-to-cannot'Libravatar Junio C Hamano6-7/+7
Docfix. * mr/doc-can-not-to-cannot: doc: typo: s/can not/cannot/ and s/is does/does/
2019-08-08Merge branch 'ds/commit-graph-octopus-fix'Libravatar Junio C Hamano2-2/+4
commit-graph did not handle commits with more than two parents correctly, which has been corrected. * ds/commit-graph-octopus-fix: commit-graph: fix bug around octopus merges
2019-08-08t0000: reword comments for "local" testLibravatar Jeff King1-8/+6
Commit 01d3a526ad (t0000: check whether the shell supports the "local" keyword, 2017-10-26) added a test to gather data on whether people run the test suite with shells that don't support "local". After almost two years, nobody has complained, and several other uses have cropped up in test-lib-functions.sh. Let's declare it acceptable to use. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2019-08-08t: decrease nesting in test_oid_to_pathLibravatar Jonathan Nieder1-1/+2
t1410.3 ("corrupt and checks") fails when run using dash versions before 0.5.8, with a cryptic message: mv: cannot stat '.git/objects//e84adb2704cbd49549e52169b4043871e13432': No such file or directory The function generating that path: test_oid_to_path () { echo "${1%${1#??}}/${1#??}" } which is supposed to produce a result like 12/3456789.... But a dash bug[*] causes it to instead expand to /3456789... The stream of symbols that makes up this function is hard for humans to follow, too. The complexity mostly comes from the repeated use of the expression ${1#??} for the basename of the loose object. Use a variable instead --- nowadays, the dialect of shell used by Git permits local variables, so this is cheap. An alternative way to work around [*] is to remove the double-quotes around test_oid_to_path's return value. That makes the expression easier for dash to read, but harder for humans. Let's prefer the rephrasing that's helpful for humans, too. Noticed by building on Ubuntu trusty, which uses dash 0.5.7. [*] Fixed by v0.5.8~13 ("[EXPAND] Propagate EXP_QPAT in subevalvar, 2013-08-23). Signed-off-by: Jonathan Nieder <jrnieder@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2019-08-07sha1-file: release strbuf after useLibravatar René Scharfe1-0/+1
Signed-off-by: René Scharfe <l.s.r@web.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2019-08-07test-dir-iterator: use path argument directlyLibravatar René Scharfe1-3/+1
Avoid allocating and leaking a strbuf for holding a verbatim copy of the path argument and pass the latter directly to dir_iterator_begin() instead. Signed-off-by: René Scharfe <l.s.r@web.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2019-08-07dir-iterator: release strbuf after useLibravatar René Scharfe1-1/+3
Signed-off-by: René Scharfe <l.s.r@web.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2019-08-07commit-graph: release strbufs after useLibravatar René Scharfe1-5/+7
Signed-off-by: René Scharfe <l.s.r@web.de> Acked-by: Derrick Stolee <dstolee@microsoft.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2019-08-06l10n: reformat some localized strings for v2.23.0Libravatar Jean-Noël Avila2-5/+12
Signed-off-by: Jean-Noël Avila <jn.avila@free.fr> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2019-08-06merge-recursive: avoid directory rename detection in recursive caseLibravatar Elijah Newren2-1/+113
Ever since commit 8c8e5bd6eb33 ("merge-recursive: switch directory rename detection default", 2019-04-05), the default handling with directory rename detection was to report a conflict and leave unstaged entries in the index. However, when creating a virtual merge base in the recursive case, we absolutely need a tree, and the only way a tree can be written is if we have no unstaged entries -- otherwise we hit a BUG(). There are a few fixes possible here which at least fix the BUG(), but none of them seem optimal for other reasons; see the comments with the new testcase 13e in t6043 for details (which testcase triggered a BUG() prior to this patch). As such, just opt for a very conservative and simple choice that is still relatively reasonable: have the recursive case treat 'conflict' as 'false' for opt->detect_directory_renames. Reported-by: Emily Shaffer <emilyshaffer@google.com> Signed-off-by: Elijah Newren <newren@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>