All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] gitk: parse arbitrary commit-ish in SHA1 field
@ 2009-08-08 14:56 Thomas Rast
  2009-08-11  5:13 ` Junio C Hamano
  0 siblings, 1 reply; 4+ messages in thread
From: Thomas Rast @ 2009-08-08 14:56 UTC (permalink / raw)
  To: Paul Mackerras; +Cc: git

We only accepted either SHA1s or heads/tags that have been read.  This
meant the user could not, e.g., enter HEAD to go back to the current
commit.

Add code to call out to git-rev-parse with the string entered if all
other methods of interpreting it failed.  The error paths change
slighly, because we now know from the rev-parse invocation whether the
expression was valid at all.  The previous "unknown" path is now only
triggered if the revision does exist, but is not in the current view
display.

Signed-off-by: Thomas Rast <trast@student.ethz.ch>
---

Of course, *ideally* we'd resort to *changing* the current view so
that it also lists the requested commit.  But my Tk-fu is currently
not up to that task.


 gitk |    7 ++++++-
 1 files changed, 6 insertions(+), 1 deletions(-)

diff --git a/gitk b/gitk
index 4604c83..4b27886 100755
--- a/gitk
+++ b/gitk
@@ -7906,6 +7906,11 @@ proc gotocommit {} {
 		}
 		set id [lindex $matches 0]
 	    }
+	} else {
+	    if {[catch {set id [exec git rev-parse $sha1string]}]} {
+		error_popup [mc "Revision %s is not known" $sha1string]
+		return
+	    }
 	}
     }
     if {[commitinview $id $curview]} {
@@ -7915,7 +7920,7 @@ proc gotocommit {} {
     if {[regexp {^[0-9a-fA-F]{4,}$} $sha1string]} {
 	set msg [mc "SHA1 id %s is not known" $sha1string]
     } else {
-	set msg [mc "Tag/Head %s is not known" $sha1string]
+	set msg [mc "Revision %s is not in the current view" $sha1string]
     }
     error_popup $msg
 }
-- 
1.6.4.199.g24c3

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] gitk: parse arbitrary commit-ish in SHA1 field
  2009-08-08 14:56 [PATCH] gitk: parse arbitrary commit-ish in SHA1 field Thomas Rast
@ 2009-08-11  5:13 ` Junio C Hamano
  2009-08-13  7:25   ` [PATCH v2] " Thomas Rast
  0 siblings, 1 reply; 4+ messages in thread
From: Junio C Hamano @ 2009-08-11  5:13 UTC (permalink / raw)
  To: Thomas Rast; +Cc: Paul Mackerras, git

Thomas Rast <trast@student.ethz.ch> writes:

> +	} else {
> +	    if {[catch {set id [exec git rev-parse $sha1string]}]} {

"--verify", or "--no-flags --revs-only"?  Examples of possible bad input
strings that you may otherwise not catch are:

	master..
        --merge -- a

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH v2] gitk: parse arbitrary commit-ish in SHA1 field
  2009-08-11  5:13 ` Junio C Hamano
@ 2009-08-13  7:25   ` Thomas Rast
  2009-08-13 11:54     ` Paul Mackerras
  0 siblings, 1 reply; 4+ messages in thread
From: Thomas Rast @ 2009-08-13  7:25 UTC (permalink / raw)
  To: Paul Mackerras; +Cc: Junio C Hamano, git

We only accepted either SHA1s or heads/tags that have been read.  This
meant the user could not, e.g., enter HEAD to go back to the current
commit.

Add code to call out to git rev-parse --verify with the string entered
if all other methods of interpreting it failed.  (git-rev-parse alone
is not enough as we really want a single revision.)

The error paths change slighly, because we now know from the rev-parse
invocation whether the expression was valid at all.  The previous
"unknown" path is now only triggered if the revision does exist, but
is not in the current view display.

Signed-off-by: Thomas Rast <trast@student.ethz.ch>
---

Junio C Hamano wrote:
> > +     } else {
> > +         if {[catch {set id [exec git rev-parse $sha1string]}]} {
> 
> "--verify", or "--no-flags --revs-only"?

Indeed, thanks.


 gitk |    7 ++++++-
 1 files changed, 6 insertions(+), 1 deletions(-)

diff --git a/gitk b/gitk
index 4604c83..e50b666 100755
--- a/gitk
+++ b/gitk
@@ -7906,6 +7906,11 @@ proc gotocommit {} {
 		}
 		set id [lindex $matches 0]
 	    }
+	} else {
+	    if {[catch {set id [exec git rev-parse --verify $sha1string]}]} {
+		error_popup [mc "Revision %s is not known" $sha1string]
+		return
+	    }
 	}
     }
     if {[commitinview $id $curview]} {
@@ -7915,7 +7920,7 @@ proc gotocommit {} {
     if {[regexp {^[0-9a-fA-F]{4,}$} $sha1string]} {
 	set msg [mc "SHA1 id %s is not known" $sha1string]
     } else {
-	set msg [mc "Tag/Head %s is not known" $sha1string]
+	set msg [mc "Revision %s is not in the current view" $sha1string]
     }
     error_popup $msg
 }
-- 
1.6.4.269.g0449d

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] gitk: parse arbitrary commit-ish in SHA1 field
  2009-08-13  7:25   ` [PATCH v2] " Thomas Rast
@ 2009-08-13 11:54     ` Paul Mackerras
  0 siblings, 0 replies; 4+ messages in thread
From: Paul Mackerras @ 2009-08-13 11:54 UTC (permalink / raw)
  To: Thomas Rast; +Cc: Junio C Hamano, git

Thomas Rast writes:

> We only accepted either SHA1s or heads/tags that have been read.  This
> meant the user could not, e.g., enter HEAD to go back to the current
> commit.
> 
> Add code to call out to git rev-parse --verify with the string entered
> if all other methods of interpreting it failed.  (git-rev-parse alone
> is not enough as we really want a single revision.)
> 
> The error paths change slighly, because we now know from the rev-parse
> invocation whether the expression was valid at all.  The previous
> "unknown" path is now only triggered if the revision does exist, but
> is not in the current view display.
> 
> Signed-off-by: Thomas Rast <trast@student.ethz.ch>

Thanks, applied.

Paul.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2009-08-13 11:55 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-08-08 14:56 [PATCH] gitk: parse arbitrary commit-ish in SHA1 field Thomas Rast
2009-08-11  5:13 ` Junio C Hamano
2009-08-13  7:25   ` [PATCH v2] " Thomas Rast
2009-08-13 11:54     ` Paul Mackerras

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.