aboutsummaryrefslogtreecommitdiff
path: root/sha1_file.c
diff options
context:
space:
mode:
authorJunio C Hamano <junkio@cox.net>2005-08-03 22:15:49 -0700
committerJunio C Hamano <junkio@cox.net>2005-08-05 00:51:07 -0700
commit9938af6a85dd08436ad373fc07a1ddba8dcfa170 (patch)
tree476d9177c8b5023e1804dcf9354efc1966bcdea1 /sha1_file.c
parent37fde874c2448ae2cd98abe24df2bd2a50aa2cda (diff)
downloadgit-9938af6a85dd08436ad373fc07a1ddba8dcfa170.tar.gz
git-9938af6a85dd08436ad373fc07a1ddba8dcfa170.tar.xz
Update get_sha1() to grok extended format.
Everybody envies rev-parse, who is the only one that can grok the extended sha1 format. Move the get_extended_sha1() out of rev-parse, rename it to get_sha1() and make it available to everybody else. The one I posted earlier to the list had one bug where it did not handle a name that ends with a digit correctly (it incorrectly tried the "Nth parent" path). This commit fixes it. Signed-off-by: Junio C Hamano <junkio@cox.net>
Diffstat (limited to 'sha1_file.c')
-rw-r--r--sha1_file.c39
1 files changed, 0 insertions, 39 deletions
diff --git a/sha1_file.c b/sha1_file.c
index df5eb2ac6..a17a6d13b 100644
--- a/sha1_file.c
+++ b/sha1_file.c
@@ -46,21 +46,6 @@ int get_sha1_hex(const char *hex, unsigned char *sha1)
return 0;
}
-static int get_sha1_file(const char *path, unsigned char *result)
-{
- char buffer[60];
- int fd = open(path, O_RDONLY);
- int len;
-
- if (fd < 0)
- return -1;
- len = read(fd, buffer, sizeof(buffer));
- close(fd);
- if (len < 40)
- return -1;
- return get_sha1_hex(buffer, result);
-}
-
static char *git_dir, *git_object_dir, *git_index_file, *git_refs_dir,
*git_graft_file;
static void setup_git_env(void)
@@ -132,30 +117,6 @@ int safe_create_leading_directories(char *path)
return 0;
}
-int get_sha1(const char *str, unsigned char *sha1)
-{
- static const char *prefix[] = {
- "",
- "refs",
- "refs/tags",
- "refs/heads",
- "refs/snap",
- NULL
- };
- const char **p;
-
- if (!get_sha1_hex(str, sha1))
- return 0;
-
- for (p = prefix; *p; p++) {
- char * pathname = git_path("%s/%s", *p, str);
- if (!get_sha1_file(pathname, sha1))
- return 0;
- }
-
- return -1;
-}
-
char * sha1_to_hex(const unsigned char *sha1)
{
static char buffer[50];