[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#52349: 29.0.50; vc-git and diff-mode: stage hunks
From: |
Juri Linkov |
Subject: |
bug#52349: 29.0.50; vc-git and diff-mode: stage hunks |
Date: |
Mon, 12 Sep 2022 21:19:41 +0300 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (x86_64-pc-linux-gnu) |
>> + (if (string-search file-diff vc-git-patch-string)
>> + (setq vc-git-patch-string
>> + (string-replace file-diff "" vc-git-patch-string))
>
> Not sure I understand this part. We're replacing some text (the diff file
> header) with empty text in the patch string? But not the whole hunk?
Actually it replaces the whole new/deleted file differences.
> It might work if we removed the whole hunk as well, but we need to make
> sure that the staged contents for that file are exactly the same as what is
> contained for that file in vc-git-patch-string.
This is exactly what this patch does.
> Perhaps if we called diff-file-next in addition to (move-beginning-of-line
> 1)?
diff-file-next doesn't work: it stops in the middle of the diff file header.
Therefore the patch navigates git diff file headers explicitly.
> But we need to save both strings: and ensure that if there is a match
> for that file header, then all hunks are contained in the patch as well
> (and nothing extra, for that file).
This is implemented by the patch. Maybe it could help you to see how it works
by running it under debugger and stepping through it.
> It's complex logic, so if you manage to write a test as well, that would be
> excellent.
A test could written when someone will create infrastructure for testing
git commands with helpers to create a git repository and checking its content.
- bug#52349: 29.0.50; vc-git and diff-mode: stage hunks, Juri Linkov, 2022/09/08
- bug#52349: 29.0.50; vc-git and diff-mode: stage hunks, Sean Whitton, 2022/09/08
- bug#52349: 29.0.50; vc-git and diff-mode: stage hunks, Dmitry Gutov, 2022/09/09
- bug#52349: 29.0.50; vc-git and diff-mode: stage hunks, Juri Linkov, 2022/09/11
- bug#52349: 29.0.50; vc-git and diff-mode: stage hunks, Dmitry Gutov, 2022/09/11
- bug#52349: 29.0.50; vc-git and diff-mode: stage hunks,
Juri Linkov <=
- bug#52349: 29.0.50; vc-git and diff-mode: stage hunks, Dmitry Gutov, 2022/09/18
- bug#52349: 29.0.50; vc-git and diff-mode: stage hunks, Juri Linkov, 2022/09/19
- bug#52349: 29.0.50; vc-git and diff-mode: stage hunks, Dmitry Gutov, 2022/09/19