Merge branch 'lt/objlist'
* lt/objlist: Add "named object array" concept
This commit is contained in:
commit
f97ccded31
@ -41,7 +41,7 @@ int cmd_diff_files(int argc, const char **argv, char **envp)
|
|||||||
* rev.max_count is reasonable (0 <= n <= 3),
|
* rev.max_count is reasonable (0 <= n <= 3),
|
||||||
* there is no other revision filtering parameters.
|
* there is no other revision filtering parameters.
|
||||||
*/
|
*/
|
||||||
if (rev.pending_objects ||
|
if (rev.pending.nr ||
|
||||||
rev.min_age != -1 || rev.max_age != -1)
|
rev.min_age != -1 || rev.max_age != -1)
|
||||||
usage(diff_files_usage);
|
usage(diff_files_usage);
|
||||||
/*
|
/*
|
||||||
|
@ -32,7 +32,7 @@ int cmd_diff_index(int argc, const char **argv, char **envp)
|
|||||||
* Make sure there is one revision (i.e. pending object),
|
* Make sure there is one revision (i.e. pending object),
|
||||||
* and there is no revision filtering parameters.
|
* and there is no revision filtering parameters.
|
||||||
*/
|
*/
|
||||||
if (!rev.pending_objects || rev.pending_objects->next ||
|
if (rev.pending.nr != 1 ||
|
||||||
rev.max_count != -1 || rev.min_age != -1 || rev.max_age != -1)
|
rev.max_count != -1 || rev.min_age != -1 || rev.max_age != -1)
|
||||||
usage(diff_cache_usage);
|
usage(diff_cache_usage);
|
||||||
return run_diff_index(&rev, cached);
|
return run_diff_index(&rev, cached);
|
||||||
|
@ -65,7 +65,6 @@ int cmd_diff_tree(int argc, const char **argv, char **envp)
|
|||||||
char line[1000];
|
char line[1000];
|
||||||
struct object *tree1, *tree2;
|
struct object *tree1, *tree2;
|
||||||
static struct rev_info *opt = &log_tree_opt;
|
static struct rev_info *opt = &log_tree_opt;
|
||||||
struct object_list *list;
|
|
||||||
int read_stdin = 0;
|
int read_stdin = 0;
|
||||||
|
|
||||||
git_config(git_diff_config);
|
git_config(git_diff_config);
|
||||||
@ -86,45 +85,28 @@ int cmd_diff_tree(int argc, const char **argv, char **envp)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* NOTE! "setup_revisions()" will have inserted the revisions
|
* NOTE! We expect "a ^b" to be equal to "a..b", so we
|
||||||
* it parsed in reverse order. So if you do
|
* reverse the order of the objects if the second one
|
||||||
*
|
* is marked UNINTERESTING.
|
||||||
* git-diff-tree a b
|
|
||||||
*
|
|
||||||
* the commit list will be "b" -> "a" -> NULL, so we reverse
|
|
||||||
* the order of the objects if the first one is not marked
|
|
||||||
* UNINTERESTING.
|
|
||||||
*/
|
*/
|
||||||
nr_sha1 = 0;
|
nr_sha1 = opt->pending.nr;
|
||||||
list = opt->pending_objects;
|
|
||||||
if (list) {
|
|
||||||
nr_sha1++;
|
|
||||||
tree1 = list->item;
|
|
||||||
list = list->next;
|
|
||||||
if (list) {
|
|
||||||
nr_sha1++;
|
|
||||||
tree2 = tree1;
|
|
||||||
tree1 = list->item;
|
|
||||||
if (list->next)
|
|
||||||
usage(diff_tree_usage);
|
|
||||||
/* Switch them around if the second one was uninteresting.. */
|
|
||||||
if (tree2->flags & UNINTERESTING) {
|
|
||||||
struct object *tmp = tree2;
|
|
||||||
tree2 = tree1;
|
|
||||||
tree1 = tmp;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (nr_sha1) {
|
switch (nr_sha1) {
|
||||||
case 0:
|
case 0:
|
||||||
if (!read_stdin)
|
if (!read_stdin)
|
||||||
usage(diff_tree_usage);
|
usage(diff_tree_usage);
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
|
tree1 = opt->pending.objects[0].item;
|
||||||
diff_tree_commit_sha1(tree1->sha1);
|
diff_tree_commit_sha1(tree1->sha1);
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
|
tree1 = opt->pending.objects[0].item;
|
||||||
|
tree2 = opt->pending.objects[1].item;
|
||||||
|
if (tree2->flags & UNINTERESTING) {
|
||||||
|
struct object *tmp = tree2;
|
||||||
|
tree2 = tree1;
|
||||||
|
tree1 = tmp;
|
||||||
|
}
|
||||||
diff_tree_sha1(tree1->sha1,
|
diff_tree_sha1(tree1->sha1,
|
||||||
tree2->sha1,
|
tree2->sha1,
|
||||||
"", &opt->diffopt);
|
"", &opt->diffopt);
|
||||||
|
@ -50,7 +50,7 @@ static int builtin_diff_files(struct rev_info *revs,
|
|||||||
* specified rev.max_count is reasonable (0 <= n <= 3), and
|
* specified rev.max_count is reasonable (0 <= n <= 3), and
|
||||||
* there is no other revision filtering parameter.
|
* there is no other revision filtering parameter.
|
||||||
*/
|
*/
|
||||||
if (revs->pending_objects ||
|
if (revs->pending.nr ||
|
||||||
revs->min_age != -1 ||
|
revs->min_age != -1 ||
|
||||||
revs->max_age != -1 ||
|
revs->max_age != -1 ||
|
||||||
3 < revs->max_count)
|
3 < revs->max_count)
|
||||||
@ -172,7 +172,7 @@ static int builtin_diff_index(struct rev_info *revs,
|
|||||||
* Make sure there is one revision (i.e. pending object),
|
* Make sure there is one revision (i.e. pending object),
|
||||||
* and there is no revision filtering parameters.
|
* and there is no revision filtering parameters.
|
||||||
*/
|
*/
|
||||||
if (!revs->pending_objects || revs->pending_objects->next ||
|
if (revs->pending.nr != 1 ||
|
||||||
revs->max_count != -1 || revs->min_age != -1 ||
|
revs->max_count != -1 || revs->min_age != -1 ||
|
||||||
revs->max_age != -1)
|
revs->max_age != -1)
|
||||||
usage(builtin_diff_usage);
|
usage(builtin_diff_usage);
|
||||||
@ -181,10 +181,10 @@ static int builtin_diff_index(struct rev_info *revs,
|
|||||||
|
|
||||||
static int builtin_diff_tree(struct rev_info *revs,
|
static int builtin_diff_tree(struct rev_info *revs,
|
||||||
int argc, const char **argv,
|
int argc, const char **argv,
|
||||||
struct object_list *ent)
|
struct object_array_entry *ent)
|
||||||
{
|
{
|
||||||
const unsigned char *(sha1[2]);
|
const unsigned char *(sha1[2]);
|
||||||
int swap = 1;
|
int swap = 0;
|
||||||
while (1 < argc) {
|
while (1 < argc) {
|
||||||
const char *arg = argv[1];
|
const char *arg = argv[1];
|
||||||
if (!strcmp(arg, "--raw"))
|
if (!strcmp(arg, "--raw"))
|
||||||
@ -195,10 +195,10 @@ static int builtin_diff_tree(struct rev_info *revs,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* We saw two trees, ent[0] and ent[1].
|
/* We saw two trees, ent[0] and ent[1].
|
||||||
* unless ent[0] is unintesting, they are swapped
|
* if ent[1] is unintesting, they are swapped
|
||||||
*/
|
*/
|
||||||
if (ent[0].item->flags & UNINTERESTING)
|
if (ent[1].item->flags & UNINTERESTING)
|
||||||
swap = 0;
|
swap = 1;
|
||||||
sha1[swap] = ent[0].item->sha1;
|
sha1[swap] = ent[0].item->sha1;
|
||||||
sha1[1-swap] = ent[1].item->sha1;
|
sha1[1-swap] = ent[1].item->sha1;
|
||||||
diff_tree_sha1(sha1[0], sha1[1], "", &revs->diffopt);
|
diff_tree_sha1(sha1[0], sha1[1], "", &revs->diffopt);
|
||||||
@ -208,7 +208,7 @@ static int builtin_diff_tree(struct rev_info *revs,
|
|||||||
|
|
||||||
static int builtin_diff_combined(struct rev_info *revs,
|
static int builtin_diff_combined(struct rev_info *revs,
|
||||||
int argc, const char **argv,
|
int argc, const char **argv,
|
||||||
struct object_list *ent,
|
struct object_array_entry *ent,
|
||||||
int ents)
|
int ents)
|
||||||
{
|
{
|
||||||
const unsigned char (*parent)[20];
|
const unsigned char (*parent)[20];
|
||||||
@ -242,13 +242,14 @@ void add_head(struct rev_info *revs)
|
|||||||
obj = parse_object(sha1);
|
obj = parse_object(sha1);
|
||||||
if (!obj)
|
if (!obj)
|
||||||
return;
|
return;
|
||||||
add_object(obj, &revs->pending_objects, NULL, "HEAD");
|
add_pending_object(revs, obj, "HEAD");
|
||||||
}
|
}
|
||||||
|
|
||||||
int cmd_diff(int argc, const char **argv, char **envp)
|
int cmd_diff(int argc, const char **argv, char **envp)
|
||||||
{
|
{
|
||||||
|
int i;
|
||||||
struct rev_info rev;
|
struct rev_info rev;
|
||||||
struct object_list *list, ent[100];
|
struct object_array_entry ent[100];
|
||||||
int ents = 0, blobs = 0, paths = 0;
|
int ents = 0, blobs = 0, paths = 0;
|
||||||
const char *path = NULL;
|
const char *path = NULL;
|
||||||
struct blobinfo blob[2];
|
struct blobinfo blob[2];
|
||||||
@ -281,7 +282,7 @@ int cmd_diff(int argc, const char **argv, char **envp)
|
|||||||
/* Do we have --cached and not have a pending object, then
|
/* Do we have --cached and not have a pending object, then
|
||||||
* default to HEAD by hand. Eek.
|
* default to HEAD by hand. Eek.
|
||||||
*/
|
*/
|
||||||
if (!rev.pending_objects) {
|
if (!rev.pending.nr) {
|
||||||
int i;
|
int i;
|
||||||
for (i = 1; i < argc; i++) {
|
for (i = 1; i < argc; i++) {
|
||||||
const char *arg = argv[i];
|
const char *arg = argv[i];
|
||||||
@ -294,7 +295,8 @@ int cmd_diff(int argc, const char **argv, char **envp)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (list = rev.pending_objects; list; list = list->next) {
|
for (i = 0; i < rev.pending.nr; i++) {
|
||||||
|
struct object_array_entry *list = rev.pending.objects+i;
|
||||||
struct object *obj = list->item;
|
struct object *obj = list->item;
|
||||||
const char *name = list->name;
|
const char *name = list->name;
|
||||||
int flags = (obj->flags & UNINTERESTING);
|
int flags = (obj->flags & UNINTERESTING);
|
||||||
|
@ -658,7 +658,7 @@ int cmd_grep(int argc, const char **argv, char **envp)
|
|||||||
int cached = 0;
|
int cached = 0;
|
||||||
int seen_dashdash = 0;
|
int seen_dashdash = 0;
|
||||||
struct grep_opt opt;
|
struct grep_opt opt;
|
||||||
struct object_list *list, **tail, *object_list = NULL;
|
struct object_array list = { 0, 0, NULL };
|
||||||
const char *prefix = setup_git_directory();
|
const char *prefix = setup_git_directory();
|
||||||
const char **paths = NULL;
|
const char **paths = NULL;
|
||||||
int i;
|
int i;
|
||||||
@ -678,7 +678,6 @@ int cmd_grep(int argc, const char **argv, char **envp)
|
|||||||
* that continues up to the -- (if exists), and then paths.
|
* that continues up to the -- (if exists), and then paths.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
tail = &object_list;
|
|
||||||
while (1 < argc) {
|
while (1 < argc) {
|
||||||
const char *arg = argv[1];
|
const char *arg = argv[1];
|
||||||
argc--; argv++;
|
argc--; argv++;
|
||||||
@ -852,12 +851,9 @@ int cmd_grep(int argc, const char **argv, char **envp)
|
|||||||
/* Is it a rev? */
|
/* Is it a rev? */
|
||||||
if (!get_sha1(arg, sha1)) {
|
if (!get_sha1(arg, sha1)) {
|
||||||
struct object *object = parse_object(sha1);
|
struct object *object = parse_object(sha1);
|
||||||
struct object_list *elem;
|
|
||||||
if (!object)
|
if (!object)
|
||||||
die("bad object %s", arg);
|
die("bad object %s", arg);
|
||||||
elem = object_list_insert(object, tail);
|
add_object_array(object, arg, &list);
|
||||||
elem->name = arg;
|
|
||||||
tail = &elem->next;
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (!strcmp(arg, "--")) {
|
if (!strcmp(arg, "--")) {
|
||||||
@ -882,16 +878,16 @@ int cmd_grep(int argc, const char **argv, char **envp)
|
|||||||
paths[1] = NULL;
|
paths[1] = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!object_list)
|
if (!list.nr)
|
||||||
return !grep_cache(&opt, paths, cached);
|
return !grep_cache(&opt, paths, cached);
|
||||||
|
|
||||||
if (cached)
|
if (cached)
|
||||||
die("both --cached and trees are given.");
|
die("both --cached and trees are given.");
|
||||||
|
|
||||||
for (list = object_list; list; list = list->next) {
|
for (i = 0; i < list.nr; i++) {
|
||||||
struct object *real_obj;
|
struct object *real_obj;
|
||||||
real_obj = deref_tag(list->item, NULL, 0);
|
real_obj = deref_tag(list.objects[i].item, NULL, 0);
|
||||||
if (grep_object(&opt, paths, real_obj, list->name))
|
if (grep_object(&opt, paths, real_obj, list.objects[i].name))
|
||||||
hit = 1;
|
hit = 1;
|
||||||
}
|
}
|
||||||
return !hit;
|
return !hit;
|
||||||
|
@ -257,8 +257,8 @@ int cmd_format_patch(int argc, const char **argv, char **envp)
|
|||||||
output_directory);
|
output_directory);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rev.pending_objects && rev.pending_objects->next == NULL) {
|
if (rev.pending.nr == 1) {
|
||||||
rev.pending_objects->item->flags |= UNINTERESTING;
|
rev.pending.objects[0].item->flags |= UNINTERESTING;
|
||||||
add_head(&rev);
|
add_head(&rev);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -99,26 +99,26 @@ static void show_commit(struct commit *commit)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct object_list **process_blob(struct blob *blob,
|
static void process_blob(struct blob *blob,
|
||||||
struct object_list **p,
|
struct object_array *p,
|
||||||
struct name_path *path,
|
struct name_path *path,
|
||||||
const char *name)
|
const char *name)
|
||||||
{
|
{
|
||||||
struct object *obj = &blob->object;
|
struct object *obj = &blob->object;
|
||||||
|
|
||||||
if (!revs.blob_objects)
|
if (!revs.blob_objects)
|
||||||
return p;
|
return;
|
||||||
if (obj->flags & (UNINTERESTING | SEEN))
|
if (obj->flags & (UNINTERESTING | SEEN))
|
||||||
return p;
|
return;
|
||||||
obj->flags |= SEEN;
|
obj->flags |= SEEN;
|
||||||
name = strdup(name);
|
name = strdup(name);
|
||||||
return add_object(obj, p, path, name);
|
add_object(obj, p, path, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct object_list **process_tree(struct tree *tree,
|
static void process_tree(struct tree *tree,
|
||||||
struct object_list **p,
|
struct object_array *p,
|
||||||
struct name_path *path,
|
struct name_path *path,
|
||||||
const char *name)
|
const char *name)
|
||||||
{
|
{
|
||||||
struct object *obj = &tree->object;
|
struct object *obj = &tree->object;
|
||||||
struct tree_desc desc;
|
struct tree_desc desc;
|
||||||
@ -126,14 +126,14 @@ static struct object_list **process_tree(struct tree *tree,
|
|||||||
struct name_path me;
|
struct name_path me;
|
||||||
|
|
||||||
if (!revs.tree_objects)
|
if (!revs.tree_objects)
|
||||||
return p;
|
return;
|
||||||
if (obj->flags & (UNINTERESTING | SEEN))
|
if (obj->flags & (UNINTERESTING | SEEN))
|
||||||
return p;
|
return;
|
||||||
if (parse_tree(tree) < 0)
|
if (parse_tree(tree) < 0)
|
||||||
die("bad tree object %s", sha1_to_hex(obj->sha1));
|
die("bad tree object %s", sha1_to_hex(obj->sha1));
|
||||||
obj->flags |= SEEN;
|
obj->flags |= SEEN;
|
||||||
name = strdup(name);
|
name = strdup(name);
|
||||||
p = add_object(obj, p, path, name);
|
add_object(obj, p, path, name);
|
||||||
me.up = path;
|
me.up = path;
|
||||||
me.elem = name;
|
me.elem = name;
|
||||||
me.elem_len = strlen(name);
|
me.elem_len = strlen(name);
|
||||||
@ -143,57 +143,59 @@ static struct object_list **process_tree(struct tree *tree,
|
|||||||
|
|
||||||
while (tree_entry(&desc, &entry)) {
|
while (tree_entry(&desc, &entry)) {
|
||||||
if (S_ISDIR(entry.mode))
|
if (S_ISDIR(entry.mode))
|
||||||
p = process_tree(lookup_tree(entry.sha1), p, &me, entry.path);
|
process_tree(lookup_tree(entry.sha1), p, &me, entry.path);
|
||||||
else
|
else
|
||||||
p = process_blob(lookup_blob(entry.sha1), p, &me, entry.path);
|
process_blob(lookup_blob(entry.sha1), p, &me, entry.path);
|
||||||
}
|
}
|
||||||
free(tree->buffer);
|
free(tree->buffer);
|
||||||
tree->buffer = NULL;
|
tree->buffer = NULL;
|
||||||
return p;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void show_commit_list(struct rev_info *revs)
|
static void show_commit_list(struct rev_info *revs)
|
||||||
{
|
{
|
||||||
|
int i;
|
||||||
struct commit *commit;
|
struct commit *commit;
|
||||||
struct object_list *objects = NULL, **p = &objects, *pending;
|
struct object_array objects = { 0, 0, NULL };
|
||||||
|
|
||||||
while ((commit = get_revision(revs)) != NULL) {
|
while ((commit = get_revision(revs)) != NULL) {
|
||||||
p = process_tree(commit->tree, p, NULL, "");
|
process_tree(commit->tree, &objects, NULL, "");
|
||||||
show_commit(commit);
|
show_commit(commit);
|
||||||
}
|
}
|
||||||
for (pending = revs->pending_objects; pending; pending = pending->next) {
|
for (i = 0; i < revs->pending.nr; i++) {
|
||||||
|
struct object_array_entry *pending = revs->pending.objects + i;
|
||||||
struct object *obj = pending->item;
|
struct object *obj = pending->item;
|
||||||
const char *name = pending->name;
|
const char *name = pending->name;
|
||||||
if (obj->flags & (UNINTERESTING | SEEN))
|
if (obj->flags & (UNINTERESTING | SEEN))
|
||||||
continue;
|
continue;
|
||||||
if (obj->type == TYPE_TAG) {
|
if (obj->type == TYPE_TAG) {
|
||||||
obj->flags |= SEEN;
|
obj->flags |= SEEN;
|
||||||
p = add_object(obj, p, NULL, name);
|
add_object_array(obj, name, &objects);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (obj->type == TYPE_TREE) {
|
if (obj->type == TYPE_TREE) {
|
||||||
p = process_tree((struct tree *)obj, p, NULL, name);
|
process_tree((struct tree *)obj, &objects, NULL, name);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (obj->type == TYPE_BLOB) {
|
if (obj->type == TYPE_BLOB) {
|
||||||
p = process_blob((struct blob *)obj, p, NULL, name);
|
process_blob((struct blob *)obj, &objects, NULL, name);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
die("unknown pending object %s (%s)", sha1_to_hex(obj->sha1), name);
|
die("unknown pending object %s (%s)", sha1_to_hex(obj->sha1), name);
|
||||||
}
|
}
|
||||||
while (objects) {
|
for (i = 0; i < objects.nr; i++) {
|
||||||
|
struct object_array_entry *p = objects.objects + i;
|
||||||
|
|
||||||
/* An object with name "foo\n0000000..." can be used to
|
/* An object with name "foo\n0000000..." can be used to
|
||||||
* confuse downstream git-pack-objects very badly.
|
* confuse downstream git-pack-objects very badly.
|
||||||
*/
|
*/
|
||||||
const char *ep = strchr(objects->name, '\n');
|
const char *ep = strchr(p->name, '\n');
|
||||||
if (ep) {
|
if (ep) {
|
||||||
printf("%s %.*s\n", sha1_to_hex(objects->item->sha1),
|
printf("%s %.*s\n", sha1_to_hex(p->item->sha1),
|
||||||
(int) (ep - objects->name),
|
(int) (ep - p->name),
|
||||||
objects->name);
|
p->name);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
printf("%s %s\n", sha1_to_hex(objects->item->sha1), objects->name);
|
printf("%s %s\n", sha1_to_hex(p->item->sha1), p->name);
|
||||||
objects = objects->next;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -348,7 +350,7 @@ int cmd_rev_list(int argc, const char **argv, char **envp)
|
|||||||
|
|
||||||
if ((!list &&
|
if ((!list &&
|
||||||
(!(revs.tag_objects||revs.tree_objects||revs.blob_objects) &&
|
(!(revs.tag_objects||revs.tree_objects||revs.blob_objects) &&
|
||||||
!revs.pending_objects)) ||
|
!revs.pending.nr)) ||
|
||||||
revs.diff)
|
revs.diff)
|
||||||
usage(rev_list_usage);
|
usage(rev_list_usage);
|
||||||
|
|
||||||
|
@ -329,8 +329,8 @@ int run_diff_index(struct rev_info *revs, int cached)
|
|||||||
}
|
}
|
||||||
mark_merge_entries();
|
mark_merge_entries();
|
||||||
|
|
||||||
ent = revs->pending_objects->item;
|
ent = revs->pending.objects[0].item;
|
||||||
tree_name = revs->pending_objects->name;
|
tree_name = revs->pending.objects[0].name;
|
||||||
tree = parse_tree_indirect(ent->sha1);
|
tree = parse_tree_indirect(ent->sha1);
|
||||||
if (!tree)
|
if (!tree)
|
||||||
return error("bad tree object %s", tree_name);
|
return error("bad tree object %s", tree_name);
|
||||||
|
28
http-push.c
28
http-push.c
@ -1171,7 +1171,7 @@ static void one_remote_object(const char *hex)
|
|||||||
|
|
||||||
obj->flags |= REMOTE;
|
obj->flags |= REMOTE;
|
||||||
if (!object_list_contains(objects, obj))
|
if (!object_list_contains(objects, obj))
|
||||||
add_object(obj, &objects, NULL, "");
|
object_list_insert(obj, &objects);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void handle_lockprop_ctx(struct xml_ctx *ctx, int tag_closed)
|
static void handle_lockprop_ctx(struct xml_ctx *ctx, int tag_closed)
|
||||||
@ -1699,6 +1699,15 @@ static int locking_available(void)
|
|||||||
return lock_flags;
|
return lock_flags;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct object_list **add_one_object(struct object *obj, struct object_list **p)
|
||||||
|
{
|
||||||
|
struct object_list *entry = xmalloc(sizeof(struct object_list));
|
||||||
|
entry->item = obj;
|
||||||
|
entry->next = *p;
|
||||||
|
*p = entry;
|
||||||
|
return &entry->next;
|
||||||
|
}
|
||||||
|
|
||||||
static struct object_list **process_blob(struct blob *blob,
|
static struct object_list **process_blob(struct blob *blob,
|
||||||
struct object_list **p,
|
struct object_list **p,
|
||||||
struct name_path *path,
|
struct name_path *path,
|
||||||
@ -1712,8 +1721,7 @@ static struct object_list **process_blob(struct blob *blob,
|
|||||||
return p;
|
return p;
|
||||||
|
|
||||||
obj->flags |= SEEN;
|
obj->flags |= SEEN;
|
||||||
name = strdup(name);
|
return add_one_object(obj, p);
|
||||||
return add_object(obj, p, path, name);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct object_list **process_tree(struct tree *tree,
|
static struct object_list **process_tree(struct tree *tree,
|
||||||
@ -1735,7 +1743,7 @@ static struct object_list **process_tree(struct tree *tree,
|
|||||||
|
|
||||||
obj->flags |= SEEN;
|
obj->flags |= SEEN;
|
||||||
name = strdup(name);
|
name = strdup(name);
|
||||||
p = add_object(obj, p, NULL, name);
|
p = add_one_object(obj, p);
|
||||||
me.up = path;
|
me.up = path;
|
||||||
me.elem = name;
|
me.elem = name;
|
||||||
me.elem_len = strlen(name);
|
me.elem_len = strlen(name);
|
||||||
@ -1756,8 +1764,9 @@ static struct object_list **process_tree(struct tree *tree,
|
|||||||
|
|
||||||
static int get_delta(struct rev_info *revs, struct remote_lock *lock)
|
static int get_delta(struct rev_info *revs, struct remote_lock *lock)
|
||||||
{
|
{
|
||||||
|
int i;
|
||||||
struct commit *commit;
|
struct commit *commit;
|
||||||
struct object_list **p = &objects, *pending;
|
struct object_list **p = &objects;
|
||||||
int count = 0;
|
int count = 0;
|
||||||
|
|
||||||
while ((commit = get_revision(revs)) != NULL) {
|
while ((commit = get_revision(revs)) != NULL) {
|
||||||
@ -1767,15 +1776,16 @@ static int get_delta(struct rev_info *revs, struct remote_lock *lock)
|
|||||||
count += add_send_request(&commit->object, lock);
|
count += add_send_request(&commit->object, lock);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (pending = revs->pending_objects; pending; pending = pending->next) {
|
for (i = 0; i < revs->pending.nr; i++) {
|
||||||
struct object *obj = pending->item;
|
struct object_array_entry *entry = revs->pending.objects + i;
|
||||||
const char *name = pending->name;
|
struct object *obj = entry->item;
|
||||||
|
const char *name = entry->name;
|
||||||
|
|
||||||
if (obj->flags & (UNINTERESTING | SEEN))
|
if (obj->flags & (UNINTERESTING | SEEN))
|
||||||
continue;
|
continue;
|
||||||
if (obj->type == TYPE_TAG) {
|
if (obj->type == TYPE_TAG) {
|
||||||
obj->flags |= SEEN;
|
obj->flags |= SEEN;
|
||||||
p = add_object(obj, p, NULL, name);
|
p = add_one_object(obj, p);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (obj->type == TYPE_TREE) {
|
if (obj->type == TYPE_TREE) {
|
||||||
|
19
name-rev.c
19
name-rev.c
@ -125,11 +125,10 @@ static const char* get_rev_name(struct object *o)
|
|||||||
|
|
||||||
return buffer;
|
return buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char **argv)
|
int main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
struct object_list *revs = NULL;
|
struct object_array revs = { 0, 0, NULL };
|
||||||
struct object_list **walker = &revs;
|
|
||||||
int as_is = 0, all = 0, transform_stdin = 0;
|
int as_is = 0, all = 0, transform_stdin = 0;
|
||||||
|
|
||||||
setup_git_directory();
|
setup_git_directory();
|
||||||
@ -184,9 +183,7 @@ int main(int argc, char **argv)
|
|||||||
if (cutoff > commit->date)
|
if (cutoff > commit->date)
|
||||||
cutoff = commit->date;
|
cutoff = commit->date;
|
||||||
|
|
||||||
object_list_append((struct object *)commit, walker);
|
add_object_array((struct object *)commit, *argv, &revs);
|
||||||
(*walker)->name = *argv;
|
|
||||||
walker = &((*walker)->next);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for_each_ref(name_ref);
|
for_each_ref(name_ref);
|
||||||
@ -243,9 +240,13 @@ int main(int argc, char **argv)
|
|||||||
if (objs[i])
|
if (objs[i])
|
||||||
printf("%s %s\n", sha1_to_hex(objs[i]->sha1),
|
printf("%s %s\n", sha1_to_hex(objs[i]->sha1),
|
||||||
get_rev_name(objs[i]));
|
get_rev_name(objs[i]));
|
||||||
} else
|
} else {
|
||||||
for ( ; revs; revs = revs->next)
|
int i;
|
||||||
printf("%s %s\n", revs->name, get_rev_name(revs->item));
|
for (i = 0; i < revs.nr; i++)
|
||||||
|
printf("%s %s\n",
|
||||||
|
revs.objects[i].name,
|
||||||
|
get_rev_name(revs.objects[i].item));
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
17
object.c
17
object.c
@ -200,3 +200,20 @@ int object_list_contains(struct object_list *list, struct object *obj)
|
|||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void add_object_array(struct object *obj, const char *name, struct object_array *array)
|
||||||
|
{
|
||||||
|
unsigned nr = array->nr;
|
||||||
|
unsigned alloc = array->alloc;
|
||||||
|
struct object_array_entry *objects = array->objects;
|
||||||
|
|
||||||
|
if (nr >= alloc) {
|
||||||
|
alloc = (alloc + 32) * 2;
|
||||||
|
objects = xrealloc(objects, alloc * sizeof(*objects));
|
||||||
|
array->alloc = alloc;
|
||||||
|
array->objects = objects;
|
||||||
|
}
|
||||||
|
objects[nr].item = obj;
|
||||||
|
objects[nr].name = name;
|
||||||
|
array->nr = ++nr;
|
||||||
|
}
|
||||||
|
13
object.h
13
object.h
@ -4,7 +4,6 @@
|
|||||||
struct object_list {
|
struct object_list {
|
||||||
struct object *item;
|
struct object *item;
|
||||||
struct object_list *next;
|
struct object_list *next;
|
||||||
const char *name;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct object_refs {
|
struct object_refs {
|
||||||
@ -13,6 +12,15 @@ struct object_refs {
|
|||||||
struct object *ref[FLEX_ARRAY]; /* more */
|
struct object *ref[FLEX_ARRAY]; /* more */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct object_array {
|
||||||
|
unsigned int nr;
|
||||||
|
unsigned int alloc;
|
||||||
|
struct object_array_entry {
|
||||||
|
struct object *item;
|
||||||
|
const char *name;
|
||||||
|
} *objects;
|
||||||
|
};
|
||||||
|
|
||||||
#define TYPE_BITS 3
|
#define TYPE_BITS 3
|
||||||
#define FLAG_BITS 27
|
#define FLAG_BITS 27
|
||||||
|
|
||||||
@ -72,4 +80,7 @@ unsigned object_list_length(struct object_list *list);
|
|||||||
|
|
||||||
int object_list_contains(struct object_list *list, struct object *obj);
|
int object_list_contains(struct object_list *list, struct object *obj);
|
||||||
|
|
||||||
|
/* Object array handling .. */
|
||||||
|
void add_object_array(struct object *obj, const char *name, struct object_array *array);
|
||||||
|
|
||||||
#endif /* OBJECT_H */
|
#endif /* OBJECT_H */
|
||||||
|
33
revision.c
33
revision.c
@ -31,17 +31,12 @@ static char *path_name(struct name_path *path, const char *name)
|
|||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct object_list **add_object(struct object *obj,
|
void add_object(struct object *obj,
|
||||||
struct object_list **p,
|
struct object_array *p,
|
||||||
struct name_path *path,
|
struct name_path *path,
|
||||||
const char *name)
|
const char *name)
|
||||||
{
|
{
|
||||||
struct object_list *entry = xmalloc(sizeof(*entry));
|
add_object_array(obj, path_name(path, name), p);
|
||||||
entry->item = obj;
|
|
||||||
entry->next = *p;
|
|
||||||
entry->name = path_name(path, name);
|
|
||||||
*p = entry;
|
|
||||||
return &entry->next;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void mark_blob_uninteresting(struct blob *blob)
|
static void mark_blob_uninteresting(struct blob *blob)
|
||||||
@ -117,9 +112,9 @@ void mark_parents_uninteresting(struct commit *commit)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void add_pending_object(struct rev_info *revs, struct object *obj, const char *name)
|
void add_pending_object(struct rev_info *revs, struct object *obj, const char *name)
|
||||||
{
|
{
|
||||||
add_object(obj, &revs->pending_objects, NULL, name);
|
add_object_array(obj, name, &revs->pending);
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct object *get_reference(struct rev_info *revs, const char *name, const unsigned char *sha1, unsigned int flags)
|
static struct object *get_reference(struct rev_info *revs, const char *name, const unsigned char *sha1, unsigned int flags)
|
||||||
@ -836,7 +831,7 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, const ch
|
|||||||
object = get_reference(revs, arg, sha1, flags ^ local_flags);
|
object = get_reference(revs, arg, sha1, flags ^ local_flags);
|
||||||
add_pending_object(revs, object, arg);
|
add_pending_object(revs, object, arg);
|
||||||
}
|
}
|
||||||
if (def && !revs->pending_objects) {
|
if (def && !revs->pending.nr) {
|
||||||
unsigned char sha1[20];
|
unsigned char sha1[20];
|
||||||
struct object *object;
|
struct object *object;
|
||||||
if (get_sha1(def, sha1))
|
if (get_sha1(def, sha1))
|
||||||
@ -868,11 +863,13 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, const ch
|
|||||||
|
|
||||||
void prepare_revision_walk(struct rev_info *revs)
|
void prepare_revision_walk(struct rev_info *revs)
|
||||||
{
|
{
|
||||||
struct object_list *list;
|
int nr = revs->pending.nr;
|
||||||
|
struct object_array_entry *list = revs->pending.objects;
|
||||||
|
|
||||||
list = revs->pending_objects;
|
revs->pending.nr = 0;
|
||||||
revs->pending_objects = NULL;
|
revs->pending.alloc = 0;
|
||||||
while (list) {
|
revs->pending.objects = NULL;
|
||||||
|
while (--nr >= 0) {
|
||||||
struct commit *commit = handle_commit(revs, list->item, list->name);
|
struct commit *commit = handle_commit(revs, list->item, list->name);
|
||||||
if (commit) {
|
if (commit) {
|
||||||
if (!(commit->object.flags & SEEN)) {
|
if (!(commit->object.flags & SEEN)) {
|
||||||
@ -880,7 +877,7 @@ void prepare_revision_walk(struct rev_info *revs)
|
|||||||
insert_by_date(commit, &revs->commits);
|
insert_by_date(commit, &revs->commits);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
list = list->next;
|
list++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (revs->no_walk)
|
if (revs->no_walk)
|
||||||
|
12
revision.h
12
revision.h
@ -18,7 +18,7 @@ typedef void (prune_fn_t)(struct rev_info *revs, struct commit *commit);
|
|||||||
struct rev_info {
|
struct rev_info {
|
||||||
/* Starting list */
|
/* Starting list */
|
||||||
struct commit_list *commits;
|
struct commit_list *commits;
|
||||||
struct object_list *pending_objects;
|
struct object_array pending;
|
||||||
|
|
||||||
/* Basic information */
|
/* Basic information */
|
||||||
const char *prefix;
|
const char *prefix;
|
||||||
@ -99,9 +99,11 @@ struct name_path {
|
|||||||
const char *elem;
|
const char *elem;
|
||||||
};
|
};
|
||||||
|
|
||||||
extern struct object_list **add_object(struct object *obj,
|
extern void add_object(struct object *obj,
|
||||||
struct object_list **p,
|
struct object_array *p,
|
||||||
struct name_path *path,
|
struct name_path *path,
|
||||||
const char *name);
|
const char *name);
|
||||||
|
|
||||||
|
extern void add_pending_object(struct rev_info *revs, struct object *obj, const char *name);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user