From patchwork Wed Nov 13 00:52:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Philippe Blain X-Patchwork-Id: 13873056 Received: from mail-wm1-f47.google.com (mail-wm1-f47.google.com [209.85.128.47]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A97025680 for ; Wed, 13 Nov 2024 00:52:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.47 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731459134; cv=none; b=j9bayHfwMLydnFJRClh73t9DXVkMIqgTK7yu5AnkaC4B95CNwfLD0mKtALN1PtG+BTBG8SYY6RfS4/JE+OjxTPtFw4NsFLwGVTiEgOlgat4LBOWfOfNK6Qk5pw9epltsGs4TQAqahD8gm3F1M+UvUqtT9wFkSy0Zmn+p5kSeLvo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731459134; c=relaxed/simple; bh=ZxB0Pds/72H1qGrM0vIfgtVzxwiCkOcCHGBxt0XTWHs=; h=Message-Id:In-Reply-To:References:From:Date:Subject:Content-Type: MIME-Version:To:Cc; b=blY+waPQtSswUVbzPB80vJevWuihx0cftWcMVsCgJoVLCl7Ktm90o0elwcU/ia2971IxxrbQfqqZBu93dytlhejLGC8jj1i5JVcdu1b2omqsYpSbcfwheA6hu2fnLzGKkMaDGFbiQXyrS7KvjasIauX9BNV9GJrroHGMjrfPEYM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=GGkOyflk; arc=none smtp.client-ip=209.85.128.47 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="GGkOyflk" Received: by mail-wm1-f47.google.com with SMTP id 5b1f17b1804b1-4315baec69eso56156425e9.2 for ; Tue, 12 Nov 2024 16:52:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1731459130; x=1732063930; darn=vger.kernel.org; h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date:from :references:in-reply-to:message-id:from:to:cc:subject:date :message-id:reply-to; bh=FMZd6pL9I6cFzWwxp9cEAWDcZJiylGuDq1ibIm0UmaU=; b=GGkOyflkuRC5MD0nC+NGv9F7vcBOL6KnYpsLRc4USozHQ202KFWZZ+QRMkB2S3KPBe 7O2sK0y/0YbPKv4GmI3GRTzqvqJpYXnwAC8z3pi5+YoH8CKluCgdDN5rPl639Q63R2HS MNrZMaTfCc7TOXtkRYyEN+du3C6w6VNPZZXfKRdKDxMD8BO1MaWxug2nUkX6724UxFiu BToy8P1U4oBxbbfVRdf1VLZB0tX9dWptPxBQRUM2iBTcjuijy8dbp2o5JP4sA+DBbqA+ H47myXIlwCKSOQU1BxqKOMNeppGPg2F2JS45Wj4mLORQKYLv8WOfeNgv7ne4esJyumxr ETYA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1731459130; x=1732063930; h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date:from :references:in-reply-to:message-id:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=FMZd6pL9I6cFzWwxp9cEAWDcZJiylGuDq1ibIm0UmaU=; b=HpOrl0XbDKSLqYUKxivlaupt8XSdbXWNOsbokiSNBiIglqHeZVd5IZkWH0wFgaueRe WZfGZAWFaeWVryUtFFw6DGlgQf2MvhZntyIrXIcQUjz1fFMyD1bYUw62RDyKVVJK5YAj XJK//i4Tl4P/8ytDZ9hM655/6SkRAMPsVpgzCeCoxYLa7ZOYuj5dbpozqxW4k4fVGvK4 BX92LPamY7fiGf6P667hTFt9RxTnTWvYxA+g3fSHs4oob+TNlEwZWjrJvDr0shWL5Fki uDWIkfAbf94wkiblsOCetF+R2Xte/O+hRSXovvgV6Auj4TUjDc3dH5Pg1Ze/y3qBrmnD 0IZQ== X-Gm-Message-State: AOJu0Ywsza6b5gJuLxhBlt2wSa7BZ14hOur4JAqisZZoCnI5gPktTNEh QPF9RG4MLIMfo84cWd6bBVAbu6NhTY58rK1vjoPYdEILcqynZQSO+01nQw== X-Google-Smtp-Source: AGHT+IGahUgzqajstpvTM/lriCKnE6LPPSAT5Ax9tQAZPAm6i8xtU+uPBVGlFqa3zjEIrG74s5KLiA== X-Received: by 2002:a05:600c:3ca0:b0:431:586e:7e7 with SMTP id 5b1f17b1804b1-432b74fd8f0mr155367135e9.1.1731459130507; Tue, 12 Nov 2024 16:52:10 -0800 (PST) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-432d555908bsm4584095e9.44.2024.11.12.16.52.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Nov 2024 16:52:10 -0800 (PST) Message-Id: <24933ba71305caa97fe1f756aef770d40f39fbda.1731459128.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Wed, 13 Nov 2024 00:52:04 +0000 Subject: [PATCH 1/5] completion: complete '--tool-help' in 'git mergetool' Fcc: Sent Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 To: git@vger.kernel.org Cc: Seth House , David Aguilar , Johannes Sixt , Philippe Blain , Philippe Blain From: Philippe Blain From: Philippe Blain Signed-off-by: Philippe Blain --- contrib/completion/git-completion.bash | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash index 3d4dff3185c..b3b6aa3bae2 100644 --- a/contrib/completion/git-completion.bash +++ b/contrib/completion/git-completion.bash @@ -2331,7 +2331,7 @@ _git_mergetool () return ;; --*) - __gitcomp "--tool= --prompt --no-prompt --gui --no-gui" + __gitcomp "--tool= --tool-help --prompt --no-prompt --gui --no-gui" return ;; esac From patchwork Wed Nov 13 00:52:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Philippe Blain X-Patchwork-Id: 13873057 Received: from mail-wm1-f45.google.com (mail-wm1-f45.google.com [209.85.128.45]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8F5E06FB9 for ; Wed, 13 Nov 2024 00:52:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.45 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731459135; cv=none; b=diR0Kj2B+jzdZ6W6tQzD9v3G9em/PxDmVRnTYUf7mZNLRKc74t3bxy7EU7UlZoh71p6JQcsOq/SFVjlXfMjAE3B84U06ckMw0MQghYang9VajxLHmep7NWqUTHNCDaEEvKhTaoUo/H8tCUbLjW7yRNouHx8MTYFEL/KQFXcJQiI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731459135; c=relaxed/simple; bh=n1G7BircBUoK42sbe7P8yVNmu2+ti0UN8DPuRet7fW0=; h=Message-Id:In-Reply-To:References:From:Date:Subject:Content-Type: MIME-Version:To:Cc; b=fb4HRM6o5tcm+Za99Og3P+ME8fVw/Olz9dXtek2odT0y3ow9BHjmRiMW+bMw8IR7c7Qwat49umyCZyd9gg2d4iXbk46Msyjn1MrToiTS52TLstv4MXQyVUHZFroh4Khq6Y9c6qLaYQU6alBbYLH2aMdxxxAIrs5urHBtKOdI6js= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=JBskmyfk; arc=none smtp.client-ip=209.85.128.45 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="JBskmyfk" Received: by mail-wm1-f45.google.com with SMTP id 5b1f17b1804b1-4315c1c7392so56254835e9.1 for ; Tue, 12 Nov 2024 16:52:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1731459132; x=1732063932; darn=vger.kernel.org; h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date:from :references:in-reply-to:message-id:from:to:cc:subject:date :message-id:reply-to; bh=HY5kvNHgWqSM17OD+FB5pLV910wid+teJHraOEqrut0=; b=JBskmyfkA/1DbXmnDWfplJ0O6F4cYPuL12ni3i8dRgTbaiG3hEteM/w5yFYx2Mk3xU z+evl3p1BUt9f9GWZSEvGjHeP7xqzU2SZeP9Mq9avTDCKUEIT1ju450MOOxlImGi8kVX FMCjuoSIOiAdoxchGdKXifL/pYBE1ZNObdSbncXcPpLicoFwlLnlaYNjpDuAaj7GHxhK Ro5TlApBnb1dr4voP1439X0IlGdpvSwQn0JAuy1tMpDo0IHt5QpTVESkhtTNH67URpeQ p6lLa7KCldw1Omr/hoIWUAyGopwriWxA6XOpYZp8Xn4LMx39sDLhnzAaFIwnNk3cmdP9 ilPQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1731459132; x=1732063932; h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date:from :references:in-reply-to:message-id:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=HY5kvNHgWqSM17OD+FB5pLV910wid+teJHraOEqrut0=; b=xQJE36YCmxVAniQJlvdT+SJ/VXuD7B5iVz0M9ibh6CV4YWXlxMirc/insO5GGiDg0A YzoLJPkewUcE/oW/pQimonWaPz8OWgMOvuZjYA1uMGjm5gwMqdRi5qnQtdUT1dYDdqcl GFL7vD4BHtpDkZP6qsQ/GP/GLWNwGEvj1kjzEU8h+rKVlcapVLK9q6MzjHFqf/BdZSt6 ARiSIaG9UxNBlePOF1qzhZwilw9rlmgZ6FjVqMfVx03ZUbMqPG/XyFS6luV0+j8hmWum Xt8225lllYtH0DrzOJkolktQ4IrgQsFQPinCLyyigwgu0g/4ThaWlQ6YY8HYFhZcz6v/ AJsA== X-Gm-Message-State: AOJu0YwwSbSV6Xlgik+gWqL2RBKoSUP+bGb3aKJRGDMUIAb6y+OwhUVe ngFr0ymylXl8uBi9yKPS6Pw6Dx48BjYP91cVLoDjZod861hUYDpQGveONQ== X-Google-Smtp-Source: AGHT+IErpDCJsqcw/XPoycCCILoqiLLBEjw1mlQ9lvsBHc+jq2ooI9C1tgCgkG/jXRnrF8td+71EcA== X-Received: by 2002:a05:600c:1c8a:b0:431:5ba1:a529 with SMTP id 5b1f17b1804b1-432b7503557mr160334385e9.14.1731459131669; Tue, 12 Nov 2024 16:52:11 -0800 (PST) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-432d550f23bsm4677695e9.35.2024.11.12.16.52.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Nov 2024 16:52:11 -0800 (PST) Message-Id: <6f7f553b283078ba3c81190686b150a87d901240.1731459128.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Wed, 13 Nov 2024 00:52:05 +0000 Subject: [PATCH 2/5] git-mergetool--lib.sh: use TOOL_MODE when erroring about unknown tool Fcc: Sent Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 To: git@vger.kernel.org Cc: Seth House , David Aguilar , Johannes Sixt , Philippe Blain , Philippe Blain From: Philippe Blain From: Philippe Blain In git-mergetool--lib.sh::get_merge_tool_path, we check if the chosen tool is valid via valid_tool and exit with an error message if not. This error message mentions "Unknown merge tool", even if the command the user tried was 'git difftool --tool=unknown'. Use the global 'TOOL_MODE' variable for a more correct error message. Signed-off-by: Philippe Blain --- git-mergetool--lib.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/git-mergetool--lib.sh b/git-mergetool--lib.sh index 1ff26170ffc..269a60ea44c 100644 --- a/git-mergetool--lib.sh +++ b/git-mergetool--lib.sh @@ -474,7 +474,7 @@ get_merge_tool_path () { merge_tool="$1" if ! valid_tool "$merge_tool" then - echo >&2 "Unknown merge tool $merge_tool" + echo >&2 "Unknown $TOOL_MODE tool $merge_tool" exit 1 fi if diff_mode From patchwork Wed Nov 13 00:52:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Philippe Blain X-Patchwork-Id: 13873058 Received: from mail-wm1-f53.google.com (mail-wm1-f53.google.com [209.85.128.53]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A70D9C147 for ; Wed, 13 Nov 2024 00:52:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.53 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731459136; cv=none; b=rNJZLmIt6jvYol4UNXf8mNyatcXwlnLPeqPeCFOPYI74mJCIxAWOSI22gOJMzsgKvxqABrhe0gMSh/OTJkDHBZ0hf1JThLc6fJiJbDBDVKlpQ6XeYYxG58rcBqj9OilD5T21UxKZRD/7Rf4mm7BRrpAvY6Kw0MFyRVAmltC6d+Q= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731459136; c=relaxed/simple; bh=rvPhr0//X4L2n/g7/j43QDIaxRWHqGE3sZkpuEjOeYE=; h=Message-Id:In-Reply-To:References:From:Date:Subject:Content-Type: MIME-Version:To:Cc; b=p/bYNc/TVfrmPsJtnvH/xxYSsB24Vx2ASbnl2KZckJVg4DSIPZ0BK3m6JD4n9ia7R3Ih5Oo3JLH3NiVuPfBHeIkO+mnEfraTmrnm591HUVypSqjC25f/ZahchqbefTmplj7cBBNLh0Ai7u7d2UbWNXE9e95hRBSeis9VNVZoSig= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=cM5lkh5F; arc=none smtp.client-ip=209.85.128.53 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="cM5lkh5F" Received: by mail-wm1-f53.google.com with SMTP id 5b1f17b1804b1-4314f38d274so79351855e9.1 for ; Tue, 12 Nov 2024 16:52:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1731459133; x=1732063933; darn=vger.kernel.org; h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date:from :references:in-reply-to:message-id:from:to:cc:subject:date :message-id:reply-to; bh=CW1FnMD8h6nUXg181Dfk4yTuTgYRbDWen/pqY6AhIgQ=; b=cM5lkh5FsBPHXrz9qeKpeXxeO0oqL3VHvBxfQ1l2sBCRcH8kAyK1C30lhTErLPSltw arRZZq8ZG+Myk8zDErFz2P7v45K/ZbxhxdxhLjavc53IsJXEGSB0fTyt+AfwhBB/LU1a IQA3FOu+qa/v0SKx9g4x35mipmTJ4u/ENv9EePfL6aTdK1NERcXPTwgxNhEbiVOdC+Hk lZnoNpz8lO+oTf44TDNHOpFdJdNZHhiVDaOSfV+MO5FJyMZheqzWp9XgCpn8uaz9/Mi1 irZnTjxdBaOFz6pggd2yJTx4VwEuhOOmeH3UD68UFIzXYvzgBAAdaHwvO8vlbBGPEJWt GSlg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1731459133; x=1732063933; h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date:from :references:in-reply-to:message-id:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=CW1FnMD8h6nUXg181Dfk4yTuTgYRbDWen/pqY6AhIgQ=; b=Dc+mihFv4jW5MhxiYFylRcqfyTERDR379Q1LtJ6Xi1o8wFzBSk54MPay11Tkjq1Ra0 f1R95PmRrzSbhfvu7vX/REFnq1t1j3HGoZS/vv9uFW+PhjzG2emX+mZuXt7BcS9HQm01 W29GCQJRB/DxZVfgQHNqIfvmATcV/UGr6zztC7u0/b2W/Zuqst+dAa5+ymVfLBlsgE0n ciSwVvAczGkegArzjFkXdiI+yWOcs5OackRC9zFnCdDsT45IvPGaFKkFbGubobDxMEtp F1ckKbJUOVEkZuogh7gqhYM6hyQywacBZFleddZe7OgQsqYH4fG+jOEy4H3DpocAsOhL eUWw== X-Gm-Message-State: AOJu0Yz0uXArkHXePEJKyj0+pnTeyyAUSqm9DrA08csHx48xf0dQSHQd pUuflIx7/c5uXtjOimkZlPxbLg82a7D2QC/epwuLMufi1cg9hAS3x959yQ== X-Google-Smtp-Source: AGHT+IFsupcilVP21zWqtZE22N5tsmlrDO5OVvzj4k7MjGkyaSRFz/idbqPmtPCDLiTWBgCwjKd/lA== X-Received: by 2002:a05:600c:3b87:b0:431:5ba1:a520 with SMTP id 5b1f17b1804b1-432b74fec0bmr207572225e9.3.1731459132626; Tue, 12 Nov 2024 16:52:12 -0800 (PST) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-432d5503abesm4780515e9.20.2024.11.12.16.52.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Nov 2024 16:52:12 -0800 (PST) Message-Id: <79c3a6ffe8f2872755f76340e2d5ae1a94885456.1731459128.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Wed, 13 Nov 2024 00:52:06 +0000 Subject: [PATCH 3/5] git-mergetool--lib.sh: add error message in 'setup_user_tool' Fcc: Sent Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 To: git@vger.kernel.org Cc: Seth House , David Aguilar , Johannes Sixt , Philippe Blain , Philippe Blain From: Philippe Blain From: Philippe Blain In git-mergetool--lib.sh::setup_tool, we check if the given tool is a known builtin tool, a known variant, or a user-defined tool by calling setup_user_tool, and we return with the exit code from setup_user_tool if it was called. setup_user_tool checks if {diff,merge}tool.$tool.cmd is set and quietly returns with an error if not. This leads to the following invocation quietly failing: git mergetool --tool=unknown which is not very user-friendly. Adjust setup_user_tool to output an error message before returning if {diff,merge}tool.$tool.cmd is not set. Adjust the second call to setup_user_tool in setup_tool to silence this new error, as this call is only meant to allow users to redefine 'cmd' for a builtin tool; it is not an error if they have not done so (which is why we do not check the return status of this call). Note that this behaviour of quietly failing is a regression dating back to de8dafbada (mergetool: break setup_tool out into separate initialization function, 2021-02-09), as before this commit an unknown mergetool would be diagnosed in get_merge_tool_path when called from run_merge_tool. Signed-off-by: Philippe Blain --- git-mergetool--lib.sh | 10 +++++++--- t/t7610-mergetool.sh | 8 ++++++++ 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/git-mergetool--lib.sh b/git-mergetool--lib.sh index 269a60ea44c..f4786afc63f 100644 --- a/git-mergetool--lib.sh +++ b/git-mergetool--lib.sh @@ -159,14 +159,18 @@ check_unchanged () { } valid_tool () { - setup_tool "$1" && return 0 + setup_tool "$1" 2>/dev/null && return 0 cmd=$(get_merge_tool_cmd "$1") test -n "$cmd" } setup_user_tool () { merge_tool_cmd=$(get_merge_tool_cmd "$tool") - test -n "$merge_tool_cmd" || return 1 + if test -z "$merge_tool_cmd" + then + echo >&2 "error: ${TOOL_MODE}tool.$tool.cmd not set for tool '$tool'" + return 1 + fi diff_cmd () { ( eval $merge_tool_cmd ) @@ -255,7 +259,7 @@ setup_tool () { # Now let the user override the default command for the tool. If # they have not done so then this will return 1 which we ignore. - setup_user_tool + setup_user_tool 2>/dev/null if ! list_tool_variants | grep -q "^$tool$" then diff --git a/t/t7610-mergetool.sh b/t/t7610-mergetool.sh index 22b3a85b3e9..82a88107850 100755 --- a/t/t7610-mergetool.sh +++ b/t/t7610-mergetool.sh @@ -898,4 +898,12 @@ test_expect_success 'mergetool with guiDefault' ' git commit -m "branch1 resolved with mergetool" ' +test_expect_success 'mergetool with non-existent tool' ' + test_when_finished "git reset --hard" && + git checkout -b test$test_count branch1 && + test_must_fail git merge main && + yes "" | test_must_fail git mergetool --tool=absent >out 2>&1 && + test_grep -i "not set for tool" out +' + test_done From patchwork Wed Nov 13 00:52:07 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Philippe Blain X-Patchwork-Id: 13873059 Received: from mail-wm1-f44.google.com (mail-wm1-f44.google.com [209.85.128.44]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E66C018EB1 for ; Wed, 13 Nov 2024 00:52:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.44 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731459137; cv=none; b=kyUp9CZS4mL5GDOhtL5x55yqlKQSsvn0bliFUnB8/LJzt5paRgBph2fs1+JMwZ8lV5S0k3n5KYLgBX+Wal0HAokqnoaAjVxdpTS6kBYOM6gSvsxEsi6q/Ayr42yFimIQ6C2yo72juJiHWHigSBfxO/QpVn9XWSUYc/PG7/PEV04= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731459137; c=relaxed/simple; bh=ijrTHIViB3dWfhYnEmnI/vwiQSXewrBSDxjW35MGlAc=; h=Message-Id:In-Reply-To:References:From:Date:Subject:Content-Type: MIME-Version:To:Cc; b=VXIknGr4RBVe6Z7AkDyAjAkW2IghKjOJZT5PGMjHrUKrWoRc59UKY1pvBouoGBDnY4/zMgqD11KwZxndlXWKdoHn+s26e7ZqP9jSSqWEcJoskRjdJtOOy4QQo9M0Aq3KJacD91l6YfuVyHDC8eDY7k9wBTX4MI5aHU9PPSNyd5A= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=YjWmNRQF; arc=none smtp.client-ip=209.85.128.44 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="YjWmNRQF" Received: by mail-wm1-f44.google.com with SMTP id 5b1f17b1804b1-4315eac969aso1028805e9.1 for ; Tue, 12 Nov 2024 16:52:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1731459134; x=1732063934; darn=vger.kernel.org; h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date:from :references:in-reply-to:message-id:from:to:cc:subject:date :message-id:reply-to; bh=ZEwqcrVrJph7lJ7laTaMdKMBUJScDztfebfQ58iEJ6c=; b=YjWmNRQF+rWGxYtZuJuIkW13886NucwgMuumLf6q52AU2r01iAHsvyxsZTXaJfRdJR N3u64jKRyWrkP9JlNA/t3Q8v+Af856GZNh6FRvcDoGo/DF6TkZ+rARwk4ksIkhYV5tuF 53xgoG4xOom5ANUrhGT3MTKUhXZYMA1g7fUm2eSdFGv0nvlkWY6Fma3MmhzKB+tlWwvE y+h48FdMnfq7lDmYfLLVmwiUGahSyAMTvGmfs9kFBIPiHlCtV7XHAwR7f6ug7Pqnius6 x8kb+pMSO53mjGCDsOBdXBxGfm8bvOw27OU133BjjlYz9t6xvJ2WObLJcjouOg1dy2B8 YtTg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1731459134; x=1732063934; h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date:from :references:in-reply-to:message-id:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ZEwqcrVrJph7lJ7laTaMdKMBUJScDztfebfQ58iEJ6c=; b=Kg8WfgDDwrzhS4F82e8DPASYokdVphSGLY7KkbljTRyNrSe0kK+n7wn/N/TTcx9pSH QWxXFAlw62sz6JlzC2gcqLfihGHGRQFK9QSR/65P2XQlTPwXHPLKUKEOZ/2vuPHNSgsn h8z8uh5h8mccxW71vgyaS43e95k4RAEn3I10I1Vkbkjl1r5ZBmi/JUXHhySS1McYEXGV t+tp1A6Ske8xfc6OY5iYfWcCO4RnP2W2dHLpduLyUDasUGmAeRw2aERMv3/K68UrOuli AgNO+QQ3GTmM/Z12nNI4ojZcfSNPsqjDptjNyP93hI3SomO69Go1XPx1Bu+G4pvTWZvi bBGw== X-Gm-Message-State: AOJu0Yzs3NYR5zJCtOcI7eomD1mZg1+NsWB49GC7k7aFHY8FKWmTzNdF rxlFceyw3BxU5XfZgtMW6/eJZiUhVZwzWE51hYWmBvUUy5O9et1O8r3esw== X-Google-Smtp-Source: AGHT+IEItzHt7HZcsdUQW17NnmtxaOm/N1GVNCY9OTgx6vXQoFGXh38wkOxI+xh7T3rITa9PgpxmBw== X-Received: by 2002:a05:600c:3115:b0:432:7c30:abf3 with SMTP id 5b1f17b1804b1-432b685c2d7mr164296725e9.7.1731459133654; Tue, 12 Nov 2024 16:52:13 -0800 (PST) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-432d550c14esm4729555e9.28.2024.11.12.16.52.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Nov 2024 16:52:13 -0800 (PST) Message-Id: <74b83caa1e5c1a63248dd4dcbaf2cf450f9cf32d.1731459128.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Wed, 13 Nov 2024 00:52:07 +0000 Subject: [PATCH 4/5] git-mergetool--lib.sh: add error message for unknown tool variant Fcc: Sent Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 To: git@vger.kernel.org Cc: Seth House , David Aguilar , Johannes Sixt , Philippe Blain , Philippe Blain From: Philippe Blain From: Philippe Blain In setup_tool, we check if the given tool is a known variant of a tool, and quietly return with an error if not. This leads to the following invocation quietly failing: git mergetool --tool=vimdiff4 Add an error message before returning in this case. Signed-off-by: Philippe Blain --- git-mergetool--lib.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/git-mergetool--lib.sh b/git-mergetool--lib.sh index f4786afc63f..9a00fabba27 100644 --- a/git-mergetool--lib.sh +++ b/git-mergetool--lib.sh @@ -263,6 +263,7 @@ setup_tool () { if ! list_tool_variants | grep -q "^$tool$" then + echo "error: unknown ${tool%[0-9]} variant '$tool'" >&2 return 1 fi From patchwork Wed Nov 13 00:52:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Philippe Blain X-Patchwork-Id: 13873060 Received: from mail-wm1-f44.google.com (mail-wm1-f44.google.com [209.85.128.44]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BD64F1CA9C for ; Wed, 13 Nov 2024 00:52:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.44 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731459138; cv=none; b=f9cDwJ1j7g8D01Ti1JYt2zemN1mOzAgLZQw3OfPSg1pf9hki6T2ituD0rp/EjMbQ9Ize5R875whfkYeRaTbj66dvJvrZ1My/YznHlCa0xnA+Lznk0PIMrvAbI6Z+ulPLLbMQKTZzGDZDmiID+zBj+pnupiw54mC6Wgf3BIW7Awo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731459138; c=relaxed/simple; bh=cjrNcDybg+eotxIuIDwjKtIzIcasPSG0L/pSBxlJA9U=; h=Message-Id:In-Reply-To:References:From:Date:Subject:Content-Type: MIME-Version:To:Cc; b=mSjBXonHjJVKiIsK8ac9Ob57mlWHcM1vviaicvDi/JIr2qcs4py9T8MRAXt3jAkiYyJguIfxlcGON0j1406P9ms/mpLJIVQ/oZ42MiLkAuDjtWv07A1NP2pwrVMS0zgYnqFcTbZ3PNbIFohNcQTbmgOSqHNmH2sFlgfQuztadq0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=SqvDeu9z; arc=none smtp.client-ip=209.85.128.44 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="SqvDeu9z" Received: by mail-wm1-f44.google.com with SMTP id 5b1f17b1804b1-4315baa51d8so55716875e9.0 for ; Tue, 12 Nov 2024 16:52:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1731459135; x=1732063935; darn=vger.kernel.org; h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date:from :references:in-reply-to:message-id:from:to:cc:subject:date :message-id:reply-to; bh=yFDhg1t7IvcLQqH4U2PxGRD4pEqla4b+K0WdwT4ZPyU=; b=SqvDeu9zOjYbGDfd/mr8sHf50Hs7XYb1L0LMOGYKUx5LAQ8Hm5Q+0aGP2Hmx0v47kJ huRkgn5M0Lo1LJDyEZ5baV015ZEFa62oFBqsaeKgNp5ZwV7Pdk9YmakEngJI08Uy6lum Olen9rMdrZjcDe4yWia0XmxG8h5l66Ip3kDEKHlraWhEWG8g/qrVX6HRcih+AUFshj6B XvK8tHRobjAuJATousMbJU38+FRriyUvO9S76K1vSnJt2B9eizKZA/G4GTxjlkoT8YMB m06CnhBUoQsI5sxffQspMJXAND6XAGNlHYp7WhWr5ZY+0+DRddFCCq34YqUYQmBynMyR RcBA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1731459135; x=1732063935; h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date:from :references:in-reply-to:message-id:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=yFDhg1t7IvcLQqH4U2PxGRD4pEqla4b+K0WdwT4ZPyU=; b=HdGjk/BtNII1oVhQHJztt5TnnrDCh/MvZCsaj2HFrcggHZV5TZnQFic0MQCpIKxi5d b8Vyq2djzsCr4k4XnWOh/IHLY7wZ//wQ3t+VbpILUVCskUUyr0Z0GjNZCVP1m/m9QGTK Z/c5XMjI6Xqa3Fcy8yd2NhBk4dqtVPlJciiPuwfVr5pa+aXW9ilqTpV1NN55cSDNY2MU vZAnwRbHEGwqF0wlx5VsXNd44T0rGqlEUnOsArWjfVpvCfCKejTk/QfI7n9d68ECZB74 2oSfFghV1G0FEu8uNLZDiUY6k9NU/6TDHu/WI3zOtXJKkoU7oq9TA+iOLQxffDO/56KF osJg== X-Gm-Message-State: AOJu0Yyenh+3x6hbLOPWVQcPnkpx16C/HBaYTtwCTxTPBqnY7KoXcHh1 /JYsyed93s9aQ2BrdPblkGNCc+K0sWVobv7F1aQFaC81yExTexyrKdfk7w== X-Google-Smtp-Source: AGHT+IEmu22dxwbmo0JbWHJf7kfYwjE3eakiTSplU1aE6BNWxDp2uunVJ41dQIfDS9FnqX/lT9lYzw== X-Received: by 2002:a05:600c:1da7:b0:42c:a574:6360 with SMTP id 5b1f17b1804b1-432d4ad6625mr8498575e9.29.1731459134455; Tue, 12 Nov 2024 16:52:14 -0800 (PST) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-432d554183dsm4639935e9.29.2024.11.12.16.52.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Nov 2024 16:52:14 -0800 (PST) Message-Id: In-Reply-To: References: Date: Wed, 13 Nov 2024 00:52:08 +0000 Subject: [PATCH 5/5] git-difftool--helper.sh: exit upon initialize_merge_tool errors Fcc: Sent Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 To: git@vger.kernel.org Cc: Seth House , David Aguilar , Johannes Sixt , Philippe Blain , Philippe Blain From: Philippe Blain From: Philippe Blain Since the introduction of 'initialize_merge_tool' in de8dafbada (mergetool: break setup_tool out into separate initialization function, 2021-02-09), any errors from this function are ignored in git-difftool--helper.sh::launch_merge_tool, which is not the case for its call in git-mergetool.sh::merge_file. Despite the in-code comment, initialize_merge_tool (via its call to setup_tool) does different checks than run_merge_tool, so it makes sense to abort early if it encounters errors. Add exit calls if initialize_merge_tool fails. Signed-off-by: Philippe Blain --- git-difftool--helper.sh | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/git-difftool--helper.sh b/git-difftool--helper.sh index dd0c9a5b7f2..d32e47cc09e 100755 --- a/git-difftool--helper.sh +++ b/git-difftool--helper.sh @@ -61,9 +61,7 @@ launch_merge_tool () { export BASE eval $GIT_DIFFTOOL_EXTCMD '"$LOCAL"' '"$REMOTE"' else - initialize_merge_tool "$merge_tool" - # ignore the error from the above --- run_merge_tool - # will diagnose unusable tool by itself + initialize_merge_tool "$merge_tool" || exit 1 run_merge_tool "$merge_tool" fi } @@ -87,9 +85,7 @@ if test -n "$GIT_DIFFTOOL_DIRDIFF" then LOCAL="$1" REMOTE="$2" - initialize_merge_tool "$merge_tool" - # ignore the error from the above --- run_merge_tool - # will diagnose unusable tool by itself + initialize_merge_tool "$merge_tool" || exit 1 run_merge_tool "$merge_tool" false status=$?