Skip to content

Commit 5be25a8

Browse files
committed
gitk: Fix handling of flag arguments
Despite the name, the --revs-only flag to git rev-parse doesn't make it output only revision IDs. It makes it output only arguments that are suitable for giving to git rev-list. So make start_rev_list and updatecommits cope with arguments output by git rev-parse that aren't revision IDs. This way we won't get an error when an argument such as "-300" has been given to gitk and the view is updated. Signed-off-by: Paul Mackerras <paulus@samba.org>
1 parent 6636b88 commit 5be25a8

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

gitk

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ proc start_rev_list {view} {
110110
$viewargs($view)]
111111
set viewincl($view) {}
112112
foreach c $commits {
113-
if {![string match "^*" $c]} {
113+
if {[regexp {^[0-9a-fA-F]{40}$} $c]} {
114114
lappend viewincl($view) $c
115115
}
116116
}
@@ -187,14 +187,17 @@ proc updatecommits {} {
187187
$viewargs($view)]
188188
set pos {}
189189
set neg {}
190+
set flags {}
190191
foreach c $commits {
191192
if {[string match "^*" $c]} {
192193
lappend neg $c
193-
} else {
194+
} elseif {[regexp {^[0-9a-fA-F]{40}$} $c]} {
194195
if {!([info exists varcid($view,$c)] ||
195196
[lsearch -exact $viewincl($view) $c] >= 0)} {
196197
lappend pos $c
197198
}
199+
} else {
200+
lappend flags $c
198201
}
199202
}
200203
if {$pos eq {}} {
@@ -206,7 +209,7 @@ proc updatecommits {} {
206209
set viewincl($view) [concat $viewincl($view) $pos]
207210
if {[catch {
208211
set fd [open [concat | git log --no-color -z --pretty=raw --parents \
209-
--boundary $pos $neg "--" $viewfiles($view)] r]
212+
--boundary $pos $neg $flags "--" $viewfiles($view)] r]
210213
} err]} {
211214
error_popup "Error executing git log: $err"
212215
exit 1

0 commit comments

Comments
 (0)