git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH (GITK,GIT-GUI,DOCS) 1/7] gitk: Allow overriding the default commit.

From
Alexander Gavrilov <angavrilov@gmail.com>
Date
Aug 23, 2008, 08:27 UTC
Message-ID
<200808231227.45013.angavrilov@gmail.com>
In-Reply-To
<200808231225.12596.angavrilov@gmail.com>

Other GUI tools may occasionally need to start gitk and make it automatically select a certain commit. This patch supports doing it using a new command-line option.

Signed-off-by: Alexander Gavrilov <angavrilov@gmail.com>
---
 gitk |   21 ++++++++++++++++++++-
 1 files changed, 20 insertions(+), 1 deletions(-)
diff --git a/gitk b/gitk
index 087c4ac..7698b70 100755
--- a/gitk
+++ b/gitk
@@ -418,10 +418,12 @@ proc stop_rev_list {view} {
 }
 
 proc reset_pending_select {selid} {
-    global pending_select mainheadid
+    global pending_select mainheadid selectheadid
 
     if {$selid ne {}} {
 	set pending_select $selid
+    } elseif {$selectheadid ne {}} {
+	set pending_select $selectheadid
     } else {
 	set pending_select $mainheadid
     }
@@ -1609,6 +1611,7 @@ proc getcommit {id} {
 proc readrefs {} {
     global tagids idtags headids idheads tagobjid
     global otherrefids idotherrefs mainhead mainheadid
+    global selecthead selectheadid
 
     foreach v {tagids idtags headids idheads otherrefids idotherrefs} {
 	catch {unset $v}
@@ -1655,6 +1658,12 @@ proc readrefs {} {
 	    set mainhead [string range $thehead 11 end]
 	}
     }
+    set selectheadid {}
+    if {$selecthead ne {}} {
+	catch {
+	    set selectheadid [exec git rev-parse --verify $selecthead]
+	}
+    }
 }
 
 # skip over fake commits
@@ -9865,6 +9874,9 @@ if {![file isdirectory $gitdir]} {
     exit 1
 }
 
+set selecthead {}
+set selectheadid {}
+
 set revtreeargs {}
 set cmdline_files {}
 set i 0
@@ -9876,6 +9888,9 @@ foreach arg $argv {
 	    set cmdline_files [lrange $argv [expr {$i + 1}] end]
 	    break
 	}
+	"--select-commit=*" {
+	    set selecthead [string range $arg 16 end]
+	}
 	"--argscmd=*" {
 	    set revtreeargscmd [string range $arg 10 end]
 	}
@@ -9886,6 +9901,10 @@ foreach arg $argv {
     incr i
 }
 
+if {$selecthead eq "HEAD"} {
+    set selecthead {}
+}
+
 if {$i >= [llength $argv] && $revtreeargs ne {}} {
     # no -- on command line, but some arguments (other than --argscmd)
     if {[catch {
-- 
1.6.0.rc2
Previous: Alexander GavrilovNext: Alexander Gavrilov
Message 2 of 12 in “Improve gui blame and gitk integration”
  1. 0/7 Improve gui blame and gitk integrationAlexander Gavrilov, Aug 23, 2008
  2. 1/7 gitk: Allow overriding the default commit.Alexander Gavrilov, Aug 23, 2008
  3. 2/7 gitk: Support calling git gui blame from gitk.Alexander Gavrilov, Aug 23, 2008
  4. Paul MackerrasAug 26, 2008
  5. Johannes SixtAug 26, 2008
  6. Paul MackerrasAug 26, 2008
  7. 3/7 git-gui: Support starting gitk from Gui BlameAlexander Gavrilov, Aug 23, 2008
  8. 4/7 git-gui: Support passing blame to a parent commit.Alexander Gavrilov, Aug 23, 2008
  9. 5/7 git-gui: Better positioning in Blame Parent CommitAlexander Gavrilov, Aug 23, 2008
  10. 6/7 git-gui: Allow specifying an initial line for git gui blame.Alexander Gavrilov, Aug 23, 2008
  11. Shawn O. PearceAug 25, 2008
  12. 7/7 Document new options of gui tools.Alexander Gavrilov, Aug 23, 2008

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.