diff options
author | Johannes Schindelin <johannes.schindelin@gmx.de> | 2019-11-15 11:11:17 +0000 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2019-11-18 11:18:30 +0900 |
commit | 76b743234c6d122d9e194556f6f94f61493094f6 (patch) | |
tree | 64e8f3e7bb97b60558bb7c3e5472fc36af5bcf60 /wt-status.h | |
parent | built-in add -i: implement the main loop (diff) | |
download | tgif-76b743234c6d122d9e194556f6f94f61493094f6.tar.xz |
built-in add -i: show unique prefixes of the commands
Just like in the Perl script `git-add--interactive.perl`, for each
command a unique prefix is determined (if there exists any within the
given parameters), and shown in the list, and accepted as a shortcut for
the command.
To determine the unique prefixes, as well as to look up the command in
question, we use a copy of the list and sort it.
While this might seem like overkill for a single command, it will make
much more sense when all the commands are implemented, and when we reuse
the same logic to present a list of files to edit, with convenient
unique prefixes.
At the start of the development of this patch series, a dedicated data
structure was introduced that imitated the Trie that the Perl version
implements. However, this was deemed overkill, and we now simply sort
the list before determining the length of the unique prefixes by looking
at each item's neighbor. As a bonus, we now use the same sorted list to
perform a binary search using the user-provided prefix as search key.
Original-patch-by: Slavica Đukić <slawica92@hotmail.com>
Helped-by: SZEDER Gábor <szeder.dev@gmail.com>
Signed-off-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'wt-status.h')
0 files changed, 0 insertions, 0 deletions