builtin/rm: convert to use 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
Sep 5, 2016 at 20:08 UTC
8ec46d7e3e0c7d48dc61b9b521937aad11908439
1 file changed
+9
-9
builtin/rm.c
+9
-9
@@ -107,7 +107,7 @@ static int check_submodules_use_gitfiles(void)
107
return errs;
108
}
109
110
-static int check_local_mod(unsigned char *head, int index_only)
110
+static int check_local_mod(struct object_id *head, int index_only)
111
{
112
/*
113
* Items in list are already sorted in the cache order,
@@ -123,13 +123,13 @@ static int check_local_mod(unsigned char *head, int index_only)
123
struct string_list files_submodule = STRING_LIST_INIT_NODUP;
124
struct string_list files_local = STRING_LIST_INIT_NODUP;
125
126
- no_head = is_null_sha1(head);
126
+ no_head = is_null_oid(head);
127
for (i = 0; i < list.nr; i++) {
128
struct stat st;
129
int pos;
130
const struct cache_entry *ce;
131
const char *name = list.entry[i].name;
132
- unsigned char sha1[20];
132
+ struct object_id oid;
133
unsigned mode;
134
int local_changes = 0;
135
int staged_changes = 0;
@@ -197,9 +197,9 @@ static int check_local_mod(unsigned char *head, int index_only)
197
* way as changed from the HEAD.
198
*/
199
if (no_head
200
- || get_tree_entry(head, name, sha1, &mode)
200
+ || get_tree_entry(head->hash, name, oid.hash, &mode)
201
|| ce->ce_mode != create_ce_mode(mode)
202
- || hashcmp(ce->oid.hash, sha1))
202
+ || oidcmp(&ce->oid, &oid))
203
staged_changes = 1;
204
205
/*
@@ -351,10 +351,10 @@ int cmd_rm(int argc, const char **argv, const char *prefix)
351
* report no changes unless forced.
352
*/
353
if (!force) {
354
- unsigned char sha1[20];
355
- if (get_sha1("HEAD", sha1))
356
- hashclr(sha1);
357
- if (check_local_mod(sha1, index_only))
354
+ struct object_id oid;
355
+ if (get_oid("HEAD", &oid))
356
+ oidclr(&oid);
357
+ if (check_local_mod(&oid, index_only))
358
exit(1);
359
} else if (!index_only) {
360
if (check_submodules_use_gitfiles())