Skip to content

yesno_dialog #20

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 189 commits into
base: js/ask-yesno
Choose a base branch
from
Draft

yesno_dialog #20

wants to merge 189 commits into from

Conversation

mark987
Copy link
Contributor

@mark987 mark987 commented Aug 1, 2025

Tk provides tk_dialog that is compatible across 8.6 and 9.0 and handles git-gui--askyesno requirements. The latter is not compatible with Tk 9.0, so let's use tk_dialog.

Note: this is a single commit on top of js/ask-yesno, the latter is not merged to master. I'm leaving this as a draft, the commit should probably be cherry-picked, and as I'm not using g4w and experiencing the need for this dialog, more testing is needed that I cannot really provide. This does work for me on Linux invoked from the command line on Tcl 8.6, 8.7, and 9.0.

tomyy and others added 30 commits October 1, 2019 19:10
Git for Windows 2.x ships with an executable that starts the Git Bash
with all the environment variables and what not properly set up. It is
also adjusted according to the Terminal emulator option chosen when
installing Git for Windows (while `bash.exe --login -i` would always
launch with Windows' default console).

So let's use that executable (usually C:\Program Files\Git\git-bash.exe)
instead of `bash.exe --login -i` if its presence was detected.

This fixes git-for-windows/git#490

Signed-off-by: Thomas Kläger <[email protected]>
Signed-off-by: Johannes Schindelin <[email protected]>
Signed-off-by: Pratyush Yadav <[email protected]>
git-gui will now use git-bash instead of bash on Windows, if it is
available.

* js/git-bash-if-available:
  git-gui (Windows): use git-bash.exe if it is available
Replace the hand-coded call to git check-attr with the already provided one.

Signed-off-by: Bert Wesarg <[email protected]>
Signed-off-by: Pratyush Yadav <[email protected]>
This adds highlight support for the diff3 conflict style.

The common pre-image will be reversed to --, because it has been removed
and replaced with ours or theirs side respectively.

Signed-off-by: Bert Wesarg <[email protected]>
Signed-off-by: Pratyush Yadav <[email protected]>
git-gui now highlights diff3 style conflicts properly. As an auxiliary
change, querying a path's attribute is done via the existing interface
instead of hand-rolling the code.

* bw/diff3-conflict-style:
  git-gui: support for diff3 conflict style
  git-gui: use existing interface to query a path's attribute
It is a good idea to have a readme so people finding the project can
know more about it, and know how they can get involved.

Signed-off-by: Pratyush Yadav <[email protected]>
Acked-by: Bert Wesarg <[email protected]>
Add a readme to introduce people finding the repo to the project.

* py/readme:
  git-gui: add a readme
Signed-off-by: kdnakt <[email protected]>
Signed-off-by: Pratyush Yadav <[email protected]>
Improve Japanese translation.

* ka/japanese-translation:
  git-gui: improve Japanese translation
A few variables in this file use camelCase, while the overall standard
is snake_case. A consistent naming scheme will improve readability of
future changes. To avoid mixing naming changes with semantic changes,
this commit contains only naming changes.

Signed-off-by: Jonathan Gilbert <[email protected]>
Signed-off-by: Pratyush Yadav <[email protected]>
Update the status bar to track updates as individual "operations" that
can overlap. Update all call sites to interact with the new status bar
mechanism. Update initialization to explicitly clear status text,
since otherwise it may persist across future operations.

Signed-off-by: Jonathan Gilbert <[email protected]>
Signed-off-by: Pratyush Yadav <[email protected]>
Update the revert_helper proc to check for untracked files as well as
changes, and then handle changes to be reverted and untracked files with
independent blocks of code. Prompt the user independently for untracked
files, since the underlying action is fundamentally different (rm -f).
If after deleting untracked files, the directory containing them becomes
empty, then remove the directory as well. Migrate unlocking of the index
out of _close_updateindex to a responsibility of the caller, to permit
paths that don't directly unlock the index, and refactor the error
handling added in d4e890e so that callers can make flow control
decisions in the event of errors. Update Tcl/Tk dependency from 8.4 to
8.6 in git-gui.sh.

A new proc delete_files takes care of actually deleting the files in
batches, using the Tcler's Wiki recommended approach for keeping the UI
responsive.

Since the checkout_index and delete_files calls are both asynchronous
and could potentially complete in any order, a "chord" is used to
coordinate unlocking the index and returning the UI to a usable state
only after both operations are complete. The `SimpleChord` class,
based on TclOO (Tcl/Tk 8.6), is added in this commit.

Signed-off-by: Jonathan Gilbert <[email protected]>
Signed-off-by: Pratyush Yadav <[email protected]>
git-gui learned to delete untracked files when the "Revert Changes"
option is selected. Since there are two types of revert operations (one
for tracked files and one for untracked ones), the "checkout" and
"deletion" operations are done in parallel. The status bar is updated
to allow both to use it in parallel.

* jg/revert-untracked:
  git-gui: revert untracked files by deleting them
  git-gui: update status bar to track operations
  git-gui: consolidate naming conventions
After "git checkout -b '漢字'" to create a branch with UTF-8 character
in it, "git gui" shows the branch name incorrectly, as it forgets to
turn the bytes read from the "git for-each-ref" and read from "HEAD"
file into Unicode characters.

Signed-off-by: Kazuhiro Kato <[email protected]>
Signed-off-by: Pratyush Yadav <[email protected]>
Fix UTF-8 refnames not displaying properly because the encoding was not
set to UTF-8.

* kk/branch-name-encoding:
  git gui: fix branch name encoding error
This gives users a quick shortcut to close the window. But since the
window can also show commands in progress, closing the window on Escape
can give the perception that the command has been cancelled even though
it hasn't been. So, only enable this binding when the command is done.

Signed-off-by: Pratyush Yadav <[email protected]>
Allow closing console window with Escape once the command is completed.

* py/console-close-esc:
  git-gui: allow closing console window with Escape
Many times there's the need to quickly open a source file (the one you're
looking at in Git GUI) in the predefined text editor / IDE. Of course,
the file can be searched for in your preferred file manager or directly
in the text editor, but having the option to directly open the current
file from Git GUI would be just faster. This change enables just that by:
 - clicking the diff header path (which is now highlighted as a hyperlink)
 - or diff header path context menu -> Open

Note: executable files will be run and not opened for editing.

Signed-off-by: Zoli Szabó <[email protected]>
Signed-off-by: Pratyush Yadav <[email protected]>
Allow opening the currently selected file in its default app by clicking
on its name.

* zs/open-current-file:
  git-gui: allow opening currently selected file in default app
… code

No content changes so far, only the preparation for subsequent edits.

Signed-off-by: Christian Stimming <[email protected]>
Signed-off-by: Pratyush Yadav <[email protected]>
The English glossary template was missing some terms, some of them
not only for git-gui, but also gitk and/or git core. Many such terms
have been added.

Also, the list has been sorted alphabetically so that comparison to
other glossary lists are easier.

Signed-off-by: Christian Stimming <[email protected]>
Signed-off-by: Pratyush Yadav <[email protected]>
Update German translation (glossary and final translation) with
recent additions, but also switch several terms from uncommon
translations back to English vocabulary.

This most prominently concerns "commit" (noun, verb), "repository",
"branch", and some more. These uncommon translations have been introduced
long ago and never been changed since. In fact, the whole German
translation here hasn't been touched for a long time. However, in German
literature and magazines, git-gui is regularly noted for its uncommon
choice of translated vocabulary. This somewhat distracts from the actual
benefits of this tool. So it is probably better to abandon the uncommon
translations and rather stick to the common English vocabulary in git
version control.

Signed-off-by: Christian Stimming <[email protected]>
Signed-off-by: Pratyush Yadav <[email protected]>
Update the German translation and extend glossary.

* cs/german-translation:
  git-gui: update German translation
  git-gui: extend translation glossary template with more terms
  git-gui: update pot template and German translation to current source code
In d9c6469 (git-gui: update status bar to track operations, 2019-12-01),
the status bar was refactored to allow multiple overlapping operations.

Since the refactor changed the status bar interface, all callsites had
to be refactored to use the new interface. During that refactoring, this
closing bracket was missed. This leads to an error message popping up
when doing 'Branch->Reset...'.

Signed-off-by: Pratyush Yadav <[email protected]>
Fix an error popping up because of an unmatched closed bracket.

* py/missing-bracket:
  git-gui: add missing close bracket
In d9c6469 (git-gui: update status bar to track operations, 2019-12-01)
the call to 'ui_status' in 'do_gitk' was updated to create the newly
introduced "status bar operation". This allowed this status text to show
along with other operations happening in parallel, and removed a race
between all these operations.

But in that refactor, the fact that 'ui_status' checks for the existence
of 'main_status' was overlooked. This leads to an error message popping
up when the user selects "Show History Context" from the blame window
context menu on a source line. The error occurs because when running
"blame" 'main_status' is not initialized.

So, add a check for the existence of 'main_status' in 'do_gitk'. This
fix reverts to the original behaviour. In the future, we might want to
look into a better way of telling 'do_gitk' which status bar to use.

Signed-off-by: Pratyush Yadav <[email protected]>
Fixes an error popup in blame because of a missing closing bracket.

* py/blame-status-error:
  git-gui: fix error popup when doing blame -> "Show History Context"
This addresses the issue where Git for Windows asks the user for a
password, no credential helper is available, and then Git fails to pick
up non-ASCII characters from the Git GUI helper.

This can be verified e.g. via

	echo host=http://abc.com |
	git -c credential.helper= credential fill

and then pasting some umlauts.

The underlying reason is that Git for Windows tries to communicate using
the UTF-8 encoding no matter what the actual current code page is. So
let's indulge Git for Windows and do use that encoding.

This fixes git-for-windows/git#2215

Signed-off-by: Luke Bonanomi <[email protected]>
Helped-by: Junio C Hamano <[email protected]>
Signed-off-by: Johannes Schindelin <[email protected]>
Signed-off-by: Pratyush Yadav <[email protected]>
Askpass can now send non-ASCII to Git on Windows.

* js/askpass-coerce-utf8:
  git-gui--askpass: coerce answers to UTF-8 on Windows
On some MacOS distributions like High Sierra, Tcl 8.5 is shipped by
default. This makes git-gui error out at startup because of the version
mismatch.

The only part that requires Tcl 8.6 is SimpleChord, which depends on
TclOO. So, don't use it and use our homegrown class.tcl instead.

This means some slight syntax changes. Since class.tcl doesn't have an
"unknown" method like TclOO does, we can't just call '$note', but have
to use '$note activate' instead. The constructor now needs a proper
namespace qualifier. Update the documentation to reflect the new syntax.

As of now, the only part of git-gui that needs Tcl 8.5 is a call to
'apply' in lib/index.tcl::lambda. Keep using it until someone shows up
shouting that their OS ships with 8.4 only. Then we would have to look
into implementing it in pure Tcl.

Signed-off-by: Pratyush Yadav <[email protected]>
mark987 and others added 29 commits July 18, 2025 16:33
git-gui includes code to implement ls-files for git versions prior to
1.63 that did not know --exclude-standard. But, git-gui now requires git
version >= 2.36, so remove the obsolete code.

Signed-off-by: Mark Levedahl <[email protected]>
git-gui asks for submodule info only on git-versions >=1.72, which
introduced such capability. But, git-gui requires git version >= 2.36,
so this alternate code path is obsolete. Remove it.

Signed-off-by: Mark Levedahl <[email protected]>
git-gui relies upon the files back-end to determine the current branch.
This does not support the newer reftables backend.  But, git-branch has
long supported --show-current to get this same information regardless of
backend cahnged.  So teach git-gui to use git-branch --show-current.

Signed-off-by: Mark Levedahl <[email protected]>
git-gui has its own code to determine the worktree root for git-versions
earlier than 1.7.0, where git rev-parse learned this function.  git-gui
requires git v2.36 or later, so delete the now obsolete alternate code.

Signed-off-by: Mark Levedahl <[email protected]>
git-gui uses alternate code paths for git versions < 1.7.2, avoiding use
of --ignore-all-space and textconv. git-gui requires git v2.36 or later,
so this alternate code is obsolete. Remove it.

Signed-off-by: Mark Levedahl <[email protected]>
git-gui's diff functions avoid using textconv filters on git < 1.6.1, or
asking about submodules on version before 1.7.2, but git-gui requires
git >= v2.36.  So, remove this now obsolete code.

Signed-off-by: Mark Levedahl <[email protected]>
git-gui's merge driver includes code to invoke the recursive strategy
for merging prior to git v2.5 that added a simpler syntax. As git-gui
requires git v2.36 or later, let's delete the code targeting earlier
git.

Signed-off-by: Mark Levedahl <[email protected]>
git-gui checks for git version >= 1.6.6 before enabling the remotes
menu. But git-gui requires git v2.36 or later, so git-remote is always
available.  Delete this check and always enable the menu.

Signed-off-by: Mark Levedahl <[email protected]>
When creating a new repository, git-gui creates a directory, cds to it,
then runs git-init, but git-init learned to create and initialize the
directory in 1.6.5. git-gui requires git version >= 2.36, so teach
git-gui to use git-init's full capability.

Signed-off-by: Mark Levedahl <[email protected]>
git-version supports choosing different bodies of code passed into it,
rather than using the more traditional if/else construct typically used.
The only use of git-version in this mode was by its author in 2007, and
that code has been deleted.  So, delete this now unused function that
was mostly ignored.

Signed-off-by: Mark Levedahl <[email protected]>
git-gui has remnant code to allow some drawing with Tk 8.4 predating the
addition of themed widgets. As git-gui requires Tk >= 8.6, this code can
never trigger. Remove it.

Signed-off-by: Mark Levedahl <[email protected]>
Since commit c80d7be, git-gui checks for the availability of ttk
before enabling its use, but this check is redundant as Tk >= 8.6 is
required.  Remove the redundant check.

Signed-off-by: Mark Levedahl <[email protected]>
git-gui optionally uses themed ui elements from ttk, but the full set of
ttk ui elements is always available with Tk 8.6.  Keeping code making
ttk use optional increases maintenance burden for no benefit.  Let's use
ttk always, allowing removal of alternate code paths in subsequent
patches.

Signed-off-by: Mark Levedahl <[email protected]>
git-gui uses ${NS} to switch between non-themed and themed widgets, with
${NS} == 'ttk' selecting the latter. As git-gui now always uses ttk,
this indirection is not needed. Remove it.

Signed-off-by: Mark Levedahl <[email protected]>
git-gui on Windows prepends three directories to PATH so does not honor
PATH as configured. This can have undesirable consequences, for instance
by preventing use of a different git for testing.  This also provides at
best a subset of the configuration included with Git for Windows (g4w),
so is neither necessary nor sufficient there.

Since commit be700fe, git-gui.sh adds its directory to the front of
PATH: this is essentially adding $(git --execdir) to the path, this is
long deprecated as git moved to using "dashless" subcommands.

The windows/git-gui.sh wrapper file, since commit 99fe594, adds two
directories relative to its installed location to PATH, and does so
without checking that either exists or is needed.

The above modifications were made before the Git For Windows project
took responsibility for distributing a working solution on Windows. g4w
assures a correct configuration on Windows without these, and doing so
requires more than the above modifications.  See [1] for a more thorough
treatment.

git-gui does not modify PATH on any platform except on Windows, and
doing so is not needed by g4w.  Let's stop modifying PATH on Windows as
well.

[1] https://gitforwindows.org/git-wrapper.html

Signed-off-by: Mark Levedahl <[email protected]>
git-gui runs blame and diff commands with nice by default. On Unix, nice
is accepted if found and it will run git. Commit ff9db6c ("On
Windows, avoid git-gui to call Cygwin's nice utility", 2010-10-05)
rejects nice if not collocated with git. In Git for Windows' (g4w) POSIX
path name space, nice and git are found in different directories:

	$ which git
	/mingw64/bin/git
	$ which nice
	/usr/bin/nice

Thus, git-gui will not use nice in the supported Windows configuration.
Commit ff9db6c justifies the collocation requirement as avoiding
problems in a mixed MSYS and Cygwin configuration: such configurations
are not supported by either project as they are known to cause many
problems.

So, let's revert ff9db6c and let git-gui work correctly in the
supported configuration.

Signed-off-by: Mark Levedahl <[email protected]>
git-gui invokes the tk_getSaveFile dialog to determine the full
path-name of the shortcut file to create. But, on Windows, this dialog
always dereferences a shortcut (.lnk) file, as this is essentially a
soft-link to its target. If the shortcut file already exists, the dialog
returns the path-name of the target (i.e., GIT/cmd/git-gui.exe), and not
the desired shortcut file selected by the user.

There is no Windows file chooser available in Tcl/Tk that does not
dereference .lnk files, so this patch avoids using a dialog: the
shortcut to be created is on the desktop and named as "Git + Repository
Name". If this .lnk file already exists, the user must give permission
to overwrite it or the process terminates.

Signed-off-by: Mark Levedahl <[email protected]>
git-gui has code paths to support older non-ttk widgets, but this code
is no longer reachable as ttk is always used. Remove that code.

Signed-off-by: Mark Levedahl <[email protected]>
git-gui clones a repository by invoking git-plumbing commands, in proc
do_clone, rather than using git-clone.  The justification was that the
low-level commands are guaranteed to provide a stable interface, while
the higher level commands such as git-clone may not be stable. This
approach requires git-gui to continually evolve by mirroring new
features in git itself, which has not happened, while the user interface
in git-clone has proven very stable. Also, git-gui does directly call
many other non-plumbing commands in git's repertoire.

do_clone's last significant functionality change was in 2015, and
updates are required for shallow clones, the reftable backend, cloning
from linked worktrees, and perhaps other features and bugs. For
instance, I had reports of git-gui failing to correctly clone
repositories prior to 2015, resulting in essentially the patch given
here. The only significant work was supporting .gitfile linked worktrees
unknown to do_clone, but supported by git-clone, and none regarding the
interface to git-clone itself. That interface is clearly stable enough
to not be a problem.

Supporting new use-cases with this requires exposing new options in the
clone dialog, then passing flags to git-clone. This avoids updating
do_clone to understand those options, reducing the maintenance burdens.

So, teach git-gui to use git-clone.  This change is in one patch as
there is no obvious incremental path to migration. The existing dialog /
options / status screen are unchanged, the known user-visible changes
are that cloning from a working directory linked by a gitfile now works,
there is no auto-fallback to a full copy when cloning linked workdirs
and worktrees (meaning git-clone fails unless a full or shared copy is
selected), and messages displayed are from git-clone.

Signed-off-by: Mark Levedahl <[email protected]>
git-gui's default clone method is git-clone's default, and this uses
hardlinks rather than copying the objects directory for local
repositories. However, this method explicitly fails if a symlink (or
.gitfile) exists in the path to the objects directory. Thus, the default
clone option fails for worktrees created by git-new-workdir or
git-worktree.  git-gui's original do_clone trapped this error for a
symlinked git-new-workdir tree, directly falling back to a full clone,
while the updated git-gui using git-clone does not. (The old do_clone
could not handle gitfile linked worktrees, however).

Let's apply the more friendly fallback to a full clone in both these
cases where git-clone behavior throws an error on the default method.

Signed-off-by: Mark Levedahl <[email protected]>
git-gui implements its own approach to locating and running various git
subcommands, bypassing git's capabilities for running git-*.  This was
written in 2007: at that time, many git commands were shell-scripts
stored in $(git --exec-path), git's run-command api was not well adapted
to Windows and had serious performance issues when it worked at all, and
running subcommand 'git foo' as 'git-foo' was common and fully supported.

On Windows, git-gui searches $(git --exec-path) for builtin commands,
then attempts to find an interpreter on PATH to run those, invoking
these differently than on other platforms. For instance, the explicit
shebang #!/usr/bin/perl found in a script will be run by the first Perl
interpreter found on $PATH, which might not be at that specific location
so could be different than what git would run.

The various issues leading to the current implemention no longer exist.
Most git commands are now builtins, links to run those are not installed
in $(git --exec-path) by default (the "dashless" form is recommended
instead), and git's run-command api works well everywhere.

So, let's use git to launch its subcommands on all platforms.  Do so by
modifying procs git_read and git_write to use the "dashless" form for
invoking git commands, avoiding the search for git-<foo>. This leaves
_git_cmd unused with cleanup in a later patch.

Signed-off-by: Mark Levedahl <[email protected]>
gitexec looks up and caches the method to execute git subcommands using
the long deprecated dashed form if found in $(git--exec-path). But,
git_read and git_write now use the dashless form, by-passing gitexec.
This leaves two remaining uses of gitexec: one during startup to define
use of an ssh_key helper, and one in the about dialog box. These are
neither performance critical nor likely to be called more than once, so
do not justify an otherwise unused cacheing system.

Let's change those two uses, making gitexec unused. This allows removing
gitexec and _git_cmd.

Signed-off-by: Mark Levedahl <[email protected]>
git-gui has _search_exe as needed to give the executable suffix
(.exe) on Windows. But, the prior commit eliminated the only user of
this variable. Delete it.

Signed-off-by: Mark Levedahl <[email protected]>
git-gui on Windows creates a shortcut that presumes the git-gui script
will run on the basic Windows environment as configured. But, Git for
Windows uses wrapper scripts to launch executables, assuring the
environment is correct (see [1] for details). The launcher for git-gui
is /cmd/git-gui.exe, is not on PATH, and is not detected or used by the
current shortcut code. Let's look for this before trying the existing
approaches.

[1] https://gitforwindows.org/git-wrapper.html

Signed-off-by: Mark Levedahl <[email protected]>
* ml/tcl86:
  git-gui: remove non-ttk code
  git-gui: remove ${NS} indirection for ttk
  git-gui: always use themed widgets from ttk
  git-gui: remove redundant check for Tk >= 8.5
  git-gui: remove unreachable Tk 8.4 code
  git-gui: Make TclTk 8.6 the minimum, allow 8.7

Signed-off-by: Johannes Sixt <[email protected]>
* ml/abandon-old-versions:
  git-gui: eliminate _search_exe
  git-gui: remove procs gitexec and _git_cmd
  git-gui: use dashless 'git cmd' form for read/write
  git-gui: default to full copy for linked worktrees
  git-gui: use git-clone
  git-gui: remove unused git-version
  git-gui: use git_init to create new repository dir
  git-gui: git-remote is always available
  git-gui: git merge understands --strategy=recursive
  git-gui: git-diff knows submodules and textconv
  git-gui: git-blame understands -w and textconv
  git-gui: git rev-parse knows show_toplevel
  git-gui: use git-branch --show-current
  git-gui: git-diff-index always knows submodules
  git-gui: git ls-files knows --exclude-standard
  git-gui: require git >= 2.36

Signed-off-by: Johannes Sixt <[email protected]>
* ml/windows-tie-loose-ends:
  git-gui: use /cmd/git-gui.exe for shortcut
  git-gui: Windows tk_getSaveFile is not useful for shortcuts
  git-gui: let nice work on Windows
  git-gui: do not add directories to PATH on Windows

Signed-off-by: Johannes Sixt <[email protected]>
git-gui's proposed command-line dialog script relies upon Tk 8.5'ish
constructs and is incompatible with Tcl 9.0. This dialog is hand crafted
from several widgets, while Tk provides tk_dialog that handles the need
here, and is fully supported in Tk 8.6 and 9.0. So, let's switch to
that.

Signed-off-by: Mark Levedahl <[email protected]>
@j6t
Copy link
Owner

j6t commented Aug 1, 2025

I carry the js/ask-yesno topic in my testing tree only as a courtesy. I have no intent to move it forward, but would rather eject it if it hinders testing other topics on Tcl/Tk 9. I took it from gitgitgadget/git#358. Any improvements should be done there or submitted as PR here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.