path: root/t/
AgeCommit message (Collapse)Author
2020-03-25Merge branch 'pw/advise-rebase-skip'Junio C Hamano
The mechanism to prevent "git commit" from making an empty commit or amending during an interrupted cherry-pick was broken during the rewrite of "git rebase" in C, which has been corrected. * pw/advise-rebase-skip: commit: give correct advice for empty commit during a rebase commit: encapsulate determine_whence() for sequencer commit: use enum value for multiple cherry-picks sequencer: write CHERRY_PICK_HEAD for reword and edit cherry-pick: check commit error messages cherry-pick: add test for `--skip` advice in `git commit` t3404: use test_cmp_rev
2020-01-27t3507: use test_path_is_missing()Denton Liu
The test_must_fail() function should only be used for git commands since we should assume that external commands work sanely. Replace `test_must_fail test_path_exists` with `test_path_is_missing` since we expect these paths to not exist. Signed-off-by: Denton Liu <> Signed-off-by: Junio C Hamano <>
2020-01-27t3507: fix indentationDenton Liu
We have some test cases which are indented 7-spaces instead of a tab. Reindent with a tab instead. This patch should appear empty with `--ignore-all-space`. Signed-off-by: Denton Liu <> Signed-off-by: Junio C Hamano <>
2019-12-06cherry-pick: check commit error messagesPhillip Wood
We disallow partial commits and amending when CHERRY_PICK_HEAD exists. Add a couple of tests to check the error message printed in each case before we refactor the code responsible for this. Signed-off-by: Phillip Wood <> Signed-off-by: Junio C Hamano <>
2019-05-13Merge branch 'pw/clean-sequencer-state-upon-final-commit'Junio C Hamano
"git chery-pick" (and "revert" that shares the same runtime engine) that deals with multiple commits got confused when the final step gets stopped with a conflict and the user concluded the sequence with "git commit". Attempt to fix it by cleaning up the state files used by these commands in such a situation. * pw/clean-sequencer-state-upon-final-commit: fix cherry-pick/revert status after commit commit/reset: try to clean up sequencer state
2019-05-08Merge branch 'dl/merge-cleanup-scissors-fix'Junio C Hamano
The list of conflicted paths shown in the editor while concluding a conflicted merge was shown above the scissors line when the clean-up mode is set to "scissors", even though it was commented out just like the list of updated paths and other information to help the user explain the merge better. * dl/merge-cleanup-scissors-fix: cherry-pick/revert: add scissors line on merge conflict sequencer.c: save and restore cleanup mode merge: add scissors line on merge conflict merge: cleanup messages like commit parse-options.h: extract common --cleanup option commit: extract cleanup_mode functions to sequencer t7502: clean up style t7604: clean up style t3507: clean up style t7600: clean up style
2019-04-19cherry-pick/revert: add scissors line on merge conflictDenton Liu
Fix a bug where the scissors line is placed after the Conflicts: section, in the case where a merge conflict occurs and commit.cleanup = scissors. Helped-by: Phillip Wood <> Signed-off-by: Denton Liu <> Signed-off-by: Junio C Hamano <>
2019-04-18t3507: clean up styleDenton Liu
Remove space after redirection operators for style. Also, remove a git command which was upstream of a pipe. Finally, let grep and sed open their own input instead of letting the shell redirect the input. Helped-by: SZEDER Gábor <> Signed-off-by: Denton Liu <> Signed-off-by: Junio C Hamano <>
2019-04-17commit/reset: try to clean up sequencer statePhillip Wood
When cherry-picking or reverting a sequence of commits and if the final pick/revert has conflicts and the user uses `git commit` to commit the conflict resolution and does not run `git cherry-pick --continue` then the sequencer state is left behind. This can cause problems later. In my case I cherry-picked a sequence of commits the last one of which I committed with `git commit` after resolving some conflicts, then a while later, on a different branch I aborted a revert which rewound my HEAD to the end of the cherry-pick sequence on the previous branch. Avoid this potential problem by removing the sequencer state if we're committing or resetting the final pick in a sequence. Signed-off-by: Phillip Wood <> Signed-off-by: Junio C Hamano <>
2019-03-18cherry-pick --continue: remember optionsPhillip Wood
Remember --allow-empty, --allow-empty-message and --keep-redundant-commits when cherry-pick stops for a conflict resolution. Signed-off-by: Phillip Wood <> Signed-off-by: Junio C Hamano <>
2019-03-18cherry-pick: demonstrate option amnesiaPhillip Wood
When cherry-pick stops for a conflict resolution it forgets --allow-empty --allow-empty-message and --keep-redundant-commits. Signed-off-by: Phillip Wood <> Signed-off-by: Junio C Hamano <>
2018-07-27merge-recursive: preserve skip_worktree bit when necessaryElijah Newren
merge-recursive takes any files marked as unmerged by unpack_trees, tries to figure out whether they can be resolved (e.g. using renames or a file-level merge), and then if they can be it will delete the old cache entries and writes new ones. This means that any ce_flags for those cache entries are essentially cleared when merging. Unfortunately, if a file was marked as skip_worktree and it needs a file-level merge but the merge results in the same version of the file that was found in HEAD, we skip updating the worktree (because the file was unchanged) but clear the skip_worktree bit (because of the delete-cache-entry-and-write-new-one). This makes git treat the file as having a local change in the working copy, namely a delete, when it should appear as unchanged despite not being present. Avoid this problem by copying the skip_worktree flag in this case. Signed-off-by: Elijah Newren <> Signed-off-by: Junio C Hamano <>
2018-07-27t3507: add a testcase showing failure with sparse checkoutBen Peart
Recent changes in merge_content() induced a bug when merging files that are not present in the local working directory due to sparse-checkout. Add a test case to demonstrate the bug so that we can ensure the fix resolves it and to prevent future regressions. Signed-off-by: Ben Peart <> Signed-off-by: Elijah Newren <> Signed-off-by: Junio C Hamano <>
2014-10-28merge & sequencer: turn "Conflicts:" hint into a commentJunio C Hamano
Just like other hints such as "Changes to be committed" we show in the editor to remind the committer what paths were involved in the resulting commit to help improving their log message, this section is merely a reminder. Traditionally, it was not made into comments primarily because it has to be generated outside the wt-status infrastructure, and also because it was meant as a bit stronger reminder than the others (i.e. explaining how you resolved conflicts is much more important than mentioning what you did to every paths involved in the commit). But that still does not make this hint a part of the log message proper, and not showing it as a comment is inviting mistakes. Note that we still notice "Conflicts:" followed by list of indented pathnames as an old-style cruft and insert a new Signed-off-by: before it. This is so that "commit --amend -s" adds the new S-o-b at the right place when used on an older commit. Signed-off-by: Junio C Hamano <>
2012-12-23tests: move test_cmp_rev to test-lib-functionsMartin von Zweigbergk
A function for checking that two given parameters refer to the same revision was defined in several places, so move the definition to instead. Signed-off-by: Martin von Zweigbergk <> Signed-off-by: Junio C Hamano <>
2012-09-14cherry-pick: don't forget -s on failureMiklos Vajna
In case 'git cherry-pick -s <commit>' failed, the user had to use 'git commit -s' (i.e. state the -s option again), which is easy to forget about. Instead, write the signed-off-by line early, so plain 'git commit' will have the same result. Also update 'git commit -s', so that in case there is already a relevant Signed-off-by line before the Conflicts: line, it won't add one more at the end of the message. If there is no such line, then add it before the the Conflicts: line. Signed-off-by: Miklos Vajna <> Signed-off-by: Junio C Hamano <>
2012-02-22cherry-pick: No advice to commit if --no-commitPhil Hord
When cherry-pick fails it offers a helpful hint about how to proceed. The hint tells the user how to do the cleanup needed by the conflicted cherry-pick and finish the job after conflict resolution. In case of cherry-pick --no-commit, the hint goes too far. It tells the user to finish up with 'git commit'. That is not what this git-cherry-pick was trying to do in the first place. Restrict the hint in case of --no-commit to avoid giving this extra advice. Also, add a test verifying the reduced hint for the --no-commit version of cherry-pick. Signed-off-by: Phil Hord <> Acked-by: Jonathan Nieder <> Signed-off-by: Junio C Hamano <>
2011-11-22revert: write REVERT_HEAD pseudoref during conflicted revertJonathan Nieder
When conflicts are encountered while reverting a commit, it can be handy to have the name of that commit easily available. For example, to produce a copy of the patch to refer to while resolving conflicts: $ git revert 2eceb2a8 error: could not revert 2eceb2a8... awesome, buggy feature $ git show -R REVERT_HEAD >the-patch $ edit $(git diff --name-only) Set a REVERT_HEAD pseudoref when "git revert" does not make a commit, for cases like this. This also makes it possible for scripts to distinguish between a revert that encountered conflicts and other sources of an unmerged index. After successfully committing, resetting with "git reset", or moving to another commit with "git checkout" or "git reset", the pseudoref is no longer useful, so remove it. Signed-off-by: Jonathan Nieder <> Signed-off-by: Junio C Hamano <>
2011-10-06revert.c: defer writing CHERRY_PICK_HEAD till it is safe to do soJay Soffian
do_pick_commit() writes out CHERRY_PICK_HEAD before invoking merge (either via do_recursive_merge() or try_merge_command()) on the assumption that if the merge fails it is due to conflict. However, if the tree is dirty, the merge may not even start, aborting before do_pick_commit() can remove CHERRY_PICK_HEAD. Instead, defer writing CHERRY_PICK_HEAD till after merge has returned. At this point we know the merge has either succeeded or failed due to conflict. In either case, we want CHERRY_PICK_HEAD to be written so that it may be picked up by the subsequent invocation of commit. Note that do_recursive_merge() aborts if the merge cannot start, while try_merge_command() returns a non-zero value other than 1. Signed-off-by: Jay Soffian <> Signed-off-by: Junio C Hamano <>
2011-04-13i18n: use test_i18ncmp and test_i18ngrep in t3203, t3501 and t3507Junio C Hamano
Signed-off-by: Junio C Hamano <>
2011-04-02Merge branch 'ab/i18n-st'Junio C Hamano
* ab/i18n-st: (69 commits) i18n: git-shortlog basic messages i18n: git-revert split up "could not revert/apply" message i18n: git-revert literal "me" messages i18n: git-revert "Your local changes" message i18n: git-revert basic messages i18n: git-notes GIT_NOTES_REWRITE_MODE error message i18n: git-notes basic commands i18n: git-gc "Auto packing the repository" message i18n: git-gc basic messages i18n: git-describe basic messages i18n: git-clean clean.requireForce messages i18n: git-clean basic messages i18n: git-bundle basic messages i18n: git-archive basic messages i18n: git-status "renamed: " message i18n: git-status "Initial commit" message i18n: git-status "Changes to be committed" message i18n: git-status shortstatus messages i18n: git-status "nothing to commit" messages i18n: git-status basic messages ... Conflicts: builtin/branch.c builtin/checkout.c builtin/clone.c builtin/commit.c builtin/grep.c builtin/merge.c builtin/push.c builtin/revert.c t/ t/
2011-03-10i18n: git-revert split up "could not revert/apply" messageÆvar Arnfjörð Bjarmason
Split up the "could not %s %s... %s" message into "could not revert %s... %s" and "could not apply %s... %s". This makes it easier for translators to understand the message. Signed-off-by: Ævar Arnfjörð Bjarmason <> Signed-off-by: Junio C Hamano <>
2011-02-22Teach commit about CHERRY_PICK_HEADJay Soffian
Previously the user was advised to use commit -c CHERRY_PICK_HEAD after a conflicting cherry-pick. While this would preserve the original commit's authorship, it would sadly discard cherry-pick's carefully crafted MERGE_MSG (which contains the list of conflicts as well as the original commit-id in the case of cherry-pick -x). On the other hand, if a bare 'commit' were performed, it would preserve the MERGE_MSG while resetting the authorship. In other words, there was no way to simultaneously take the authorship from CHERRY_PICK_HEAD and the commit message from MERGE_MSG. This change fixes that situation. A bare 'commit' will now take the authorship from CHERRY_PICK_HEAD and the commit message from MERGE_MSG. If the user wishes to reset authorship, that must now be done explicitly via --reset-author. A side-benefit of passing commit authorship along this way is that we can eliminate redundant authorship parsing code from revert.c. (Also removed an unused include from revert.c) Signed-off-by: Jay Soffian <> Signed-off-by: Junio C Hamano <>
2011-02-22Introduce CHERRY_PICK_HEADJay Soffian
When a cherry-pick conflicts git advises: $ git commit -c <original commit id> to preserve the original commit message and authorship. Instead, let's record the original commit id in CHERRY_PICK_HEAD and advise: $ git commit -c CHERRY_PICK_HEAD A later patch teaches git to handle the '-c CHERRY_PICK_HEAD' part. Note that we record CHERRY_PICK_HEAD even in the case where there are no conflicts so that we may use it to communicate authorship to commit; this will then allow us to remove set_author_ident_env from revert.c. However, we do not record CHERRY_PICK_HEAD when --no-commit is used, as presumably the user intends to further edit the commit and possibly even cherry-pick additional commits on top. Tests and documentation contributed by Jonathan Nieder. Reviewed-by: Jonathan Nieder <> Signed-off-by: Jay Soffian <> Signed-off-by: Junio C Hamano <>
2011-02-22t3507: introduce pristine-detach helperJonathan Nieder
All the tests in t3507 (cherry-pick with conflicts) begin with the same checkout + read-tree + clean incantation to ensure a predictable starting point. Factor out a function for that so the interesting part of the tests is easier to read. The "update-index --refresh" and "diff-index --exit-code HEAD" are not necessary as the point of this testsuite is not about testing "read-tree --reset". Improved-by: Junio C Hamano <> Signed-off-by: Jonathan Nieder <> Signed-off-by: Junio C Hamano <>
2010-08-18tests: fix syntax error in "Use advise() for hints" testÆvar Arnfjörð Bjarmason
Change the test introduced in the "Use advise() for hints" patch by Jonathan Nieder not to use '' for quotes inside '' delimited code. It ended up introducing a file called <paths> to the main git repository. Signed-off-by: Ævar Arnfjörð Bjarmason <> Signed-off-by: Junio C Hamano <>
2010-08-16cherry-pick/revert: Use advise() for hintsJonathan Nieder
When cherry-pick fails after picking a large series of commits, it can be hard to pick out the error message and advice. Prefix the advice with “hint: ” to help. Before: error: could not apply 7ab78c9... foo After resolving the conflicts, mark the corrected paths with 'git add <paths>' or 'git rm <paths>' and commit the result with: git commit -c 7ab78c9a7898b87127365478431289cb98f8d98f After: error: could not apply 7ab78c9... foo hint: after resolving the conflicts, mark the corrected paths hint: with 'git add <paths>' or 'git rm <paths>' hint: and commit the result with 'git commit -c 7ab78c9' Noticed-by: Thomas Rast <> Encouraged-by: Sverre Rabbelier <> Signed-off-by: Jonathan Nieder <> Signed-off-by: Junio C Hamano <>
2010-04-11t3507: Make test executableStephen Boyd
Signed-off-by: Stephen Boyd <> Signed-off-by: Junio C Hamano <>
2010-03-21cherry-pick, revert: add a label for ancestorJonathan Nieder
When writing conflict hunks in ‘diff3 -m’ format, also add a label to the common ancestor. Especially in a cherry-pick, it is not immediately obvious without such a label what the common ancestor represents. git rerere does not have trouble parsing the new output and its preimage ids are unchanged since it includes its own code for recreating conflict hunks. No other code in git parses conflict hunks. Requested-by: Stefan Monnier <> Signed-off-by: Jonathan Nieder <> Signed-off-by: Junio C Hamano <>
2010-03-21revert: clarify label on conflict hunksJonathan Nieder
When reverting a commit, the commit being merged is not the commit to revert itself but its parent. Add “parent of” to the conflict hunk label to make this more clear. The conflict hunk labels are all pieces of a single string written in the new get_message() function. Avoid some complication by using mempcpy to advance a pointer as the result is written. Also free the corresponding temporary buffer (it was leaked before). This is not important because it is a small one-time allocation. It would become a memory leak if unnoticed when libifying revert. This patch uses calls to strlen() instead of integer constants in some places. GCC will compute the length at compile time; I am not sure about other compilers, but this is not performance-critical anyway. Signed-off-by: Jonathan Nieder <> Signed-off-by: Junio C Hamano <>
2010-03-21tests: document cherry-pick behavior in face of conflictsJonathan Nieder
We are about to change the format of the conflict hunks that cherry-pick and revert write. Add tests checking the current behavior first. Signed-off-by: Jonathan Nieder <> Signed-off-by: Junio C Hamano <>