diff options
author | Jeff King <peff@peff.net> | 2012-07-10 16:40:29 -0400 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2012-07-10 14:16:41 -0700 |
commit | ea2d4ed35902ce15959965ab86d80527731a177c (patch) | |
tree | 4512fb08e9c98c699f40e59a1fbbe8002ce54ea1 /t | |
parent | Git 1.7.0.8 (diff) | |
download | tgif-ea2d4ed35902ce15959965ab86d80527731a177c.tar.xz |
commit: fix "--amend --only" with no pathspec
When we do not have any pathspec, we typically disallow an
explicit "--only", because it makes no sense (your commit
would, by definition, be empty). But since 6a74642
(git-commit --amend: two fixes., 2006-04-20), we have
allowed "--amend --only" with the intent that it would amend
the commit, ignoring any contents staged in the index.
However, while that commit allowed the combination, we never
actually implemented the logic to make it work. The current
code notices that we have no pathspec and assumes we want to
do an as-is commit (i.e., the "--only" is ignored).
Instead, we must make sure to follow the partial-commit
code-path. We also need to tweak the list_paths function to
handle a NULL pathspec.
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't')
-rwxr-xr-x | t/t7501-commit.sh | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/t/t7501-commit.sh b/t/t7501-commit.sh index 7940901d47..e1181f0979 100755 --- a/t/t7501-commit.sh +++ b/t/t7501-commit.sh @@ -88,6 +88,16 @@ test_expect_success \ "amend commit" \ "EDITOR=./editor git commit --amend" +test_expect_success 'amend --only ignores staged contents' ' + cp file file.expect && + echo changed >file && + git add file && + git commit --no-edit --amend --only && + git cat-file blob HEAD:file >file.actual && + test_cmp file.expect file.actual && + git diff --exit-code +' + test_expect_success \ "passing -m and -F" \ "echo 'enough with the bongos' >file && \ |