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

Re: [PATCH v3 1/4] Introduce CHERRY_PICK_HEAD

From
Junio C Hamano <gitster@pobox.com>
Date
Feb 17, 2011, 20:01 UTC
Message-ID
<7vipwibfc5.fsf@alter.siamese.dyndns.org>
In-Reply-To
<1297916325-89688-2-git-send-email-jaysoffian@gmail.com>
Jay Soffian <jaysoffian@gmail.com> writes:
Show 15 quoted lines
> diff --git a/builtin/merge.c b/builtin/merge.c
> index 9403747..454dad2 100644
> --- a/builtin/merge.c
> +++ b/builtin/merge.c
> @@ -971,6 +971,13 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
>  		else
>  			die("You have not concluded your merge (MERGE_HEAD exists).");
>  	}
> +	if (file_exists(git_path("CHERRY_PICK_HEAD"))) {
> +		if (advice_resolve_conflict)
> +			die("You have not concluded your cherry-pick (CHERRY_PICK_HEAD exists).\n"
> +			    "Please, commit your changes before you can merge.");
> +		else
> +			die("You have not concluded your cherry-pick (CHERRY_PICK_HEAD exists).");
> +	}
Micronit: "Please, commit your changes before you can merge."
 - We are not merging in this codepath to begin with;
 - I'd suggest rephrasing this (together with "MERGE_HEAD" codepath) to
   something like:
	"Commit your changes first before retrying."
Show 8 quoted lines
> +test_expect_success 'cherry-pick --no-commit sets CHERRY_PICK_HEAD' '
> +
> +	git checkout -f initial^0 &&
> +	git read-tree -u --reset HEAD &&
> +	git clean -d -f -f -q -x &&
> +
> +	git update-index --refresh &&
> +	git diff-index --exit-code HEAD &&

Getting tired of seeing these five lines repeated over and over. Perhaps it is time to introduce:

	pristine_detach () {
        	git checkout -f "$1^0" &&
                git read-tree -u --reset HEAD &&
                git clean -d -f -f -q -x
	}

I don't think "diff-index --exit-code HEAD" is necessary as the point of this testsuite is not about testing "read-tree --reset", and the index refresh is just a prerequisite for diff-index that can go together with it.

> +	git cherry-pick --no-commit base &&
> +
> +	test_cmp_rev base CHERRY_PICK_HEAD

If the next "git commit" would notice and use this information, that would introduce an unpleasant regression to one use case in my workflow, which is to pick and consolidate one or more small pieces made on a private "misc" branch, possibly with a bit of further work, into a new commit with a readable explanation that is unrelated to any of the original commits:

	git cherry-pick --no-commit $some_commit
	git cherry-pick --no-commit $another_commit ;# optional
	edit ;# optional
        git commit

I'd prefer to see a way to tell cherry-pick not to leave CHERRY_PICK_HEAD behind when "cherry-pick --no-commit" results in a successful cherry-pick to avoid a backward incompatibility surprise. Otherwise people need to retrain their fingers to say --reset-author when they run "git commit".

Other then the above three points, this patch looks good.  Thanks.
Previous: Jay SoffianNext: Jonathan Nieder
Message 3 of 17 in “CHERRY_PICK_HEAD”
  1. 0/4 CHERRY_PICK_HEADJay Soffian, Feb 17, 2011
  2. 1/4 Introduce CHERRY_PICK_HEADJay Soffian, Feb 17, 2011
  3. Junio C HamanoFeb 17, 2011
  4. Jonathan NiederFeb 17, 2011
  5. Jay SoffianFeb 20, 2011
  6. Jonathan NiederFeb 20, 2011
  7. Junio C HamanoFeb 20, 2011
  8. Junio C HamanoFeb 17, 2011
  9. Jay SoffianFeb 17, 2011
  10. Jonathan NiederFeb 17, 2011
  11. 2/4 bash: teach __git_ps1 about CHERRY_PICK_HEADJay Soffian, Feb 17, 2011
  12. 3/4 commit.c: replace some literal strings with constantsJay Soffian, Feb 17, 2011
  13. Jonathan NiederFeb 17, 2011
  14. Teach commit about CHERRY_PICK_HEADJay Soffian, Feb 17, 2011
  15. Jonathan NiederFeb 18, 2011
  16. Junio C HamanoFeb 17, 2011
  17. 4/4 Teach commit about CHERRY_PICK_HEADJay Soffian, Feb 17, 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.