gitk gives "argument list too long" error
Asked Answered
C

4

6

I always got the "argument list too long" error when I try to use "gitk" to open the GUI of the history for some large repo. Even using "gitk -n" didn't solve the problem. Does anybody here have same issue? Thanks,

couldn't execute "git": argument list too long
couldn't execute "git": argument list too long
    while executing
"open [concat $cmd $ids] r"
    (procedure "getallcommits" line 47)
    invoked from within
"getallcommits"
    (procedure "readcache" line 80)
    invoked from within
"readcache file13"
    ("eval" body line 1)
    invoked from within
"eval $script"
    (procedure "dorunq" line 11)
    invoked from within
"dorunq"
    ("after" script)
Cicatrix answered 9/2, 2017 at 7:49 Comment(2)
what are you trying to do? whats your comand? seems that you added too many argumentsMindamindanao
My command is just "gitk"Cicatrix
Z
2

"Argument list too long" is a kernel error when you pass in too many arguments on a command line.

Probably your repo contains something which causes $ids (I'm purely speculating here) to exceed the ARG_MAX limit of your platform.

This is basically a bug in Gitk, but if you can figure out which resource is causing this, you can probably work around the problem by limiting or pruning it somehow.

Ziska answered 9/2, 2017 at 8:0 Comment(6)
This appears to attempt to address the problem, or a similar one -- does your repo have a lot of tags? git.vger.kernel.narkive.com/tDVsZzg7/…Ziska
Though I guess the error message seems to allude to a repo with a lot of commits.Ziska
Yes. It's a big repo. It currently has 9K tags.Cicatrix
Ok. But even "gitk -n" can not limit the results?Cicatrix
Not finding that in the manual page, never used gitk so no direct experience ... Try checking out a shallow clone or otherwise limiting what ends up in the clone you are operating on.Ziska
I have this issue at Windows. It helps to limit number of tags and branches - fetch only what is needed, remove as it's merged, etc.Adila
L
13

I've found a workaroung here and it worked for me: just remove .git/gitk.cache file.

Luciusluck answered 29/11, 2017 at 9:16 Comment(2)
Worked for me as well. Thanks :)Everard
Doesn't work for me (macOS 12.6 French, system Git)Superpatriot
Q
3

Adding on to the answer above: If you are using worktrees, bear in mind that there are other gitk.cache files too, like so:

.git/worktrees/dev-2/gitk.cache

You may have to delete those too.

Quadratic answered 26/7, 2019 at 14:55 Comment(0)
Z
2

"Argument list too long" is a kernel error when you pass in too many arguments on a command line.

Probably your repo contains something which causes $ids (I'm purely speculating here) to exceed the ARG_MAX limit of your platform.

This is basically a bug in Gitk, but if you can figure out which resource is causing this, you can probably work around the problem by limiting or pruning it somehow.

Ziska answered 9/2, 2017 at 8:0 Comment(6)
This appears to attempt to address the problem, or a similar one -- does your repo have a lot of tags? git.vger.kernel.narkive.com/tDVsZzg7/…Ziska
Though I guess the error message seems to allude to a repo with a lot of commits.Ziska
Yes. It's a big repo. It currently has 9K tags.Cicatrix
Ok. But even "gitk -n" can not limit the results?Cicatrix
Not finding that in the manual page, never used gitk so no direct experience ... Try checking out a shallow clone or otherwise limiting what ends up in the clone you are operating on.Ziska
I have this issue at Windows. It helps to limit number of tags and branches - fetch only what is needed, remove as it's merged, etc.Adila
F
0

I consistently had this error on a repo with a large number of references (50k+ remote branches).

The solution is twofold:

1. Reduce the number of refs to something your system can handle.

Obviously, deleting merged branches is a good practice, as well is keeping the total number of refs to a reasonable value.

In my case I had no control on the remote and therefore couldn’t do so at the source. So I used git’s ability to filter remote refs by setting the remote.<name>.fetch configuration option through the git remote set-branches command:

git remote set-branches $REMOTE $BRANCH0 $BRANCH1 $BRANCH2 # List only the few branches I’m interested in.
for REMOTE_BRANCH in $(git branch -r); do
  git branch -rd "${REMOTE_BRANCH}" # Clear the branches I already know about
done
git fetch $REMOTE # Fetch again the branches I selected on the first line.

2. THEN, delete gitk’s cache(s)

Once the total number of refs existings in .git/refs is low enough, you should clear all gitk’s caches with:

find .git -name gitk.cache -delete
Foxed answered 16/9 at 12:31 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.