Re:Magit, the magical Git interface (2017)
by NateEag on Friday October 22, 2021 @10:35AM
(#28957738)
Magit has great support for staging parts of lines - select the section you want to stage and press 's'.
[ Parent
| on HN ]
> Magit has great support for staging parts of lines
This is news to me.
> select the section you want to stage and press 's'.
It stages line-wise for me. How do I get it to stage less than an entire line?
Re:Magit, the magical Git interface (2017)
by fouric on Friday October 22, 2021 @11:42AM
(#28958601)
When your press 's', you should have a region selected, in order to stage that region - if your cursor is just sitting on a line without selecting part of it, you'll (probably) just get the whole line staged.
When I press s, the entire line is staged even if my region is a subset of that line.
Re:Magit, the magical Git interface (2017)
by NateEag on Friday October 22, 2021 @09:36PM
(#28964842)
...huh. I just tested this in my Emacs instance and it works as you describe.
I could swear I remember this working in the past, but I can find no hint of it in a few quick searches, so I'm likely mistaken.
I'm sorry for the misinformation.Thanks for saying something.
Re:Magit, the magical Git interface (2017)
by PaulDavisThe1st on Friday October 22, 2021 @11:22AM
(#28958365)
The second line you quoted tells you how.
It does not. As I said, pressing s does not stage less than a line for me, even if my region is a subset of the line.
Re:Magit, the magical Git interface (2017)
by gpderetta on Friday October 22, 2021 @11:47AM
(#28958654)
When selecting only part of line, 's' will still stage the full line for me.
Indeed.
cd $(mktemp -d)
git init
echo bar > file.txt
git add file.txt
git commit -m "init"
echo foo_bar_baz > file.txt
# select only "foo_" in magit-status and press "s"
git diff --cached
will show diff --git a/file.txt b/file.txt
index 5716ca5..2fd000c 100644
--- a/file.txt
+++ b/file.txt
@@ -1 +1,2 @@
bar
+foo_bar_baz
rather than the desired diff --git a/file.txt b/file.txt
index 5716ca5..2fd000c 100644
--- a/file.txt
+++ b/file.txt
@@ -1 +1,2 @@
-bar
+foo_bar
I can't really imagine this feature working that well with just selection. Editing of the diff seems required.I just updated magit, too. It seems to have been published 3 days ago.
Re:Magit, the magical Git interface (2017)
by NateEag on Friday October 22, 2021 @09:37PM
(#28964848)
..huh. I just tested this in my Emacs instance and it works as you describe.
I could swear I remember this working in the past, but I can find no hint of it in a few quick searches, so I'm likely mistaken.
I'm sorry for the misinformation. Thanks for saying something.