git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [REGRESSION] gitk can't be run from non-worktree folders

From
SZEDER Gábor <szeder.dev@gmail.com>
Date
Jan 23, 2020, 17:46 UTC
Message-ID
<20200123174602.GE6837@szeder.dev>
In-Reply-To
<20200123170412.GD6837@szeder.dev>
On Thu, Jan 23, 2020 at 06:04:12PM +0100, SZEDER Gábor wrote:
> On Thu, Jan 23, 2020 at 11:36:49AM -0500, Eric Sunshine wrote:
Show 19 quoted lines
> > > Are you sure it's a recent regression?  I have no experience with
> > > 'gitk' in Git for Windows, but on Linux this has been broken for quite
> > > some time, namely since 784b7e2f25 (gitk: Fix "External diff" with
> > > separate work tree, 2011-04-04) in the v1.7 era.  FWIW, reverting that
> > > commit on top of v2.25.0 makes 'gitk' work again in bare repositories.
> > 
> > It's a new regression introduced by 2d92ab32fd (rev-parse: make
> > --show-toplevel without a worktree an error, 2019-11-19), as far as I
> > can tell.
> 
> Oh, that's interesting.
> 
> My local commit reverting 784b7e2f25 that I build my Git with is newer
> than 2d92ab32fd, so maybe that's why I haven't recalled seeing this
> issue earlier.  I did try to bisect it, but had a real hard time with
> gitk being subtree merged, and ultimately gave up on that, and started
> to look for a commit adding '--show-toplevel' to 'gitk', which lead me
> to 784b7e2f25, I reverted it, my issue went away, which then lead me
> to the wrong conclusion.
Oh, this is interesting indeed :)

I have a couple of older Git versions lying around, so I can quickly ballpark a revision range for a regression, without checking out and building older versions. This has always worked well so far, because Git looks for its non-builtin commands in the hardcoded exec-path that was specified at build time, while builtin commands are, well, builtins. Alas, 'gitk' is not a regular Git command, and it runs whatever 'git' executable comes first in PATH, which in my case was a recent build already containing 2d92ab32fd.

  $ ~/src/git/BUILDS/v1.8.0/bin/git --exec-path
  /home/szeder/src/git/BUILDS/v1.8.0/libexec/git-core
  $ cd .git
  $ ~/src/git/BUILDS/v1.8.0/bin/gitk
  Error in startup script: fatal: this operation must be run in a work
  tree
      while executing
  "exec git rev-parse --show-toplevel"
      invoked from within
  "set worktree [exec git rev-parse --show-toplevel]"
      (file "/home/szeder/src/git/BUILDS/v1.8.0/bin/gitk" line 11810)
  $ PATH=~/src/git/BUILDS/v1.8.0/bin:"$PATH" ~/src/git/BUILDS/v1.8.0/bin/gitk
  # Works even in the .git directory!
  $ PATH=~/src/git/BUILDS/v2.24.0/bin:"$PATH" ~/src/git/BUILDS/v2.24.0/bin/gitk
  # This works, too!

With this newly gained knowledge I added 'bin-wrappers' to $PATH when running gitk built from 2d92ab32fd and its parent, and indeed that's the commit that introduced this regression.

Previous: SZEDER GáborNext: Junio C Hamano
Message 5 of 15 in “[REGRESSION] gitk can't be run from non-worktree folders”
  1. chJan 23, 2020
  2. SZEDER GáborJan 23, 2020
  3. Eric SunshineJan 23, 2020
  4. SZEDER GáborJan 23, 2020
  5. SZEDER GáborJan 23, 2020
  6. Junio C HamanoJan 23, 2020
  7. gitk: to run in a bare repository (was: gitk can't be run from non-worktree folders)Junio C Hamano, Jan 23, 2020
  8. Eric SunshineJan 23, 2020
  9. Jeff KingJan 23, 2020
  10. chMar 30, 2020
  11. Eric SunshineOct 11, 2020
  12. chOct 13, 2020
  13. Pratyush YadavOct 13, 2020
  14. chApr 2, 2020
  15. Junio C HamanoApr 2, 2020

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.