From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS54825 147.75.192.0/21 X-Spam-Status: No, score=-1.5 required=3.0 tests=AWL,BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI,RCVD_IN_SBL_CSS,SPF_HELO_NONE, SPF_PASS shortcircuit=no autolearn=no autolearn_force=no version=3.4.6 Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org [147.75.199.223]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by dcvr.yhbt.net (Postfix) with ESMTPS id 398491F452 for ; Mon, 30 Oct 2023 16:27:26 +0000 (UTC) Authentication-Results: dcvr.yhbt.net; dkim=pass (3072-bit key; secure) header.d=crustytoothpaste.net header.i=@crustytoothpaste.net header.a=rsa-sha256 header.s=default header.b=wLsRp9/t; dkim-atps=neutral Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 7626A1C20852 for ; Mon, 30 Oct 2023 16:27:25 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D52F31944C; Mon, 30 Oct 2023 16:27:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (3072-bit key) header.d=crustytoothpaste.net header.i=@crustytoothpaste.net header.b="wLsRp9/t" Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A774B18E3D for ; Mon, 30 Oct 2023 16:27:15 +0000 (UTC) Received: from ring.crustytoothpaste.net (ring.crustytoothpaste.net [IPv6:2600:3c04::f03c:92ff:fe9e:c6d8]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 00395103 for ; Mon, 30 Oct 2023 09:27:03 -0700 (PDT) Received: from tapette.crustytoothpaste.net (unknown [IPv6:2001:470:b056:101:5e4a:89fa:93b9:2058]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (3072 bits) server-digest SHA256) (No client certificate requested) by ring.crustytoothpaste.net (Postfix) with ESMTPSA id E22C35B0B9; Mon, 30 Oct 2023 16:26:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=crustytoothpaste.net; s=default; t=1698683219; bh=YqJGBBvdWaZRKAYOTfH8HOFQ2RSStwx8FCSk2uq3biw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From:Reply-To: Subject:Date:To:CC:Resent-Date:Resent-From:Resent-To:Resent-Cc: In-Reply-To:References:Content-Type:Content-Disposition; b=wLsRp9/tqld8/W6LyF6x7KNRs48+L3KABV2hVOoOIKhYV/i31QgkOzqe/wKKRlB1o LLkFT9++WTSbCc89lkJejz5fuY6TeT5PSqG3u66Gq+URP8Z/0JQweCMX9GK4pLSIPO m7uyhyCLMaiS/EGu7jtYME8QA1nlyqC7MPFaEdea5kavhr+qmsrgg7PhZ8nhSpYxWG ZSeDAs3VmgEGEQ6/7ockhapw2YNIkmkwLyFcWV/PELI/abAZkhP7h+zvNxVzoqOU6Z SOjWwn+kIHG+KFqK35NtSoqM0zy/wexkZIUphyb/HMVv3VG6dCBihzIbeK9+9qzaGZ rlyWK/fDY8mDUWjegCd1TO82c5pAyuZqaN8gR4NPVg/Abi1m2n6B6UXB2X/8nU4g0H lGqiKcf26p894C6fuDaqoGVbhm+1lSCv5u0adj3pYL/AtlCI0zxM7cYuhhGuzcuuKJ myPcj3hmgRmhK3UuOjuopD21RoDLKbNeqfXX5tgDsSXzdekbZGN From: "brian m. carlson" To: Cc: Junio C Hamano , Elijah Newren , Phillip Wood , Eric Sunshine , Taylor Blau Subject: [PATCH v2 1/1] merge-file: add an option to process object IDs Date: Mon, 30 Oct 2023 16:26:58 +0000 Message-ID: <20231030162658.567523-2-sandals@crustytoothpaste.net> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231030162658.567523-1-sandals@crustytoothpaste.net> References: <20231024195655.2413191-1-sandals@crustytoothpaste.net> <20231030162658.567523-1-sandals@crustytoothpaste.net> Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Unsubscribe-Post: List-Unsubscribe=One-Click From: "brian m. carlson" git merge-file knows how to merge files on the file system already. It would be helpful, however, to allow it to also merge single blobs. Teach it an `--object-id` option which means that its arguments are object IDs and not files to allow it to do so. Since we obviously won't be writing the data to the first argument, imply the -p option so we write to standard output. We handle the empty blob specially since read_mmblob doesn't read it directly and otherwise users cannot specify an empty ancestor. Signed-off-by: brian m. carlson --- Documentation/git-merge-file.txt | 20 +++++++++++ builtin/merge-file.c | 62 +++++++++++++++++++++++--------- t/t6403-merge-file.sh | 58 ++++++++++++++++++++++++++++++ 3 files changed, 124 insertions(+), 16 deletions(-) diff --git a/Documentation/git-merge-file.txt b/Documentation/git-merge-file.txt index 7e9093fab6..a4de2bd297 100644 --- a/Documentation/git-merge-file.txt +++ b/Documentation/git-merge-file.txt @@ -12,6 +12,9 @@ SYNOPSIS 'git merge-file' [-L [-L [-L ]]] [--ours|--theirs|--union] [-p|--stdout] [-q|--quiet] [--marker-size=] [--[no-]diff3] +'git merge-file' --object-id [-L [-L [-L ]]] + [--ours|--theirs|--union] [-p|--stdout] [-q|--quiet] [--marker-size=] + [--[no-]diff3] DESCRIPTION @@ -40,6 +43,10 @@ however, these conflicts are resolved favouring lines from ``, lines from ``, or lines from both respectively. The length of the conflict markers can be given with the `--marker-size` option. +If `--object-id` is specified, exactly the same behavior occurs, except that +instead of specifying what to merge as files, it is specified as a list of +object IDs referring to blobs. + The exit value of this program is negative on error, and the number of conflicts otherwise (truncated to 127 if there are more than that many conflicts). If the merge was clean, the exit value is 0. @@ -52,6 +59,14 @@ linkgit:git[1]. OPTIONS ------- +--object-id:: + Specify the contents to merge as blobs in the current repository instead of + files. In this case, the operation must take place within a valid repository. ++ +If the `-p` option is specified, the merged file (including conflicts, if any) +goes to standard output as normal; otherwise, the merged file is written to the +object store and the object ID of its blob is written to standard output. + -L