git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: "Carlo Marcelo Arenas Belón" <carenas@gmail.com>
To: git@vger.kernel.org
Cc: angavrilov@gmail.com, me@yadavpratyush.com,
	"Carlo Marcelo Arenas Belón" <carenas@gmail.com>
Subject: [RFC PATCH 1/4] blame: prefer null_sha1 over nullid and retire later
Date: Mon, 11 Oct 2021 05:17:54 -0700	[thread overview]
Message-ID: <20211011121757.627-2-carenas@gmail.com> (raw)
In-Reply-To: <20211011121757.627-1-carenas@gmail.com>

a9786bb (git-gui: Fix Blame Parent & Context for working copy lines.,
2008-09-08) adds nullid (and a never used nullid2) for matching locally
modified lines in blame.

Use instead the already available null_sha1 for the same and in
preparation to making that hash independent on a future patch.

Signed-off-by: Carlo Marcelo Arenas Belón <carenas@gmail.com>
---
 git-gui.sh    |  3 ---
 lib/blame.tcl | 10 +++++-----
 2 files changed, 5 insertions(+), 8 deletions(-)

diff --git a/git-gui.sh b/git-gui.sh
index 201524c..a69b0fe 100755
--- a/git-gui.sh
+++ b/git-gui.sh
@@ -1353,9 +1353,6 @@ set diff_empty_count 0
 set last_revert {}
 set last_revert_enc {}
 
-set nullid "0000000000000000000000000000000000000000"
-set nullid2 "0000000000000000000000000000000000000001"
-
 ######################################################################
 ##
 ## task management
diff --git a/lib/blame.tcl b/lib/blame.tcl
index 8441e10..6ece79d 100644
--- a/lib/blame.tcl
+++ b/lib/blame.tcl
@@ -1056,14 +1056,14 @@ method _format_offset_date {base offset} {
 }
 
 method _gitkcommit {} {
-	global nullid
+	global null_sha1
 
 	set dat [_get_click_amov_info $this]
 	if {$dat ne {}} {
 		set cmit [lindex $dat 0]
 
 		# If the line belongs to the working copy, use HEAD instead
-		if {$cmit eq $nullid} {
+		if {$cmit eq $null_sha1} {
 			if {[catch {set cmit [git rev-parse --verify HEAD]} err]} {
 				error_popup [strcat [mc "Cannot find HEAD commit:"] "\n\n$err"]
 				return;
@@ -1106,7 +1106,7 @@ method _gitkcommit {} {
 }
 
 method _blameparent {} {
-	global nullid
+	global null_sha1
 
 	set dat [_get_click_amov_info $this]
 	if {$dat ne {}} {
@@ -1114,7 +1114,7 @@ method _blameparent {} {
 		set new_path [lindex $dat 1]
 
 		# Allow using Blame Parent on lines modified in the working copy
-		if {$cmit eq $nullid} {
+		if {$cmit eq $null_sha1} {
 			set parent_ref "HEAD"
 		} else {
 			set parent_ref "$cmit^"
@@ -1129,7 +1129,7 @@ method _blameparent {} {
 		# Generate a diff between the commit and its parent,
 		# and use the hunks to update the line number.
 		# Request zero context to simplify calculations.
-		if {$cmit eq $nullid} {
+		if {$cmit eq $null_sha1} {
 			set diffcmd [list diff-index --unified=0 $cparent -- $new_path]
 		} else {
 			set diffcmd [list diff-tree --unified=0 $cparent $cmit -- $new_path]
-- 
2.33.0.1081.g099423f5b7


  reply	other threads:[~2021-10-11 12:18 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-11 12:17 [RFC PATCH 0/4] git-gui: support SHA-256 repositories Carlo Marcelo Arenas Belón
2021-10-11 12:17 ` Carlo Marcelo Arenas Belón [this message]
2021-10-27 19:43   ` [RFC PATCH 1/4] blame: prefer null_sha1 over nullid and retire later Pratyush Yadav
2021-10-11 12:17 ` [RFC PATCH 2/4] rename all *_sha1 variables and make null_oid hash aware Carlo Marcelo Arenas Belón
2021-10-11 20:07   ` Eric Sunshine
2021-11-13  6:54   ` Pratyush Yadav
2021-10-11 12:17 ` [RFC PATCH 3/4] expand regexp matching an oid to be hash agnostic Carlo Marcelo Arenas Belón
2021-11-13  7:55   ` Pratyush Yadav
2021-10-11 12:17 ` [RFC PATCH 4/4] track oid_size to allow for checks that are " Carlo Marcelo Arenas Belón
2021-11-13  8:04   ` Pratyush Yadav
2021-11-13  8:10     ` Pratyush Yadav
2021-10-11 14:15 ` [RFC PATCH 0/4] git-gui: support SHA-256 repositories Ævar Arnfjörð Bjarmason
2021-10-11 19:47   ` Carlo Arenas
2021-11-13  8:08 ` Pratyush Yadav

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20211011121757.627-2-carenas@gmail.com \
    --to=carenas@gmail.com \
    --cc=angavrilov@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=me@yadavpratyush.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).