From: Junio C Hamano Date: Mon, 06 Jul 2026 20:42:55 GMT Subject: Re: [PATCH v7 0/5] history: add squash subcommand to fold a range Message-ID: In-Reply-To: "Harald Nordgren via GitGitGadget" writes: > Adds git history squash to fold a range of commits. What I saw in the range-diff looked all reasonable. > 3: 811e393ab4 ! 3: cf3346a1cd history: add squash subcommand to fold a range > @@ Commit message > Add "git history squash " to do this directly. It folds > every commit in the range into the oldest one, keeping that commit's > message and authorship and taking the tree of the newest commit, then > - replays the commits above the range on top. fixup!, squash! and amend! > - commits are folded like any other and are not interpreted, so the > - squashed message comes from the oldest commit, or from an editor with > - --reedit-message. > + replays the commits above the range on top. The squashed message comes > + from the oldest commit, or from an editor with --reedit-message. As that > + message is reused, a range whose oldest commit is a fixup!, squash! or > + amend! is refused, since the marker's target cannot be in the range. > ... > -+git history squash [--dry-run] [--update-refs=(branches|head)] [--reedit-message] > ++git history squash [--dry-run] [--update-refs=(branches|head)] [--reedit-message] > ++static int reject_fixupish_oldest(struct repository *repo, > ++ struct commit *oldest) > ++{ > ++ const char *message, *subject; > ++ int ret = 0; > ++ > ++ message = repo_logmsg_reencode(repo, oldest, NULL, NULL); > ++ find_commit_subject(message, &subject); > ++ if (starts_with(subject, "fixup! ") || > ++ starts_with(subject, "squash! ") || > ++ starts_with(subject, "amend! ")) > ++ ret = error(_("the range begins with a fixup!, squash! or amend! " > ++ "commit whose target is not in the range")); > ++ repo_unuse_commit_buffer(repo, oldest, message); > ++ return ret; > ++} Nice. I often see myself getting rescued by the corresponding sanity checks in the sequencer. Will replace. Thanks.