From: Pratyush Yadav <me@yadavpratyush.com>
To: Birger Skogeng Pedersen <birger.sp@gmail.com>
Cc: git@vger.kernel.org
Subject: Re: [PATCH 1/2] git-gui: implement proc select_path_in_widget
Date: Mon, 14 Oct 2019 01:51:10 +0530 [thread overview]
Message-ID: <20191013202110.z3gyx7eikackvmzb@yadavpratyush.com> (raw)
In-Reply-To: <20191007171145.1259-1-birger.sp@gmail.com>
Hi Birger,
Your subject is a bit redundant. A reader of this commit can easily see
the diff and know that you implemented "proc select_path_in_widget".
What's more important is why you implemented it. That is what should go
in the commit message. So for example in this patch, you can say
something like:
git-gui: move last clicked path selection logic to a separate function
This same logic will be used elsewhere in a follow-up commit, so make
it re-useable.
This is what I came up with at first thought. Maybe something even
better and concise can say the same thing.
On 07/10/19 07:11PM, Birger Skogeng Pedersen wrote:
> Signed-off-by: Birger Skogeng Pedersen <birger.sp@gmail.com>
> ---
> git-gui.sh | 32 +++++++++++++++++++-------------
> 1 file changed, 19 insertions(+), 13 deletions(-)
>
> diff --git a/git-gui.sh b/git-gui.sh
> index fd476b6..b7f4d1e 100755
> --- a/git-gui.sh
> +++ b/git-gui.sh
> @@ -2669,25 +2669,31 @@ proc show_less_context {} {
> }
>
> proc focus_widget {widget} {
> - global file_lists last_clicked selected_paths
> - global file_lists_last_clicked
> + global file_lists
>
> if {[llength $file_lists($widget)] > 0} {
> - set path $file_lists_last_clicked($widget)
> - set index [lsearch -sorted -exact $file_lists($widget) $path]
> - if {$index < 0} {
> - set index 0
> - set path [lindex $file_lists($widget) $index]
> - }
> -
> + select_path_in_widget $widget
> focus $widget
> - set last_clicked [list $widget [expr $index + 1]]
> - array unset selected_paths
> - set selected_paths($path) 1
> - show_diff $path $widget
There is a change in the order of events here. Earlier, we first
focussed the widget, and then ran `show_diff`. Now we first run
`show_diff` (via `select_path_in_widget`), and then focus the widget.
This won't cause any problems, right?
> }
> }
>
> +proc select_path_in_widget {widget} {
> + global file_lists last_clicked selected_paths
> + global file_lists_last_clicked
> +
> + set path $file_lists_last_clicked($widget)
> + set index [lsearch -sorted -exact $file_lists($widget) $path]
> + if {$index < 0} {
> + set index 0
> + set path [lindex $file_lists($widget) $index]
> + }
> +
> + set last_clicked [list $widget [expr $index + 1]]
> + array unset selected_paths
> + set selected_paths($path) 1
> + show_diff $path $widget
> +}
> +
> proc toggle_commit_type {} {
> global commit_type_is_amend
> set commit_type_is_amend [expr !$commit_type_is_amend]
Other than that, looks good. There isn't much changed here. Just some
code moved around.
--
Regards,
Pratyush Yadav
next prev parent reply other threads:[~2019-10-13 20:21 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-09-14 12:24 git-gui: automatically move focus to staged file before typing commit message? Birger Skogeng Pedersen
2019-09-14 21:15 ` Pratyush Yadav
2019-09-14 21:26 ` Johannes Sixt
2019-09-14 21:27 ` Pratyush Yadav
2019-09-15 7:55 ` Birger Skogeng Pedersen
2019-09-16 18:01 ` Pratyush Yadav
2019-09-26 18:33 ` Birger Skogeng Pedersen
2019-09-26 19:30 ` Pratyush Yadav
2019-09-26 21:17 ` Birger Skogeng Pedersen
2019-10-07 16:52 ` Birger Skogeng Pedersen
2019-10-07 17:11 ` [PATCH 1/2] git-gui: implement proc select_path_in_widget Birger Skogeng Pedersen
2019-10-07 17:11 ` [PATCH 2/2] git-gui: select staged on ui_comm focus Birger Skogeng Pedersen
2019-10-16 19:25 ` Pratyush Yadav
2019-10-13 20:21 ` Pratyush Yadav [this message]
2019-10-15 10:51 ` [PATCH 1/2] git-gui: implement proc select_path_in_widget Birger Skogeng Pedersen
2019-10-16 19:28 ` Pratyush Yadav
2019-10-17 5:08 ` Birger Skogeng Pedersen
2019-10-17 5:33 ` Johannes Sixt
2019-10-17 6:54 ` Birger Skogeng Pedersen
2019-10-17 18:28 ` Pratyush Yadav
2019-10-08 17:59 ` git-gui: automatically move focus to staged file before typing commit message? Pratyush Yadav
2019-10-08 19:46 ` Birger Skogeng Pedersen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20191013202110.z3gyx7eikackvmzb@yadavpratyush.com \
--to=me@yadavpratyush.com \
--cc=birger.sp@gmail.com \
--cc=git@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).