From patchwork Wed Jul 1 21:19:06 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Cai via GitGitGadget X-Patchwork-Id: 11637279 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 2843C913 for ; Wed, 1 Jul 2020 21:19:14 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0EB0B20870 for ; Wed, 1 Jul 2020 21:19:14 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="ntLaz235" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727069AbgGAVTM (ORCPT ); Wed, 1 Jul 2020 17:19:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58092 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726144AbgGAVTL (ORCPT ); Wed, 1 Jul 2020 17:19:11 -0400 Received: from mail-wm1-x344.google.com (mail-wm1-x344.google.com [IPv6:2a00:1450:4864:20::344]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 87332C08C5C1 for ; Wed, 1 Jul 2020 14:19:11 -0700 (PDT) Received: by mail-wm1-x344.google.com with SMTP id l2so23581690wmf.0 for ; Wed, 01 Jul 2020 14:19:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=message-id:in-reply-to:references:from:date:subject:fcc :content-transfer-encoding:mime-version:to:cc; bh=iXEFssLPF3N2PO6fm0qRhM3QJ9o6Zg4A4QMSRviZytE=; b=ntLaz235VfOevVhQKGyf3BiKpZoqX1OBV8og0OfR9UyG8LzsV1PWkJWUYoe30FTiWx BLZI4GaspNZt06A9PahBXASMsnO6h3cThE4PivxY8/LsVWzsuUUju+SMEWDUeGJuXrHs /73LZxUGZkW/2OUQuaX0hvBHxRkyiDlHoFDKr/ptgguWaL/B+7gxqFy+Rgd+1B7APVmG n5oMXOSuiENEo+CCq9M7LrJDDxt8j1kc5OkoZpzyvMys6hdy/JjI3TxqTYnRmKWIyo22 ile4yTdYC/OLKj3YUX/OfSjC/UP9inX/TlW1IZnISFq1tFcgQ5HbpXvHqCCmSew1H4jH 5LJQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:in-reply-to:references:from:date :subject:fcc:content-transfer-encoding:mime-version:to:cc; bh=iXEFssLPF3N2PO6fm0qRhM3QJ9o6Zg4A4QMSRviZytE=; b=PpXiPUVcoB083mOrYMp5e7OCSyJH159GQ972Cg4F2Af5zIPKoWovsGTx14Syqy24wu /E0O9clJqD5d13ce2ptBrfU57JGX8nWe8F/9ikLkcNGqf7s+gtk3rz6icfhMzAJ5GgJe vjgQxlQnz7WYeIa62t7fWp7pkvjwuqXOuxdFY8HC8Hm6mx4MP+MpkQV2wBzB++3SNhMs 9iuO+qzFv+UGsAgCM97WmzJWIK0ahMF1GMtoi1Yf8Vhd7tDoK4tDR4OKClwLWD2Apg06 zbp5/fxd/cdqXdnEAGq51r+SPiHhmMfnQXURwd/mLhOG8z0Jb8mgNOp1TDh2qhrzv7dt VbxA== X-Gm-Message-State: AOAM532HT3NOhBZsTnXQCFON+rrcpDJnzFyPd7AG1ymLxD4Np2cDPRIP WCxbZzQsaRtc196mnI8BMEbEtst4 X-Google-Smtp-Source: ABdhPJxxjo+xybUgF/KB95M9E6H8VSNKkOICv0iBqRKXMgQlBdmadRB+K2TU5eim/h1yq2Xt9PfTfw== X-Received: by 2002:a1c:9d07:: with SMTP id g7mr28379502wme.160.1593638350082; Wed, 01 Jul 2020 14:19:10 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id 65sm9067528wre.6.2020.07.01.14.19.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 Jul 2020 14:19:09 -0700 (PDT) Message-Id: <4392ae4be6ff4f1baad4bba7d166a0aaf634ca6e.1593638347.git.gitgitgadget@gmail.com> In-Reply-To: References: From: "Johannes Schindelin via GitGitGadget" Date: Wed, 01 Jul 2020 21:19:06 +0000 Subject: [PATCH v5 1/2] diff-files --raw: show correct post-image of intent-to-add files Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: Srinidhi Kaushik , Johannes Schindelin , Johannes Schindelin Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Johannes Schindelin The documented behavior of `git diff-files --raw` is to display [...] 0{40} if creation, unmerged or "look at work tree". on the right hand (i.e. postimage) side. This happens for files that have unstaged modifications, and for files that are unmodified but stat-dirty. For intent-to-add files, we used to show the empty blob's hash instead. In c26022ea8f5 (diff: convert diff_addremove to struct object_id, 2017-05-30), we made that worse by inadvertently changing that to the hash of the empty tree. Let's make the behavior consistent with files that have unstaged modifications (which applies to intent-to-add files, too) by showing all-zero values also for intent-to-add files. Accordingly, this patch adjusts the expectations set by the regression test introduced in feea6946a5b (diff-files: treat "i-t-a" files as "not-in-index", 2020-06-20). Signed-off-by: Johannes Schindelin --- diff-lib.c | 3 +-- t/t2203-add-intent.sh | 5 ++--- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/diff-lib.c b/diff-lib.c index 61812f48c2..25fd2dee19 100644 --- a/diff-lib.c +++ b/diff-lib.c @@ -220,8 +220,7 @@ int run_diff_files(struct rev_info *revs, unsigned int option) } else if (revs->diffopt.ita_invisible_in_index && ce_intent_to_add(ce)) { diff_addremove(&revs->diffopt, '+', ce->ce_mode, - the_hash_algo->empty_tree, 0, - ce->name, 0); + &null_oid, 0, ce->name, 0); continue; } diff --git a/t/t2203-add-intent.sh b/t/t2203-add-intent.sh index 8a5d55054f..cf0175ad6e 100755 --- a/t/t2203-add-intent.sh +++ b/t/t2203-add-intent.sh @@ -240,7 +240,6 @@ test_expect_success 'i-t-a files shown as new for "diff", "diff-files"; not-new hash_e=$(git hash-object empty) && hash_n=$(git hash-object not-empty) && - hash_t=$(git hash-object -t tree /dev/null) && cat >expect.diff_p <<-EOF && diff --git a/empty b/empty @@ -259,8 +258,8 @@ test_expect_success 'i-t-a files shown as new for "diff", "diff-files"; not-new create mode 100644 not-empty EOF cat >expect.diff_a <<-EOF && - :000000 100644 0000000 $(git rev-parse --short $hash_t) A$(printf "\t")empty - :000000 100644 0000000 $(git rev-parse --short $hash_t) A$(printf "\t")not-empty + :000000 100644 0000000 0000000 A$(printf "\t")empty + :000000 100644 0000000 0000000 A$(printf "\t")not-empty EOF git add -N empty not-empty && From patchwork Wed Jul 1 21:19:07 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Cai via GitGitGadget X-Patchwork-Id: 11637281 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 65CF8913 for ; Wed, 1 Jul 2020 21:19:15 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4F82B20870 for ; Wed, 1 Jul 2020 21:19:15 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="tk/tjUpD" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727093AbgGAVTO (ORCPT ); Wed, 1 Jul 2020 17:19:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58098 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727072AbgGAVTN (ORCPT ); Wed, 1 Jul 2020 17:19:13 -0400 Received: from mail-wr1-x435.google.com (mail-wr1-x435.google.com [IPv6:2a00:1450:4864:20::435]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 77823C08C5C1 for ; Wed, 1 Jul 2020 14:19:12 -0700 (PDT) Received: by mail-wr1-x435.google.com with SMTP id z15so14322524wrl.8 for ; Wed, 01 Jul 2020 14:19:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=message-id:in-reply-to:references:from:date:subject:fcc :content-transfer-encoding:mime-version:to:cc; bh=Wip/BOAPjBQuilhDL536V1VaSJh22i2Ta+Tt/pVsoFM=; b=tk/tjUpDodJhAqJqd3vQ1ETupGyT8Cj6Y/sX3yl3QHF+42OmiPocIve3fJMUyWifQn jmqbsU5T3vnATG7gwuzbcG3Rke2JIqyd7HuEVH8mEEHxgqc2U+tOnBLkije1NwSPx/DJ aEkPJ/xt2/k5DHntOIzAeh/p8zRNC97xW1I20UIHwCb/MqvQjAVIfqlH1bDrtIsxWdGN uoOI5imxZlg8y1WznW7rWpRgPtvs6VQwotD4ntDYYbwYZNR9UrCTnebkXeUJ0brFO+7G 9cueKnKVDdmP+X70YtsCoz3XDQu4Sq6zvnvUEUznw7pE5/5MoLVYNYXV5B7cVdvLFVVG SUig== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:in-reply-to:references:from:date :subject:fcc:content-transfer-encoding:mime-version:to:cc; bh=Wip/BOAPjBQuilhDL536V1VaSJh22i2Ta+Tt/pVsoFM=; b=PbcnVhDfpcJurMhfB+0S9e5+2I3NqRm9ZYedGozrhseeIlTm7jHPu1m3cyfcdxeqEW WN59/+aQD1SEDEvVx9UOavv452HLd5F4tET27VN4+uPSc2Rp/fiF8lZ2umwQxqWHhk1O L+y78z6djRzb5fwgACEzDfz2qeuN38j05WFS7K8nzyB8+dOowf77rmmTNSUvZSVHdGKb W0Yrukgw/JF6coTGj42w/T9GEGVULsyg5JOip71aiUDgiawfn3YMvf6E44pwbVKw9cKB ow3SdXLIM66tD+yXIGEiOZogtF9l0PPD/e3TD5+6X6Rv1p7NCBcBrlOZ/1LwVA4/5V9P Mb6Q== X-Gm-Message-State: AOAM5314yWTyxy9itk6vkHknLVxES8ZrCim8ZxL3damt7qhlgBhvJNRq PnxI+9ucDXr5pWO60YPEB++oyqAc X-Google-Smtp-Source: ABdhPJxOy7oAnYhQE8MB9aY36ZLQrtw+QA5AFiReyCfakxgyZ65ulw3Q/eqOaX6vsw4eWBOQSCAOAQ== X-Received: by 2002:a05:6000:1283:: with SMTP id f3mr28762842wrx.106.1593638350942; Wed, 01 Jul 2020 14:19:10 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id c20sm11094262wrb.65.2020.07.01.14.19.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 Jul 2020 14:19:10 -0700 (PDT) Message-Id: <5f933e852a525d4721b6f3e38ec12abf9c0d1aea.1593638347.git.gitgitgadget@gmail.com> In-Reply-To: References: From: "Johannes Schindelin via GitGitGadget" Date: Wed, 01 Jul 2020 21:19:07 +0000 Subject: [PATCH v5 2/2] difftool -d: ensure that intent-to-add files are handled correctly Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: Srinidhi Kaushik , Johannes Schindelin , Johannes Schindelin Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Johannes Schindelin In https://github.com/git-for-windows/git/issues/2677, a `git difftool -d` problem was reported. The underlying cause was a bug in `git diff-files --raw` that we just fixed: it reported intent-to-add files with the empty _tree_ as the post-image OID, when we need to show an all-zero (or, "null") OID instead, to indicate to the caller that they have to look at the worktree file. The symptom of that problem shown by `git difftool` was this: error: unable to read sha1 file of () error: could not write '' Make sure that the reported `difftool` problem stays fixed. Signed-off-by: Johannes Schindelin --- t/t7800-difftool.sh | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/t/t7800-difftool.sh b/t/t7800-difftool.sh index 29b92907e2..524f30f7dc 100755 --- a/t/t7800-difftool.sh +++ b/t/t7800-difftool.sh @@ -720,6 +720,14 @@ test_expect_success SYMLINKS 'difftool --dir-diff handles modified symlinks' ' test_cmp expect actual ' +test_expect_success 'add -N and difftool -d' ' + test_when_finished git reset --hard && + + test_write_lines A B C >intent-to-add && + git add -N intent-to-add && + git difftool --dir-diff --extcmd ls +' + test_expect_success 'outside worktree' ' echo 1 >1 && echo 2 >2 &&