From patchwork Tue Feb 6 22:50:36 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ghanshyam Thakkar X-Patchwork-Id: 13547898 Received: from mail-pj1-f50.google.com (mail-pj1-f50.google.com [209.85.216.50]) (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 1AD3F1C684 for ; Tue, 6 Feb 2024 22:57:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.50 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707260235; cv=none; b=Y8bezAYfeice5n1ePUnqs9zgB5w2nVDzhRQkySe+uFNRU6MSuH8VeISA5oJVGDXalfnkwQ4JPO70KTa2oy6VqwKKhZz0x5vpkoXm5ARPJ1/xYqJZNLRMhc24bcAPOOasq+71GwWooqdN91mrbbjR7QLodu5Ka52g6owG009xUas= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707260235; c=relaxed/simple; bh=3qKh27jsrUcj7bfIOZep3BM3tLL6s7jWgR8ZlXFcl4k=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Aqkw1XJhH3vC4+yYK+GsNf5uimAm65tPV/2LoRk1okZZMm5CP3mPjfuDhRDDEtbd8wgUuP84pNxquRflgii58o8lYoCuzDaVgay0pbq/YQZ3LJ3w41816Sf30tA6vwY8EUQ10HJ1y6RT6HhEhkhx4jpkFymrsJirXbdWZ81yIAc= 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=ItvZF2/T; arc=none smtp.client-ip=209.85.216.50 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="ItvZF2/T" Received: by mail-pj1-f50.google.com with SMTP id 98e67ed59e1d1-290fb65531eso4614372a91.2 for ; Tue, 06 Feb 2024 14:57:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1707260233; x=1707865033; 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=5g+/7jrq18KLHAbv5nChhn1t9Cdsv01Fs6TwNRYoGcM=; b=ItvZF2/TwlHIcUnzbDUu+zJhgoYZP5UBeEcKOWcLRkS0oB0DjksfGCs/2s0VJoKEF7 CutZ/oRnSmOlk3N9G3JjjJctG9nyjGQivQEk05Ava+at9klW7pebX98+LIc0mBJ+pURR agND3LS8fhkaXtzglrOvwvf5FmeVmRYjpSlR7JoB22W3g3cNvZNNXkKdcxtMTGqLol9U 7pHZOqMuz8i8pD+ymohV81x8Que3Z24hKkJyYLHCeq4/u+8GMVW/rJq343gDBUEsGhZz WhlX1S/EaOaW9hQKt+RzH2KCa0LreS+uppWTgku9BJiGSqUyPP0X7gRCeRcTgGGuHmi/ mwPw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707260233; x=1707865033; 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=5g+/7jrq18KLHAbv5nChhn1t9Cdsv01Fs6TwNRYoGcM=; b=wtdEINv7VmDFDf81dkHrKAuXNgiu91PDKCk5Y+oxYwa1NAUcDut2GolP1y2EQh6h82 wrB+c9tji9yKZ3Pd93+i/dNUB2PjL1URCMZenAyjHcFO5CV290KvsUUntwgmmIvWYolQ VvFiJ3R6av5t/aQ9dcNi96vGT0VyCZb05pwu1SSd1hIyy++3Qmccx2kulN4JH61R/ivI n7V/mUX47UwIyw+k5/Lr58xAg4waGBi8H2zZu4gBXE/pdcSrPyupgsfeVJYD4wP1fjbl Sr3zwubzNhZneBMo3MJRkc2eOzGKAUFR69h8MHUT+O/y43RDLAx4hBR5EVcXwebu1c7M qsnA== X-Gm-Message-State: AOJu0YwIOeS3X5pf7bcAh2S03K3yyJFDNhNKh3qAvF8lsorhUKwtZyyQ rW0/FaFg8LrxfvPEEaCyAyIHPeLaOhvgheyEU5SFiBb16jYIvtGZBxLb+X1c X-Google-Smtp-Source: AGHT+IEEq8GUeggErb+OeyXIA+hdHBr2A/Jv2tY18Tny3U71jNRebmJ75BpE6o7EA1VohtEMYbUqeQ== X-Received: by 2002:a17:90a:b90b:b0:286:9d2d:3a79 with SMTP id p11-20020a17090ab90b00b002869d2d3a79mr1034033pjr.12.1707260232625; Tue, 06 Feb 2024 14:57:12 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCXE3lRxorngc7+RO1bwwZTlxUBDAKh4LdoCQ8B27RvtcNRoZLaZpSQ60zYS2epMKVoC310KM7mWO+96PChJy0rwIdlRzxZnvCwAy+OAQlgsdeAx9R4NXyxb2Us9q2nTUcj0gHR52lYrqPSmYPQocwQ= Received: from localhost.localdomain ([2402:a00:401:a99b:f188:2dd3:d960:a8ab]) by smtp.gmail.com with ESMTPSA id x20-20020a17090aca1400b00290f9e8b4f9sm46741pjt.46.2024.02.06.14.57.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Feb 2024 14:57:12 -0800 (PST) From: Ghanshyam Thakkar To: git@vger.kernel.org Cc: gitster@pobox.com, phillip.wood123@gmail.com, ps@pks.im, Ghanshyam Thakkar Subject: [PATCH v4 1/3] add-patch: remove unnecessary NEEDSWORK comment Date: Wed, 7 Feb 2024 04:20:36 +0530 Message-ID: <20240206225122.1095766-4-shyamthakkar001@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240203112619.979239-2-shyamthakkar001@gmail.com> References: <20240203112619.979239-2-shyamthakkar001@gmail.com> Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 The comment suggested to compare commit objects instead of string comparison to 'HEAD' for supporting more ways of saying 'HEAD' (e.g. '@'). However, this approach would also count a non-checked out branch pointing to same commit as HEAD, as HEAD. This would cause confusion to the user. Junio described it best as[1]: "Users may consider 'HEAD' and '@' the same and may want them to behave the same way, but the user, when explicitly naming '$branch', means they want to "check contents out of that OTHER thing named '$branch', not the current branch"; it may or may not happen to be pointing at the same commit as HEAD, but if the user meant to say "check contents out of the current commit, (partially) reverting the local changes I have", the user would have said HEAD. After all, the user may not even be immediately aware that '$branch' happens to point at the same commit as HEAD." [1]: https://lore.kernel.org/git/xmqqmssohu69.fsf@gitster.g/ Signed-off-by: Ghanshyam Thakkar --- add-patch.c | 8 -------- 1 file changed, 8 deletions(-) diff --git a/add-patch.c b/add-patch.c index 79eda168eb..68f525b35c 100644 --- a/add-patch.c +++ b/add-patch.c @@ -1729,14 +1729,6 @@ int run_add_p(struct repository *r, enum add_p_mode mode, if (mode == ADD_P_STASH) s.mode = &patch_mode_stash; else if (mode == ADD_P_RESET) { - /* - * NEEDSWORK: Instead of comparing to the literal "HEAD", - * compare the commit objects instead so that other ways of - * saying the same thing (such as "@") are also handled - * appropriately. - * - * This applies to the cases below too. - */ if (!revision || !strcmp(revision, "HEAD")) s.mode = &patch_mode_reset_head; else From patchwork Tue Feb 6 22:50:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ghanshyam Thakkar X-Patchwork-Id: 13547899 Received: from mail-pl1-f173.google.com (mail-pl1-f173.google.com [209.85.214.173]) (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 13C411C298 for ; Tue, 6 Feb 2024 22:58:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.173 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707260331; cv=none; b=YH0OQJRoAUcFol94opYbBLRpdb8Q8SZDSEJw952JhafLCgxNtBnxw8SgIabRZHallHxO7oXC9eD9YSD0l1lR/b7tf+BEJOwf3XyK659w0mGlMDO4J+anS9nwU58FqUbS+poam+m6lmhOHtEv+owDxDaCJIaGEfPx+2WgaloxAhI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707260331; c=relaxed/simple; bh=b3fk27teWiststUmEija90xdmCTRbA56x6SCLHNvUdE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=onR9WHWhrpRZD5RyOme5PeWh8C8TzdUG0t50qXx64lLFIwNzHi4N7VHDViDJM1kBmaJFTD61yv4xRCdULJrk7tVDSPj5KwflscvNMD+XJlPf7ppbSYN07e12rr8b3fp1w+hB69TLf4ZIRMGcBY0xma7Y+7npkFEKx+DHMZIbATA= 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=ZnptykJw; arc=none smtp.client-ip=209.85.214.173 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="ZnptykJw" Received: by mail-pl1-f173.google.com with SMTP id d9443c01a7336-1d780a392fdso438755ad.3 for ; Tue, 06 Feb 2024 14:58:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1707260329; x=1707865129; 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=lOuoOVAI5aayObgUcf6aL99zUPnQl4bECVX3RdqxgbQ=; b=ZnptykJwIT5YLWehki34x7yiOEjKOrf9+KA1/89eb3xhhxuFnvmqDUJ8yTJ7BjscYq gAGWjXjl64J+sG/BWbBJhz9GXmUXf2p0hMHcmyLM2pbbpKBTPI3R5mjL64PYw3s4IcUc b8db812CsUqi7hubzE9v0JZYEeAAl/+kjEUZAiGfb1ZK2P7Tfe0c6ebRbjGUuLqjSZw9 PXByZEkmVr91QUaijCmFAULGFFuhhZObW0YQXxQ9sRr77Kw17lq8eImS1yuoBt8bMz0p BZGwPCkeIkYC5fjUcJor+7n9eKJc33qbO6yVTmCz2FmSEe6scVB6hZwLbnjJHXRC/a4d RHXQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707260329; x=1707865129; 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=lOuoOVAI5aayObgUcf6aL99zUPnQl4bECVX3RdqxgbQ=; b=QBubW35EdhEXMLCeh4q5/zekeOMXt4NkYKbxLA9xtwjtExu9IACGMBennMhogYhlTs jE8qqHNBe7sy9Lg9RUdLoFeDAz0KV5XbW0KtyuZqeRTjml+RZnmI+BmKB2+fREBbN5Eq a1lKoDhfL34lnBF6kpbqE/TL/ReF0TfJmoc7jOhs55zACxSAaIhLr1G5ixTvkOUJFlhK cpkVzF47xdU+A0w4GK6SxtAeoJXiC2RnspFdI1AcdoUTHFsfvB8qjuz9EUFlP6etVTbo DuM9mLeW86AuGNHzIj42MFL6DM2ffFe6QQXydtj61acw8DuTWYMGnbuZo3i7wN1mKzJR qfvA== X-Gm-Message-State: AOJu0YwWGYXiYs4l9F9tCy7RQWDf9YGYZUVJX72GccSWTOMxZgvVwQJX +0PPoczeAvnHx6TOlqE3J25z5Aul88aKNxznjLU0cO8H7Ls492tazTg7z55J X-Google-Smtp-Source: AGHT+IF4C21ccUujVW5QULPXIVuV7m1oSRnlzs/+Cj62b4QvHVbu6tAbXiP/VQAx8qrTMhREzc7xrw== X-Received: by 2002:a17:90a:ff95:b0:290:f5db:c4ad with SMTP id hf21-20020a17090aff9500b00290f5dbc4admr940567pjb.46.1707260328985; Tue, 06 Feb 2024 14:58:48 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCX07OHuiSCmHjgejzNKVwszW6xdop7t9di1AWtSJY+AGqE2IYX5elnDZKNln9g+gLAUfOs6Nhe1K1DNGo1WH6cXvfXsNC+2H+A0QtoEANV6p32m01C5qe2Q2XP2OjPyvIby6iB8uVDMZh9iQYciNSs= Received: from localhost.localdomain ([2402:a00:401:a99b:f188:2dd3:d960:a8ab]) by smtp.gmail.com with ESMTPSA id x20-20020a17090aca1400b00290f9e8b4f9sm46741pjt.46.2024.02.06.14.58.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Feb 2024 14:58:48 -0800 (PST) From: Ghanshyam Thakkar To: git@vger.kernel.org Cc: gitster@pobox.com, phillip.wood123@gmail.com, ps@pks.im, Ghanshyam Thakkar Subject: [PATCH v4 2/3] add-patch: classify '@' as a synonym for 'HEAD' Date: Wed, 7 Feb 2024 04:20:38 +0530 Message-ID: <20240206225122.1095766-6-shyamthakkar001@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240203112619.979239-2-shyamthakkar001@gmail.com> References: <20240203112619.979239-2-shyamthakkar001@gmail.com> Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Currently, (checkout, reset, restore) commands correctly take '@' as a synonym for 'HEAD'. However, in patch mode (-p/--patch), for both '@' and 'HEAD', different prompts/messages are given by the commands mentioned above (because of applying reverse mode(-R) in case of '@'). This is due to the literal and only string comparison with the word 'HEAD' in run_add_p(). Synonymity between '@' and 'HEAD' is obviously desired, especially since '@' already resolves to 'HEAD'. Therefore, replace '@' to 'HEAD' at the beginning of add-patch.c:run_add_p(). There is also logic in builtin/checkout.c to convert all command line input rev to the raw object name for underlying machinery (e.g., diff-index) that does not recognize the ... notation, but we'd need to leave 'HEAD' intact. Now we need to teach that '@' is a synonym to 'HEAD' to that code and leave '@' intact, too. There is one unintended side-effect/behavior change of this, even if there exists a branch named '@', when providing '@' as a rev-source to (checkout, reset, restore) commands in patch mode, it will consider it as HEAD. This is due to the behavior of diff-index. However, naming a branch '@' is an obvious foot-gun and there are many existing commands which already take '@' for 'HEAD' regardless of whether 'refs/heads/@' exists or not (e.g., 'git log @', 'git push origin @' etc.). Therefore, this should be fine. Helped-by: Junio C Hamano Signed-off-by: Ghanshyam Thakkar --- add-patch.c | 4 ++++ builtin/checkout.c | 11 +++++----- t/t2016-checkout-patch.sh | 46 ++++++++++++++++++++++----------------- t/t2071-restore-patch.sh | 18 +++++++++------ t/t7105-reset-patch.sh | 10 +++++++++ 5 files changed, 57 insertions(+), 32 deletions(-) diff --git a/add-patch.c b/add-patch.c index 68f525b35c..6f4ca8f4e4 100644 --- a/add-patch.c +++ b/add-patch.c @@ -1726,6 +1726,10 @@ int run_add_p(struct repository *r, enum add_p_mode mode, init_add_i_state(&s.s, r); + /* helpful in deciding the patch mode ahead */ + if(revision && !strcmp(revision, "@")) + revision = "HEAD"; + if (mode == ADD_P_STASH) s.mode = &patch_mode_stash; else if (mode == ADD_P_RESET) { diff --git a/builtin/checkout.c b/builtin/checkout.c index a6e30931b5..79e208ee6d 100644 --- a/builtin/checkout.c +++ b/builtin/checkout.c @@ -539,12 +539,13 @@ static int checkout_paths(const struct checkout_opts *opts, * recognized by diff-index), we will always replace the name * with the hex of the commit (whether it's in `...` form or * not) for the run_add_interactive() machinery to work - * properly. However, there is special logic for the HEAD case - * so we mustn't replace that. Also, when we were given a - * tree-object, new_branch_info->commit would be NULL, but we - * do not have to do any replacement, either. + * properly. However, there is special logic for the 'HEAD' and + * '@' case so we mustn't replace that. Also, when we were + * given a tree-object, new_branch_info->commit would be NULL, + * but we do not have to do any replacement, either. */ - if (rev && new_branch_info->commit && strcmp(rev, "HEAD")) + if (rev && new_branch_info->commit && strcmp(rev, "HEAD") && + strcmp(rev, "@")) rev = oid_to_hex_r(rev_oid, &new_branch_info->commit->object.oid); if (opts->checkout_index && opts->checkout_worktree) diff --git a/t/t2016-checkout-patch.sh b/t/t2016-checkout-patch.sh index 747eb5563e..c4f9bf09aa 100755 --- a/t/t2016-checkout-patch.sh +++ b/t/t2016-checkout-patch.sh @@ -38,26 +38,32 @@ test_expect_success 'git checkout -p with staged changes' ' verify_state dir/foo index index ' -test_expect_success 'git checkout -p HEAD with NO staged changes: abort' ' - set_and_save_state dir/foo work head && - test_write_lines n y n | git checkout -p HEAD && - verify_saved_state bar && - verify_saved_state dir/foo -' - -test_expect_success 'git checkout -p HEAD with NO staged changes: apply' ' - test_write_lines n y y | git checkout -p HEAD && - verify_saved_state bar && - verify_state dir/foo head head -' - -test_expect_success 'git checkout -p HEAD with change already staged' ' - set_state dir/foo index index && - # the third n is to get out in case it mistakenly does not apply - test_write_lines n y n | git checkout -p HEAD && - verify_saved_state bar && - verify_state dir/foo head head -' +for opt in "HEAD" "@" +do + test_expect_success "git checkout -p $opt with NO staged changes: abort" ' + set_and_save_state dir/foo work head && + test_write_lines n y n | git checkout -p $opt >output && + verify_saved_state bar && + verify_saved_state dir/foo && + test_grep "Discard" output + ' + + test_expect_success "git checkout -p $opt with NO staged changes: apply" ' + test_write_lines n y y | git checkout -p $opt >output && + verify_saved_state bar && + verify_state dir/foo head head && + test_grep "Discard" output + ' + + test_expect_success "git checkout -p $opt with change already staged" ' + set_state dir/foo index index && + # the third n is to get out in case it mistakenly does not apply + test_write_lines n y n | git checkout -p $opt >output && + verify_saved_state bar && + verify_state dir/foo head head && + test_grep "Discard" output + ' +done test_expect_success 'git checkout -p HEAD^...' ' # the third n is to get out in case it mistakenly does not apply diff --git a/t/t2071-restore-patch.sh b/t/t2071-restore-patch.sh index b5c5c0ff7e..dbbefc188d 100755 --- a/t/t2071-restore-patch.sh +++ b/t/t2071-restore-patch.sh @@ -44,13 +44,17 @@ test_expect_success PERL 'git restore -p with staged changes' ' verify_state dir/foo index index ' -test_expect_success PERL 'git restore -p --source=HEAD' ' - set_state dir/foo work index && - # the third n is to get out in case it mistakenly does not apply - test_write_lines n y n | git restore -p --source=HEAD && - verify_saved_state bar && - verify_state dir/foo head index -' +for opt in "HEAD" "@" +do + test_expect_success "git restore -p --source=$opt" ' + set_state dir/foo work index && + # the third n is to get out in case it mistakenly does not apply + test_write_lines n y n | git restore -p --source=$opt >output && + verify_saved_state bar && + verify_state dir/foo head index && + test_grep "Discard" output + ' +done test_expect_success PERL 'git restore -p --source=HEAD^' ' set_state dir/foo work index && diff --git a/t/t7105-reset-patch.sh b/t/t7105-reset-patch.sh index 05079c7246..7147148138 100755 --- a/t/t7105-reset-patch.sh +++ b/t/t7105-reset-patch.sh @@ -33,6 +33,16 @@ test_expect_success PERL 'git reset -p' ' test_grep "Unstage" output ' +for opt in "HEAD" "@" +do + test_expect_success "git reset -p $opt" ' + test_write_lines n y | git reset -p $opt >output && + verify_state dir/foo work head && + verify_saved_state bar && + test_grep "Unstage" output + ' +done + test_expect_success PERL 'git reset -p HEAD^' ' test_write_lines n y | git reset -p HEAD^ >output && verify_state dir/foo work parent && From patchwork Tue Feb 6 22:50:39 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ghanshyam Thakkar X-Patchwork-Id: 13547900 Received: from mail-pj1-f48.google.com (mail-pj1-f48.google.com [209.85.216.48]) (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 0D6CA1C68F for ; Tue, 6 Feb 2024 22:58:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.48 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707260337; cv=none; b=FFC+0d0XpvPKVraB3AA0DyzXElKorJh1w9SOzFZ1ImSiGpslgGfEw9xWSfjGgmw6x/M07ywhcGv8hQ2A57Ayy7NDxTd4fxAr/0Fdpu5nI7j+Na+Ay+Zjrf+UKJlm7GZIeojvhEej4I9AghDae/CHsyz1nlzEVnufj41GXulgt3s= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707260337; c=relaxed/simple; bh=6ec2bdsuTMuroQ4E35vXOtkIaYmz3t7UIlvaNBg/Ljc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=A+OyVdmObaZw9arIxoJgX+FTtMq4Ff+3vUXlZE3wQQPuyzIrQfC0caVNlNW4LLd6OKy+BRewPYsrPzAMlKK8iCEZPL1ANMsZq/HXag/kQsQzl7PBb9+wTYXt+FJgSwzX2DevC1Qe08bGnlwf4wyQRuii+3SnzKnEZ2j1ghzBrDE= 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=bTBRYiUe; arc=none smtp.client-ip=209.85.216.48 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="bTBRYiUe" Received: by mail-pj1-f48.google.com with SMTP id 98e67ed59e1d1-2909978624eso906a91.1 for ; Tue, 06 Feb 2024 14:58:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1707260335; x=1707865135; 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=hNLUdmy/+b5Lm/CfOkIR8ER/NgOrIBatIucmGzVtfHk=; b=bTBRYiUe/8n0+Ch66zW4XtlvNFK8mz2YinyHoWjcKPBVxB0G5b37snY+hKUSGQNrSU IWko+629TJOtwCgyE7j0CiWTnegVrGtwIcG9bVVTfC6EgN/6aJlKVQyCWkdUgHRVcOCX MBBURvPZKmCAawKNu3JwKIOSJrMutYnCUXXEqmvz/8UHS8lAA6APoBMke0ad2pZrrGx7 EFmmusY8enrAIl3mgTJzUhWRabqA/Wuyb3ovBUYw0eilvhhnCK0Dt4Ngy8cuAbCWng+5 32/MJBGuRRF2gMRuTPgiEuXTGifZYVjG/8LLWtvvPhaZUoqjt1SjXkbk9+rBuqgMLUz3 22fw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707260335; x=1707865135; 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=hNLUdmy/+b5Lm/CfOkIR8ER/NgOrIBatIucmGzVtfHk=; b=vCFO6/dIpvUTvgp4IQsAfFXhfnZXkwwuJ4zerhYRUZJj6fSgV2F/3p4WTThx0oXHFG fDkEY+RRYsQt1YqARDVqQWAocv1wIWho/tboCTx0JUIeuznba6WpisEil+Hn3hAUheIr 1xK5BiUfNXdBoFi/LZFSo5RwkPoyLuOJ1nyPDwgWMZOeh/Q80dm9z8r4Do3G8GdZXDGE y7YwwQ0N1R9WA4yMFxy+B6JwUt33Yt/FFDGDmF66SwWE0dGpwWwG5VUBTp8MtLGYGqmO pcvhvE+sHgwKkYjCREOdQ/aAu5kJaJtM1ZqSfJTLoIzFpGMkQ+mGTSxofInudv4yTL3V qVpg== X-Gm-Message-State: AOJu0Ywk6dpKvWOnf1kbVdhURI5TpFU2/pWUeWc5hYh/3heqcm2T+58J mEhgZxP/YuL/OW8Zg6e5RmDUnJEPCjq/lWqDRKJ2JKXHcPHxufBblSXlTV1u X-Google-Smtp-Source: AGHT+IGDUhq4yLBMgzm+kzPfIs5fuz0ULPNfJcxft445O0AKXexqweuhQOVT+lhWSeBFj3cvXjHR0Q== X-Received: by 2002:a17:90b:ecc:b0:296:65c5:d69b with SMTP id gz12-20020a17090b0ecc00b0029665c5d69bmr1074809pjb.6.1707260334800; Tue, 06 Feb 2024 14:58:54 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCUR1enmdMu1du34f+MNZqBSvhP/v/wnJOs4rANvxIgdhMPuSvQbl+6+aPbxkvrW/x2ym6bGfm3XvERyhjJa91y6N/vk3p8Xp3HTpXvtKZ1tg8bjaILQECYQLEbzHCCEHMYv8dwrNDn9ojRYHczpk6A= Received: from localhost.localdomain ([2402:a00:401:a99b:f188:2dd3:d960:a8ab]) by smtp.gmail.com with ESMTPSA id x20-20020a17090aca1400b00290f9e8b4f9sm46741pjt.46.2024.02.06.14.58.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Feb 2024 14:58:54 -0800 (PST) From: Ghanshyam Thakkar To: git@vger.kernel.org Cc: gitster@pobox.com, phillip.wood123@gmail.com, ps@pks.im, Ghanshyam Thakkar Subject: [PATCH v4 3/3] add -p tests: remove Perl prerequisite Date: Wed, 7 Feb 2024 04:20:39 +0530 Message-ID: <20240206225122.1095766-7-shyamthakkar001@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240203112619.979239-2-shyamthakkar001@gmail.com> References: <20240203112619.979239-2-shyamthakkar001@gmail.com> Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 The Perl version of the add -i/-p commands has been removed since 20b813d (add: remove "add.interactive.useBuiltin" & Perl "git add--interactive", 2023-02-07) Therefore, Perl prerequisite in t2071-restore-patch and t7105-reset-patch is not necessary. Signed-off-by: Ghanshyam Thakkar --- t/t2071-restore-patch.sh | 26 +++++++++++++------------- t/t7105-reset-patch.sh | 22 +++++++++++----------- 2 files changed, 24 insertions(+), 24 deletions(-) diff --git a/t/t2071-restore-patch.sh b/t/t2071-restore-patch.sh index dbbefc188d..27e85be40a 100755 --- a/t/t2071-restore-patch.sh +++ b/t/t2071-restore-patch.sh @@ -4,7 +4,7 @@ test_description='git restore --patch' . ./lib-patch-mode.sh -test_expect_success PERL 'setup' ' +test_expect_success 'setup' ' mkdir dir && echo parent >dir/foo && echo dummy >bar && @@ -16,28 +16,28 @@ test_expect_success PERL 'setup' ' save_head ' -test_expect_success PERL 'restore -p without pathspec is fine' ' +test_expect_success 'restore -p without pathspec is fine' ' echo q >cmd && git restore -p dir/foo && echo dummy > bar && @@ -19,14 +19,14 @@ test_expect_success PERL 'setup' ' # note: bar sorts before foo, so the first 'n' is always to skip 'bar' -test_expect_success PERL 'saying "n" does nothing' ' +test_expect_success 'saying "n" does nothing' ' set_and_save_state dir/foo work work && test_write_lines n n | git reset -p && verify_saved_state dir/foo && verify_saved_state bar ' -test_expect_success PERL 'git reset -p' ' +test_expect_success 'git reset -p' ' test_write_lines n y | git reset -p >output && verify_state dir/foo work head && verify_saved_state bar && @@ -43,28 +43,28 @@ do ' done -test_expect_success PERL 'git reset -p HEAD^' ' +test_expect_success 'git reset -p HEAD^' ' test_write_lines n y | git reset -p HEAD^ >output && verify_state dir/foo work parent && verify_saved_state bar && test_grep "Apply" output ' -test_expect_success PERL 'git reset -p HEAD^^{tree}' ' +test_expect_success 'git reset -p HEAD^^{tree}' ' test_write_lines n y | git reset -p HEAD^^{tree} >output && verify_state dir/foo work parent && verify_saved_state bar && test_grep "Apply" output ' -test_expect_success PERL 'git reset -p HEAD^:dir/foo (blob fails)' ' +test_expect_success 'git reset -p HEAD^:dir/foo (blob fails)' ' set_and_save_state dir/foo work work && test_must_fail git reset -p HEAD^:dir/foo && verify_saved_state dir/foo && verify_saved_state bar ' -test_expect_success PERL 'git reset -p aaaaaaaa (unknown fails)' ' +test_expect_success 'git reset -p aaaaaaaa (unknown fails)' ' set_and_save_state dir/foo work work && test_must_fail git reset -p aaaaaaaa && verify_saved_state dir/foo && @@ -76,27 +76,27 @@ test_expect_success PERL 'git reset -p aaaaaaaa (unknown fails)' ' # dir/foo. There's always an extra 'n' to reject edits to dir/foo in # the failure case (and thus get out of the loop). -test_expect_success PERL 'git reset -p dir' ' +test_expect_success 'git reset -p dir' ' set_state dir/foo work work && test_write_lines y n | git reset -p dir && verify_state dir/foo work head && verify_saved_state bar ' -test_expect_success PERL 'git reset -p -- foo (inside dir)' ' +test_expect_success 'git reset -p -- foo (inside dir)' ' set_state dir/foo work work && test_write_lines y n | (cd dir && git reset -p -- foo) && verify_state dir/foo work head && verify_saved_state bar ' -test_expect_success PERL 'git reset -p HEAD^ -- dir' ' +test_expect_success 'git reset -p HEAD^ -- dir' ' test_write_lines y n | git reset -p HEAD^ -- dir && verify_state dir/foo work parent && verify_saved_state bar ' -test_expect_success PERL 'none of this moved HEAD' ' +test_expect_success 'none of this moved HEAD' ' verify_saved_head '