gitui icon indicating copy to clipboard operation
gitui copied to clipboard

Allow selecting of multiple unstaged

Open AndreasBergmeier6176 opened this issue 2 years ago • 4 comments

Is your feature request related to a problem? Please describe. Currently reverting a lot of unstaged files is very slow since one cannot do "shift arrow" to mark multiple. So it seems you have to revert every single file on its own

Describe the solution you'd like Just like in the diff view it should be possible to mark multiple entries.

AndreasBergmeier6176 avatar Jan 10 '23 09:01 AndreasBergmeier6176

@extrawurst I would try to tackle this next. Is the biggest reason for me to switch back to git-gui currently.

AndreasBergmeier6176 avatar Jan 12 '23 14:01 AndreasBergmeier6176

@AndreasBergmeier6176 this is a rather big change for two reasons:

  1. before we add more functionality to the tree view we need to swap it out for the new component: https://github.com/extrawurst/gitui/blob/master/src/components/status_tree.rs#L22

  2. current revert/stage/unstage calls only take a single path pattern, same for the underlying libgit2 calls we make, they do not support an array and we need to make successive calls to the api to do what we want for each selected element and for this we need to support making this async with the whole progress bar shebang.

if you wanna tackle it lets tackle it iteratively and start with 1) first which deserve its own issue and a separate PR

extrawurst avatar Jan 12 '23 15:01 extrawurst

@extrawurst Can you create an Issue for 1) then so we can continue further discussion there?

EDIT: Have a working PR for 1) now: https://github.com/extrawurst/gitui/pull/1508

abergmeier avatar Jan 12 '23 21:01 abergmeier

@extrawurst Since 1) is nearly done, the next problem is 2).

As a reference, here is how git gui handles this: https://github.com/git/git/blob/a7caae2729742fc80147bca1c02ae848cb55921a/git-gui/lib/index.tcl#L428

Basically it calls in 25 file batches:

set fd [git_write checkout-index \
		--index \
		--quiet \
		--force \
		-z \
		--stdin \
		]
	fconfigure $fd \
		-blocking 0 \
		-buffering full \
		-buffersize 512 \
		-encoding binary \
		-translation binary
	fileevent $fd writable [list \
		write_checkout_index \
		$fd \
		$path_list \
		$total_cnt \
		$batch \
		$status_bar_operation \
		$after \
		$capture_error \
		]

The signature of git_checkout_index in libgit2 seems not too shabby.

One of the important things will be to change the code to introduce the concept of active. Thus active ∈ selection. I would implement selection now as a range that can be extended/shrunk by active and SHIFT.

Started implementing initial tests here: https://github.com/abergmeier/gitui/tree/multistatus

Probably best to extract the selection handling into a own library, IMO.

abergmeier avatar Jan 17 '23 18:01 abergmeier