From patchwork Tue Feb 23 01:10:33 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matheus Tavares X-Patchwork-Id: 12099693 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 36C2AC433E0 for ; Tue, 23 Feb 2021 01:11:41 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id EA39764E32 for ; Tue, 23 Feb 2021 01:11:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230310AbhBWBLb (ORCPT ); Mon, 22 Feb 2021 20:11:31 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55842 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229863AbhBWBLa (ORCPT ); Mon, 22 Feb 2021 20:11:30 -0500 Received: from mail-qt1-x831.google.com (mail-qt1-x831.google.com [IPv6:2607:f8b0:4864:20::831]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A6AA4C06174A for ; Mon, 22 Feb 2021 17:10:49 -0800 (PST) Received: by mail-qt1-x831.google.com with SMTP id w6so3344369qti.6 for ; Mon, 22 Feb 2021 17:10:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=usp.br; s=usp-google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=ruYFxjqcS/4yQR/z2Ny8ID736SH3S4b4FkF5EydICTo=; b=aCa/uP7VGSZpz/ikEn/SFveYTVXNw9MVl9aPoFZgDo4r1rTrc2ygXm9CbmKV+31XeV 6pv22p1IvjoU0F3p5eoHyHa7gLvTGJ+XhZNBAUig0MB2bjPE2Sf3k9fymo9EYw8dngxs RGE10t1zn9+CUFk7HIJTuB0NFz/S550FnHymVXqxFAc6X4zYIBmrDZQRlDqwVnuhUqqT WNnnftGqJ3qgk1KGkAYvXGy5CKKWdDBx11wnU9PJV6QVhu/uicaxE1LInvzUSX+fvWN5 bQcV2J+WTUW13OxWm8gUH+Js+oJo7TdjFZXw/CbRylo/0ld1pKkGEPo8FmF/hCLuLT6p ucTA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ruYFxjqcS/4yQR/z2Ny8ID736SH3S4b4FkF5EydICTo=; b=Kit8Hoq6dfOzYGHL2XssiploE/O7AWGxtglU1RlddjP1eWlIH1xWww72NOynwKp355 PXr8ddfwOl1DYyRu/azsEwYzVnlwHwxXbWU73vS1RS73oqYVoGY2C4cdNDHNQo2VefwQ KdUMmioQdc12cxEPzBJytAS2v9nrO7OwqYMblcIlLIqxxpIghx+IkSVgG9gwA0LiMmar xDJX0+7sJ0rr8GhbfQL5LZPLrz4cLIR+KjbCLmKo5cAaQPzlLEkJjOgUOkSxuJwcfxBZ 4chDnEsslta6GtJIv36vUutRL5vdBGtwvUVpZAjQKD6DO6MYs92mKFJPX9dWG88U2vOb iReQ== X-Gm-Message-State: AOAM533dnFjU+AgHztX/+TBBJgV57ZOvH/utuAL77XpXnkBEkxI6s38g P27kvd0vPEE5OQeXpDQV+PJhTH1eYLO+SA== X-Google-Smtp-Source: ABdhPJxo9SK7vkNn2FwpDKmLJlQaRRLF4hnQJkbx+YdyCCNnW6mopdyYDce1pG+6C4B5fMUiw5a2bQ== X-Received: by 2002:ac8:ace:: with SMTP id g14mr22118087qti.156.1614042648513; Mon, 22 Feb 2021 17:10:48 -0800 (PST) Received: from mango.meuintelbras.local ([177.32.118.149]) by smtp.gmail.com with ESMTPSA id v75sm13599070qkb.14.2021.02.22.17.10.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Feb 2021 17:10:48 -0800 (PST) From: Matheus Tavares To: git@vger.kernel.org Cc: gitster@pobox.com, newren@gmail.com Subject: [PATCH 1/3] add --chmod: don't update index when --dry-run is used Date: Mon, 22 Feb 2021 22:10:33 -0300 Message-Id: <8ca9ba0d7f1e6efb04cae5c2ff00c9c9af50362d.1614037664.git.matheus.bernardino@usp.br> X-Mailer: git-send-email 2.30.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org `git add --chmod` applies the mode changes even when `--dry-run` is used. Fix that and add some tests for this option combination. Helped-by: Junio C Hamano Signed-off-by: Matheus Tavares --- builtin/add.c | 12 +++++++++--- t/t3700-add.sh | 20 ++++++++++++++++++++ 2 files changed, 29 insertions(+), 3 deletions(-) diff --git a/builtin/add.c b/builtin/add.c index a825887c50..1e33ab81f2 100644 --- a/builtin/add.c +++ b/builtin/add.c @@ -38,17 +38,23 @@ struct update_callback_data { int add_errors; }; -static void chmod_pathspec(struct pathspec *pathspec, char flip) +static void chmod_pathspec(struct pathspec *pathspec, char flip, int show_only) { int i; for (i = 0; i < active_nr; i++) { struct cache_entry *ce = active_cache[i]; + int err; if (pathspec && !ce_path_match(&the_index, ce, pathspec, NULL)) continue; - if (chmod_cache_entry(ce, flip) < 0) + if (!show_only) + err = chmod_cache_entry(ce, flip); + else + err = S_ISREG(ce->ce_mode) ? 0 : -1; + + if (err < 0) fprintf(stderr, "cannot chmod %cx '%s'\n", flip, ce->name); } } @@ -609,7 +615,7 @@ int cmd_add(int argc, const char **argv, const char *prefix) exit_status |= add_files(&dir, flags); if (chmod_arg && pathspec.nr) - chmod_pathspec(&pathspec, chmod_arg[0]); + chmod_pathspec(&pathspec, chmod_arg[0], show_only); unplug_bulk_checkin(); finish: diff --git a/t/t3700-add.sh b/t/t3700-add.sh index b7d4ba608c..fc81f2ef00 100755 --- a/t/t3700-add.sh +++ b/t/t3700-add.sh @@ -386,6 +386,26 @@ test_expect_success POSIXPERM 'git add --chmod=[+-]x does not change the working ! test -x foo4 ' +test_expect_success 'git add --chmod honors --dry-run' ' + git reset --hard && + echo foo >foo4 && + git add foo4 && + git add --chmod=+x --dry-run foo4 && + test_mode_in_index 100644 foo4 +' + +test_expect_success 'git add --chmod --dry-run reports error for non regular files' ' + git reset --hard && + test_ln_s_add foo foo4 && + git add --chmod=+x --dry-run foo4 2>stderr && + grep "cannot chmod +x .foo4." stderr +' + +test_expect_success 'git add --chmod --dry-run reports error for unmatched pathspec' ' + test_must_fail git add --chmod=+x --dry-run nonexistent 2>stderr && + test_i18ngrep "pathspec .nonexistent. did not match any files" stderr +' + test_expect_success 'no file status change if no pathspec is given' ' >foo5 && >foo6 && From patchwork Tue Feb 23 01:10:34 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matheus Tavares X-Patchwork-Id: 12099695 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 27184C433E0 for ; Tue, 23 Feb 2021 01:11:58 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E583164E31 for ; Tue, 23 Feb 2021 01:11:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230426AbhBWBLl (ORCPT ); Mon, 22 Feb 2021 20:11:41 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55848 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229863AbhBWBLb (ORCPT ); Mon, 22 Feb 2021 20:11:31 -0500 Received: from mail-qt1-x831.google.com (mail-qt1-x831.google.com [IPv6:2607:f8b0:4864:20::831]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 77129C061786 for ; Mon, 22 Feb 2021 17:10:51 -0800 (PST) Received: by mail-qt1-x831.google.com with SMTP id r24so1902373qtt.8 for ; Mon, 22 Feb 2021 17:10:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=usp.br; s=usp-google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=AV30jvg19iiOQp5i8GIiqK0WZIwnIM0Qoe0MlTFkSmk=; b=VH+di2mWMX1HoEDsTEHGfEq/RxAed47nOqXq58RtNrroifLFzOmJsyxsM6+kqfRNJ4 GfyUTtNM9jTzVWjMzLzURGNvQBANJWIa5Cv3A7J5N98VhP2/myEFEoxKUr9dEKuouOF+ HPlvVuIRKYUDNsrcHoSq+DOV3EAvK0oXxYTjysyavZV8SdVjlnTPcJE4ANxs3mmNVU8p e14gDSgu/n76docYz6S9P4oHFVvY7hccvgXjb6yzjto42XgBReD7sWYPtu4xUr0QTKDY wzIM0I6z0TRfntTQhj/4vAFvHHHpsiMWvxQfw1U7/+wvdglNPhx8KAZ1qvXVHQrNCsVQ sr2g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=AV30jvg19iiOQp5i8GIiqK0WZIwnIM0Qoe0MlTFkSmk=; b=nHR62fgoWxVkbJExWdrd77ds4tdHu5A+JvQdp0aNhuz24+ZRYsx5+9n2d+AIHUnmtK HSUK/QmjKcM/EAztrhzD0Ro6VweEf4DafAWKFuB6swFZ3JCJolt6Zt0uNsTFpJ5Y/XZM 0Nxz0hvMgZIWZydw3PMIBI8QJwv4T/u8OM5j0Xve8ooE5FXj99Ot8PE5/O9s7iibX6O/ ipjsK6kM8I4gbetrfiIjKwt5UrrMbchpKWHJmieIMyiZdl4/niNZ6BUQ4Vm3ntfRh7gz YD8TuuimTxYf+ci3zj2xFll0mIVgWZq1dwxIAUNfhtBUpDWF9N0OCmz0o2LP7oU9Cdc+ nwPg== X-Gm-Message-State: AOAM5327IG+xTGffqDe9mtHH1P7hP4smF1Xjs/MCx6YUXCo3iU4nSOyC iZ8Zy084d1bCFs7AjKzo9GpKCsTlrQ1h+A== X-Google-Smtp-Source: ABdhPJxwpD82dmEBqfNQ7iQbdhaX3XyTTlV6OHEztg2VnDTxNy7bWVz29EYTu1SShlRETFWm767auA== X-Received: by 2002:ac8:74d2:: with SMTP id j18mr7143662qtr.28.1614042650323; Mon, 22 Feb 2021 17:10:50 -0800 (PST) Received: from mango.meuintelbras.local ([177.32.118.149]) by smtp.gmail.com with ESMTPSA id v75sm13599070qkb.14.2021.02.22.17.10.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Feb 2021 17:10:49 -0800 (PST) From: Matheus Tavares To: git@vger.kernel.org Cc: gitster@pobox.com, newren@gmail.com Subject: [PATCH 2/3] add: mark --chmod error string for translation Date: Mon, 22 Feb 2021 22:10:34 -0300 Message-Id: X-Mailer: git-send-email 2.30.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org This error message is intended for humans, so mark it for translation. Also use error() instead of fprintf(stderr, ...), to make the corresponding line a bit cleaner, and to display the "error:" prefix, which helps classifying the nature/severity of the message. Signed-off-by: Matheus Tavares --- builtin/add.c | 2 +- t/t3700-add.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/builtin/add.c b/builtin/add.c index 1e33ab81f2..0c5f53c0bb 100644 --- a/builtin/add.c +++ b/builtin/add.c @@ -55,7 +55,7 @@ static void chmod_pathspec(struct pathspec *pathspec, char flip, int show_only) err = S_ISREG(ce->ce_mode) ? 0 : -1; if (err < 0) - fprintf(stderr, "cannot chmod %cx '%s'\n", flip, ce->name); + error(_("cannot chmod %cx '%s'"), flip, ce->name); } } diff --git a/t/t3700-add.sh b/t/t3700-add.sh index fc81f2ef00..6a8b94a4f7 100755 --- a/t/t3700-add.sh +++ b/t/t3700-add.sh @@ -398,7 +398,7 @@ test_expect_success 'git add --chmod --dry-run reports error for non regular fil git reset --hard && test_ln_s_add foo foo4 && git add --chmod=+x --dry-run foo4 2>stderr && - grep "cannot chmod +x .foo4." stderr + test_i18ngrep "cannot chmod +x .foo4." stderr ' test_expect_success 'git add --chmod --dry-run reports error for unmatched pathspec' ' From patchwork Tue Feb 23 01:10:35 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matheus Tavares X-Patchwork-Id: 12099697 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A7F2FC433E6 for ; Tue, 23 Feb 2021 01:11:59 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 67EE764E2E for ; Tue, 23 Feb 2021 01:11:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230437AbhBWBLn (ORCPT ); Mon, 22 Feb 2021 20:11:43 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55860 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230352AbhBWBLd (ORCPT ); Mon, 22 Feb 2021 20:11:33 -0500 Received: from mail-qk1-x730.google.com (mail-qk1-x730.google.com [IPv6:2607:f8b0:4864:20::730]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 80E9CC06178A for ; Mon, 22 Feb 2021 17:10:53 -0800 (PST) Received: by mail-qk1-x730.google.com with SMTP id x14so14783111qkm.2 for ; Mon, 22 Feb 2021 17:10:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=usp.br; s=usp-google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=TbO1zt/X+JGd8omuGI7GLSIVH48owqp2UOkHxbgbu7k=; b=vR2YMJRQNO+yWYIeJL4xmwmps4ktRv5aK5P5KsLOTXOzC5AedYaxugGyZRqkkdkKqp vrYqu4UQ5RocvH3FhGgOWDSvMBTQf/D5ZbX34LZT/Rp2Tb0Yf5hQBPPgN9wQt+Pe4TVp LxrxmvY4itVh5ES/kuHnESDONE/XCs7d8x4QTMV16L5oR/lvDPC+YcJmoJYjvmbq2xep FsoUKmr6fkdzlKD5nLsiaTu8g6yOPSBlAVuqM0uwsP8NuEcqSCeu1Ft+nR2KCMHZsHwk 0vBkykEhinqZqCS9H3FNEgocu0yn+lVMkyaIV1/VbHva3W0jKiesGgPYvEM8lLOqKbZ8 H5hA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=TbO1zt/X+JGd8omuGI7GLSIVH48owqp2UOkHxbgbu7k=; b=YswA/jyGSDgClCIYuOohFCVoAaYcMyAhMoWnrWd9GyuBDRvnSrLBZnPlTQ6b2/tW7M 5DjEY13f5aV5Lf3oru8EO97wKH1InjG7V/F/GYLqIOyFDy67B/o/THabMtvPldj2R/dH sPBAq/cGyH9HPSCtuY+I+XwmkUgqsrJ/cpakYQvrv4sjwTrhgxi40hbwugsNdBK/ztDK eRaahI0JSP54wg42bzeeUSKSst5g5HgvCvu63I/BajrpO9tNRAVGYMITOnWCDDughZYr tGCp6pSGO1AagmlbyWUXbZHWxdyzS+fehaPKuVqBh8d85m6wiLGqEDUPXv3+u3ffUF6G hx4A== X-Gm-Message-State: AOAM532jnJfRbDtp1sbtK4mILVGDybCsRr8j56/H07oXPkzXkYvWV7lO jOhwFYUgsfkjuA5Qsvp4gKt/oG3VAsQi2A== X-Google-Smtp-Source: ABdhPJxt+ndb7UCH0hwphh3rPIvY3Tkozc17Ins5oFsM/FqWTL3h76060bWyyEWai1Iq4cdHQxobsg== X-Received: by 2002:a05:620a:20ce:: with SMTP id f14mr21164727qka.163.1614042652257; Mon, 22 Feb 2021 17:10:52 -0800 (PST) Received: from mango.meuintelbras.local ([177.32.118.149]) by smtp.gmail.com with ESMTPSA id v75sm13599070qkb.14.2021.02.22.17.10.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Feb 2021 17:10:51 -0800 (PST) From: Matheus Tavares To: git@vger.kernel.org Cc: gitster@pobox.com, newren@gmail.com Subject: [PATCH 3/3] add: propagate --chmod errors to exit status Date: Mon, 22 Feb 2021 22:10:35 -0300 Message-Id: X-Mailer: git-send-email 2.30.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org If `add` encounters an error while applying the --chmod changes, it prints a message to stderr, but exits with a success code. This might have been an oversight, as the command does exit with a non-zero code in other situations where it cannot (or refuses to) update all of the requested paths (e.g. when some of the given paths are ignored). So make the exit behavior more consistent by also propagating --chmod errors to the exit status. Note: the test "all statuses changed in folder if . is given" uses paths added by previous test cases, some of which might be symbolic links. Because `git add --chmod` will now fail with such paths, this test would depend on whether all the previous tests were executed, or only some of them. Avoid that by running the test on a fresh repo with only regular files. Signed-off-by: Matheus Tavares --- builtin/add.c | 10 ++++++---- t/t3700-add.sh | 28 ++++++++++++++++++++++------ 2 files changed, 28 insertions(+), 10 deletions(-) diff --git a/builtin/add.c b/builtin/add.c index 0c5f53c0bb..ea762a41e3 100644 --- a/builtin/add.c +++ b/builtin/add.c @@ -38,9 +38,9 @@ struct update_callback_data { int add_errors; }; -static void chmod_pathspec(struct pathspec *pathspec, char flip, int show_only) +static int chmod_pathspec(struct pathspec *pathspec, char flip, int show_only) { - int i; + int i, ret = 0; for (i = 0; i < active_nr; i++) { struct cache_entry *ce = active_cache[i]; @@ -55,8 +55,10 @@ static void chmod_pathspec(struct pathspec *pathspec, char flip, int show_only) err = S_ISREG(ce->ce_mode) ? 0 : -1; if (err < 0) - error(_("cannot chmod %cx '%s'"), flip, ce->name); + ret = error(_("cannot chmod %cx '%s'"), flip, ce->name); } + + return ret; } static int fix_unmerged_status(struct diff_filepair *p, @@ -615,7 +617,7 @@ int cmd_add(int argc, const char **argv, const char *prefix) exit_status |= add_files(&dir, flags); if (chmod_arg && pathspec.nr) - chmod_pathspec(&pathspec, chmod_arg[0], show_only); + exit_status |= chmod_pathspec(&pathspec, chmod_arg[0], show_only); unplug_bulk_checkin(); finish: diff --git a/t/t3700-add.sh b/t/t3700-add.sh index 6a8b94a4f7..d402c775c0 100755 --- a/t/t3700-add.sh +++ b/t/t3700-add.sh @@ -386,6 +386,16 @@ test_expect_success POSIXPERM 'git add --chmod=[+-]x does not change the working ! test -x foo4 ' +test_expect_success 'git add --chmod fails with non regular files (but updates the other paths)' ' + git reset --hard && + test_ln_s_add foo foo3 && + touch foo4 && + test_must_fail git add --chmod=+x foo3 foo4 2>stderr && + test_i18ngrep "cannot chmod +x .foo3." stderr && + test_mode_in_index 120000 foo3 && + test_mode_in_index 100755 foo4 +' + test_expect_success 'git add --chmod honors --dry-run' ' git reset --hard && echo foo >foo4 && @@ -397,7 +407,7 @@ test_expect_success 'git add --chmod honors --dry-run' ' test_expect_success 'git add --chmod --dry-run reports error for non regular files' ' git reset --hard && test_ln_s_add foo foo4 && - git add --chmod=+x --dry-run foo4 2>stderr && + test_must_fail git add --chmod=+x --dry-run foo4 2>stderr && test_i18ngrep "cannot chmod +x .foo4." stderr ' @@ -429,11 +439,17 @@ test_expect_success 'no file status change if no pathspec is given in subdir' ' ' test_expect_success 'all statuses changed in folder if . is given' ' - rm -fr empty && - git add --chmod=+x . && - test $(git ls-files --stage | grep ^100644 | wc -l) -eq 0 && - git add --chmod=-x . && - test $(git ls-files --stage | grep ^100755 | wc -l) -eq 0 + git init repo && + ( + cd repo && + mkdir -p sub/dir && + touch x y z sub/a sub/dir/b && + git add -A && + git add --chmod=+x . && + test $(git ls-files --stage | grep ^100644 | wc -l) -eq 0 && + git add --chmod=-x . && + test $(git ls-files --stage | grep ^100755 | wc -l) -eq 0 + ) ' test_expect_success CASE_INSENSITIVE_FS 'path is case-insensitive' '