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

[GSoC][PATCH v5 0/5] Teach cherry-pick/revert to skip commits

From
Rohit Ashiwal <rohit.ashiwal265@gmail.com>
Date
Jun 18, 2019, 17:06 UTC
Message-ID
<20190618170650.22721-1-rohit.ashiwal265@gmail.com>
In-Reply-To
<20190608191958.4593-1-rohit.ashiwal265@gmail.com>
Here is another round of my patch, hopefully I have addressed all the changes.
  - I have introduced a separate commit which changes `reset_merge` to use
    `argv_array` instead of a manual `char *argv`. This will avoid specifying
    array size and index and make code easier to read and extend
  - Removed _() from BUG() messages
  - Rearrange comments under `sequencer_skip`. I have not changed switch-case to
    if-else since the former looked better to me
Thanks
Rohit Ashiwal (5):
  sequencer: add advice for revert
  sequencer: rename reset_for_rollback to reset_merge
  sequencer: use argv_array in reset_merge
  cherry-pick/revert: add --skip option
  cherry-pick/revert: advise using --skip
 Documentation/git-cherry-pick.txt |   4 +-
 Documentation/git-revert.txt      |   4 +-
 Documentation/sequencer.txt       |   4 +
 builtin/commit.c                  |  13 +--
 builtin/revert.c                  |   5 ++
 sequencer.c                       | 131 ++++++++++++++++++++++++++----
 sequencer.h                       |   1 +
 t/t3510-cherry-pick-sequence.sh   | 122 ++++++++++++++++++++++++++++
 8 files changed, 258 insertions(+), 26 deletions(-)
Range-diff:
1:  59fa13c4d8 ! 1:  67c212090d sequencer: add advice for revert
    @@ -41,7 +41,7 @@
     +			_("try \"git cherry-pick (--continue | --abort | --quit)\"");
     +			break;
     +		default:
    -+			BUG(_("unexpected action in create_seq_dir"));
    ++			BUG("unexpected action in create_seq_dir");
     +		}
     +	}
     +	if (in_progress_error) {
2:  dea4582591 = 2:  300d6f64f0 sequencer: rename reset_for_rollback to reset_merge
-:  ---------- > 3:  edc35f6a4c sequencer: use argv_array in reset_merge
3:  29686d828f ! 4:  825486c22d cherry-pick/revert: add --skip option
    @@ -11,9 +11,8 @@
         skipping commits easier for the user and to make the commands more
         consistent.
     
    -    In the next commit, we will change the advice messages and some tests
    -    hence finishing the process of teaching revert and cherry-pick
    -    "how to skip commits".
    +    In the next commit, we will change the advice messages hence finishing
    +    the process of teaching revert and cherry-pick "how to skip commits".
     
         Signed-off-by: Rohit Ashiwal <rohit.ashiwal265@gmail.com>
     
    @@ -96,31 +95,6 @@
      --- a/sequencer.c
      +++ b/sequencer.c
     @@
    - 
    - static int reset_merge(const struct object_id *oid)
    - {
    --	const char *argv[4];	/* reset --merge <arg> + NULL */
    -+	int ret;
    -+	struct argv_array argv = ARGV_ARRAY_INIT;
    - 
    --	argv[0] = "reset";
    --	argv[1] = "--merge";
    --	argv[2] = oid_to_hex(oid);
    --	argv[3] = NULL;
    --	return run_command_v_opt(argv, RUN_GIT_CMD);
    -+	argv_array_pushl(&argv, "reset", "--merge", NULL);
    -+
    -+	if (!is_null_oid(oid))
    -+		argv_array_push(&argv, oid_to_hex(oid));
    -+
    -+	ret = run_command_v_opt(argv.argv, RUN_GIT_CMD);
    -+	argv_array_clear(&argv);
    -+
    -+	return ret;
    - }
    - 
    - static int rollback_single_pick(struct repository *r)
    -@@
      	return reset_merge(&head_oid);
      }
      
    @@ -146,48 +120,40 @@
     +	sequencer_get_last_command(r, &action);
     +
     +	/*
    -+	 * opts->action tells us which subcommand requested to skip
    -+	 * the commit.
    ++	 * Check whether the subcommand requested to skip the commit is actually
    ++	 * in progress and that it's safe to skip the commit.
    ++	 *
    ++	 * opts->action tells us which subcommand requested to skip the commit.
    ++	 * If the corresponding .git/<ACTION>_HEAD exists, we know that the
    ++	 * action is in progress and we can skip the commit.
    ++	 *
    ++	 * Otherwise we check that the last instruction was related to the
    ++	 * particular subcommand we're trying to execute and barf if that's not
    ++	 * the case.
    ++	 *
    ++	 * Finally we check that the rollback is "safe", i.e., has the HEAD
    ++	 * moved? In this case, it doesn't make sense to "reset the merge" and
    ++	 * "skip the commit" as the user already handled this by committing. But
    ++	 * we'd not want to barf here, instead give advice on how to proceed. We
    ++	 * only need to check that when .git/<ACTION>_HEAD doesn't exist because
    ++	 * it gets removed when the user commits, so if it still exists we're
    ++	 * sure the user can't have committed before.
     +	 */
     +	switch (opts->action) {
     +	case REPLAY_REVERT:
    -+		/*
    -+		 * If .git/REVERT_HEAD exists then we are sure that we are in
    -+		 * the middle of a revert and we allow to skip the commit.
    -+		 */
     +		if (!file_exists(git_path_revert_head(r))) {
    -+			/*
    -+			 * Check if the last instruction executed was related to
    -+			 * revert. If so, we are sure that a revert is in progress.
    -+			 *
    -+			 * NB: single commit revert is also counted in this
    -+			 * definition of "progress" (and was dealt with in the
    -+			 * previous check).
    -+			 */
    -+			if (action == REPLAY_REVERT) {
    -+				/*
    -+				 * Check if the user has moved the HEAD, i.e.,
    -+				 * already committed. In this case, we would like
    -+				 * to advise instead of skipping.
    -+				 */
    -+				if (!rollback_is_safe())
    -+					goto give_advice;
    -+				else
    -+					/* skip commit :) */
    -+					break;
    -+			}
    -+			return error(_("no revert in progress"));
    ++			if (action != REPLAY_REVERT)
    ++				return error(_("no revert in progress"));
    ++			if (!rollback_is_safe())
    ++				goto give_advice;
     +		}
     +		break;
     +	case REPLAY_PICK:
     +		if (!file_exists(git_path_cherry_pick_head(r))) {
    -+			if (action == REPLAY_PICK) {
    -+				if (!rollback_is_safe())
    -+					goto give_advice;
    -+				else
    -+					break;
    -+			}
    -+			return error(_("no cherry-pick in progress"));
    ++			if (action != REPLAY_PICK)
    ++				return error(_("no cherry-pick in progress"));
    ++			if (!rollback_is_safe())
    ++				goto give_advice;
     +		}
     +		break;
     +	default:
4:  941e73b654 ! 5:  63dbc11ab1 cherry-pick/revert: advise using --skip
    @@ -62,7 +62,7 @@
     +			_("try \"git cherry-pick (--continue | %s--abort | --quit)\"");
      			break;
      		default:
    - 			BUG(_("unexpected action in create_seq_dir"));
    + 			BUG("unexpected action in create_seq_dir");
     @@
      	}
      	if (in_progress_error) {
-- 
2.21.0
Previous: Thomas GummererNext: Rohit Ashiwal
Message 59 of 95 in “Teach cherry-pick/revert to skip commits”
  1. Rohit AshiwalJun 8, 2019
  2. [GSoC][PATCH 1/3] sequencer: add advice for revertRohit Ashiwal, Jun 8, 2019
  3. Phillip WoodJun 9, 2019
  4. Rohit AshiwalJun 10, 2019
  5. Phillip WoodJun 10, 2019
  6. Rohit AshiwalJun 10, 2019
  7. Phillip WoodJun 10, 2019
  8. Junio C HamanoJun 10, 2019
  9. [GSoC][PATCH 2/3] cherry-pick/revert: add --skip optionRohit Ashiwal, Jun 8, 2019
  10. Thomas GummererJun 9, 2019
  11. Phillip WoodJun 9, 2019
  12. Rohit AshiwalJun 10, 2019
  13. Phillip WoodJun 10, 2019
  14. Rohit AshiwalJun 10, 2019
  15. Phillip WoodJun 10, 2019
  16. [GSoC][PATCH 3/3] cherry-pick/revert: update hintsRohit Ashiwal, Jun 8, 2019
  17. Thomas GummererJun 9, 2019
  18. Phillip WoodJun 9, 2019
  19. Rohit AshiwalJun 10, 2019
  20. Phillip WoodJun 10, 2019
  21. Rohit AshiwalJun 10, 2019
  22. Phillip WoodJun 10, 2019
  23. Thomas GummererJun 9, 2019
  24. Rohit AshiwalJun 9, 2019
  25. Thomas GummererJun 9, 2019
  26. [GSoC][PATCH v2 0/3] Teach cherry-pick/revert to skip commitsRohit Ashiwal, Jun 11, 2019
  27. [GSoC][PATCH v2 1/3] sequencer: add advice for revertRohit Ashiwal, Jun 11, 2019
  28. Junio C HamanoJun 11, 2019
  29. [GSoC][PATCH v2 3/3] cherry-pick/revert: advise using --skipRohit Ashiwal, Jun 11, 2019
  30. Phillip WoodJun 12, 2019
  31. [GSoC][PATCH v2 2/3] cherry-pick/revert: add --skip optionRohit Ashiwal, Jun 11, 2019
  32. Phillip WoodJun 12, 2019
  33. Junio C HamanoJun 12, 2019
  34. Phillip WoodJun 12, 2019
  35. [GSoC][PATCH v3 0/3] Teach cherry-pick/revert to skip commitsRohit Ashiwal, Jun 13, 2019
  36. [GSoC][PATCH v3 3/3] cherry-pick/revert: advise using --skipRohit Ashiwal, Jun 13, 2019
  37. [GSoC][PATCH v3 2/3] cherry-pick/revert: add --skip optionRohit Ashiwal, Jun 13, 2019
  38. Junio C HamanoJun 13, 2019
  39. Junio C HamanoJun 13, 2019
  40. Rohit AshiwalJun 14, 2019
  41. Rohit AshiwalJun 14, 2019
  42. Junio C HamanoJun 14, 2019
  43. Rohit AshiwalJun 16, 2019
  44. Phillip WoodJun 13, 2019
  45. [GSoC][PATCH v3 1/3] sequencer: add advice for revertRohit Ashiwal, Jun 13, 2019
  46. Phillip WoodJun 13, 2019
  47. Martin ÅgrenJun 13, 2019
  48. Junio C HamanoJun 13, 2019
  49. Rohit AshiwalJun 14, 2019
  50. Rohit AshiwalJun 14, 2019
  51. [GSoC][PATCH v4 0/4] [GSoC][PATCH 0/3] Teach cherry-pick/revert to skip commitsRohit Ashiwal, Jun 16, 2019
  52. [GSoC][PATCH v4 1/4] sequencer: add advice for revertRohit Ashiwal, Jun 16, 2019
  53. Thomas GummererJun 17, 2019
  54. [GSoC][PATCH v4 2/4] sequencer: rename reset_for_rollback to reset_mergeRohit Ashiwal, Jun 16, 2019
  55. [GSoC][PATCH v4 3/4] cherry-pick/revert: add --skip optionRohit Ashiwal, Jun 16, 2019
  56. Thomas GummererJun 17, 2019
  57. [GSoC][PATCH v4 4/4] cherry-pick/revert: advise using --skipRohit Ashiwal, Jun 16, 2019
  58. Thomas GummererJun 17, 2019
  59. [GSoC][PATCH v5 0/5] Teach cherry-pick/revert to skip commitsRohit Ashiwal, Jun 18, 2019
  60. [GSoC][PATCH v5 1/5] sequencer: add advice for revertRohit Ashiwal, Jun 18, 2019
  61. [GSoC][PATCH v5 2/5] sequencer: rename reset_for_rollback to reset_mergeRohit Ashiwal, Jun 18, 2019
  62. [GSoC][PATCH v5 3/5] sequencer: use argv_array in reset_mergeRohit Ashiwal, Jun 18, 2019
  63. [GSoC][PATCH v5 4/5] cherry-pick/revert: add --skip optionRohit Ashiwal, Jun 18, 2019
  64. Junio C HamanoJun 20, 2019
  65. Rohit AshiwalJun 20, 2019
  66. Phillip WoodJun 20, 2019
  67. Junio C HamanoJun 20, 2019
  68. Phillip WoodJun 20, 2019
  69. Rohit AshiwalJun 20, 2019
  70. Phillip WoodJun 20, 2019
  71. Rohit AshiwalJun 21, 2019
  72. [GSoC][PATCH v5 5/5] cherry-pick/revert: advise using --skipRohit Ashiwal, Jun 18, 2019
  73. [GSoC][PATCH v6 0/5] Teach cherry-pick/revert to skip commitsRohit Ashiwal, Jun 21, 2019
  74. [GSoC][PATCH v6 1/5] sequencer: add advice for revertRohit Ashiwal, Jun 21, 2019
  75. [GSoC][PATCH v6 2/5] sequencer: rename reset_for_rollback to reset_mergeRohit Ashiwal, Jun 21, 2019
  76. [GSoC][PATCH v6 3/5] sequencer: use argv_array in reset_mergeRohit Ashiwal, Jun 21, 2019
  77. [GSoC][PATCH v6 4/5] cherry-pick/revert: add --skip optionRohit Ashiwal, Jun 21, 2019
  78. [GSoC][PATCH v6 5/5] cherry-pick/revert: advise using --skipRohit Ashiwal, Jun 21, 2019
  79. Junio C HamanoJun 21, 2019
  80. [GSoC][PATCH v7 0/6] Teach cherry-pick/revert to skip commitsRohit Ashiwal, Jun 23, 2019
  81. [GSoC][PATCH v7 1/6] advice: add sequencerInUse config variableRohit Ashiwal, Jun 23, 2019
  82. Thomas GummererJun 25, 2019
  83. [GSoC][PATCH v7 4/6] sequencer: use argv_array in reset_mergeRohit Ashiwal, Jun 23, 2019
  84. [GSoC][PATCH v7 2/6] sequencer: add advice for revertRohit Ashiwal, Jun 23, 2019
  85. Phillip WoodJun 29, 2019
  86. [GSoC][PATCH v7 3/6] sequencer: rename reset_for_rollback to reset_mergeRohit Ashiwal, Jun 23, 2019
  87. [GSoC][PATCH v7 5/6] cherry-pick/revert: add --skip optionRohit Ashiwal, Jun 23, 2019
  88. [GSoC][PATCH v7 6/6] cherry-pick/revert: advise using --skipRohit Ashiwal, Jun 23, 2019
  89. [GSoC][PATCH v8 0/5] Teach cherry-pick/revert to skip commitsRohit Ashiwal, Jul 2, 2019
  90. [GSoC][PATCH v8 1/5] sequencer: add advice for revertRohit Ashiwal, Jul 2, 2019
  91. [GSoC][PATCH v8 2/5] sequencer: rename reset_for_rollback to reset_mergeRohit Ashiwal, Jul 2, 2019
  92. [GSoC][PATCH v8 3/5] sequencer: use argv_array in reset_mergeRohit Ashiwal, Jul 2, 2019
  93. [GSoC][PATCH v8 4/5] cherry-pick/revert: add --skip optionRohit Ashiwal, Jul 2, 2019
  94. [GSoC][PATCH v8 5/5] cherry-pick/revert: advise using --skipRohit Ashiwal, Jul 2, 2019
  95. Phillip WoodJul 2, 2019

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.