What is the proper way to stage / unstage specific lines in a diff? [message #1853155] |
Mon, 20 June 2022 21:39  |
Eclipse User |
|
|
|
Hello,
Is there a way in Jgit to take a diff like so
--- a/src/test/kotlin/state/GitDownStateSpec.kt
+++ b/src/test/kotlin/state/GitDownStateSpec.kt
@@ -16,8 +16,9 @@
val git: Git,
) {
+
fun addFile(filename: String, content: String) = this.also {
- val path = this.dir.toString() + "/" + filename
+ val path = this.dir.toString() + "/" + filename
File(path).also { file -> file.parentFile.mkdirs() }.writeText("Foo")
}
@@ -51,7 +52,6 @@
fun closeGitDownState() = this.also {
GitDownState.git.value.close()
}
-
}
fun createTestRepository() =
And specify that I want to stage two specific lines of the first hunk and one line of the second hunk?
Is there a way to do the inverse looking at a staged diff?
Using git, I believe these would be achieved by
git add -p
and
git reset -p
although interactively, which is not what I want.
[Updated on: Mon, 20 June 2022 22:26] by Moderator
|
|
|
|
Re: What is the proper way to stage / unstage specific lines in a diff? [message #1853383 is a reply to message #1853370] |
Thu, 30 June 2022 03:12  |
Eclipse User |
|
|
|
Staging/unstaging are operations that modify the blob stored in the git index. If you stage a whole file, the file content is run through the clean and CRLF filters, and then stored in the index. Unstaging a whole file runs the blob in the index through the smudge and crlf filters, and replaces the file in the file system with that.
If you want to stage/unstage individual lines, you have to do the same, but instead of replacing the whole blob/file you'll have to update both by inserting/deleting the appropriate lines.
|
|
|
Powered by
FUDForum. Page generated in 0.07112 seconds