claudiofreitas / stow

My configuration files (dotfiles)
1 stars 0 forks source link

Research automatic hunk splitting by unchanged line for `git add -p` #4

Open claudiofreitas opened 2 years ago

claudiofreitas commented 2 years ago

Recently I've learned about the command git add -p to stage the file by hunks instead of staging the whole file. I already used such feature in IntelliJ IDEA, but it is also possible to do via command line.

I would like to research if there is any git config option that given a file with changes such as

diff --git a/lorem b/lorem
index 1234567..9876543 abcdef7
--- a/lorem
+++ b/lorem
@@ -1,9 +1,9 @@
 Quisquam explicabo et iste voluptatibus rerum. 
-Voluptatibus iusto sit dolores. 
+Dignissimos iusto sit dolores. 
 Iure eum ut delectus. 
-Dolore nemo quia incidunt dignissimos quisquam. 
+Libero nemo quia incidunt dignissimos quisquam. 
 Quos eos sit officia libero deleniti minus dolor.

it would automatically display the change Voluptatibus -> Dignissimos in a hunk, and the next change Dolore -> Libero in the next hunk.

But because the number of unchanged lines in between (only 1, the one starting with Iure) is too small, it groups them into a single hunk.