Skip to content

Commit fd52124

Browse files
bk2204gitster
authored andcommitted
revision: replace use of hard-coded constants
Replace two uses of the hard-coded constant 40 with references to the_hash_algo. Signed-off-by: brian m. carlson <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent dd724bc commit fd52124

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

revision.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1751,6 +1751,7 @@ static int handle_revision_opt(struct rev_info *revs, int argc, const char **arg
17511751
const char *arg = argv[0];
17521752
const char *optarg;
17531753
int argcount;
1754+
const unsigned hexsz = the_hash_algo->hexsz;
17541755

17551756
/* pseudo revision arguments */
17561757
if (!strcmp(arg, "--all") || !strcmp(arg, "--branches") ||
@@ -2038,8 +2039,8 @@ static int handle_revision_opt(struct rev_info *revs, int argc, const char **arg
20382039
revs->abbrev = strtoul(optarg, NULL, 10);
20392040
if (revs->abbrev < MINIMUM_ABBREV)
20402041
revs->abbrev = MINIMUM_ABBREV;
2041-
else if (revs->abbrev > 40)
2042-
revs->abbrev = 40;
2042+
else if (revs->abbrev > hexsz)
2043+
revs->abbrev = hexsz;
20432044
} else if (!strcmp(arg, "--abbrev-commit")) {
20442045
revs->abbrev_commit = 1;
20452046
revs->abbrev_commit_given = 1;

0 commit comments

Comments
 (0)