gitui-org/gitui

Wrong patch when staged line by line, compared to other alternatives

Open

#1,416 建立於 2022年10月31日

在 GitHub 查看
 (8 留言) (1 反應) (0 負責人)Rust (721 fork)batch import
bughelp wantednostale

倉庫指標

Star
 (21,937 star)
PR 合併指標
 (平均合併 41天 9小時) (30 天內合併 6 個 PR)

描述

Describe the bug Wrong patch when line by line staging compared to using hunks or lazygit or git add -e.

To Reproduce Steps to reproduce the behavior:

  1. Create a empty repo
  2. Stage & commit this on a file:
struct Earth;

impl Earth {
	fn new() -> Self {
		Self
	}
}

struct Mars;

impl Mars {
	fn new() -> Self {
		Self
	}
}
  1. Update the file with this:
struct Earth;

impl Earth {
	fn new() -> Self {
		Self
	}
	fn into_mars(self) -> Mars {
		Mars
	}
}

struct Mars;

impl Mars {
	fn new() -> Self {
		Self
	}
	fn into_earth(self) -> Earth {
		Earth
	}
}
  1. Use gitui to just stage into_mars and its body
  2. Check the resulted patch with git diff --staged

Expected behavior I expect it to match other commands and tools.

Screenshots (source code is different from the example above as I recorded these before creating the issue) Using gitui: https://asciinema.org/a/dL8rEfpOHRQskpa7wmfVTJDQF Using lazygit: https://asciinema.org/a/z0iSujDQzZO24wr7qXjKNwTf2

Context (please complete the following information):

  • OS/Distro + Version: Windows 10 22H2
  • GitUI Version: 0.21.0
  • Rust version: 1.66.0-nightly

Additional context I don't know if this is actually an issue because I don't know much about git patches; but it looks like it corrupts(?) the patch.

貢獻者指南