From: Jonathan Nieder <jrnieder@gmail.com>
To: Alexander Gladysh <agladysh@gmail.com>
Cc: git@vger.kernel.org
Subject: [PATCH/RFC] gitk: refresh index before checking for local changes
Date: Tue, 6 Apr 2010 19:43:53 -0500 [thread overview]
Message-ID: <20100407004353.GA11346@progeny.tock> (raw)
In-Reply-To: <n2kc6c947f61004061647ybb6c2f55zc70197362764ef8@mail.gmail.com>
Most git porcelain silently refreshes stat-dirty index entries. Teach
gitk to, too; this will make the behavior easier to understand when a
person makes a change to a file and then changes mind and restores the
old version in her editor of choice.
This patch does not change the ‘checkout’ code path, since it is
assumed that the index is already being cleaned in that case.
Testing is needed to check if this breaks operation with read-only
access to a repository.
Requested-by: Alexander Gladysh <agladysh@gmail.com>
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
---
Alexander Gladysh wrote:
> Jonathan Nieder wrote:
[some nonsense about configurability]
> That's fine as far as I'm concerned.
>
> The current behaviour is really annoying.
Maybe that could be added in the future. From testing this out,
refreshing unconditionally seems fast enough, at least.
gitk | 50 +++++++++++++++++++++++++++++++++++++++++---------
1 files changed, 41 insertions(+), 9 deletions(-)
diff --git a/gitk b/gitk
index 1f36a3e..2753446 100755
--- a/gitk
+++ b/gitk
@@ -375,7 +375,7 @@ proc start_rev_list {view} {
get_viewmainhead $view
}
if {$showlocalchanges && $viewmainheadid($view) ne {}} {
- interestedin $viewmainheadid($view) dodiffindex
+ interestedin $viewmainheadid($view) dorefreshindex
}
fconfigure $fd -blocking 0 -translation lf -eofchar {}
if {$tclencoding != {}} {
@@ -4974,9 +4974,9 @@ proc doshowlocalchanges {} {
if {$viewmainheadid($curview) eq {}} return
if {[commitinview $viewmainheadid($curview) $curview]} {
- dodiffindex
+ dorefreshindex
} else {
- interestedin $viewmainheadid($curview) dodiffindex
+ interestedin $viewmainheadid($curview) dorefreshindex
}
}
@@ -4992,6 +4992,42 @@ proc dohidelocalchanges {} {
incr lserial
}
+# spawn off a process to refresh the index
+proc dorefreshindex {} {
+ global lserial showlocalchanges isworktree vfilelimit curview
+
+ if {!$showlocalchanges || !$isworktree} return
+ incr lserial
+ set cmd "|git update-index --refresh -q"
+ if {$vfilelimit($curview) ne {}} {
+ set cmd [concat $cmd -- $vfilelimit($curview)]
+ }
+ set fd [open $cmd r]
+ fconfigure $fd -blocking 0
+ set i [reg_instance $fd]
+ filerun $fd [list readrefreshindex $fd $lserial $i]
+}
+
+# update-index --refresh -q finished?
+proc readrefreshindex {fd serial inst} {
+ global lserial
+
+ if {$serial != $lserial} {
+ stop_instance $inst
+ return 0
+ }
+ if {[gets $fd line] == 0} {
+ # ignore output
+ return 0
+ }
+ if {![eof $fd]} {
+ return 1
+ }
+ stop_instance $inst
+ dodiffindex
+ return 0
+}
+
# spawn off a process to do git diff-index --cached HEAD
proc dodiffindex {} {
global lserial showlocalchanges vfilelimit curview
@@ -7504,13 +7540,9 @@ proc getblobdiffs {ids} {
global git_version
set textconv {}
- if {[package vcompare $git_version "1.6.1"] >= 0} {
- set textconv "--textconv"
- }
+ set textconv "--textconv"
set submodule {}
- if {[package vcompare $git_version "1.6.6"] >= 0} {
- set submodule "--submodule"
- }
+ set submodule "--submodule"
set cmd [diffcmd $ids "-p $textconv $submodule -C --cc --no-commit-id -U$diffcontext"]
if {$ignorespace} {
append cmd " -w"
--
debian.1.7.0.3.1.469.g398f8
next prev parent reply other threads:[~2010-04-07 0:44 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-04-06 22:57 gitk pays too much attention to file timestamps Alexander Gladysh
2010-04-06 23:15 ` Markus Heidelberg
2010-04-06 23:36 ` Jonathan Nieder
2010-04-06 23:47 ` Alexander Gladysh
2010-04-07 0:43 ` Jonathan Nieder [this message]
2010-04-07 1:07 ` [PATCH/RFC] gitk: refresh index before checking for local changes Alexander Gladysh
2010-04-07 1:16 ` Jonathan Nieder
2010-04-07 2:21 ` A Large Angry SCM
2010-04-07 2:57 ` Jonathan Nieder
2010-04-07 5:47 ` Junio C Hamano
2010-04-07 11:21 ` A Large Angry SCM
2010-04-07 16:48 ` Avery Pennarun
2010-04-07 14:36 ` Jon Seymour
2010-04-06 23:58 ` gitk pays too much attention to file timestamps Avery Pennarun
2010-04-07 1:01 ` Jonathan Nieder
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20100407004353.GA11346@progeny.tock \
--to=jrnieder@gmail.com \
--cc=agladysh@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.
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 NNTP newsgroup(s).