Re: BUG: `git commit` adding unstaged chunks of files to commits on 2.33.0
From: Junio C Hamano <hidden>
Date: 2021-08-31 19:25:57
Andrew Thorp [off-list ref] writes:
quoted
git commit" without pathspec would have made a partial commit thatrecords only the changes that were added with "git add -p" to the index, though. Yeah, that was the expected behavior, but not what I experienced.
Sorry but it does not reproduce for me. Here is my "reproduction recipe", designed to be followable by anybody who has a copy of git and this piece of e-mail without referencing anything else. $ edit Makefile ; git diff Makefile
diff --git i/Makefile w/Makefile
index 9573190f1d..6bf8f3147b 100644
--- i/Makefile
+++ w/Makefile@@ -1,4 +1,4 @@ -# The default target of this Makefile is... +# The default target of this Makefile is..... all:: # Define V=1 to have a more verbose compile.
@@ -30,7 +30,7 @@ all:: # Define USE_LIBPCRE if you have and want to use libpcre. Various # commands such as log and grep offer runtime options to use # Perl-compatible regular expressions instead of standard or extended -# POSIX regular expressions. +# POSIX regular expressions... # # Only libpcre version 2 is supported. USE_LIBPCRE2 is a synonym for # USE_LIBPCRE, support for the old USE_LIBPCRE1 has been removed.
... You can see that we have two changes to a single file now ... $ printf "y\nn\n" | git add -p >/dev/null $ git status -uno On branch test Changes to be committed: (use "git restore --staged <file>..." to unstage) modified: Makefile Changes not staged for commit: (use "git add <file>..." to update what will be committed) (use "git restore <file>..." to discard changes in working directory) modified: Makefile Untracked files not listed (use -u option to show untracked files) ... And tell "add -p" to add the first but not the second hunk. $ git commit -m test ... And commit. $ git status -uno On branch test Changes not staged for commit: (use "git add <file>..." to update what will be committed) (use "git restore <file>..." to discard changes in working directory) modified: Makefile no changes added to commit (use "git add" and/or "git commit -a") ... Then the working tree file stays dirty because the second hunk was not added. $ git diff
diff --git i/Makefile w/Makefile
index fe6d649c27..6bf8f3147b 100644
--- i/Makefile
+++ w/Makefile@@ -30,7 +30,7 @@ all:: # Define USE_LIBPCRE if you have and want to use libpcre. Various # commands such as log and grep offer runtime options to use # Perl-compatible regular expressions instead of standard or extended -# POSIX regular expressions. +# POSIX regular expressions... # # Only libpcre version 2 is supported. USE_LIBPCRE2 is a synonym for # USE_LIBPCRE, support for the old USE_LIBPCRE1 has been removed.
... just as we can see here. Of course, the first hunk is in the commit, as can be seen ehre $ git diff HEAD^ HEAD
diff --git a/Makefile b/Makefile
index 9573190f1d..fe6d649c27 100644
--- a/Makefile
+++ b/Makefile@@ -1,4 +1,4 @@ -# The default target of this Makefile is... +# The default target of this Makefile is..... all:: # Define V=1 to have a more verbose compile.