Skip to content

Commit f01cc14

Browse files
committed
sha1_name.c: hide get_sha1_with_context_1() ugliness
There is no outside caller that cares about the "only-to-die" ugliness. Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent a1b475e commit f01cc14

2 files changed

Lines changed: 19 additions & 18 deletions

File tree

cache.h

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -817,11 +817,7 @@ static inline int get_sha1_with_mode(const char *str, unsigned char *sha1, unsig
817817
{
818818
return get_sha1_with_mode_1(str, sha1, mode, 0, NULL);
819819
}
820-
extern int get_sha1_with_context_1(const char *name, unsigned char *sha1, struct object_context *orc, int only_to_die, const char *prefix);
821-
static inline int get_sha1_with_context(const char *str, unsigned char *sha1, struct object_context *orc)
822-
{
823-
return get_sha1_with_context_1(str, sha1, orc, 0, NULL);
824-
}
820+
extern int get_sha1_with_context(const char *str, unsigned char *sha1, struct object_context *orc);
825821

826822
/*
827823
* Try to read a SHA1 in hexadecimal format from the 40 characters

sha1_name.c

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -992,16 +992,6 @@ static void diagnose_invalid_index_path(int stage,
992992
}
993993

994994

995-
int get_sha1_with_mode_1(const char *name, unsigned char *sha1, unsigned *mode,
996-
int only_to_die, const char *prefix)
997-
{
998-
struct object_context oc;
999-
int ret;
1000-
ret = get_sha1_with_context_1(name, sha1, &oc, only_to_die, prefix);
1001-
*mode = oc.mode;
1002-
return ret;
1003-
}
1004-
1005995
static char *resolve_relative_path(const char *rel)
1006996
{
1007997
if (prefixcmp(rel, "./") && prefixcmp(rel, "../"))
@@ -1019,9 +1009,9 @@ static char *resolve_relative_path(const char *rel)
10191009
rel);
10201010
}
10211011

1022-
int get_sha1_with_context_1(const char *name, unsigned char *sha1,
1023-
struct object_context *oc,
1024-
int only_to_die, const char *prefix)
1012+
static int get_sha1_with_context_1(const char *name, unsigned char *sha1,
1013+
struct object_context *oc,
1014+
int only_to_die, const char *prefix)
10251015
{
10261016
int ret, bracket_depth;
10271017
int namelen = strlen(name);
@@ -1134,3 +1124,18 @@ int get_sha1_with_context_1(const char *name, unsigned char *sha1,
11341124
}
11351125
return ret;
11361126
}
1127+
1128+
int get_sha1_with_mode_1(const char *name, unsigned char *sha1, unsigned *mode,
1129+
int only_to_die, const char *prefix)
1130+
{
1131+
struct object_context oc;
1132+
int ret;
1133+
ret = get_sha1_with_context_1(name, sha1, &oc, only_to_die, prefix);
1134+
*mode = oc.mode;
1135+
return ret;
1136+
}
1137+
1138+
int get_sha1_with_context(const char *str, unsigned char *sha1, struct object_context *orc)
1139+
{
1140+
return get_sha1_with_context_1(str, sha1, orc, 0, NULL);
1141+
}

0 commit comments

Comments
 (0)