Andrew's git
/
gitweb.git
/ diff
summary
|
log
|
commit
| diff |
tree
commit
grep
author
committer
pickaxe
?
re
walker: convert to struct object_id
author
brian m. carlson
<sandals@crustytoothpaste.net>
Sun, 15 Oct 2017 22:06:48 +0000
(22:06 +0000)
committer
Junio C Hamano
<gitster@pobox.com>
Mon, 16 Oct 2017 02:05:50 +0000
(11:05 +0900)
Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
walker.c
patch
|
blob
|
history
raw
|
patch
|
inline
| side by side (parent:
111ef79
)
diff --git
a/walker.c
b/walker.c
index 274f1a4935798cba3e8cc7250559f14305678419..2d83254bc0350bf213860bbff9a835455ed6a2ce 100644
(file)
--- a/
walker.c
+++ b/
walker.c
@@
-7,7
+7,7
@@
#include "blob.h"
#include "refs.h"
#include "blob.h"
#include "refs.h"
-static
unsigned char current_commit_sha1[20]
;
+static
struct object_id current_commit_oid
;
void walker_say(struct walker *walker, const char *fmt, ...)
{
void walker_say(struct walker *walker, const char *fmt, ...)
{
@@
-24,9
+24,9
@@
static void report_missing(const struct object *obj)
fprintf(stderr, "Cannot obtain needed %s %s\n",
obj->type ? typename(obj->type): "object",
oid_to_hex(&obj->oid));
fprintf(stderr, "Cannot obtain needed %s %s\n",
obj->type ? typename(obj->type): "object",
oid_to_hex(&obj->oid));
- if (!is_null_
sha1(current_commit_sha1
))
+ if (!is_null_
oid(¤t_commit_oid
))
fprintf(stderr, "while processing commit %s.\n",
fprintf(stderr, "while processing commit %s.\n",
-
sha1_to_hex(current_commit_sha1
));
+
oid_to_hex(¤t_commit_oid
));
}
static int process(struct walker *walker, struct object *obj);
}
static int process(struct walker *walker, struct object *obj);
@@
-82,7
+82,7
@@
static int process_commit(struct walker *walker, struct commit *commit)
if (commit->object.flags & COMPLETE)
return 0;
if (commit->object.flags & COMPLETE)
return 0;
-
hashcpy(current_commit_sha1, commit->object.oid.hash
);
+
oidcpy(¤t_commit_oid, &commit->object.oid
);
walker_say(walker, "walk %s\n", oid_to_hex(&commit->object.oid));
walker_say(walker, "walk %s\n", oid_to_hex(&commit->object.oid));
@@
-187,14
+187,14
@@
static int loop(struct walker *walker)
return 0;
}
return 0;
}
-static int interpret_target(struct walker *walker, char *target,
unsigned char *sha1
)
+static int interpret_target(struct walker *walker, char *target,
struct object_id *oid
)
{
{
- if (!get_
sha1_hex(target, sha1
))
+ if (!get_
oid_hex(target, oid
))
return 0;
if (!check_refname_format(target, 0)) {
struct ref *ref = alloc_ref(target);
if (!walker->fetch_ref(walker, ref)) {
return 0;
if (!check_refname_format(target, 0)) {
struct ref *ref = alloc_ref(target);
if (!walker->fetch_ref(walker, ref)) {
-
hashcpy(sha1, ref->old_oid.hash
);
+
oidcpy(oid, &ref->old_oid
);
free(ref);
return 0;
}
free(ref);
return 0;
}
@@
-259,7
+259,7
@@
int walker_fetch(struct walker *walker, int targets, char **target,
struct strbuf refname = STRBUF_INIT;
struct strbuf err = STRBUF_INIT;
struct ref_transaction *transaction = NULL;
struct strbuf refname = STRBUF_INIT;
struct strbuf err = STRBUF_INIT;
struct ref_transaction *transaction = NULL;
-
unsigned char *sha1 = xmalloc(targets * 20
);
+
struct object_id *oids = xmalloc(targets * sizeof(struct object_id)
);
char *msg = NULL;
int i, ret = -1;
char *msg = NULL;
int i, ret = -1;
@@
-279,11
+279,11
@@
int walker_fetch(struct walker *walker, int targets, char **target,
}
for (i = 0; i < targets; i++) {
}
for (i = 0; i < targets; i++) {
- if (interpret_target(walker, target[i],
&sha1[20 * i]
)) {
+ if (interpret_target(walker, target[i],
oids + i
)) {
error("Could not interpret response from server '%s' as something to pull", target[i]);
goto done;
}
error("Could not interpret response from server '%s' as something to pull", target[i]);
goto done;
}
- if (process(walker, lookup_unknown_object(
&sha1[20 * i]
)))
+ if (process(walker, lookup_unknown_object(
oids[i].hash
)))
goto done;
}
goto done;
}
@@
-304,7
+304,7
@@
int walker_fetch(struct walker *walker, int targets, char **target,
strbuf_reset(&refname);
strbuf_addf(&refname, "refs/%s", write_ref[i]);
if (ref_transaction_update(transaction, refname.buf,
strbuf_reset(&refname);
strbuf_addf(&refname, "refs/%s", write_ref[i]);
if (ref_transaction_update(transaction, refname.buf,
-
&sha1[20 * i]
, NULL, 0,
+
oids[i].hash
, NULL, 0,
msg ? msg : "fetch (unknown)",
&err)) {
error("%s", err.buf);
msg ? msg : "fetch (unknown)",
&err)) {
error("%s", err.buf);
@@
-321,7
+321,7
@@
int walker_fetch(struct walker *walker, int targets, char **target,
done:
ref_transaction_free(transaction);
free(msg);
done:
ref_transaction_free(transaction);
free(msg);
- free(
sha1
);
+ free(
oids
);
strbuf_release(&err);
strbuf_release(&refname);
return ret;
strbuf_release(&err);
strbuf_release(&refname);
return ret;