From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS3215 2.6.0.0/16 X-Spam-Status: No, score=-4.0 required=3.0 tests=AWL,BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,NICE_REPLY_A, RCVD_IN_DNSWL_HI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from out1.vger.email (out1.vger.email [IPv6:2620:137:e000::1:20]) by dcvr.yhbt.net (Postfix) with ESMTP id 13DB21F54E for ; Thu, 11 Aug 2022 15:51:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234931AbiHKPvL (ORCPT ); Thu, 11 Aug 2022 11:51:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35158 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236796AbiHKPu3 (ORCPT ); Thu, 11 Aug 2022 11:50:29 -0400 Received: from bsmtp2.bon.at (bsmtp2.bon.at [213.33.87.16]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4976A9DB53 for ; Thu, 11 Aug 2022 08:42:20 -0700 (PDT) Received: from [192.168.0.98] (unknown [93.83.142.38]) by bsmtp2.bon.at (Postfix) with ESMTPSA id 4M3WJm26bmz5tlB; Thu, 11 Aug 2022 17:42:16 +0200 (CEST) Message-ID: Date: Thu, 11 Aug 2022 17:42:15 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.11.0 Subject: Re: Fwd: Idea: add --squash to cherry-pick Content-Language: en-US To: Noam Yorav-Raphael References: From: Johannes Sixt Cc: git@vger.kernel.org In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Am 11.08.22 um 10:53 schrieb Noam Yorav-Raphael: > The need is described in this Stack Overflow question: > https://stackoverflow.com/q/35123108. It's fairly popular (107 votes > for the question, 154 for the best answer), but I find the suggested > solution lacking. > > Basically, I would like to add a flag --squash to the cherry-pick > command, that would apply the diff between the start and end of the > specified range in one operation. > > The use case is that there's a feature branch which I would like to > apply on another branch as one commit. > > I could use the `-n` flag to apply all the commits from the source > branch without committing them. However, if there are conflicts, I > would have to deal with them on every commit applied. Instead, what I > want is to just apply the diff between the first and last commit, and > then deal with the conflicts. > > I find this to be a very natural operation. Usual cherry-pick applies > the difference between commit A^ and commit A over HEAD. The suggested > `git cherry-pick --squash A..B` would apply the difference between > commit A and commit B over HEAD. That question on Stackoverflow asks "how to do X with Y". But Y (git cherry-pick) is the wrong tool to do X (apply commits from a branch to somewhere else in squashed form). git diff A...B | git apply --3way would do what you want. You would have to come up with a new commit message anyway, so cherry-pick would be of little use there. -- Hannes