diff mbox series

[v2] git: replace two checks with one not equal check

Message ID pull.1432.v2.git.git.1734482334390.gitgitgadget@gmail.com (mailing list archive)
State New
Headers show
Series [v2] git: replace two checks with one not equal check | expand

Commit Message

Seija Kijin Dec. 18, 2024, 12:38 a.m. UTC
From: Seija Kijin <doremylover123@gmail.com>

(version < 2 || version > 2) looks silly
considering this is an integer.

Signed-off-by: Seija Kijin <doremylover123@gmail.com>
---
    git: replace two checks with one not equal check
    
    (version < 2 || version > 2) looks silly considering this is an integer.
    
    Signed-off-by: Seija Kijin doremylover123@gmail.com

Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-1432%2FAreaZR%2Fversion-v2
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-1432/AreaZR/version-v2
Pull-Request: https://github.com/git/git/pull/1432

Range-diff vs v1:

 1:  e9172aea097 ! 1:  07e0d614c21 git: replace two checks with one not equal check
     @@ Commit message
          Signed-off-by: Seija Kijin <doremylover123@gmail.com>
      
       ## builtin/show-index.c ##
     -@@ builtin/show-index.c: int cmd_show_index(int argc, const char **argv, const char *prefix)
     +@@ builtin/show-index.c: int cmd_show_index(int argc,
       		die("unable to read header");
       	if (top_index[0] == htonl(PACK_IDX_SIGNATURE)) {
       		version = ntohl(top_index[1]);


 builtin/show-index.c | 2 +-
 packfile.c           | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)


base-commit: 063bcebf0c917140ca0e705cbe0fdea127e90086
diff mbox series

Patch

diff --git a/builtin/show-index.c b/builtin/show-index.c
index f164c01bbea..5fb71a1c425 100644
--- a/builtin/show-index.c
+++ b/builtin/show-index.c
@@ -44,7 +44,7 @@  int cmd_show_index(int argc,
 		die("unable to read header");
 	if (top_index[0] == htonl(PACK_IDX_SIGNATURE)) {
 		version = ntohl(top_index[1]);
-		if (version < 2 || version > 2)
+		if (version != 2)
 			die("unknown index version");
 		if (fread(top_index, 256 * 4, 1, stdin) != 1)
 			die("unable to read index");
diff --git a/packfile.c b/packfile.c
index 9c4bd81a8c7..de0662b2353 100644
--- a/packfile.c
+++ b/packfile.c
@@ -114,7 +114,7 @@  int load_idx(const char *path, const unsigned int hashsz, void *idx_map,
 
 	if (hdr->idx_signature == htonl(PACK_IDX_SIGNATURE)) {
 		version = ntohl(hdr->idx_version);
-		if (version < 2 || version > 2)
+		if (version != 2)
 			return error("index file %s is version %"PRIu32
 				     " and is not supported by this binary"
 				     " (try upgrading GIT to a newer version)",