Skip to content

Fix gitk (long cmdline) #2170

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

Merged
merged 4 commits into from
Apr 26, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 18 additions & 20 deletions gitk-git/gitk
Original file line number Diff line number Diff line change
Expand Up @@ -406,14 +406,16 @@ proc start_rev_list {view} {
if {$revs eq {}} {
return 0
}
set args [limit_arg_length [concat $vflags($view) $revs]]
set args $vflags($view)
} else {
set revs {}
set args $vorigargs($view)
}

if {[catch {
set fd [open [concat | git log --no-color -z --pretty=raw $show_notes \
--parents --boundary $args "--" $files] r]
--parents --boundary $args --stdin \
"<<[join [concat $revs "--" $files] "\\n"]"] r]
} err]} {
error_popup "[mc "Error executing git log:"] $err"
return 0
Expand Down Expand Up @@ -555,13 +557,19 @@ proc updatecommits {} {
set revs $newrevs
set vposids($view) [lsort -unique [concat $oldpos $vposids($view)]]
}
set args [concat $vflags($view) $revs --not $oldpos]
set args $vflags($view)
foreach r $oldpos {
lappend revs "^$r"
}
} else {
set revs {}
set args $vorigargs($view)
}
if {[catch {
set fd [open [concat | git log --no-color -z --pretty=raw $show_notes \
--parents --boundary $args "--" $vfilelimit($view)] r]
--parents --boundary $args --stdin \
"<<[join [concat $revs "--" \
$vfilelimit($view)] "\\n"]"] r]
} err]} {
error_popup "[mc "Error executing git log:"] $err"
return
Expand Down Expand Up @@ -10174,10 +10182,15 @@ proc getallcommits {} {
foreach id $seeds {
lappend ids "^$id"
}
lappend ids "--"
}
}
if {$ids ne {}} {
set cmd [limit_arg_length [concat $cmd $ids]]
if {$ids eq "--all"} {
set cmd [concat $cmd "--all"]
} else {
set cmd [concat $cmd --stdin "<<[join $ids "\\n"]"]
}
set fd [open $cmd r]
fconfigure $fd -blocking 0
incr allcommits
Expand All @@ -10188,21 +10201,6 @@ proc getallcommits {} {
}
}

# The maximum command line length for the CreateProcess function is 32767 characters, see
# http://blogs.msdn.com/oldnewthing/archive/2003/12/10/56028.aspx
# Be a little conservative in case Tcl adds some more stuff to the command line we do not
# know about and truncate the command line at a SHA1-boundary below 32000 characters.
proc limit_arg_length {cmd} {
if {[tk windowingsystem] == "win32" &&
[string length $cmd] > 32000} {
set ndx [string last " " $cmd 32000]
if {$ndx != -1} {
return [string range $cmd 0 $ndx]
}
}
return $cmd
}

# Since most commits have 1 parent and 1 child, we group strings of
# such commits into "arcs" joining branch/merge points (BMPs), which
# are commits that either don't have 1 parent or don't have 1 child.
Expand Down