From 34cb704a9b8b45ff3e1342678c5892e1ee6e27f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Steinbrink?= Date: Mon, 5 Nov 2007 20:36:33 +0100 Subject: [PATCH 1/2] git-commit.sh: Fix usage checks regarding paths given when they do not make sense MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The checks that looked for paths given to git-commit in addition to --all or --interactive expected only 3 values, while the case statement actually provides 4, so the check was never triggered. The bug was introduced in 6cbf07efc5702351897dee4742525c9b9f7828ac when the case statement was extended to handle --interactive. Signed-off-by: Björn Steinbrink Signed-off-by: Junio C Hamano --- git-commit.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/git-commit.sh b/git-commit.sh index ab43217be4..5e3908f2cb 100755 --- a/git-commit.sh +++ b/git-commit.sh @@ -322,9 +322,9 @@ unset only case "$all,$interactive,$also,$#" in *t,*t,*) die "Cannot use -a, --interactive or -i at the same time." ;; -t,,[1-9]*) +t,,,[1-9]*) die "Paths with -a does not make sense." ;; -,t,[1-9]*) +,t,,[1-9]*) die "Paths with --interactive does not make sense." ;; ,,t,0) die "No paths with -i does not make sense." ;; From 9d87442f03c9e3fea7e24e2821fc0342f8efe1d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Steinbrink?= Date: Mon, 12 Nov 2007 16:15:39 +0100 Subject: [PATCH 2/2] git-commit: Add tests for invalid usage of -a/--interactive with paths MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit git-commit was/is broken in that it accepts paths together with -a or --interactive, which it shouldn't. There tests check those usage errors. Signed-off-by: Björn Steinbrink Signed-off-by: Junio C Hamano --- t/t7501-commit.sh | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/t/t7501-commit.sh b/t/t7501-commit.sh index b151b51a34..7f25689bb7 100644 --- a/t/t7501-commit.sh +++ b/t/t7501-commit.sh @@ -33,6 +33,16 @@ test_expect_failure \ "invalid options 2" \ "git-commit -C HEAD -m illegal" +test_expect_failure \ + "using paths with -a" \ + "echo King of the bongo >file && + git-commit -m foo -a file" + +test_expect_failure \ + "using paths with --interactive" \ + "echo bong-o-bong >file && + echo 7 | git-commit -m foo --interactive file" + test_expect_failure \ "using invalid commit with -C" \ "git-commit -C bogus"