projects
/
platform
/
upstream
/
git.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
packaging: Add contrib installation
[platform/upstream/git.git]
/
walker.c
diff --git
a/walker.c
b/walker.c
index
2c86e40
..
4984bf8
100644
(file)
--- a/
walker.c
+++ b/
walker.c
@@
-1,13
+1,16
@@
#include "cache.h"
#include "walker.h"
#include "cache.h"
#include "walker.h"
+#include "repository.h"
+#include "object-store.h"
#include "commit.h"
#include "tree.h"
#include "tree-walk.h"
#include "tag.h"
#include "blob.h"
#include "refs.h"
#include "commit.h"
#include "tree.h"
#include "tree-walk.h"
#include "tag.h"
#include "blob.h"
#include "refs.h"
+#include "progress.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, ...)
{
@@
-22,11
+25,11
@@
void walker_say(struct walker *walker, const char *fmt, ...)
static void report_missing(const struct object *obj)
{
fprintf(stderr, "Cannot obtain needed %s %s\n",
static void report_missing(const struct object *obj)
{
fprintf(stderr, "Cannot obtain needed %s %s\n",
- obj->type ? typename(obj->type): "object",
+ obj->type ? type
_
name(obj->type): "object",
oid_to_hex(&obj->oid));
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);
@@
-47,12
+50,14
@@
static int process_tree(struct walker *walker, struct tree *tree)
if (S_ISGITLINK(entry.mode))
continue;
if (S_ISDIR(entry.mode)) {
if (S_ISGITLINK(entry.mode))
continue;
if (S_ISDIR(entry.mode)) {
- struct tree *tree = lookup_tree(entry.oid->hash);
+ struct tree *tree = lookup_tree(the_repository,
+ &entry.oid);
if (tree)
obj = &tree->object;
}
else {
if (tree)
obj = &tree->object;
}
else {
- struct blob *blob = lookup_blob(entry.oid->hash);
+ struct blob *blob = lookup_blob(the_repository,
+ &entry.oid);
if (blob)
obj = &blob->object;
}
if (blob)
obj = &blob->object;
}
@@
-72,6
+77,8
@@
static struct commit_list *complete = NULL;
static int process_commit(struct walker *walker, struct commit *commit)
{
static int process_commit(struct walker *walker, struct commit *commit)
{
+ struct commit_list *parents;
+
if (parse_commit(commit))
return -1;
if (parse_commit(commit))
return -1;
@@
-82,23
+89,18
@@
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));
- if (walker->get_tree) {
- if (process(walker, &commit->tree->object))
+ if (process(walker, &get_commit_tree(commit)->object))
+ return -1;
+
+ for (parents = commit->parents; parents; parents = parents->next) {
+ if (process(walker, &parents->item->object))
return -1;
return -1;
- if (!walker->get_all)
- walker->get_tree = 0;
- }
- if (walker->get_history) {
- struct commit_list *parents = commit->parents;
- for (; parents; parents = parents->next) {
- if (process(walker, &parents->item->object))
- return -1;
- }
}
}
+
return 0;
}
return 0;
}
@@
-134,7
+136,7
@@
static int process_object(struct walker *walker, struct object *obj)
}
return error("Unable to determine requirements "
"of type %s for %s",
}
return error("Unable to determine requirements "
"of type %s for %s",
- typename(obj->type), oid_to_hex(&obj->oid));
+ type
_
name(obj->type), oid_to_hex(&obj->oid));
}
static int process(struct walker *walker, struct object *obj)
}
static int process(struct walker *walker, struct object *obj)
@@
-161,6
+163,11
@@
static int process(struct walker *walker, struct object *obj)
static int loop(struct walker *walker)
{
struct object_list *elem;
static int loop(struct walker *walker)
{
struct object_list *elem;
+ struct progress *progress = NULL;
+ uint64_t nr = 0;
+
+ if (walker->get_progress)
+ progress = start_delayed_progress(_("Fetching objects"), 0);
while (process_queue) {
struct object *obj = process_queue->item;
while (process_queue) {
struct object *obj = process_queue->item;
@@
-175,26
+182,31
@@
static int loop(struct walker *walker)
*/
if (! (obj->flags & TO_SCAN)) {
if (walker->fetch(walker, obj->oid.hash)) {
*/
if (! (obj->flags & TO_SCAN)) {
if (walker->fetch(walker, obj->oid.hash)) {
+ stop_progress(&progress);
report_missing(obj);
return -1;
}
}
if (!obj->type)
report_missing(obj);
return -1;
}
}
if (!obj->type)
- parse_object(obj->oid.hash);
- if (process_object(walker, obj))
+ parse_object(the_repository, &obj->oid);
+ if (process_object(walker, obj)) {
+ stop_progress(&progress);
return -1;
return -1;
+ }
+ display_progress(progress, ++nr);
}
}
+ stop_progress(&progress);
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;
}
@@
-206,7
+218,8
@@
static int interpret_target(struct walker *walker, char *target, unsigned char *
static int mark_complete(const char *path, const struct object_id *oid,
int flag, void *cb_data)
{
static int mark_complete(const char *path, const struct object_id *oid,
int flag, void *cb_data)
{
- struct commit *commit = lookup_commit_reference_gently(oid->hash, 1);
+ struct commit *commit = lookup_commit_reference_gently(the_repository,
+ oid, 1);
if (commit) {
commit->object.flags |= COMPLETE;
if (commit) {
commit->object.flags |= COMPLETE;
@@
-259,12
+272,14
@@
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
;
char *msg = NULL;
int i, ret = -1;
save_commit_buffer = 0;
char *msg = NULL;
int i, ret = -1;
save_commit_buffer = 0;
+ ALLOC_ARRAY(oids, targets);
+
if (write_ref) {
transaction = ref_transaction_begin(&err);
if (!transaction) {
if (write_ref) {
transaction = ref_transaction_begin(&err);
if (!transaction) {
@@
-279,11
+294,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])))
goto done;
}
goto done;
}
@@
-304,7
+319,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
, NULL, 0,
msg ? msg : "fetch (unknown)",
&err)) {
error("%s", err.buf);
msg ? msg : "fetch (unknown)",
&err)) {
error("%s", err.buf);
@@
-321,7
+336,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;