From patchwork Tue Jan 9 06:04:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ghanshyam Thakkar X-Patchwork-Id: 13514324 Received: from mail-pl1-f171.google.com (mail-pl1-f171.google.com [209.85.214.171]) (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 D72F179D4 for ; Tue, 9 Jan 2024 06:10:00 +0000 (UTC) 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="lK/PScxA" Received: by mail-pl1-f171.google.com with SMTP id d9443c01a7336-1d542701796so9026175ad.1 for ; Mon, 08 Jan 2024 22:10:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1704780600; x=1705385400; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Ca2kQ3kJp21oTxrgP8Bu2taXSfqZrs6WOSlykmaWYSc=; b=lK/PScxAVyF6dud32R1COGyuxUy1at3x5bKJHhpayWQezVjgxDYiuV3GBUgiGWg63d jB5e2Jk00ZR01O4C1VMijhR+1Thl8qhYO6O26zdvx8RHSVDdzMI+hGT5lteVhOl9n5tA od2T/9S0R9ofekIvD3YFCkt9QQ5sMeIjhoK4TpH20YY3PLMaA2PXbNzHdHeTaFSsJwKr ObWDrpe6yAeFr44RVpB1YVVYp/Ke8z8tiiFizk/M8zLa5hqiB6gHUqPBwKptyaqZgvRV w8xsd8DCqRhlQyJlF5Kh5H0cfkFZRgxsjtUtseFESYbn3/PZCl3AGlrN0cKnIYXz8p/i BbLA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704780600; x=1705385400; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Ca2kQ3kJp21oTxrgP8Bu2taXSfqZrs6WOSlykmaWYSc=; b=Phroh5hhTplzytYRCj2uczQVN+ALcZeCQLlmUjANDUgd6f18+Ia2xx60QvE+4Y3Dbn DmpPEMjmfNfB/f+IvMK6pGdsWcV9JTv3p0aXrMYYFyve/Z4A0+q0xw860pvDUncqIz55 4Sp+WZt9jtgEKDgFJJ7oOZXqNAtVlT+WGJk9jov0qofZftTJheQyI8eLAo32I3f9segV tdVOVeEP4Rw27CKmEJwvfd1zk9vmXL3lI5epdMdTUKTtgdvF+qWIZIZd9tyUehiUbrLF 72Jt0DFTIPy34Mu83lG6Na2CRLfe4YBSst6siSuVnUmDAe/mVbd95sy/HgK1QGowF3W8 Txpg== X-Gm-Message-State: AOJu0YxVlyg936cNdcicCkXEsvfpSdijNcvnM2DHqQNAyPQk5St+DQQr DOsH3B6Ff9n6JqQotm9ZhAGQOYzOdQ+SUPVcCCk= X-Google-Smtp-Source: AGHT+IHMmO3+1vZA4q/yQbIRr5lITl9IoSl84BuOxFx9qcKZ+avcSEf00cz8SC4QpgkIYzdGFfM+pg== X-Received: by 2002:a17:902:b7c4:b0:1d4:3ef:2810 with SMTP id v4-20020a170902b7c400b001d403ef2810mr2749107plz.107.1704780599684; Mon, 08 Jan 2024 22:09:59 -0800 (PST) Received: from localhost.localdomain ([2402:a00:401:a99b:65e8:f5a4:7adb:5726]) by smtp.gmail.com with ESMTPSA id v20-20020a1709028d9400b001d05456394csm896020plo.28.2024.01.08.22.09.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 Jan 2024 22:09:59 -0800 (PST) From: Ghanshyam Thakkar To: git@vger.kernel.org Cc: Ghanshyam Thakkar Subject: [PATCH 1/2] t7501: Add tests for various index usages, -i and -o, of commit command. Date: Tue, 9 Jan 2024 11:34:13 +0530 Message-ID: <20240109060417.1144647-3-shyamthakkar001@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240109060417.1144647-2-shyamthakkar001@gmail.com> References: <20240109060417.1144647-2-shyamthakkar001@gmail.com> Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 This commit adds tests for -i and -o flags of the commit command. It includes testing -i with and without staged changes, testing -o with and without staged changes, and testing -i and -o together. Signed-off-by: Ghanshyam Thakkar --- t/t7501-commit-basic-functionality.sh | 90 +++++++++++++++++++++++++++ 1 file changed, 90 insertions(+) diff --git a/t/t7501-commit-basic-functionality.sh b/t/t7501-commit-basic-functionality.sh index 3d8500a52e..71dc52ce3a 100755 --- a/t/t7501-commit-basic-functionality.sh +++ b/t/t7501-commit-basic-functionality.sh @@ -76,6 +76,96 @@ test_expect_success 'nothing to commit' ' test_must_fail git commit -m initial ' +test_expect_success 'commit with -i fails with untracked files' ' + test_when_finished "rm -rf testdir" && + git init testdir && + echo content >testdir/file.txt && + test_must_fail git -C testdir commit -i file.txt -m initial +' + +test_expect_success 'commit with -i' ' + echo content >bar && + git add bar && + git commit -m "bar" && + + echo content2 >bar && + git commit -i bar -m "bar second" +' + +test_expect_success 'commit with -i multiple files' ' + test_when_finished "git reset --hard" && + echo content >bar && + echo content >baz && + echo content >saz && + git add bar baz saz && + git commit -m "bar baz saz" && + + echo content2 >bar && + echo content2 >baz && + echo content2 >saz && + git commit -i bar saz -m "bar" && + git diff --name-only >remaining && + test_grep "baz" remaining +' + +test_expect_success 'commit with -i includes staged changes' ' + test_when_finished "git reset --hard" && + echo content >bar && + git add bar && + git commit -m "bar" && + + echo content2 >bar && + echo content2 >baz && + git add baz && + git commit -i bar -m "bar baz" && + git diff --name-only >remaining && + test_must_be_empty remaining && + git diff --name-only --staged >remaining && + test_must_be_empty remaining +' + +test_expect_success 'commit with -o' ' + echo content >bar && + git add bar && + git commit -m "bar" && + echo content2 >bar && + git commit -o bar -m "bar again" +' + +test_expect_success 'commit with -o fails with untracked files' ' + test_when_finished "rm -rf testdir" && + git init testdir && + echo content >testdir/bar && + test_must_fail git -C testdir commit -o bar -m "bar" +' + +test_expect_success 'commit with -o exludes staged changes' ' + test_when_finished "git reset --hard" && + echo content >bar && + echo content >baz && + git add . && + git commit -m "bar baz" && + + echo content2 >bar && + echo content2 >baz && + git add baz && + git commit -o bar -m "bar" && + git diff --name-only --staged >actual && + test_grep "baz" actual +' + +test_expect_success 'commit with both -i and -o fails' ' + test_when_finished "git reset --hard" && + echo content >bar && + echo content >baz && + git add . && + git commit -m "bar baz" && + + echo content2 >bar && + echo content2 >baz && + test_must_fail git commit -i baz -o bar -m "bar" +' + test_expect_success '--dry-run fails with nothing to commit' ' test_must_fail git commit -m initial --dry-run ' From patchwork Tue Jan 9 06:04:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ghanshyam Thakkar X-Patchwork-Id: 13514325 Received: from mail-pl1-f179.google.com (mail-pl1-f179.google.com [209.85.214.179]) (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 CEF3F8F69 for ; Tue, 9 Jan 2024 06:10:03 +0000 (UTC) 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="Wf9aRnRt" Received: by mail-pl1-f179.google.com with SMTP id d9443c01a7336-1d3ea5cc137so22946255ad.0 for ; Mon, 08 Jan 2024 22:10:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1704780603; x=1705385403; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=eETwQf+ok/3MYSY+fSF8wd0AjBlqwk182XnHB+9IZ6o=; b=Wf9aRnRtDK1etucGd6HVCp9n0X6ck3f3I/uSA85xi1akHd4YwVmqVw3Ykgqc7eq77Q 3oC2llC0bXt2BVarpISmDve+wSdS20il6iM9xOyXbrgv6tUUUksOxIf3dzqzB/BPfQj1 h7qu1jC/BJI5/XwhGwb0ZlgBM0VtVa4VRZufdxNe5pZBtA/p3M3HM9dr5dDy3UvkAz+T nfLKsHD6tDrFven18n9yG0G0z6NTk4fashQ1O3K9MyQw/AOUyGvjlI2H81LxLfGf/1oZ VEVRR9mSMuRIt5C0eAv19T8GtlPtMn7H6H8OQKj9hDtKKX3TNLrA1HgctHO3Ui27krin oD4Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704780603; x=1705385403; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=eETwQf+ok/3MYSY+fSF8wd0AjBlqwk182XnHB+9IZ6o=; b=WvmS7svCGMWgQbUgbr+nKhnQ+P+kE1Dog+ZoHSrxU32zx05h+WSReJC5AL3P2cQxDX xAM/dFh+M0LKYmmB0st51aIaL8Q3SwQ1czFMZMain4Kg/0szdq/Bxnc6zHRLaPmtbhWr cysMkjKY5n61B5emwWLx2BV3haT0POOrpaMo3qnYHM4jAlubkhzzj1+F82+mIlMVbktV Dhehfefnunym0QgGoKdakj9/tsskGJck6BKcD/bLb8nmB8gmlEGjyivUxW5PbKiwPsYi r5/BKRFRuvRRVaY9vaSQhSPM/E6X0cfTNOgURPNJ7hBKT64hiDaAgkZvbDXTT51RQy+n jKmg== X-Gm-Message-State: AOJu0Yyn5dilMZTQRzfWFiDKvZrhQ8DoKkjH7YIi2/Y7vBSK0pfkHDHr Ap7fscLqnAm3N7L2gQhssyacgEMUA0HXHNt7x6k= X-Google-Smtp-Source: AGHT+IG0YLtSlJqhKXhVNR7O8BAc4IC1g/MrJ/WnFo++/7OGDFGn0dAStdszBpG5OBjCpLbrCXW4Zg== X-Received: by 2002:a17:902:9005:b0:1d4:97a:7f5a with SMTP id a5-20020a170902900500b001d4097a7f5amr4546522plp.95.1704780602741; Mon, 08 Jan 2024 22:10:02 -0800 (PST) Received: from localhost.localdomain ([2402:a00:401:a99b:65e8:f5a4:7adb:5726]) by smtp.gmail.com with ESMTPSA id v20-20020a1709028d9400b001d05456394csm896020plo.28.2024.01.08.22.10.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 Jan 2024 22:10:02 -0800 (PST) From: Ghanshyam Thakkar To: git@vger.kernel.org Cc: Ghanshyam Thakkar Subject: [PATCH 2/2] t7501: Add test for amending commit to add signoff. Date: Tue, 9 Jan 2024 11:34:14 +0530 Message-ID: <20240109060417.1144647-4-shyamthakkar001@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240109060417.1144647-2-shyamthakkar001@gmail.com> References: <20240109060417.1144647-2-shyamthakkar001@gmail.com> Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 This commit adds test for amending the latest commit to add Signed-off-by trailer at the end of commit message. Signed-off-by: Ghanshyam Thakkar --- t/t7501-commit-basic-functionality.sh | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/t/t7501-commit-basic-functionality.sh b/t/t7501-commit-basic-functionality.sh index 71dc52ce3a..35c69c3ddd 100755 --- a/t/t7501-commit-basic-functionality.sh +++ b/t/t7501-commit-basic-functionality.sh @@ -464,6 +464,24 @@ test_expect_success 'amend commit to fix author' ' ' +test_expect_success 'amend commit to add signoff' ' + + test_when_finished "rm -rf testdir" && + git init testdir && + echo content >testdir/file && + git -C testdir add file && + git -C testdir commit -m "file" && + git -C testdir commit --amend --signoff && + git -C testdir log -1 --pretty=format:%B >actual && + ( + echo file && + echo && + git -C testdir var GIT_COMMITTER_IDENT >ident && + sed -e "s/>.*/>/" -e "s/^/Signed-off-by: /" ident + ) >expected && + test_cmp expected actual +' + test_expect_success 'amend commit to fix date' ' test_tick &&