builtin/unpack-file: convert to struct object_id
Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
brian m. carlson committed
Jul 13, 2017 at 23:49 UTC
c300b1ed5b0583aa6a4bc668a5da0ec33f2573fa
1 file changed
+6
-6
builtin/unpack-file.c
+6
-6
@@ -1,7 +1,7 @@
1
#include "builtin.h"
2
#include "config.h"
3
4
-static char *create_temp_file(unsigned char *sha1)
4
+static char *create_temp_file(struct object_id *oid)
5
{
6
static char path[50];
7
void *buf;
@@ -9,9 +9,9 @@ static char *create_temp_file(unsigned char *sha1)
9
unsigned long size;
10
int fd;
11
12
- buf = read_sha1_file(sha1, &type, &size);
12
+ buf = read_sha1_file(oid->hash, &type, &size);
13
if (!buf || type != OBJ_BLOB)
14
- die("unable to read blob object %s", sha1_to_hex(sha1));
14
+ die("unable to read blob object %s", oid_to_hex(oid));
15
16
xsnprintf(path, sizeof(path), ".merge_file_XXXXXX");
17
fd = xmkstemp(path);
@@ -23,15 +23,15 @@ static char *create_temp_file(unsigned char *sha1)
23
24
int cmd_unpack_file(int argc, const char **argv, const char *prefix)
25
{
26
- unsigned char sha1[20];
26
+ struct object_id oid;
27
28
if (argc != 2 || !strcmp(argv[1], "-h"))
29
usage("git unpack-file <sha1>");
30
- if (get_sha1(argv[1], sha1))
30
+ if (get_oid(argv[1], &oid))
31
die("Not a valid object name %s", argv[1]);
32
33
git_config(git_default_config, NULL);
34
35
- puts(create_temp_file(sha1));
35
+ puts(create_temp_file(&oid));
36
return 0;
37
}