summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 621f1b4)
raw | patch | inline | side by side (parent: 621f1b4)
author | Lars Hjemli <hjemli@gmail.com> | |
Sun, 25 Jan 2009 00:52:05 +0000 (01:52 +0100) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Sat, 7 Feb 2009 20:14:34 +0000 (12:14 -0800) |
When the callback function invoked from read_tree_recursive() returns
the value `READ_TREE_RECURSIVE` for a gitlink entry, the traversal will
now continue into the tree connected to the gitlinked commit. This
functionality can be used to allow inter-repository operations, but
since the current users of read_tree_recursive() does not yet support
such operations, they have been modified where necessary to make sure
that they never return READ_TREE_RECURSIVE for gitlink entries (hence
no change in behaviour should be introduces by this patch alone).
Signed-off-by: Lars Hjemli <hjemli@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
the value `READ_TREE_RECURSIVE` for a gitlink entry, the traversal will
now continue into the tree connected to the gitlinked commit. This
functionality can be used to allow inter-repository operations, but
since the current users of read_tree_recursive() does not yet support
such operations, they have been modified where necessary to make sure
that they never return READ_TREE_RECURSIVE for gitlink entries (hence
no change in behaviour should be introduces by this patch alone).
Signed-off-by: Lars Hjemli <hjemli@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
archive.c | patch | blob | history | |
builtin-ls-tree.c | patch | blob | history | |
merge-recursive.c | patch | blob | history | |
tree.c | patch | blob | history |
diff --git a/archive.c b/archive.c
index 9ac455d889b72deba8c949da1d9efe2be3a50244..e6de0397cc82ae97018cbf4fc82d5697ec4d915d 100644 (file)
--- a/archive.c
+++ b/archive.c
err = write_entry(args, sha1, path.buf, path.len, mode, NULL, 0);
if (err)
return err;
- return READ_TREE_RECURSIVE;
+ return (S_ISDIR(mode) ? READ_TREE_RECURSIVE : 0);
}
buffer = sha1_file_to_archive(path_without_prefix, sha1, mode,
diff --git a/builtin-ls-tree.c b/builtin-ls-tree.c
index 5b63e6eada5cd6de764acef694da624a70ce6dab..fca46312f681caf077565fb4bd5b59a70008eb59 100644 (file)
--- a/builtin-ls-tree.c
+++ b/builtin-ls-tree.c
*
* Something similar to this incomplete example:
*
- if (show_subprojects(base, baselen, pathname)) {
- struct child_process ls_tree;
-
- ls_tree.dir = base;
- ls_tree.argv = ls-tree;
- start_command(&ls_tree);
- }
+ if (show_subprojects(base, baselen, pathname))
+ retval = READ_TREE_RECURSIVE;
*
*/
type = commit_type;
diff --git a/merge-recursive.c b/merge-recursive.c
index b97026bd5cc1d2ef1b46a9ef3dcd7562ad52c377..ee853b990d8bfb15e0058fefbbd267bd58ed40fc 100644 (file)
--- a/merge-recursive.c
+++ b/merge-recursive.c
string_list_insert(newpath, &o->current_file_set);
free(newpath);
- return READ_TREE_RECURSIVE;
+ return (S_ISDIR(mode) ? READ_TREE_RECURSIVE : 0);
}
static int get_files_dirs(struct merge_options *o, struct tree *tree)
index 03e782a9cabc0a12ed5baec0ef59c99f19dbc843..dfe4d5f303bdecd5d446db1044251f77eae03a3d 100644 (file)
--- a/tree.c
+++ b/tree.c
if (retval)
return -1;
continue;
+ } else if (S_ISGITLINK(entry.mode)) {
+ int retval;
+ struct strbuf path;
+ unsigned int entrylen;
+ struct commit *commit;
+
+ entrylen = tree_entry_len(entry.path, entry.sha1);
+ strbuf_init(&path, baselen + entrylen + 1);
+ strbuf_add(&path, base, baselen);
+ strbuf_add(&path, entry.path, entrylen);
+ strbuf_addch(&path, '/');
+
+ commit = lookup_commit(entry.sha1);
+ if (!commit)
+ die("Commit %s in submodule path %s not found",
+ sha1_to_hex(entry.sha1), path.buf);
+
+ if (parse_commit(commit))
+ die("Invalid commit %s in submodule path %s",
+ sha1_to_hex(entry.sha1), path.buf);
+
+ retval = read_tree_recursive(commit->tree,
+ path.buf, path.len,
+ stage, match, fn, context);
+ strbuf_release(&path);
+ if (retval)
+ return -1;
+ continue;
}
}
return 0;