Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save uprego/600445d4f4633113c3ed0ff24994bbed to your computer and use it in GitHub Desktop.
Save uprego/600445d4f4633113c3ed0ff24994bbed to your computer and use it in GitHub Desktop.
Surprisingly simple multi stash patch for gitk. Works for gitk as it comes in rev a4685d2f58e2230d4e27fb2ee581d7ea35e5d046 (found in branch 'master' of the remote 'git://ozlabs.org/~paulus/gitk') and definitely possibly others. See also https://gist.github.com/uprego/d8c3c059c56ebb911974bb905157a81e that is a deprecated version of this. Credits …
$ git diff
diff --git a/gitk b/gitk
index a14d7a1..afd7585 100755
--- a/gitk
+++ b/gitk
@@ -296,6 +296,12 @@ proc parseviewrevs {view revs} {
set revs HEAD
} elseif {[lsearch -exact $revs --all] >= 0} {
lappend revs HEAD
+ set stashesfd [open [concat | \
+ git stash list --pretty=format:%H] r]
+ while {[gets $stashesfd stashline] >= 0} {
+ lappend revs $stashline
+ }
+ catch {close $stashesfd}
}
if {[catch {set ids [eval exec git rev-parse $revs]} err]} {
# we get stdout followed by stderr in $err
@@ -1784,7 +1790,8 @@ proc readrefs {} {
foreach v {tagids idtags headids idheads otherrefids idotherrefs} {
unset -nocomplain $v
}
- set refd [open [list | git show-ref -d] r]
+ set refd [open [list | \
+ git show-ref -d | grep -v { refs/stash}] r]
while {[gets $refd line] >= 0} {
if {[string index $line 40] ne " "} continue
set id [string range $line 0 39]
@@ -1817,6 +1824,17 @@ proc readrefs {} {
}
}
catch {close $refd}
+ set stashesidsrefsfd [open [list | \
+ git stash list {--pretty=format:%H %gD}] 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 {
$ figlet -w 120 'On macOS you might want to hold the `set refd [open [list | git show-ref -d] r]` line instead of replacing it for the `set ref [open [list | git show-ref -d | grep -v { refs/stash}] r]` line.'
___ ___ ____ _ _ _
/ _ \ _ __ _ __ ___ __ _ ___ / _ \/ ___| _ _ ___ _ _ _ __ ___ (_) __ _| |__ | |_
| | | | '_ \ | '_ ` _ \ / _` |/ __| | | \___ \ | | | |/ _ \| | | | | '_ ` _ \| |/ _` | '_ \| __|
| |_| | | | | | | | | | | (_| | (__| |_| |___) | | |_| | (_) | |_| | | | | | | | | (_| | | | | |_
\___/|_| |_| |_| |_| |_|\__,_|\___|\___/|____/ \__, |\___/ \__,_| |_| |_| |_|_|\__, |_| |_|\__|
|___/ |___/
_ _ _ _ _ _ _ _ _ __ _
__ ____ _ _ __ | |_ | |_ ___ | |__ ___ | | __| | | |_| |__ ___ ( )___ ___| |_ _ __ ___ / _| __| |
\ \ /\ / / _` | '_ \| __| | __/ _ \ | '_ \ / _ \| |/ _` | | __| '_ \ / _ \ \/ __|/ _ \ __| | '__/ _ \ |_ / _` |
\ V V / (_| | | | | |_ | || (_) | | | | | (_) | | (_| | | |_| | | | __/ \__ \ __/ |_ | | | __/ _| (_| |
\_/\_/ \__,_|_| |_|\__| \__\___/ |_| |_|\___/|_|\__,_| \__|_| |_|\___| |___/\___|\__| |_| \___|_| \__,_|
__ __ _ _ _ _ _ _ _ __
| _|___ _ __ ___ _ __ | _| (_)___| |_ | | __ _(_) |_ ___| |__ _____ __ _ __ ___ / _|
| |/ _ \| '_ \ / _ \ '_ \ | || | / __| __| | | / _` | | __| / __| '_ \ / _ \ \ /\ / /____| '__/ _ \ |_
| | (_) | |_) | __/ | | | | || | \__ \ |_ | | | (_| | | |_ \__ \ | | | (_) \ V V /_____| | | __/ _|
| |\___/| .__/ \___|_| |_| | ||_|_|___/\__| | | \__, |_|\__| |___/_| |_|\___/ \_/\_/ |_| \___|_|
|__| |_| |__| |_| |___/
_ __ __ _ _ _ _ _ _ __
__| |_ | _ _|_ ( ) | (_)_ __ ___ (_)_ __ ___| |_ ___ __ _ __| | ___ / _|
_____ / _` || | | '__| |\| | | | '_ \ / _ \ | | '_ \/ __| __/ _ \/ _` |/ _` | / _ \| |_
|_____| (_| || | | | | | | | | | | | __/ | | | | \__ \ || __/ (_| | (_| | | (_) | _|
\__,_|| | |_| | | |_|_|_| |_|\___| |_|_| |_|___/\__\___|\__,_|\__,_| \___/|_|
|__| |__|
_ _ _ _ __ _ _ _ _ __
_ __ ___ _ __ | | __ _ ___(_)_ __ __ _ (_) |_ / _| ___ _ __ | |_| |__ ___ ( )___ ___| |_ _ __ ___ / _|
| '__/ _ \ '_ \| |/ _` |/ __| | '_ \ / _` | | | __| | |_ / _ \| '__| | __| '_ \ / _ \ \/ __|/ _ \ __| | '__/ _ \ |_
| | | __/ |_) | | (_| | (__| | | | | (_| | | | |_ | _| (_) | | | |_| | | | __/ \__ \ __/ |_ | | | __/ _|
|_| \___| .__/|_|\__,_|\___|_|_| |_|\__, | |_|\__| |_| \___/|_| \__|_| |_|\___| |___/\___|\__| |_| \___|_|
|_| |___/
__ __ _ _ _ _ _ _ _ __ _
| _|___ _ __ ___ _ __ | _| (_)___| |_ | | __ _(_) |_ ___| |__ _____ __ _ __ ___ / _| __| |
| |/ _ \| '_ \ / _ \ '_ \ | || | / __| __| | | / _` | | __| / __| '_ \ / _ \ \ /\ / /____| '__/ _ \ |_ _____ / _` |
| | (_) | |_) | __/ | | | | || | \__ \ |_ | | | (_| | | |_ \__ \ | | | (_) \ V V /_____| | | __/ _| |_____| (_| |
| |\___/| .__/ \___|_| |_| | ||_|_|___/\__| | | \__, |_|\__| |___/_| |_|\___/ \_/\_/ |_| \___|_| \__,_|
|__| |_| |__| |_| |___/
_ __ __ __ _ _ __ __ __ _
| | __ _ _ __ ___ _ __ __ __ / / _ __ ___ / _|___ / /__| |_ __ _ ___| |__\ \|_ | _ _|_ ( )
| | / _` | '__/ _ \ '_ \ ____\ \ / / | | | '__/ _ \ |_/ __| / / __| __/ _` / __| '_ \| || | | '__| |\|
| | | (_| | | | __/ |_) | |_____\ V / < < | | | __/ _\__ \/ /\__ \ || (_| \__ \ | | |> > | | | | |
| | \__, |_| \___| .__/ \_/ | | |_| \___|_| |___/_/ |___/\__\__,_|___/_| |_| || | |_| | |
|_| |___/ |_| \_\ /_/|__| |__|
_ _
| (_)_ __ ___
| | | '_ \ / _ \
| | | | | | __/_
|_|_|_| |_|\___(_)
$ _
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment