Re: [PATCH 3/6] commit: add a reword suboption to --fixup

2 messages, 2 authors, 2021-02-18 · open the first message on its own page

Re: [PATCH 3/6] commit: add a reword suboption to --fixup

From: Junio C Hamano <hidden>
Date: 2021-02-17 19:57:40

Charvi Mendiratta [off-list ref] writes:
`git commit --fixup=reword:<commit>` creates an empty "amend!" commit
that will reword <commit> without changing its contents when it is
rebased with --autosquash.

Apart from ignoring staged changes it works similarly to
`--fixup=amend:<commit>`.

Example usage:
$ git commit --fixup=reword:HEAD~3
$ git commit --fixup=reword:HEAD~3 -m "new commit message"
The same comment applies to the above as an earlier step.
+static void check_fixup_reword_options(void) {
+	if (whence != FROM_COMMIT) {
+		if (whence == FROM_MERGE)
+			die(_("You are in the middle of a merge -- cannot reword."));
+		else if (is_from_cherry_pick(whence))
+			die(_("You are in the middle of a cherry-pick -- cannot reword."));
+	}
+	if (all)
+		die(_("cannot combine reword option of --fixup with --all"));
+	if (also)
+		die(_("cannot combine reword option of --fixup with --include"));
+	if (only)
+		die(_("cannot combine reword option of --fixup with --only"));
+}
Not just these options, wouldn't it be an error to ask to commit
anything but an empty commit?  E.g. shouldn't this sequence

	edit builtin/commit.c
	git commit --fixup=reword:HEAD~3 -- builtin/commit.c

trigger an error, as we will *not* be taking any change made to the
working tree file?

Or is that implicitly covered by some other code?

In any case, we'd need a test for that (this is just a mental note
for myself---I haven't finished reading the series to the end, so
you may have one already).

Thanks.

Re: [PATCH 3/6] commit: add a reword suboption to --fixup

From: Charvi Mendiratta <hidden>
Date: 2021-02-18 12:24:47

On Thu, 18 Feb 2021 at 01:26, Junio C Hamano [off-list ref] wrote:
[...]
The same comment applies to the above as an earlier step.
Okay, will remove it.
quoted
+static void check_fixup_reword_options(void) {
+     if (whence != FROM_COMMIT) {
+             if (whence == FROM_MERGE)
+                     die(_("You are in the middle of a merge -- cannot reword."));
+             else if (is_from_cherry_pick(whence))
+                     die(_("You are in the middle of a cherry-pick -- cannot reword."));
+     }
+     if (all)
+             die(_("cannot combine reword option of --fixup with --all"));
+     if (also)
+             die(_("cannot combine reword option of --fixup with --include"));
+     if (only)
+             die(_("cannot combine reword option of --fixup with --only"));
+}
Not just these options, wouldn't it be an error to ask to commit
anything but an empty commit?  E.g. shouldn't this sequence

        edit builtin/commit.c
        git commit --fixup=reword:HEAD~3 -- builtin/commit.c

trigger an error, as we will *not* be taking any change made to the
working tree file?

Or is that implicitly covered by some other code?
I admit this is a bug here. Thanks for pointing this out and will add the
check for pathspec.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help