-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
Fix gitk (long cmdline) #2170
Fix gitk (long cmdline) #2170
Conversation
@max630 Thank you for your initial PR, this here PR (which I still need to touch up with a better description and proper attribution, sorry for that, I am about to run to meetings) would not have been possible. Could you have a look at the patches? |
This was an ugly hack, and in preparation for fixing it the right way, we revert this hack. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
This was an ugly hack, and in preparation for fixing it the right way, we revert this hack. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
To avoid running into command line limitations, some of Git's commands support the `--stdin` option. Let's use exactly this option in the three rev-list/log invocations in gitk that would otherwise possibly run the danger of trying to invoke a too-long command line. While it is easy to redirect either stdin or stdout in Tcl/Tk scripts, what we need here is both. We need to capture the output, yet we also need to pipe in the revs/files arguments via stdin (because stdin does not have any limit, unlike the command line). To help this, we use the neat Tcl feature where you can capture stdout and at the same time feed a fixed string as stdin to the spawned process. One non-obvious aspect about this change is that the `--stdin` option allows to specify revs, the double-dash, and files, but *no* other options such as `--not`. This is addressed by prefixing the "negative" revs with `^` explicitly rather than relying on the `--not` option (thanks for coming up with that idea, Max!). This fixes git-for-windows#1987 Analysis-and-initial-patch-by: Max Kirillov <max@max630.net> Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
fbe96f0
to
d91b855
Compare
a branch takes way more than 1 character, so it is less than 40k. In the #1987 (comment) the number is 1000 branches. |
Thanks, I did not know it can be done that simple. |
After fixing the closing bracket no smoke for me, seems working as intended. |
What expectedly does not work are files with newlines in file name. Maybe they could be filtered out, just to avoid accidetntal inclusion of other files. |
But that did not even work before this change, did it? |
This adds a missing closing bracket. Co-Authored-By: Johannes Schindelin <johannes.schindelin@gmail.com> Signed-off-by: Max A.K <max@max630.net>
7fda887
to
b62ef9c
Compare
Excellent! |
gitk [no longer fails with "filename too long"](git-for-windows/git#2170) when there are 1,000+ branches/tags. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Fix gitk (long cmdline)
Fix gitk (long cmdline)
Fix gitk (long cmdline)
Fix gitk (long cmdline)
Fix gitk (long cmdline)
Fix gitk (long cmdline)
Fix gitk (long cmdline)
Fix gitk (long cmdline)
Fix gitk (long cmdline)
Fix gitk (long cmdline)
Fix gitk (long cmdline)
Fix gitk (long cmdline)
Fix gitk (long cmdline)
Fix gitk (long cmdline)
Fix gitk (long cmdline)
Fix gitk (long cmdline)
Fix gitk (long cmdline)
Fix gitk (long cmdline)
Fix gitk (long cmdline)
Fix gitk (long cmdline)
Fix gitk (long cmdline)
Fix gitk (long cmdline)
Fix gitk (long cmdline)
When
gitk
is faced with a lot of refs, it simply passes them togit rev-list
andgit log
via the command-line without caring about any command-line size limits. On Windows, this fails as soon as the command-line is longer than roughly 32k characters (which is a lot, but not if you have over a thousand tags/branches that would amount to a longer command-line than 32k characters, which apparently some users do have).Based on the excellent groundwork performed in #2053, this PR addresses that problem by specifying the revs/files via
stdin
. In contrast to #2053, we try to avoid the full bidirectional inter-process communication: we know in advance what needs to be passed in viastdin
(it does not depend on any interactive output of the spawned process), so we can use the (otherwise rarely used)<<value
feature of Tcl'sopen
/exec
commands.This fixes #1987