]> git.ipfire.org Git - thirdparty/git.git/log
thirdparty/git.git
10 months agogit-gui: strip comments and consecutive empty lines from commit messages
Oswald Buddenhagen [Tue, 13 Aug 2024 09:06:30 +0000 (11:06 +0200)] 
git-gui: strip comments and consecutive empty lines from commit messages

This is also known as "washing". This is consistent with the behavior of
interactive git commit, which we should emulate as closely as possible
to avoid usability problems. This way commit message templates and
prepare hooks can be used properly, and comments from conflicted rebases
and merges are cleaned up without having to introduce special handling
for them.

Signed-off-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
Signed-off-by: Johannes Sixt <j6t@kdbg.org>
11 months agoMerge branch 'os/catch-rename'
Johannes Sixt [Sun, 7 Jul 2024 12:00:23 +0000 (14:00 +0200)] 
Merge branch 'os/catch-rename'

The problem can be reproduced on Linux with this sequence:

1. Run git gui from a terminal.
2. Edit the commit message and wait for at least 2 seconds.
3. Terminate the instance from the terminal, for example with Ctrl-C,
   to simulate crash. This leaves the file .git/GITGUI_BCK behind.
4. Start two instances of git gui &.

At this point the first instance can be closed (it renames
.git/GITGUI_BCK to .git/GITGUI_MSG), but the seconds brings an error
message about the absent file and cannot be closed thereafter and must
be killed from the command line.

The renaming that happens by the first instance is the correct action
and need not be repeated by the second instance. It is the correct
action to ignore the failed renaming.

On the other hand, the second instance could just edit the commit
message again, wait 2 seconds to write GITGUI_BCK, and then can be
closed without failing. At this point, since the user has edited the
message, it is again correct to preserve the edited version in
GITGUI_MSG.

* os/catch-rename:
  git-gui: fix inability to quit after closing another instance

11 months agogit-gui: fix inability to quit after closing another instance
Orgad Shaneh [Tue, 7 Feb 2023 07:43:17 +0000 (09:43 +0200)] 
git-gui: fix inability to quit after closing another instance

If you open 2 git gui instances in the same directory, then close one
of them and try to close the other, an error message pops up, saying:
'error renaming ".git/GITGUI_BCK": no such file or directory', and it
is no longer possible to close the window ever.

Fix by catching this error, and proceeding even if the file no longer
exists.

Signed-off-by: Orgad Shaneh <orgads@gmail.com>
12 months agoMerge branch 'pk/swedish-translation'
Johannes Sixt [Sun, 23 Jun 2024 08:25:57 +0000 (10:25 +0200)] 
Merge branch 'pk/swedish-translation'

* pk/swedish-translation:
  git-gui: sv.po: Update Swedish translation (576t0f0u)

12 months agoMerge branch 'bc/french-translation'
Johannes Sixt [Sun, 23 Jun 2024 08:25:41 +0000 (10:25 +0200)] 
Merge branch 'bc/french-translation'

* bc/french-translation:
  git-gui: po: fix typo in French "aperçu"

12 months agogit-gui: sv.po: Update Swedish translation (576t0f0u)
Peter Krefting [Thu, 26 Oct 2023 20:30:12 +0000 (21:30 +0100)] 
git-gui: sv.po: Update Swedish translation (576t0f0u)

Signed-off-by: Peter Krefting <peter@softwolves.pp.se>
Signed-off-by: Johannes Sixt <j6t@kdbg.org>
13 months agogit-gui: note the new maintainer
Johannes Sixt [Sat, 11 May 2024 14:45:57 +0000 (16:45 +0200)] 
git-gui: note the new maintainer

Pratyush Yadev has relinquished, and Johannes Sixt has taken over,
maintainership of Git-GUI.

Signed-off-by: Johannes Sixt <j6t@kdbg.org>
13 months agoMakefile(s): do not enforce "all indents must be done with tab"
Junio C Hamano [Mon, 8 Apr 2024 23:36:05 +0000 (16:36 -0700)] 
Makefile(s): do not enforce "all indents must be done with tab"

Our top-level Makefile follows our generic whitespace rule
established by the top-level .gitattributes file that does not
enforce indent-with-non-tab rule by default, but git-gui is set up
to enforce indent-with-non-tab by default.  With the upcoming change
to GNU make, we no longer can reject (and worse, "fix") a patch that
adds whitespace indented lines to the Makefile, so loosen the rule
there for git-gui/Makefile, too.

[j6t: cherry-picked from 227b8fd90240]

Signed-off-by: Junio C Hamano <gitster@pobox.com>
Signed-off-by: Johannes Sixt <j6t@kdbg.org>
13 months agoMakefile(s): avoid recipe prefix in conditional statements
Taylor Blau [Mon, 8 Apr 2024 15:51:44 +0000 (11:51 -0400)] 
Makefile(s): avoid recipe prefix in conditional statements

In GNU Make commit 07fcee35 ([SV 64815] Recipe lines cannot contain
conditional statements, 2023-05-22) and following, conditional
statements may no longer be preceded by a tab character (which Make
refers to as the recipe prefix).

There are a handful of spots in our various Makefile(s) which will break
in a future release of Make containing 07fcee35. For instance, trying to
compile the pre-image of this patch with the tip of make.git results in
the following:

    $ make -v | head -1 && make
    GNU Make 4.4.90
    config.mak.uname:842: *** missing 'endif'.  Stop.

The kernel addressed this issue in 82175d1f9430 (kbuild: Replace tabs
with spaces when followed by conditionals, 2024-01-28). Address the
issues in Git's tree by applying the same strategy.

When a conditional word (ifeq, ifneq, ifdef, etc.) is preceded by one or
more tab characters, replace each tab character with 8 space characters
with the following:

    find . -type f -not -path './.git/*' -name Makefile -or -name '*.mak' |
      xargs perl -i -pe '
        s/(\t+)(ifn?eq|ifn?def|else|endif)/" " x (length($1) * 8) . $2/ge unless /\\$/
      '

The "unless /\\$/" removes any false-positives (like "\telse \"
appearing within a shell script as part of a recipe).

After doing so, Git compiles on newer versions of Make:

    $ make -v | head -1 && make
    GNU Make 4.4.90
    GIT_VERSION = 2.44.0.414.gfac1dc44ca9
    [...]

    $ echo $?
    0

[j6t: cherry-picked from 728b9ac0c3b9]

Reported-by: Dario Gjorgjevski <dario.gjorgjevski@gmail.com>
Signed-off-by: Taylor Blau <me@ttaylorr.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Signed-off-by: Johannes Sixt <j6t@kdbg.org>
13 months agodoc: switch links to https
Josh Soref [Fri, 24 Nov 2023 03:35:13 +0000 (03:35 +0000)] 
doc: switch links to https

These sites offer https versions of their content.
Using the https versions provides some protection for users.

[j6t: cherry-picked from d05b08cd52cf]

Signed-off-by: Josh Soref <jsoref@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Signed-off-by: Johannes Sixt <j6t@kdbg.org>
13 months agodoc: update links to current pages
Josh Soref [Fri, 24 Nov 2023 03:35:12 +0000 (03:35 +0000)] 
doc: update links to current pages

It's somewhat traditional to respect sites' self-identification.

[j6t: cherry-picked from 65175d9ea26b]

Signed-off-by: Josh Soref <jsoref@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Signed-off-by: Johannes Sixt <j6t@kdbg.org>
13 months agoMerge branch 'ml/git-gui-exec-path-fix'
Johannes Sixt [Sun, 5 May 2024 12:41:21 +0000 (14:41 +0200)] 
Merge branch 'ml/git-gui-exec-path-fix'

* ml/git-gui-exec-path-fix:
  git-gui - use git-hook, honor core.hooksPath
  git-gui - re-enable use of hook scripts

13 months agogit-gui: po: fix typo in French "aperçu"
brian m. carlson [Fri, 3 May 2024 20:14:52 +0000 (20:14 +0000)] 
git-gui: po: fix typo in French "aperçu"

The French word "aperçu", meaning "view" or "preview", contains only a
single letter "p".  Remove the extra letter, which is an obvious typo.

Reported-by: Léonard Michelet <leonard@lebasic.com>
Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
Signed-off-by: Johannes Sixt <j6t@kdbg.org>
21 months agogit-gui - use git-hook, honor core.hooksPath
Mark Levedahl [Sun, 17 Sep 2023 19:24:31 +0000 (15:24 -0400)] 
git-gui - use git-hook, honor core.hooksPath

git-gui currently runs some hooks directly using its own code written
before 2010, long predating git v2.9 that added the core.hooksPath
configuration to override the assumed location at $GIT_DIR/hooks.  Thus,
git-gui looks for and runs hooks including prepare-commit-msg,
commit-msg, pre-commit, post-commit, and post-checkout from
$GIT_DIR/hooks, regardless of configuration. Commands (e.g., git-merge)
that git-gui invokes directly do honor core.hooksPath, meaning the
overall behaviour is inconsistent.

Furthermore, since v2.36 git exposes its hook execution machinery via
`git-hook run`, eliminating the need for others to maintain code
duplicating that functionality.  Using git-hook will both fix git-gui's
current issues on hook configuration and (presumably) reduce the
maintenance burden going forward. So, teach git-gui to use git-hook.

Signed-off-by: Mark Levedahl <mlevedahl@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
21 months agogit-gui - re-enable use of hook scripts
Mark Levedahl [Sat, 16 Sep 2023 21:01:31 +0000 (17:01 -0400)] 
git-gui - re-enable use of hook scripts

Earlier, commit aae9560a introduced search in $PATH to find executables
before running them, avoiding an issue where on Windows a same named
file in the current directory can be executed in preference to anything
in a directory in $PATH. This search is intended to find an absolute
path for a bare executable ( e.g, a function "foo") by finding the first
instance of "foo" in a directory given in $PATH, and this search works
correctly.  The search is explicitly avoided for an executable named
with an absolute path (e.g., /bin/sh), and that works as well.

Unfortunately, the search is also applied to commands named with a
relative path. A hook script (or executable) $HOOK is usually located
relative to the project directory as .git/hooks/$HOOK. The search for
this will generally fail as that relative path will (probably) not exist
on any directory in $PATH. This means that git hooks in general now fail
to run. Considerable mayhem could occur should a directory on $PATH be
git controlled. If such a directory includes .git/hooks/$HOOK, that
repository's $HOOK will be substituted for the one in the current
project, with unknown consequences.

This lookup failure also occurs in worktrees linked to a remote .git
directory using git-new-workdir. However, a worktree using a .git file
pointing to a separate git directory apparently avoids this: in that
case the hook command is resolved to an absolute path before being
passed down to the code introduced in aae9560a.

Fix this by replacing the test for an "absolute" pathname to a check for
a command name having more than one pathname component. This limits the
search and absolute pathname resolution to bare commands. The new test
uses tcl's "file split" command. Experiments on Linux and Windows, using
tclsh, show that command names with relative and absolute paths always
give at least two components, while a bare command gives only one.

  Linux:   puts [file split {foo}]       ==>  foo
  Linux:   puts [file split {/foo}]      ==>  / foo
  Linux:   puts [file split {.git/foo}]  ==> .git foo
  Windows: puts [file split {foo}]       ==>  foo
  Windows: puts [file split {c:\foo}]    ==>  c:/ foo
  Windows: puts [file split {.git\foo}]  ==> .git foo

The above results show the new test limits search and replacement
to bare commands on both Linux and Windows.

Signed-off-by: Mark Levedahl <mlevedahl@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
22 months agoMerge branch 'ml/cygwin-fixes'
Pratyush Yadav [Thu, 24 Aug 2023 14:46:29 +0000 (16:46 +0200)] 
Merge branch 'ml/cygwin-fixes'

Remove some code supporting ancient Cygwin Tcl/Tk versions. Also fix
exploring working directory and making desktop shortcuts on Cygwin.

* ml/cygwin-fixes:
  git-gui - use mkshortcut on Cygwin
  git-gui - use cygstart to browse on Cygwin
  git-gui - remove obsolete Cygwin specific code
  git gui Makefile - remove Cygwin modifications

22 months agogit-gui - use mkshortcut on Cygwin
Mark Levedahl [Mon, 26 Jun 2023 16:53:05 +0000 (12:53 -0400)] 
git-gui - use mkshortcut on Cygwin

git-gui enables the "Repository->Create Desktop Icon" item on Cygwin,
offering to create a shortcut that starts git-gui on the current
repository. The code in do_cygwin_shortcut invokes function
win32_create_lnk to create the shortcut. This latter function is shared
between Cygwin and Git For Windows and expects Windows rather than unix
pathnames, though do_cygwin_shortcut provides unix pathnames. Also, this
function tries to invoke the Windows Script Host to run a javascript
snippet, but this fails under Cygwin's Tcl. So, win32_create_lnk just
does not support Cygwin.

However, Cygwin's default installation provides /bin/mkshortcut for
creating desktop shortcuts. This is compatible with exec under Cygwin's
Tcl, understands Cygwin's unix pathnames, and avoids the need for shell
escapes to encode troublesome paths. So, teach git-gui to use mkshortcut
on Cygwin, leaving win32_create_lnk unchanged and for exclusive use by
Git For Windows.

Notes: "CHERE_INVOKING=1" is recognized by Cygwin's /etc/profile and
prevents a "chdir $HOME", leaving the shell in the working directory
specified by the shortcut. That directory is written directly by
mkshortcut eliminating any problems with shell escapes and quoting.

The code being replaced includes the full pathname of the git-gui
creating the shortcut, but that git-gui might not be compatible with the
git found after /etc/profile sets the path, and might have a pathname
that defies encoding using shell escapes that can survive the multiple
incompatible interpreters involved in the chain of creating and using
this shortcut.  The new code uses bare "git gui" as the command to
execute, thus using the system git to launch the system git-gui, and
avoiding both issues.

Signed-off-by: Mark Levedahl <mlevedahl@gmail.com>
Acked-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Pratyush Yadav <me@yadavpratyush.com>
22 months agogit-gui - use cygstart to browse on Cygwin
Mark Levedahl [Mon, 26 Jun 2023 16:53:04 +0000 (12:53 -0400)] 
git-gui - use cygstart to browse on Cygwin

git-gui enables the "Repository->Explore Working Copy" menu on Cygwin,
offering to open a Windows graphical file browser at the root of the
working directory. This code, shared with Git For Windows support,
depends upon use of Windows pathnames. However, git gui on Cygwin uses
unix pathnames, so this shared code will not work on Cygwin.

A base install of Cygwin provides the /bin/cygstart utility that runs
a registered Windows application based upon the file type, after
translating unix pathnames to Windows.  Adding the --explore option
guarantees that the Windows file explorer is opened, regardless of the
supplied pathname's file type and avoiding possibility of some other
action being taken.

So, teach git-gui to use cygstart --explore on Cygwin, restoring the
pre-2012 behavior of opening a Windows file explorer for browsing. This
separates the Git For Windows and Cygwin code paths. Note that
is_Windows is never true on Cygwin, and is_Cygwin is never true on Git
for Windows, though this is not obvious by examining the code for those
independent functions.

Signed-off-by: Mark Levedahl <mlevedahl@gmail.com>
Acked-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Pratyush Yadav <me@yadavpratyush.com>
22 months agogit-gui - remove obsolete Cygwin specific code
Mark Levedahl [Mon, 26 Jun 2023 16:53:03 +0000 (12:53 -0400)] 
git-gui - remove obsolete Cygwin specific code

In the current git release, git-gui runs on Cygwin without enabling any
of git-gui's Cygwin specific code.  This happens as the Cygwin specific
code in git-gui was (mostly) written in 2007-2008 to work with Cygwin's
then supplied Tcl/Tk which was an incompletely ported variant of the
8.4.1 Windows Tcl/Tk code.  In March, 2012, that 8.4.1 package was
replaced with a full port based upon the upstream unix/X11 code,
since maintained up to date. The two Tcl/Tk packages are completely
incompatible, and have different signatures.

When Cygwin's Tcl/Tk signature changed in 2012, git-gui no longer
detected Cygwin, so did not enable Cygwin specific code, and the POSIX
environment provided by Cygwin since 2012 supported git-gui as a generic
unix. Thus, no-one apparently noticed the existence of incompatible
Cygwin specific code.

However, since commit c5766eae6f in the git-gui source tree
(https://github.com/prati0100/git-gui, master at a5005ded), and not yet
pulled into the git repository, the is_Cygwin function does detect
Cygwin using the unix/X11 Tcl/Tk.  The Cygwin specific code is enabled,
causing use of Windows rather than unix pathnames, and enabling
incorrect warnings about environment variables that were relevant only
to the old Tcl/Tk.  The end result is that (upstream) git-gui is now
incompatible with Cygwin.

So, delete Cygwin specific code (code protected by "if is_Cygwin") that
is not needed in any form to work with the unix/X11 Tcl/Tk.

Cygwin specific code required to enable file browsing and shortcut
creation is not addressed in this patch, does not currently work, and
invocation of those items may leave git-gui in a confused state.

Signed-off-by: Mark Levedahl <mlevedahl@gmail.com>
Acked-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Pratyush Yadav <me@yadavpratyush.com>
22 months agogit gui Makefile - remove Cygwin modifications
Mark Levedahl [Mon, 26 Jun 2023 16:53:02 +0000 (12:53 -0400)] 
git gui Makefile - remove Cygwin modifications

git-gui's Makefile hardcodes the absolute Windows path of git-gui's libraries
into git-gui, destroying the ability to package git-gui on one machine and
distribute to others. The intent is to do this only if a non-Cygwin Tcl/Tk is
installed, but the test for this is wrong with the unix/X11 Tcl/Tk shipped
since 2012. Also, Cygwin does not support a non-Cygwin Tcl/Tk.

The Cygwin git maintainer disables this code, so this code is definitely
not in use in the Cygwin distribution.

The simplest fix is to just delete the Cygwin specific code,
allowing the Makefile to work out of the box on Cygwin. Do so.

Signed-off-by: Mark Levedahl <mlevedahl@gmail.com>
Acked-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Pratyush Yadav <me@yadavpratyush.com>
2 years agoMerge branch 'ab/makeflags'
Pratyush Yadav [Wed, 25 Jan 2023 10:39:35 +0000 (11:39 +0100)] 
Merge branch 'ab/makeflags'

Backport a Makefile fix from upstream git.

* ab/makeflags:
  Makefiles: change search through $(MAKEFLAGS) for GNU make 4.4

2 years agoMakefiles: change search through $(MAKEFLAGS) for GNU make 4.4
Ævar Arnfjörð Bjarmason [Wed, 30 Nov 2022 08:23:49 +0000 (09:23 +0100)] 
Makefiles: change search through $(MAKEFLAGS) for GNU make 4.4

Since GNU make 4.4 the semantics of the $(MAKEFLAGS) variable has
changed in a backward-incompatible way, as its "NEWS" file notes:

  Previously only simple (one-letter) options were added to the MAKEFLAGS
  variable that was visible while parsing makefiles.  Now, all options are
  available in MAKEFLAGS.  If you want to check MAKEFLAGS for a one-letter
  option, expanding "$(firstword -$(MAKEFLAGS))" is a reliable way to return
  the set of one-letter options which can be examined via findstring, etc.

This means that $(MAKEFLAGS) now contains long options like
"--jobserver-auth=fifo:<path>" and we have to adapt to that.

Note that the "-" in "-$(MAKEFLAGS)" is critical here, as the variable
will always contain leading whitespace if there are no short options,
but long options are present.

This is a partial backport of 67b36879fc0 (Makefiles: change search
through $(MAKEFLAGS) for GNU make 4.4, 2022-11-30), which had been
applied directly to git/git.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Pratyush Yadav <me@yadavpratyush.com>
2 years agoMerge branch 'js/windows-rce'
Pratyush Yadav [Tue, 24 Jan 2023 13:13:46 +0000 (14:13 +0100)] 
Merge branch 'js/windows-rce'

Fix a Remote Code Execution vulnerability on Windows. This is caused by
the fact that Tcl on Windows always includes the current directory when
looking for an executable. Therefore malicious repositories can ship
with an aspell.exe in their top-level directory which is executed by Git
GUI without giving the user a chance to inspect it first, i.e. running
untrusted code.

This merge fixes CVE-2022-41953.

* js/windows-rce:
  Work around Tcl's default `PATH` lookup
  Move the `_which` function (almost) to the top
  Move is_<platform> functions to the beginning
  is_Cygwin: avoid `exec`ing anything
  windows: ignore empty `PATH` elements

2 years agoWork around Tcl's default `PATH` lookup
Johannes Schindelin [Wed, 23 Nov 2022 08:31:06 +0000 (09:31 +0100)] 
Work around Tcl's default `PATH` lookup

As per https://www.tcl.tk/man/tcl8.6/TclCmd/exec.html#M23, Tcl's `exec`
function goes out of its way to imitate the highly dangerous path lookup
of `cmd.exe`, but _of course_ only on Windows:

If a directory name was not specified as part of the application
name, the following directories are automatically searched in
order when attempting to locate the application:

    The directory from which the Tcl executable was loaded.

    The current directory.

    The Windows 32-bit system directory.

    The Windows home directory.

    The directories listed in the path.

The dangerous part is the second item, of course: `exec` _prefers_
executables in the current directory to those that are actually in the
`PATH`.

It is almost as if people wanted to Windows users vulnerable,
specifically.

To avoid that, Git GUI already has the `_which` function that does not
imitate that dangerous practice when looking up executables in the
search path.

However, Git GUI currently fails to use that function e.g. when trying to
execute `aspell` for spell checking.

That is not only dangerous but combined with Tcl's unfortunate default
behavior and with the fact that Git GUI tries to spell-check a
repository just after cloning, leads to a critical Remote Code Execution
vulnerability.

Let's override both `exec` and `open` to always use `_which` instead of
letting Tcl perform the path lookup, to prevent this attack vector.

This addresses CVE-2022-41953.

For more details, see
https://github.com/git-for-windows/git/security/advisories/GHSA-v4px-mx59-w99c

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Pratyush Yadav <me@yadavpratyush.com>
2 years agoMove the `_which` function (almost) to the top
Johannes Schindelin [Mon, 5 Dec 2022 13:37:41 +0000 (14:37 +0100)] 
Move the `_which` function (almost) to the top

We are about to make use of the `_which` function to address
CVE-2022-41953 by overriding Tcl/Tk's unsafe PATH lookup on Windows.

In preparation for that, let's move it close to the top of the file to
make sure that even early `exec` calls that happen during the start-up
of Git GUI benefit from the fix.

This commit is best viewed with `--color-moved`.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Pratyush Yadav <me@yadavpratyush.com>
2 years agoMove is_<platform> functions to the beginning
Johannes Schindelin [Fri, 16 Dec 2022 19:41:28 +0000 (20:41 +0100)] 
Move is_<platform> functions to the beginning

We need these in `_which` and they should be defined before that
function's definition.

This commit is best viewed with `--color-moved`.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Pratyush Yadav <me@yadavpratyush.com>
2 years agois_Cygwin: avoid `exec`ing anything
Johannes Schindelin [Sun, 4 Dec 2022 21:56:08 +0000 (22:56 +0100)] 
is_Cygwin: avoid `exec`ing anything

The `is_Cygwin` function is used, among other things, to determine
how executables are discovered in the `PATH` list by the `_which` function.

We are about to change the behavior of the `_which` function on Windows
(but not Cygwin): On Windows, we want it to ignore empty elements of the
`PATH` instead of treating them as referring to the current directory
(which is a "legacy feature" according to
https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap08.html#tag_08_03,
but apparently not explicitly deprecated, the POSIX documentation is
quite unclear on that even if the Cygwin project itself considers it to
be deprecated: https://github.com/cygwin/cygwin/commit/fc74dbf22f5c).

This is important because on Windows, `exec` does something very unsafe
by default (unless we're running a Cygwin version of Tcl, which follows
Unix semantics).

However, we try to `exec` something _inside_ `is_Cygwin` to determine
whether we're running within Cygwin or not, i.e. before we determined
whether we need to handle `PATH` specially or not. That's a Catch-22.

Therefore, and because it is much cleaner anyway, use the
`$::tcl_platform(os)` value which is guaranteed to start with `CYGWIN_`
when running a Cygwin variant of Tcl/Tk, instead of executing `cygpath
--windir`.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Pratyush Yadav <me@yadavpratyush.com>
2 years agowindows: ignore empty `PATH` elements
Johannes Schindelin [Wed, 23 Nov 2022 08:12:49 +0000 (09:12 +0100)] 
windows: ignore empty `PATH` elements

When looking up an executable via the `_which` function, Git GUI
imitates the `execlp()` strategy where the environment variable `PATH`
is interpreted as a list of paths in which to search.

For historical reasons, stemming from the olden times when it was
uncommon to download a lot of files from the internet into the current
directory, empty elements in this list are treated as if the current
directory had been specified.

Nowadays, of course, this treatment is highly dangerous as the current
directory often contains files that have just been downloaded and not
yet been inspected by the user. Unix/Linux users are essentially
expected to be very, very careful to simply not add empty `PATH`
elements, i.e. not to make use of that feature.

On Windows, however, it is quite common for `PATH` to contain empty
elements by mistake, e.g. as an unintended left-over entry when an
application was installed from the Windows Store and then uninstalled
manually.

While it would probably make most sense to safe-guard not only Windows
users, it seems to be common practice to ignore these empty `PATH`
elements _only_ on Windows, but not on other platforms.

Sadly, this practice is followed inconsistently between different
software projects, where projects with few, if any, Windows-based
contributors tend to be less consistent or even "blissful" about it.
Here is a non-exhaustive list:

Cygwin:

It specifically "eats" empty paths when converting path lists to
POSIX: https://github.com/cygwin/cygwin/commit/753702223c7d

I.e. it follows the common practice.

PowerShell:

It specifically ignores empty paths when searching the `PATH`.
The reason for this is apparently so self-evident that it is not
even mentioned here:
https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_environment_variables#path-information

I.e. it follows the common practice.

CMD:

Oh my, CMD. Let's just forget about it, nobody in their right
(security) mind takes CMD as inspiration. It is so unsafe by
default that we even planned on dropping `Git CMD` from Git for
Windows altogether, and only walked back on that plan when we
found a super ugly hack, just to keep Git's users secure by
default:

https://github.com/git-for-windows/MINGW-packages/commit/82172388bb51

So CMD chooses to hide behind the battle cry "Works as
Designed!" that all too often leaves users vulnerable. CMD is
probably the most prominent project whose lead you want to avoid
following in matters of security.

Win32 API (`CreateProcess()`)

Just like CMD, `CreateProcess()` adheres to the original design
of the path lookup in the name of backward compatibility (see
https://learn.microsoft.com/en-us/windows/win32/api/processthreadsapi/nf-processthreadsapi-createprocessw
for details):

If the file name does not contain a directory path, the
system searches for the executable file in the following
sequence:

    1. The directory from which the application loaded.

    2. The current directory for the parent process.

    [...]

I.e. the Win32 API itself chooses backwards compatibility over
users' safety.

Git LFS:

There have been not one, not two, but three security advisories
about Git LFS executing executables from the current directory by
mistake. As part of one of them, a change was introduced to stop
treating empty `PATH` elements as equivalent to `.`:
https://github.com/git-lfs/git-lfs/commit/7cd7bb0a1f0d

I.e. it follows the common practice.

Go:

Go does not follow the common practice, and you can think about
that what you want:
https://github.com/golang/go/blob/go1.19.3/src/os/exec/lp_windows.go#L114-L135
https://github.com/golang/go/blob/go1.19.3/src/path/filepath/path_windows.go#L108-L137

Git Credential Manager:

It tries to imitate Git LFS, but unfortunately misses the empty
`PATH` element handling. As of time of writing, this is in the
process of being fixed:
https://github.com/GitCredentialManager/git-credential-manager/pull/968

So now that we have established that it is a common practice to ignore
empty `PATH` elements on Windows, let's assess this commit's change
using Schneier's Five-Step Process
(https://www.schneier.com/crypto-gram/archives/2002/0415.html#1):

Step 1: What problem does it solve?

It prevents an entire class of Remote Code Execution exploits via
Git GUI's `Clone` functionality.

Step 2: How well does it solve that problem?

Very well. It prevents the attack vector of luring an unsuspecting
victim into cloning an executable into the worktree root directory
that Git GUI immediately executes.

Step 3: What other security problems does it cause?

Maybe non-security problems: If a project (ab-)uses the unsafe
`PATH` lookup. That would not only be unsafe, though, but
fragile in the first place because it would break when running
in a subdirectory. Therefore I would consider this a scenario
not worth keeping working.

Step 4: What are the costs of this measure?

Almost nil, except for the time writing up this commit message
;-)

Step 5: Given the answers to steps two through four, is the security
measure worth the costs?

Yes. Keeping Git's users Secure By Default is worth it. It's a
tiny price to pay compared to the damages even a single
successful exploit can cost.

So let's follow that common practice in Git GUI, too.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Pratyush Yadav <me@yadavpratyush.com>
3 years agoMerge branch 'vk/readme-typo'
Pratyush Yadav [Fri, 5 Nov 2021 12:17:11 +0000 (17:47 +0530)] 
Merge branch 'vk/readme-typo'

Add missing punctuation.

* vk/readme-typo:
  git-gui: Fix a typo in README

3 years agogit-gui: Fix a typo in README
Vipul Kumar [Fri, 5 Nov 2021 06:23:33 +0000 (11:53 +0530)] 
git-gui: Fix a typo in README

Add a missing punctuation.

Signed-off-by: Vipul Kumar <kumar@onenetbeyond.org>
Signed-off-by: Pratyush Yadav <me@yadavpratyush.com>
4 years agoMerge branch 'py/revert-commit-comments'
Pratyush Yadav [Thu, 4 Mar 2021 08:29:45 +0000 (13:59 +0530)] 
Merge branch 'py/revert-commit-comments'

This commit causes breakage on macOS, or in fact any platform using
older versions of Tcl. Revert it.

* py/revert-commit-comments:
  Revert "git-gui: remove lines starting with the comment character"

4 years agoRevert "git-gui: remove lines starting with the comment character"
Pratyush Yadav [Thu, 4 Mar 2021 08:23:27 +0000 (13:53 +0530)] 
Revert "git-gui: remove lines starting with the comment character"

This reverts commit b9a43869c9f96d3577d6f568c1bda1940c8f0e31.

This commit causes breakage on macOS (10.13). It causes errors on
startup and completely breaks the commit functionality. There are two
main problems. First, it uses `string cat` which is not supported on
older Tcl versions. Second, it does a half close of the bidirectional
pipe to git-stripspace which is also not supported on older Tcl
versions.

Reported-by: Eric Sunshine <sunshine@sunshineco.com>
Signed-off-by: Pratyush Yadav <me@yadavpratyush.com>
4 years agoMerge branch 'py/commit-comments'
Pratyush Yadav [Mon, 22 Feb 2021 14:49:53 +0000 (20:19 +0530)] 
Merge branch 'py/commit-comments'

Use git-stripspace to remove comment lines from the commit message. Also
use it to clean up whitespace instead of rolling our own logic.

* py/commit-comments:
  git-gui: remove lines starting with the comment character

4 years agogit-gui: remove lines starting with the comment character
Pratyush Yadav [Tue, 2 Feb 2021 19:58:12 +0000 (01:28 +0530)] 
git-gui: remove lines starting with the comment character

The comment character is specified by the config variable
'core.commentchar'. Any lines starting with this character is considered
a comment and should not be included in the final commit message.

Teach git-gui to filter out lines in the commit message that start with
the comment character using git-stripspace. If the config is not set,
'#' is taken as the default. Also add a message educating users about
the comment character.

Signed-off-by: Pratyush Yadav <me@yadavpratyush.com>
4 years agoMerge branch 'mk/russian-translation'
Pratyush Yadav [Tue, 2 Feb 2021 18:21:30 +0000 (23:51 +0530)] 
Merge branch 'mk/russian-translation'

Fix typo in Russian translation.

* mk/russian-translation:
  git-gui: fix typo in russian locale

4 years agogit-gui: fix typo in russian locale
Mikhail Klyushin [Thu, 14 Jan 2021 10:39:10 +0000 (10:39 +0000)] 
git-gui: fix typo in russian locale

Fixed typo in russian locale: издекса -> индекса

Signed-off-by: Mikhail Klyushin <klyushinmisha@gmail.com>
Signed-off-by: Pratyush Yadav <me@yadavpratyush.com>
4 years agoMerge branch 'sh/inactive-background'
Pratyush Yadav [Fri, 18 Dec 2020 19:32:34 +0000 (01:02 +0530)] 
Merge branch 'sh/inactive-background'

Set a different background color for selections in inactive widgets.
This inactive color is calculated from the current theme colors to make
sure it works for all themes.

* sh/inactive-background:
  git-gui: use gray background for inactive text widgets

4 years agogit-gui: use gray background for inactive text widgets
Stefan Haller [Fri, 18 Dec 2020 09:43:14 +0000 (10:43 +0100)] 
git-gui: use gray background for inactive text widgets

This makes it easier to see at a glance which of the four main views has the
keyboard focus.

Signed-off-by: Stefan Haller <stefan@haller-berlin.de>
Signed-off-by: Pratyush Yadav <me@yadavpratyush.com>
4 years agoMerge branch 'st/selected-text-colors'
Pratyush Yadav [Thu, 17 Dec 2020 20:22:26 +0000 (01:52 +0530)] 
Merge branch 'st/selected-text-colors'

Set colors for selected text properly.

* st/selected-text-colors:
  git-gui: Fix selected text colors

4 years agogit-gui: Fix selected text colors
Serg Tereshchenko [Sun, 22 Nov 2020 13:32:33 +0000 (15:32 +0200)] 
git-gui: Fix selected text colors

Added selected state colors for text widget.

Same colors for active and inactive selection, to match previous
behaviour.

Signed-off-by: Serg Tereshchenko <serg.partizan@gmail.com>
Signed-off-by: Pratyush Yadav <me@yadavpratyush.com>
4 years agoMerge branch 'rj/clean-speedup'
Pratyush Yadav [Thu, 17 Dec 2020 19:12:14 +0000 (00:42 +0530)] 
Merge branch 'rj/clean-speedup'

Speed up 'make clean' on Cygwin.

* rj/clean-speedup:
  Makefile: conditionally include GIT-VERSION-FILE

4 years agoMakefile: conditionally include GIT-VERSION-FILE
Ramsay Jones [Mon, 7 Dec 2020 00:39:30 +0000 (00:39 +0000)] 
Makefile: conditionally include GIT-VERSION-FILE

The 'clean' target is noticeably slow on cygwin, even for a 'do-nothing'
invocation of 'make clean'. For example, the second 'make clean' given
below:

  $ make clean >/dev/null 2>&1
  $ make clean
  GITGUI_VERSION = 0.21.0.85.g3e5c
  rm -rf git-gui lib/tclIndex po/*.msg
  rm -rf GIT-VERSION-FILE GIT-GUI-VARS
  $

has been timed at 1.934s on my laptop (an old core i5-4200M @ 2.50GHz,
8GB RAM, 1TB HDD).

Notice that the Makefile, as part of processing the 'clean' target, is
updating the 'GIT-VERSION-FILE' file.  This is to ensure that the
$(GITGUI_VERSION) make variable is set, once that file had been included.
However, the 'clean' target does not use the $(GITGUI_VERSION) variable,
so this is wasted effort.

In order to eliminate such wasted effort, use the value of the internal
$(MAKECMDGOALS) variable to only '-include GIT-VERSION-FILE' when the
target is not 'clean'. (This drops the time down to 0.676s, on my laptop,
giving an improvement of 65.05%).

Signed-off-by: Ramsay Jones <ramsay@ramsayjones.plus.com>
Signed-off-by: Pratyush Yadav <me@yadavpratyush.com>
4 years agoMerge branch 'sh/macos-labels'
Pratyush Yadav [Thu, 17 Dec 2020 19:02:06 +0000 (00:32 +0530)] 
Merge branch 'sh/macos-labels'

Fix label background colors on MacOS when ttk is enabled.

* sh/macos-labels:
  git-gui: fix colored label backgrounds when using themed widgets

4 years agogit-gui: fix colored label backgrounds when using themed widgets
Stefan Haller [Sun, 22 Nov 2020 19:45:37 +0000 (20:45 +0100)] 
git-gui: fix colored label backgrounds when using themed widgets

The aqua theme on Mac doesn't support changing the background color for labels
and frames [1]. Since the red, green, and yellow backgrounds of the labels for
unstaged and staged files and the diff pane are so important design elements of
git gui's main window, it's not acceptable for them to have grey backgrounds on
Mac.

To work around this, simply use non-themed widgets for all labels on Mac. This
is not a big problem because labels don't look extremely different between the
themed and non-themed versions. There are subtle differences, but they are not
as bad as having the wrong background color.

[1] https://stackoverflow.com/a/6723911

Signed-off-by: Stefan Haller <stefan@haller-berlin.de>
Signed-off-by: Pratyush Yadav <me@yadavpratyush.com>
4 years agoMerge branch 'da/askpass-mask-checkbox'
Pratyush Yadav [Tue, 1 Dec 2020 19:39:01 +0000 (01:09 +0530)] 
Merge branch 'da/askpass-mask-checkbox'

Add a checkbox in the SSH askpass helper to optionally show the input
text which is often a password.

* da/askpass-mask-checkbox:
  git-gui: ssh-askpass: add a checkbox to show the input text

4 years agogit-gui: ssh-askpass: add a checkbox to show the input text
David Aguilar [Sat, 7 Nov 2020 22:20:39 +0000 (14:20 -0800)] 
git-gui: ssh-askpass: add a checkbox to show the input text

Hide the input text by default since the field is
commonly used for sensative informations such as passwords.

Add a "Show input" checkbox to conditionally show the input.

Helped-by: Miguel Boekhold <miguel.boekhold@osudio.com>
Signed-off-by: Efimov Vasily <laer.18@gmail.com>
Signed-off-by: David Aguilar <davvid@gmail.com>
Signed-off-by: Pratyush Yadav <me@yadavpratyush.com>
4 years agoMerge branch 'dr/russian-translation'
Pratyush Yadav [Tue, 1 Dec 2020 19:23:48 +0000 (00:53 +0530)] 
Merge branch 'dr/russian-translation'

Update Russian translation.

* dr/russian-translation:
  git-gui: update Russian translation

4 years agogit-gui: update Russian translation
Dimitriy Ryazantcev [Fri, 6 Nov 2020 18:49:04 +0000 (20:49 +0200)] 
git-gui: update Russian translation

Translation is done on Transifex: https://www.transifex.com/djm00n/git-po-ru/git-gui/
If you have any corrections please report them there.

Signed-off-by: Dimitriy Ryazantcev <dimitriy.ryazantcev@gmail.com>
Signed-off-by: Pratyush Yadav <me@yadavpratyush.com>
4 years agoMerge branch 'ms/commit-template'
Pratyush Yadav [Tue, 1 Dec 2020 19:10:06 +0000 (00:40 +0530)] 
Merge branch 'ms/commit-template'

Teach git-gui to read the commit message template and pre-populate it in
the commit message buffer.

* ms/commit-template:
  git-gui: use commit message template
  git-gui: Only touch GITGUI_MSG when needed

4 years agogit-gui: use commit message template
Martin Schön [Mon, 2 Jul 2018 13:28:09 +0000 (15:28 +0200)] 
git-gui: use commit message template

Use the file described by commit.template (if set) to show the commit message
template, just like other GUIs.

Signed-off-by: Martin Schön <Martin.Schoen@loewensteinmedical.de>
Signed-off-by: Pratyush Yadav <me@yadavpratyush.com>
4 years agogit-gui: Only touch GITGUI_MSG when needed
Pratyush Yadav [Fri, 27 Nov 2020 10:23:51 +0000 (15:53 +0530)] 
git-gui: Only touch GITGUI_MSG when needed

In 4e55d19 (git-gui: Cleanup end-of-line whitespace in commit messages.,
2007-01-25), the logic to decide if GITGUI_MSG should be saved or
deleted was updated to not require the commit message buffer to be
modified. This fixes a situation where if the user quits and restarts
git-gui multiple times the commit message buffer was lost.

Unfortunately, the fix was not quite correct. The check for whether the
commit message buffer has been modified is useless. If the commit is
_not_ amend, then the check is never performed. If the commit is amend,
then saving the message does not matter anyway. Amend state is destroyed
on exit and the next time git-gui is opened it starts from scratch, but
with the older message retained in the buffer. If amend is selected,
the current message is over-written by the amend commit's message.

The correct fix would be to not touch GITGUI_MSG at all if the commit
message buffer is not modified. This way, the file is not deleted even
on multiple restarts. It has the added benefit of not writing the file
unnecessarily on every exit.

Signed-off-by: Pratyush Yadav <me@yadavpratyush.com>
4 years agoMerge branch 'sh/blame-tooltip'
Pratyush Yadav [Sat, 17 Oct 2020 09:35:27 +0000 (15:05 +0530)] 
Merge branch 'sh/blame-tooltip'

Make sure `git gui blame` tooltips are destroyed once the window loses
focus on MacOS.

* sh/blame-tooltip:
  git-gui: blame: prevent tool tips from sticking around after Command-Tab

4 years agogit-gui: blame: prevent tool tips from sticking around after Command-Tab
Stefan Haller [Tue, 13 Oct 2020 13:26:43 +0000 (15:26 +0200)] 
git-gui: blame: prevent tool tips from sticking around after Command-Tab

On Mac, tooltips are not automatically removed when a window loses
focus. Furthermore, mouse-move events are only dispatched to the active
window, which means that if we Command-tab to another application while
a tool tip is showing, the tool tip will stay there forever (in front of
other applications). So we must hide it manually when we lose focus.

Do this unconditionally here (i.e. without if {[is_MacOSX]}); it
shouldn't hurt on other platforms, even though they don't seem to have
this problem.

Signed-off-by: Stefan Haller <stefan@haller-berlin.de>
Signed-off-by: Pratyush Yadav <me@yadavpratyush.com>
4 years agoMerge branch 'st/dark-mode' into master
Pratyush Yadav [Thu, 8 Oct 2020 13:04:54 +0000 (18:34 +0530)] 
Merge branch 'st/dark-mode' into master

Improve dark mode support. Do not hard-code widget colors and instead
pull them from the current theme and update them in the options
database.

* st/dark-mode:
  git-gui: improve dark mode support

4 years agogit-gui: improve dark mode support
Serg Tereshchenko [Sat, 26 Sep 2020 14:54:43 +0000 (17:54 +0300)] 
git-gui: improve dark mode support

The colors of some ttext widgets are hard-coded. These hard-coded colors
are okay with a light theme but with a dark theme some widgets are dark
colored and the hard-coded ones are still light. This defeats the
purpose of applying the theme and makes the UI look very awkward.

Remove the hard-coded colors in ttext calls and use colors from the
theme for those widgets via Text.Background and Text.Foreground from the
option database.

Similarly, the highlighting for the currently selected file(s) in the
"Staged Files" and "Unstaged Files" sections is also hard-coded. Pull
the colors for that from the current theme to make sure it is in line

Signed-off-by: Serg Tereshchenko <serg.partizan@gmail.com>
Signed-off-by: Pratyush Yadav <me@yadavpratyush.com>
4 years agoMerge branch 'st/spaces-tabs-cleanup' into master
Pratyush Yadav [Tue, 22 Sep 2020 09:51:19 +0000 (15:21 +0530)] 
Merge branch 'st/spaces-tabs-cleanup' into master

Clean up some whitespace.

* st/spaces-tabs-cleanup:
  git-gui: fix mixed tabs and spaces; prefer tabs

4 years agogit-gui: fix mixed tabs and spaces; prefer tabs
Serg Tereshchenko [Sat, 22 Aug 2020 22:24:31 +0000 (01:24 +0300)] 
git-gui: fix mixed tabs and spaces; prefer tabs

Spaces are replaced with tabs when possible. In some cases just
replacing spaces with tabs would break readability, so it was left as it
is.

Signed-off-by: Serg Tereshchenko <serg.partizan@gmail.com>
Signed-off-by: Pratyush Yadav <me@yadavpratyush.com>
5 years agoMerge branch 'mt/open-worktree'
Pratyush Yadav [Mon, 22 Jun 2020 14:53:28 +0000 (20:23 +0530)] 
Merge branch 'mt/open-worktree'

Clean up the code that checks if a directory is a Git repo. Use git
rev-parse instead of rolling our own logic to find that out. A side
effect (which also happens to be the main motivation behind it) of this
change is that git-gui can now open worktrees other than the main
worktree.

* mt/open-worktree:
  git-gui: allow opening work trees from the startup dialog

5 years agogit-gui: allow opening work trees from the startup dialog
Mikhail Terekhov [Sat, 6 Jun 2020 04:33:38 +0000 (04:33 +0000)] 
git-gui: allow opening work trees from the startup dialog

In proc _is_git check that supplied path is a valid work tree path.
This allows the choose_repository::pick dialog to accept path to a
work tree directory.

Signed-off-by: Mikhail Terekhov <termim@gmail.com>
Signed-off-by: Pratyush Yadav <me@yadavpratyush.com>
5 years agoMerge branch 'il/ctrl-bs-del'
Pratyush Yadav [Thu, 21 May 2020 12:55:32 +0000 (18:25 +0530)] 
Merge branch 'il/ctrl-bs-del'

Allow deleting words backwards and forwards using Ctrl + Backspace and
Delete in the commit message buffer.

* il/ctrl-bs-del:
  git-gui: Handle Ctrl + BS/Del in the commit msg

5 years agogit-gui: Handle Ctrl + BS/Del in the commit msg
Ismael Luceno [Tue, 12 May 2020 10:28:06 +0000 (12:28 +0200)] 
git-gui: Handle Ctrl + BS/Del in the commit msg

- Control+BackSpace: Delete word to the left of the cursor.
- Control+Delete   : Delete word to the right of the cursor.

Originally introduced by BRIEF and Turbo Vision between 1985 and 1992,
they were adopted by most CUA-Compliant UIs, including those of: OS/2,
Windows, Mac OS, Qt, GTK, Open/Libre Office, Gecko, and GNU Emacs.

In both cases Tk already implements the functionality bound to other key
combination, so we use that.

Graphical examples:

Deleting to the left:
        v------ pointer
X_WORD____X
  ^-----^------ selection

Deleting to the right:
  v--------- pointer
X_WORD_X
  ^--^------ selection

Signed-off-by: Ismael Luceno <ismael.luceno@tttech-auto.com>
Signed-off-by: Pratyush Yadav <me@yadavpratyush.com>
5 years agoMerge branch 'ar/ui-ready-semicolon'
Pratyush Yadav [Tue, 5 May 2020 12:01:05 +0000 (17:31 +0530)] 
Merge branch 'ar/ui-ready-semicolon'

Fix syntax error popups because of missing semicolons.

* ar/ui-ready-semicolon:
  Subject: git-gui: fix syntax error because of missing semicolon

5 years agoSubject: git-gui: fix syntax error because of missing semicolon
Ansgar Röber [Thu, 9 Apr 2020 18:03:25 +0000 (18:03 +0000)] 
Subject: git-gui: fix syntax error because of missing semicolon

For some asynchronous operations, we build a chain of callbacks to
execute when the operation is done. These callbacks are held in $after,
and a new callback can be added by appending to $after. Once the
operation is done, $after is executed as a script.

But if we don't append a semi-colon after the procedure calls, they will
appear to Tcl as arguments to the previous procedure's arguments. So,
for example, if $after is "foo", and we just append "bar", then $after
becomes "foo bar", and bar will be treated as an argument to foo. If foo
does not accept any optional arguments, it would result in Tcl throwing
an error. If instead we do append a semi-colon, $after will look like
"foo;bar;", and these will be treated as two separate procedure calls.

Before d9c6469 (git-gui: update status bar to track operations,
2019-12-01), this problem was masked because ui_ready/ui_status did
accept an optional argument. In d9c6469, ui_ready stopped accepting an
optional argument, and this error started showing up.

Another instance of this problem is when a call to ui_status without a
trailing semicolon. ui_status never accepted an optional argument to
begin with, but the issue never managed to surface.

So, fix these errors by making sure we always append a semi-colon after
procedure calls when multiple callbacks are involved in $after.

Helped-by: Pratyush Yadav <me@yadavpratyush.com>
Signed-off-by: Ansgar Röber <ansgar.roeber@rwth-aachen.de>
5 years agoMerge branch 'py/remove-tcloo'
Pratyush Yadav [Thu, 19 Mar 2020 15:59:19 +0000 (21:29 +0530)] 
Merge branch 'py/remove-tcloo'

Reduce the Tcl version requirement to 8.5 to allow git-gui to run on
MacOS distributions like High Sierra. While here, fix a potential
variable name collision.

* py/remove-tcloo:
  git-gui: create a new namespace for chord script evaluation
  git-gui: reduce Tcl version requirement from 8.6 to 8.5

5 years agogit-gui: create a new namespace for chord script evaluation
Pratyush Yadav [Sat, 14 Mar 2020 21:38:36 +0000 (03:08 +0530)] 
git-gui: create a new namespace for chord script evaluation

Evaluating the script in the same namespace as the chord itself creates
potential for variable name collision. And in that case the script would
unknowingly use the chord's variables.

For example, say the script has a variable called 'is_completed', which
also exists in the chord's namespace. The script then calls 'eval' and
sets 'is_completed' to 1 thinking it is setting its own variable,
completely unaware of how the chord works behind the scenes. This leads
to the chord never actually executing because it sees 'is_completed' as
true and thinks it has already completed.

Avoid the potential collision by creating a separate namespace for the
script that is a child of the chord's namespace.

Signed-off-by: Pratyush Yadav <me@yadavpratyush.com>
5 years agogit-gui: reduce Tcl version requirement from 8.6 to 8.5
Pratyush Yadav [Mon, 17 Feb 2020 15:39:29 +0000 (21:09 +0530)] 
git-gui: reduce Tcl version requirement from 8.6 to 8.5

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 <me@yadavpratyush.com>
5 years agoMerge branch 'js/askpass-coerce-utf8'
Pratyush Yadav [Sat, 14 Mar 2020 17:22:43 +0000 (22:52 +0530)] 
Merge branch 'js/askpass-coerce-utf8'

Askpass can now send non-ASCII to Git on Windows.

* js/askpass-coerce-utf8:
  git-gui--askpass: coerce answers to UTF-8 on Windows

5 years agogit-gui--askpass: coerce answers to UTF-8 on Windows
Luke Bonanomi [Thu, 12 Mar 2020 21:31:50 +0000 (21:31 +0000)] 
git-gui--askpass: coerce answers to UTF-8 on Windows

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 https://github.com/git-for-windows/git/issues/2215

Signed-off-by: Luke Bonanomi <lbonanomi@gmail.com>
Helped-by: Junio C Hamano <gitster@pobox.com>
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Pratyush Yadav <me@yadavpratyush.com>
5 years agoMerge branch 'py/blame-status-error'
Pratyush Yadav [Sat, 14 Mar 2020 17:11:45 +0000 (22:41 +0530)] 
Merge branch 'py/blame-status-error'

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"

5 years agogit-gui: fix error popup when doing blame -> "Show History Context"
Pratyush Yadav [Mon, 2 Mar 2020 18:15:54 +0000 (23:45 +0530)] 
git-gui: fix error popup when doing blame -> "Show History Context"

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 <me@yadavpratyush.com>
5 years agoMerge branch 'py/missing-bracket'
Pratyush Yadav [Tue, 18 Feb 2020 17:31:44 +0000 (23:01 +0530)] 
Merge branch 'py/missing-bracket'

Fix an error popping up because of an unmatched closed bracket.

* py/missing-bracket:
  git-gui: add missing close bracket

5 years agogit-gui: add missing close bracket
Pratyush Yadav [Mon, 17 Feb 2020 16:04:45 +0000 (21:34 +0530)] 
git-gui: add missing close bracket

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 <me@yadavpratyush.com>
5 years agoMerge branch 'cs/german-translation'
Pratyush Yadav [Mon, 17 Feb 2020 15:44:24 +0000 (21:14 +0530)] 
Merge branch 'cs/german-translation'

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

5 years agogit-gui: update German translation
Christian Stimming [Sun, 9 Feb 2020 22:00:58 +0000 (22:00 +0000)] 
git-gui: update German translation

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 <christian@cstimming.de>
Signed-off-by: Pratyush Yadav <me@yadavpratyush.com>
5 years agogit-gui: extend translation glossary template with more terms
Christian Stimming [Sun, 9 Feb 2020 22:00:57 +0000 (22:00 +0000)] 
git-gui: extend translation glossary template with more terms

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 <christian@cstimming.de>
Signed-off-by: Pratyush Yadav <me@yadavpratyush.com>
5 years agogit-gui: update pot template and German translation to current source code
Christian Stimming [Sun, 9 Feb 2020 22:00:56 +0000 (22:00 +0000)] 
git-gui: update pot template and German translation to current source code

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

Signed-off-by: Christian Stimming <christian@cstimming.de>
Signed-off-by: Pratyush Yadav <me@yadavpratyush.com>
5 years agoMerge branch 'zs/open-current-file'
Pratyush Yadav [Sat, 4 Jan 2020 21:08:03 +0000 (02:38 +0530)] 
Merge branch 'zs/open-current-file'

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

5 years agogit-gui: allow opening currently selected file in default app
Zoli Szabó [Mon, 30 Dec 2019 15:56:59 +0000 (15:56 +0000)] 
git-gui: allow opening currently selected file in default app

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ó <zoli.szabo@gmail.com>
Signed-off-by: Pratyush Yadav <me@yadavpratyush.com>
5 years agoMerge branch 'py/console-close-esc'
Pratyush Yadav [Thu, 19 Dec 2019 19:54:05 +0000 (01:24 +0530)] 
Merge branch 'py/console-close-esc'

Allow closing console window with Escape once the command is completed.

* py/console-close-esc:
  git-gui: allow closing console window with Escape

5 years agogit-gui: allow closing console window with Escape
Pratyush Yadav [Fri, 6 Dec 2019 21:46:31 +0000 (03:16 +0530)] 
git-gui: allow closing console window with Escape

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 <me@yadavpratyush.com>
5 years agoMerge branch 'kk/branch-name-encoding'
Pratyush Yadav [Wed, 11 Dec 2019 16:02:29 +0000 (21:32 +0530)] 
Merge branch 'kk/branch-name-encoding'

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

5 years agogit gui: fix branch name encoding error
Kazuhiro Kato [Sat, 7 Dec 2019 00:29:09 +0000 (00:29 +0000)] 
git gui: fix branch name encoding error

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 <kato-k@ksysllc.co.jp>
Signed-off-by: Pratyush Yadav <me@yadavpratyush.com>
5 years agoMerge branch 'jg/revert-untracked'
Pratyush Yadav [Thu, 5 Dec 2019 18:55:27 +0000 (00:25 +0530)] 
Merge branch 'jg/revert-untracked'

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

5 years agogit-gui: revert untracked files by deleting them
Jonathan Gilbert [Sun, 1 Dec 2019 02:28:33 +0000 (02:28 +0000)] 
git-gui: revert untracked files by deleting them

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 d4e890e5 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 <JonathanG@iQmetrix.com>
Signed-off-by: Pratyush Yadav <me@yadavpratyush.com>
5 years agogit-gui: update status bar to track operations
Jonathan Gilbert [Sun, 1 Dec 2019 02:28:32 +0000 (02:28 +0000)] 
git-gui: update status bar to track operations

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 <JonathanG@iQmetrix.com>
Signed-off-by: Pratyush Yadav <me@yadavpratyush.com>
5 years agogit-gui: consolidate naming conventions
Jonathan Gilbert [Sun, 1 Dec 2019 02:28:31 +0000 (02:28 +0000)] 
git-gui: consolidate naming conventions

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 <JonathanG@iQmetrix.com>
Signed-off-by: Pratyush Yadav <me@yadavpratyush.com>
5 years agoMerge branch 'ka/japanese-translation'
Pratyush Yadav [Mon, 14 Oct 2019 17:52:50 +0000 (23:22 +0530)] 
Merge branch 'ka/japanese-translation'

Improve Japanese translation.

* ka/japanese-translation:
  git-gui: improve Japanese translation

5 years agogit-gui: improve Japanese translation
kdnakt [Mon, 14 Oct 2019 01:31:38 +0000 (01:31 +0000)] 
git-gui: improve Japanese translation

Signed-off-by: kdnakt <a.kid.1985@gmail.com>
Signed-off-by: Pratyush Yadav <me@yadavpratyush.com>
5 years agoMerge branch 'py/readme'
Pratyush Yadav [Sat, 12 Oct 2019 16:10:25 +0000 (21:40 +0530)] 
Merge branch 'py/readme'

Add a readme to introduce people finding the repo to the project.

* py/readme:
  git-gui: add a readme

5 years agogit-gui: add a readme
Pratyush Yadav [Fri, 4 Oct 2019 19:53:08 +0000 (01:23 +0530)] 
git-gui: add a readme

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 <me@yadavpratyush.com>
Acked-by: Bert Wesarg <bert.wesarg@googlemail.com>
5 years agoMerge branch 'bw/diff3-conflict-style'
Pratyush Yadav [Thu, 3 Oct 2019 21:57:53 +0000 (03:27 +0530)] 
Merge branch 'bw/diff3-conflict-style'

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

5 years agogit-gui: support for diff3 conflict style
Bert Wesarg [Wed, 2 Oct 2019 07:36:02 +0000 (09:36 +0200)] 
git-gui: support for diff3 conflict style

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 <bert.wesarg@googlemail.com>
Signed-off-by: Pratyush Yadav <me@yadavpratyush.com>
5 years agogit-gui: use existing interface to query a path's attribute
Bert Wesarg [Mon, 30 Sep 2019 19:54:52 +0000 (21:54 +0200)] 
git-gui: use existing interface to query a path's attribute

Replace the hand-coded call to git check-attr with the already provided one.

Signed-off-by: Bert Wesarg <bert.wesarg@googlemail.com>
Signed-off-by: Pratyush Yadav <me@yadavpratyush.com>
5 years agoMerge branch 'js/git-bash-if-available'
Pratyush Yadav [Wed, 2 Oct 2019 23:11:58 +0000 (04:41 +0530)] 
Merge branch 'js/git-bash-if-available'

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

5 years agogit-gui (Windows): use git-bash.exe if it is available
Thomas Klaeger [Thu, 26 Sep 2019 17:46:19 +0000 (10:46 -0700)] 
git-gui (Windows): use git-bash.exe if it is available

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 https://github.com/git-for-windows/git/issues/490

Signed-off-by: Thomas Kläger <thomas.klaeger@10a.ch>
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Pratyush Yadav <me@yadavpratyush.com>
5 years agoMerge branch 'py/git-git-extra-stuff'
Pratyush Yadav [Tue, 24 Sep 2019 14:20:33 +0000 (19:50 +0530)] 
Merge branch 'py/git-git-extra-stuff'

Some changes were added directly to git.git's git-gui subtree, instead
of being added to the separate git-gui repo and then being pulled back
into git.git. This means those changes are now not in the git-gui tree.
So pull them back into git-gui so we match with what git.git has (after
they pull in the recently added commits).

Most of the changes could be added back in via an octopus merge of all
the missing branches. But there were two commits (faf420e05a and
b71c6c3b64) which touched other parts of git.git along with git-gui, so
they had to be added back in via a cherry-pick because directly pulling
them in would also pull in all the ancestors of those commits,
needlessly bloating git-gui with git.git's history.

Thanks to Denton Liu <liu.denton@gmail.com> for providing me with a
script to generate and merge all the branches that were missing, which
made this task much easier.

* py/git-git-extra-stuff:
  treewide: correct several "up-to-date" to "up to date"
  Fix build with core.autocrlf=true
  git-gui: call do_quit before destroying the main window
  git-gui: workaround ttk:style theme use
  git-gui: bind CTRL/CMD+numpad ENTER to do_commit
  git-gui: search for all current SSH key types
  git-gui: allow Ctrl+T to toggle multiple paths
  git-gui: fix exception when trying to stage with empty file list
  git-gui: avoid exception upon Ctrl+T in an empty list
  git gui: fix staging a second line to a 1-line file
  git-gui: prevent double UTF-8 conversion
  git-gui: sort entries in optimized tclIndex
  Replace Free Software Foundation address in license notices
  git-gui (MinGW): make use of MSys2's msgfmt

5 years agotreewide: correct several "up-to-date" to "up to date"
Martin Ågren [Wed, 23 Aug 2017 17:49:35 +0000 (19:49 +0200)] 
treewide: correct several "up-to-date" to "up to date"

Follow the Oxford style, which says to use "up-to-date" before the noun,
but "up to date" after it. Don't change plumbing (specifically
send-pack.c, but transport.c (git push) also has the same string).

This was produced by grepping for "up-to-date" and "up to date". It
turned out we only had to edit in one direction, removing the hyphens.

Fix a typo in Documentation/git-diff-index.txt while we're there.

Reported-by: Jeffrey Manian <jeffrey.manian@gmail.com>
Reported-by: STEVEN WHITE <stevencharleswhitevoices@gmail.com>
Signed-off-by: Martin Ågren <martin.agren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Signed-off-by: Pratyush Yadav <me@yadavpratyush.com>
5 years agoFix build with core.autocrlf=true
Johannes Schindelin [Tue, 9 May 2017 12:53:21 +0000 (14:53 +0200)] 
Fix build with core.autocrlf=true

On Windows, the default line endings are denoted by a Carriage Return
byte followed by a Line Feed byte, while Linux and MacOSX use a single
Line Feed byte to denote a line ending.

To help with this situation, Git introduced several mechanisms over the
last decade, most prominently the `core.autocrlf` setting.

Sometimes, however, a single setting is incorrect, e.g. when certain
files in the source code are to be consumed by software that can handle
only LF line endings, while other files can use whatever is appropriate
for the current platform.

To allow for that, Git added the `eol` option to its .gitattributes
handling, expecting every user of Git to mark their source code
appropriately.

Bash assumes that line-endings of scripts are denoted by a single Line
Feed byte. Therefore, shell scripts in Git's source code are one example
where that `eol=lf` option is *required*.

When generating common-cmds.h, the Unix tools we use generally operate on
the assumption that input and output deliminate their lines using LF-only
line endings. Consequently, they would happily copy the CR byte verbatim
into the strings in common-cmds.h, which in turn makes the C preprocessor
barf (that interprets them as MacOS-style line endings). Therefore, we
have to mark the input files as LF-only: command-list.txt and
Documentation/git-*.txt.

Quite a bit belatedly, this patch brings Git's own source code in line
with those expectations by setting those attributes to allow for a
correct build even when core.autocrlf=true.

This patch can be validated even on Linux, by using this cadence:

git config core.autocrlf true
rm .git/index && git stash
make -j15 DEVELOPER=1

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Reviewed-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Signed-off-by: Pratyush Yadav <me@yadavpratyush.com>
5 years agoMerge branches 'js/msgfmt-on-windows', 'tz/fsf-address-update', 'jn/reproducible...
Pratyush Yadav [Thu, 19 Sep 2019 17:52:03 +0000 (23:22 +0530)] 
Merge branches 'js/msgfmt-on-windows', 'tz/fsf-address-update', 'jn/reproducible-build', 'ls/no-double-utf8-author-name', 'js/misc-git-gui-stuff', 'bb/ssh-key-files', 'bp/bind-kp-enter', 'cb/ttk-style' and 'py/call-do-quit-before-exit' of ../git into py/git-git-extra-stuff

5 years agoMerge branch 'bp/amend-toggle-bind'
Pratyush Yadav [Sat, 14 Sep 2019 17:53:12 +0000 (23:23 +0530)] 
Merge branch 'bp/amend-toggle-bind'

Toggle amend on and off with the keyboard shortcut "Ctrl+e".

* bp/amend-toggle-bind:
  git-gui: add hotkey to toggle "Amend Last Commit"