git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH 12/14] revert: Introduce --reset to cleanup sequencer data

From
Ramkumar Ramachandra <artagnon@gmail.com>
Date
Jul 6, 2011, 14:32 UTC
Message-ID
<CALkWK0nhH=_3+Gj=O4Ov2zOGBoVquzD--+RW_QYYnb8YMAHniA@mail.gmail.com>
In-Reply-To
<1309938868-2028-13-git-send-email-artagnon@gmail.com>
Hi,
Ramkumar Ramachandra writes:
Show 12 quoted lines
>  builtin/revert.c                   |   54 ++++++++++++++++++++++++++++++-----
>  git-rebase--interactive.sh         |   25 +++++++++++++---
>  t/t3032-merge-recursive-options.sh |    2 +
>  t/t3501-revert-cherry-pick.sh      |    1 +
>  t/t3502-cherry-pick-merge.sh       |    9 ++++-
>  t/t3504-cherry-pick-rerere.sh      |    2 +
>  t/t3505-cherry-pick-empty.sh       |   14 ++++-----
>  t/t3506-cherry-pick-ff.sh          |    3 ++
>  t/t3507-cherry-pick-conflict.sh    |   24 ++++++++++++---
>  t/t3510-cherry-pick-sequence.sh    |   14 +++++++++
>  t/t7502-commit.sh                  |    1 +
>  11 files changed, 121 insertions(+), 28 deletions(-)

By making `reset --hard` blow away the sequencer state, and trying hard not to modify existing scripts, the diffstat still contains these files: builtin/revert.c git-rebase--interactive.sh t/t3032-merge-recursive-options.sh r/t3505-cherry-pick-empty.sh r/t3507-cherry-pick-conflict.sh r/t3501-cherry-pick-sequence.sh

Show 27 quoted lines
> diff --git a/t/t3032-merge-recursive-options.sh b/t/t3032-merge-recursive-options.sh
> index 2b17311..81191ae 100755
> --- a/t/t3032-merge-recursive-options.sh
> +++ b/t/t3032-merge-recursive-options.sh
> @@ -113,8 +113,10 @@ test_expect_success '--ignore-space-change makes merge succeed' '
>  test_expect_success 'naive cherry-pick fails' '
>        git read-tree --reset -u HEAD &&
>        test_must_fail git cherry-pick --no-commit remote &&
> +       git cherry-pick --reset &&
>        git read-tree --reset -u HEAD &&
>        test_must_fail git cherry-pick remote &&
> +       git cherry-pick --reset &&
>        test_must_fail git update-index --refresh &&
>        grep "<<<<<<" text.txt
>  '
> diff --git a/t/t3501-revert-cherry-pick.sh b/t/t3501-revert-cherry-pick.sh
> index 595d2ff..e0c805d 100755
> --- a/t/t3501-revert-cherry-pick.sh
> +++ b/t/t3501-revert-cherry-pick.sh
> @@ -96,6 +96,7 @@ test_expect_success 'revert forbidden on dirty working tree' '
>        echo content >extra_file &&
>        git add extra_file &&
>        test_must_fail git revert HEAD 2>errors &&
> +       git revert --reset &&
>        test_i18ngrep "Your local changes would be overwritten by " errors
>
>  '
Show 32 quoted lines
> diff --git a/t/t3505-cherry-pick-empty.sh b/t/t3505-cherry-pick-empty.sh
> index c10b28c..dc02227 100755
> --- a/t/t3505-cherry-pick-empty.sh
> +++ b/t/t3505-cherry-pick-empty.sh
> @@ -23,10 +23,9 @@ test_expect_success setup '
>  '
>
>  test_expect_success 'cherry-pick an empty commit' '
> -       git checkout master && {
> -               git cherry-pick empty-branch^
> -               test "$?" = 1
> -       }
> +       git checkout master &&
> +       test_expect_code 1 git cherry-pick empty-branch^
> +       git cherry-pick --reset
>  '
>
>  test_expect_success 'index lockfile was removed' '
> @@ -36,10 +35,9 @@ test_expect_success 'index lockfile was removed' '
>  '
>
>  test_expect_success 'cherry-pick a commit with an empty message' '
> -       git checkout master && {
> -               git cherry-pick empty-branch
> -               test "$?" = 1
> -       }
> +       git checkout master &&
> +       test_expect_code 1 git cherry-pick empty-branch &&
> +       git cherry-pick --reset
>  '
>
>  test_expect_success 'index lockfile was removed' '
Show 124 quoted lines
> diff --git a/t/t3507-cherry-pick-conflict.sh b/t/t3507-cherry-pick-conflict.sh
> index 212ec54..86f8626 100755
> --- a/t/t3507-cherry-pick-conflict.sh
> +++ b/t/t3507-cherry-pick-conflict.sh
> @@ -39,6 +39,7 @@ test_expect_success 'failed cherry-pick does not advance HEAD' '
>
>        head=$(git rev-parse HEAD) &&
>        test_must_fail git cherry-pick picked &&
> +       git cherry-pick --reset &&
>        newhead=$(git rev-parse HEAD) &&
>
>        test "$head" = "$newhead"
> @@ -55,6 +56,7 @@ test_expect_success 'advice from failed cherry-pick' "
>        hint: and commit the result with 'git commit'
>        EOF
>        test_must_fail git cherry-pick picked 2>actual &&
> +       git cherry-pick --reset &&
>
>        test_i18ncmp expected actual
>  "
> @@ -62,7 +64,8 @@ test_expect_success 'advice from failed cherry-pick' "
>  test_expect_success 'failed cherry-pick sets CHERRY_PICK_HEAD' '
>        pristine_detach initial &&
>        test_must_fail git cherry-pick picked &&
> -       test_cmp_rev picked CHERRY_PICK_HEAD
> +       test_cmp_rev picked CHERRY_PICK_HEAD &&
> +       git cherry-pick --reset
>  '
>
>  test_expect_success 'successful cherry-pick does not set CHERRY_PICK_HEAD' '
> @@ -84,13 +87,15 @@ test_expect_success 'GIT_CHERRY_PICK_HELP suppresses CHERRY_PICK_HEAD' '
>                export GIT_CHERRY_PICK_HELP &&
>                test_must_fail git cherry-pick picked
>        ) &&
> -       test_must_fail git rev-parse --verify CHERRY_PICK_HEAD
> +       test_must_fail git rev-parse --verify CHERRY_PICK_HEAD &&
> +       git cherry-pick --reset
>  '
>
>  test_expect_success 'git reset clears CHERRY_PICK_HEAD' '
>        pristine_detach initial &&
>
>        test_must_fail git cherry-pick picked &&
> +       git cherry-pick --reset &&
>        git reset &&
>
>        test_must_fail git rev-parse --verify CHERRY_PICK_HEAD
> @@ -102,7 +107,8 @@ test_expect_success 'failed commit does not clear CHERRY_PICK_HEAD' '
>        test_must_fail git cherry-pick picked &&
>        test_must_fail git commit &&
>
> -       test_cmp_rev picked CHERRY_PICK_HEAD
> +       test_cmp_rev picked CHERRY_PICK_HEAD &&
> +       git cherry-pick --reset
>  '
>
>  test_expect_success 'cancelled commit does not clear CHERRY_PICK_HEAD' '
> @@ -119,7 +125,8 @@ test_expect_success 'cancelled commit does not clear CHERRY_PICK_HEAD' '
>                test_must_fail git commit
>        ) &&
>
> -       test_cmp_rev picked CHERRY_PICK_HEAD
> +       test_cmp_rev picked CHERRY_PICK_HEAD &&
> +       git cherry-pick --reset
>  '
>
>  test_expect_success 'successful commit clears CHERRY_PICK_HEAD' '
> @@ -130,13 +137,15 @@ test_expect_success 'successful commit clears CHERRY_PICK_HEAD' '
>        git add foo &&
>        git commit &&
>
> -       test_must_fail git rev-parse --verify CHERRY_PICK_HEAD
> +       test_must_fail git rev-parse --verify CHERRY_PICK_HEAD &&
> +       git cherry-pick --reset
>  '
>
>  test_expect_success 'failed cherry-pick produces dirty index' '
>        pristine_detach initial &&
>
>        test_must_fail git cherry-pick picked &&
> +       git cherry-pick --reset &&
>
>        test_must_fail git update-index --refresh -q &&
>        test_must_fail git diff-index --exit-code HEAD
> @@ -160,6 +169,7 @@ test_expect_success 'failed cherry-pick registers participants in index' '
>        git read-tree -u --reset HEAD &&
>
>        test_must_fail git cherry-pick picked &&
> +       git cherry-pick --reset &&
>        git ls-files --stage --unmerged > actual &&
>
>        test_cmp expected actual
> @@ -176,6 +186,7 @@ test_expect_success 'failed cherry-pick describes conflict in work tree' '
>        EOF
>
>        test_must_fail git cherry-pick picked &&
> +       git cherry-pick --reset &&
>
>        sed "s/[a-f0-9]*\.\.\./objid/" foo > actual &&
>        test_cmp expected actual
> @@ -195,6 +206,7 @@ test_expect_success 'diff3 -m style' '
>        EOF
>
>        test_must_fail git cherry-pick picked &&
> +       git cherry-pick --reset &&
>
>        sed "s/[a-f0-9]*\.\.\./objid/" foo > actual &&
>        test_cmp expected actual
> @@ -227,6 +239,7 @@ test_expect_success 'revert also handles conflicts sanely' '
>
>        head=$(git rev-parse HEAD) &&
>        test_must_fail git revert picked &&
> +       git revert --reset &&
>        newhead=$(git rev-parse HEAD) &&
>        git ls-files --stage --unmerged > actual-stages &&
>
> @@ -252,6 +265,7 @@ test_expect_success 'revert conflict, diff3 -m style' '
>        EOF
>
>        test_must_fail git revert picked &&
> +       git revert --reset &&
>
>        sed "s/[a-f0-9]*\.\.\./objid/" foo > actual &&
>        test_cmp expected actual

As you can see, there is no "reset --hard" in these, and I don't see what other command I can piggy-bank on to blow away the sequencer state. There is however, one other thing I can do: if there is nothing left to cherry-pick after a successful conflict resolution + git commit, I can modify commit.c to blow away the sequencer state after checking appropriately. This will also have a nice end-user experience side-effect: $ git cherry-pick moo fatal: Conflict in foo! $ echo "Resolved" > foo $ git add moo $ git commit $ git cherry-pick --continue # This no-op will be unnecessary

Then again, teaching commit about the sequencer is inelegant, and it's possible to achieve this effect in another way: when a conflict is encountered in the sequencer && length(todo_file) == 1, throw away the sequencer state. When I say "throw away", I really mean "move .git/sequencer to .git/sequencer-old". Does this seem reasonable?

-- Ram
Previous: Ramkumar RamachandraNext: Jonathan Nieder
Message 43 of 55 in “[GSoC update] Sequencer: The insn sheet format”
  1. Ramkumar RamachandraJul 6, 2011
  2. 01/14 advice: Introduce error_resolve_conflictRamkumar Ramachandra, Jul 6, 2011
  3. Jonathan NiederJul 6, 2011
  4. Ramkumar RamachandraJul 6, 2011
  5. Jonathan NiederJul 6, 2011
  6. 02/14 revert: Inline add_message_to_msg functionRamkumar Ramachandra, Jul 6, 2011
  7. 03/14 revert: Don't check lone argument in get_encodingRamkumar Ramachandra, Jul 6, 2011
  8. 04/14 revert: Rename no_replay to record_originRamkumar Ramachandra, Jul 6, 2011
  9. 05/14 revert: Propogate errors upwards from do_pick_commitRamkumar Ramachandra, Jul 6, 2011
  10. Jonathan NiederJul 6, 2011
  11. Ramkumar RamachandraJul 6, 2011
  12. 06/14 revert: Eliminate global "commit" variableRamkumar Ramachandra, Jul 6, 2011
  13. Jonathan NiederJul 6, 2011
  14. Ramkumar RamachandraJul 6, 2011
  15. 07/14 revert: Introduce struct to keep command-line optionsRamkumar Ramachandra, Jul 6, 2011
  16. Jonathan NiederJul 6, 2011
  17. Ramkumar RamachandraJul 6, 2011
  18. Jonathan NiederJul 6, 2011
  19. Ramkumar RamachandraJul 12, 2011
  20. Junio C HamanoJul 6, 2011
  21. Ramkumar RamachandraJul 12, 2011
  22. Jonathan NiederJul 12, 2011
  23. 08/14 revert: Separate cmdline parsing from functional codeRamkumar Ramachandra, Jul 6, 2011
  24. Jonathan NiederJul 6, 2011
  25. Ramkumar RamachandraJul 6, 2011
  26. 09/14 revert: Don't create invalid replay_opts in parse_argsRamkumar Ramachandra, Jul 6, 2011
  27. Jonathan NiederJul 6, 2011
  28. 10/14 revert: Persist data for continuationRamkumar Ramachandra, Jul 6, 2011
  29. Jonathan NiederJul 6, 2011
  30. Ramkumar RamachandraJul 6, 2011
  31. Junio C HamanoJul 6, 2011
  32. 11/14 revert: Introduce a layer of indirection over pick_commitsRamkumar Ramachandra, Jul 6, 2011
  33. Jonathan NiederJul 6, 2011
  34. Ramkumar RamachandraJul 6, 2011
  35. Jonathan NiederJul 6, 2011
  36. Ramkumar RamachandraJul 6, 2011
  37. Jonathan NiederJul 6, 2011
  38. Junio C HamanoJul 6, 2011
  39. Ramkumar RamachandraJul 7, 2011
  40. 12/14 revert: Introduce --reset to cleanup sequencer dataRamkumar Ramachandra, Jul 6, 2011
  41. Jonathan NiederJul 6, 2011
  42. Ramkumar RamachandraJul 6, 2011
  43. Ramkumar RamachandraJul 6, 2011
  44. Jonathan NiederJul 6, 2011
  45. Jonathan NiederJul 6, 2011
  46. Ramkumar RamachandraJul 7, 2011
  47. 13/14 revert: Introduce --continue to continue the operationRamkumar Ramachandra, Jul 6, 2011
  48. Jonathan NiederJul 6, 2011
  49. Junio C HamanoJul 6, 2011
  50. Drew NorthupJul 6, 2011
  51. Ramkumar RamachandraJul 7, 2011
  52. 14/14 revert: Change insn sheet formatRamkumar Ramachandra, Jul 6, 2011
  53. Jonathan NiederJul 6, 2011
  54. Ramkumar RamachandraJul 6, 2011
  55. Jonathan NiederJul 6, 2011

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.