Skip to content

Instantly share code, notes, and snippets.

@uprego
Last active May 7, 2017 10:07
Show Gist options
  • Save uprego/d8c3c059c56ebb911974bb905157a81e to your computer and use it in GitHub Desktop.
Save uprego/d8c3c059c56ebb911974bb905157a81e to your computer and use it in GitHub Desktop.
Surprisingly simple multi stash patch for gitk. Works for gitk as it comes in Debian 7 and 8. Known caveat: shows stashes even running `gitk` without the --all switch, in contrast to the standard behavior. See also an improved version at https://gist.github.com/uprego/600445d4f4633113c3ed0ff24994bbed which solves the caveat and also does not dep…
$ diff -u /usr/bin/gitk-deb8-vanilla /usr/bin/gitk-deb8-multistash
--- /usr/bin/gitk-deb8-vanilla 2016-08-29 10:07:06.507344629 +0200
+++ /usr/bin/gitk-deb8-multistash 2016-09-08 14:36:35.382476634 +0200
@@ -401,6 +401,11 @@
if {$vcanopt($view)} {
set revs [parseviewrevs $view $vrevs($view)]
+ set stashesfd [open [concat | gitk-stash-list-ids.sh] r]
+ while {[gets $stashesfd stashline] >= 0} {
+ set revs [lappend revs $stashline]
+ }
+ catch {close $stashesfd}
if {$revs eq {}} {
return 0
}
@@ -1778,7 +1782,7 @@
foreach v {tagids idtags headids idheads otherrefids idotherrefs} {
catch {unset $v}
}
- set refd [open [list | git show-ref -d] r]
+ set refd [open [list | git show-ref -d | grep -v stash] r]
while {[gets $refd line] >= 0} {
if {[string index $line 40] ne " "} continue
set id [string range $line 0 39]
@@ -1811,6 +1815,16 @@
}
}
catch {close $refd}
+ set stashesidsrefsfd [open [list | gitk-stash-list-ids-refs.sh] r]
+ while {[gets $stashesidsrefsfd line] >= 0} {
+ if {[string index $line 40] ne " "} continue
+ set id [string range $line 0 39]
+ set ref [string range $line 41 end]
+ set name [string range $ref 5 end]
+ set otherrefids($name) $id
+ lappend idotherrefs($id) $name
+ }
+ catch {close $stashesidsrefsfd}
set mainhead {}
set mainheadid {}
catch {
$ cat gitk-stash-list-ids-refs.sh
#!/bin/sh
git stash list --pretty=format:"%H %gD"
$ cat gitk-stash-list-ids.sh
#!/bin/sh
git stash list --pretty=format:"%H"
$ _
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment