Skip to contentSkip to conversation

Add submodule-support to git archive

PATCH In review Lars Hjemli 4 participants 14 messages Jun 15, 2016 Documentation

lore
Share & tools
lore
#0 lore raw

cover Add submodule-support to git archive

This is a cleaned up version of my previous patches which allows git archive to include submodule content in the archive output.

The main difference between this series and the previous ones is that the behaviour of git archive --submodules are now predictable; the content included from submodules is defined by the gitlink entries found when traversing the <tree-ish> specified on the command line, and the set of submodules to include are defined by specifying either --submodules=all or --submodules=checkedout (which is the default mode of operation, i.e. what you get by only specifying --submodules).

To make the --submodules option more userfriendly, any submodule repository discovered during traversal will be registered as an alternate odb (this will typically be required to make the inter-repository traversal succeed).

Finally, the option --submodules=group:<name> is not yet implemented. I wanted to get these first two patches published early since they define the semantics of the --submodules option. Adding a 'group' selector on top is mostly a question of pulling information out of .gitmodules and .git/config, i.e. not very exciting (but it will be done ;-)

Lars Hjemli (2):
tree.c: allow read_tree_recursive() to traverse gitlink entries archive.c: add support for --submodules[=(all|checkedout)]

 Documentation/git-archive.txt |    5 ++
 archive.c                     |   81 +++++++++++++++++++++++++-
 archive.h                     |    4 +
 builtin-ls-tree.c             |    9 +--
 cache.h                       |    1 +
 merge-recursive.c             |    2 +-
 sha1_file.c                   |   11 +++-
 t/t5001-archive-submodules.sh |  129 +++++++++++++++++++++++++++++++++++++++++
 tree.c                        |   28 +++++++++
 9 files changed, 259 insertions(+), 11 deletions(-)
 create mode 100755 t/t5001-archive-submodules.sh
#1 lore raw

PATCH 1/2 tree.c: allow read_tree_recursive() to traverse gitlink entries

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).

---
 archive.c         |    2 +-
 builtin-ls-tree.c |    9 ++-------
 merge-recursive.c |    2 +-
 tree.c            |   28 ++++++++++++++++++++++++++++
 4 files changed, 32 insertions(+), 9 deletions(-)
archive.c +1 -1
index 9ac455d..e6de039 100644
@@ -132,7 +132,7 @@ static int write_archive_entry(const unsigned char *sha1, const char *base,
 		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,
builtin-ls-tree.c +2 -7
index 5b63e6e..fca4631 100644
@@ -68,13 +68,8 @@ static int show_tree(const unsigned char *sha1, const char *base, int baselen,
 		 *
 		 * 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;
merge-recursive.c +1 -1
index b97026b..ee853b9 100644
@@ -237,7 +237,7 @@ static int save_files_dirs(const unsigned char *sha1,
 		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)
tree.c +28 -0
index 03e782a..dfe4d5f 100644
@@ -131,6 +131,34 @@ int read_tree_recursive(struct tree *tree,
 			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;
Signature · 1 line
1.6.1.150.g5e733b
#2 lore raw

PATCH 2/2 archive.c: add support for --submodules[=(all|checkedout)]

The --submodules option uses the enhanced read_tree_recursive() to enable inclusion of submodules in the generated archive.

When invoked with --submodules=all all gitlink entries will be traversed, and when invoked with --submodules=checkedout (the default option) only gitlink entries with a git repo (i.e. checked out sub- modules) will be traversed.

When a gitlink has been selected for traversal, it is required that all objects necessary to perform this traversal are available in either the primary odb or through an alternate odb. To this end, git archive will insert the object database of the selected gitlink (when checked out) as an alternate odb, using the new function add_alt_odb(). And since alternates now can be added after parsing of objects/info/alternates, the error message in link_alt_odb_entry() has been updated to not mention this file.

---
 Documentation/git-archive.txt |    5 ++
 archive.c                     |   81 +++++++++++++++++++++++++-
 archive.h                     |    4 +
 cache.h                       |    1 +
 sha1_file.c                   |   11 +++-
 t/t5001-archive-submodules.sh |  129 +++++++++++++++++++++++++++++++++++++++++
 6 files changed, 228 insertions(+), 3 deletions(-)
 create mode 100755 t/t5001-archive-submodules.sh
Documentation/git-archive.txt +5 -0
index 41cbf9c..6068302 100644
@@ -47,6 +47,11 @@ OPTIONS
 --prefix=<prefix>/::
 	Prepend <prefix>/ to each filename in the archive.
 
+--submodules[=<spec>]::
+	Include the content of submodules in the archive. The specification
+	of which submodules to include can be either 'checkedout' (default)
+	or 'all'.
+
 <extra>::
 	This can be any options that the archiver backend understand.
 	See next section.
archive.c +80 -1

117 lines not on this page · raw message

archive.h +4 -0
index 0b15b35..2b078b6 100644
@@ -11,8 +11,12 @@ struct archiver_args {
 	const char **pathspec;
 	unsigned int verbose : 1;
 	int compression_level;
+	int submodules;
 };
 
+#define SUBMODULES_CHECKEDOUT 1
+#define SUBMODULES_ALL 2
+
 typedef int (*write_archive_fn_t)(struct archiver_args *);
 
 typedef int (*write_archive_entry_fn_t)(struct archiver_args *args, const unsigned char *sha1, const char *path, size_t pathlen, unsigned int mode, void *buffer, unsigned long size);
cache.h +1 -0
index 8d965b8..ea53e4b 100644
@@ -728,6 +728,7 @@ extern struct alternate_object_database {
 	char base[FLEX_ARRAY]; /* more */
 } *alt_odb_list;
 extern void prepare_alt_odb(void);
+extern int add_alt_odb(const char *path);
 extern void add_to_alternates_file(const char *reference);
 typedef int alt_odb_fn(struct alternate_object_database *, void *);
 extern void foreach_alt_odb(alt_odb_fn, void*);
sha1_file.c +9 -2
index 360f7e5..53d8db7 100644
@@ -285,8 +285,7 @@ static int link_alt_odb_entry(const char * entry, int len, const char * relative
 
 	/* Detect cases where alternate disappeared */
 	if (!is_directory(ent->base)) {
-		error("object directory %s does not exist; "
-		      "check .git/objects/info/alternates.",
+		error("Alternate object directory %s does not exist",
 		      ent->base);
 		free(ent);
 		return -1;
@@ -2573,3 +2572,11 @@ int read_pack_header(int fd, struct pack_header *header)
 		return PH_ERROR_PROTOCOL;
 	return 0;
 }
+
+int add_alt_odb(const char *path)
+{
+	int err = link_alt_odb_entry(path, strlen(path), NULL, 0);
+	if (!err)
+		prepare_packed_git_one((char *)path, 0);
+	return err;
+}
t/t5001-archive-submodules.sh new file +129 -0

129 lines not on this page · raw message

Signature · 1 line
1.6.1.150.g5e733b
#3 lore raw

Re: [PATCH 2/2] archive.c: add support for --submodules[=(all|checkedout)]

Hi,

Quoted 7 lines · Lars Hjemli

The --submodules option uses the enhanced read_tree_recursive() to enable inclusion of submodules in the generated archive.

When invoked with --submodules=all all gitlink entries will be traversed, and when invoked with --submodules=checkedout (the default option) only gitlink entries with a git repo (i.e. checked out sub- modules) will be traversed.

In bare repositories, this means: none.

My reasoning for "*" instead of "all" and "" instead for "checkedout" was that you could allow "<name1>,<name2>" at some stage, where <name> would first be interpreted as a submodule group, and if that fails, as submodule name.

Thinking about that more, "" seems illogical, that should rather mean "none", i.e. the same as --no-submodules. The "checkedout" could be "." then, perhaps? As in "what we have checked out in ./, the current directory"?

Quoted 9 lines

When a gitlink has been selected for traversal, it is required that all objects necessary to perform this traversal are available in either the primary odb or through an alternate odb. To this end, git archive will insert the object database of the selected gitlink (when checked out) as an alternate odb, using the new function add_alt_odb().

And since alternates now can be added after parsing of objects/info/alternates, the error message in link_alt_odb_entry() has been updated to not mention this file.

Could you split that part into its own patch again, please?

Quoted 6 lines
archive.c +2 -0
@@ -91,6 +92,70 @@ static void setup_archive_check(struct git_attr_check *check)
 	check[1].attr = attr_export_subst;
 }
 
+static int include_repository(const char *path)
+{

archive.c static void setup_archive_check(struct git_attr_check *check) · line 106

Quoted 10 lines
archive.c +10 -0
+	struct stat st;
+	const char *tmp;
+
+	/* Return early if the path does not exist since it is OK to not
+	 * checkout submodules.
+	 */
+	if (stat(path, &st) && errno == ENOENT)
+		return 1;
+
+	tmp = read_gitfile_gently(path);

This will leak memory, no?

Quoted 6 lines
archive.c +6 -0
+	if (tmp) {
+		path = tmp;
+		if (stat(path, &st))
+			die("Unable to stat submodule gitdir %s: %s (%d)",
+			    path, strerror(errno), errno);
+	}

archive.c static void setup_archive_check(struct git_attr_check *check) · line 122

Quoted 10 lines
archive.c +10 -0
+
+	if (!S_ISDIR(st.st_mode))
+		die("Submodule gitdir %s is not a directory", path);
+
+	if (add_alt_odb(mkpath("%s/objects", path)))
+		die("submodule odb %s could not be added as an alternate",
+		    path);
+
+	return 0;
+}

Ciao,
Dscho

#4 lore raw

Re: [PATCH 2/2] archive.c: add support for --submodules[=(all|checkedout)]

Quoted 19 lines · Johannes Schindelin

Hi,

Quoted 7 lines · Lars Hjemli

The --submodules option uses the enhanced read_tree_recursive() to enable inclusion of submodules in the generated archive.

When invoked with --submodules=all all gitlink entries will be traversed, and when invoked with --submodules=checkedout (the default option) only gitlink entries with a git repo (i.e. checked out sub- modules) will be traversed.

In bare repositories, this means: none.

My reasoning for "*" instead of "all" and "" instead for "checkedout" was that you could allow "<name1>,<name2>" at some stage, where <name> would first be interpreted as a submodule group, and if that fails, as submodule name.

Quoted 4 lines

Thinking about that more, "" seems illogical, that should rather mean "none", i.e. the same as --no-submodules. The "checkedout" could be "." then, perhaps? As in "what we have checked out in ./, the current directory"?

Yes, I think that makes sense, i.e. '--submodules' will include _all_ submodules (making the option behave identically for bare and non-bare repositories), '--submodules=.' will include checked out submodules (making the option a no-op in bare repos, which also makes sense) and '--submodules=<name>[,<name>...]' will include the named submodules, where "named" could mean groupname, submodule name or submodule path, in that order.

But then we probably also want some (optional) syntax to specify the kind of name, e.g. '--submodules=g:foo,n:bar,p:lib/baz' for group foo, name bar and path lib/baz. Agree?

Quoted 7 lines
Quoted 6 lines

When a gitlink has been selected for traversal, it is required that all objects necessary to perform this traversal are available in either the primary odb or through an alternate odb. To this end, git archive will insert the object database of the selected gitlink (when checked out) as an alternate odb, using the new function add_alt_odb().

Quoted 5 lines
Quoted 3 lines

And since alternates now can be added after parsing of objects/info/alternates, the error message in link_alt_odb_entry() has been updated to not mention this file.

Could you split that part into its own patch again, please?

Sure.

Quoted 5 lines
Quoted 5 lines
archive.c +0 -0
@@ -91,6 +92,70 @@ static void setup_archive_check(struct git_attr_check *check)
      check[1].attr = attr_export_subst;
 }
 
Quoted 14 lines

archive.c static void setup_archive_check(struct git_attr_check *check) · line 106

Quoted 12 lines
archive.c +12 -0
+static int include_repository(const char *path)
+{
+     struct stat st;
+     const char *tmp;
+
+     /* Return early if the path does not exist since it is OK to not
+      * checkout submodules.
+      */
+     if (stat(path, &st) && errno == ENOENT)
+             return 1;
+
+     tmp = read_gitfile_gently(path);

This will leak memory, no?

I don't think so: read_gitfile_gently() returns a value obtained by calling make_absolute_path() which returns a static buffer. Also, the path argument to include_repository() is obtained by calling mkpath() which returns another static buffer so I don't see any malloc()'s which should be free()'d. Is my code-reading flawed?

--
larsh

#5 lore raw

Re: [PATCH 2/2] archive.c: add support for --submodules[=(all|checkedout)]

Hi,

Quoted 13 lines · Lars Hjemli
Quoted 9 lines · Johannes Schindelin

My reasoning for "*" instead of "all" and "" instead for "checkedout" was that you could allow "<name1>,<name2>" at some stage, where <name> would first be interpreted as a submodule group, and if that fails, as submodule name.

Thinking about that more, "" seems illogical, that should rather mean "none", i.e. the same as --no-submodules. The "checkedout" could be "." then, perhaps? As in "what we have checked out in ./, the current directory"?

Quoted 7 lines

Yes, I think that makes sense, i.e. '--submodules' will include _all_ submodules (making the option behave identically for bare and non-bare repositories), '--submodules=.' will include checked out submodules (making the option a no-op in bare repos, which also makes sense) and '--submodules=<name>[,<name>...]' will include the named submodules, where "named" could mean groupname, submodule name or submodule path, in that order.

Well, I can live with the default of all submodules, even if I think that "git-submodule.sh" uses the checked out submodules by default.

Quoted 3 lines

But then we probably also want some (optional) syntax to specify the kind of name, e.g. '--submodules=g:foo,n:bar,p:lib/baz' for group foo, name bar and path lib/baz. Agree?

IMO that is overkill. Anybody naming a submodule group identically to a submodule deserves what she gets, anyway.

Quoted 19 lines
Quoted 4 lines
Quoted 4 lines
archive.c +0 -0
@@ -91,6 +92,70 @@ static void setup_archive_check(struct git_attr_check *check)
      check[1].attr = attr_export_subst;
 }
 
Quoted 14 lines

archive.c static void setup_archive_check(struct git_attr_check *check) · line 106

Quoted 12 lines
archive.c +12 -0
+static int include_repository(const char *path)
+{
+     struct stat st;
+     const char *tmp;
+
+     /* Return early if the path does not exist since it is OK to not
+      * checkout submodules.
+      */
+     if (stat(path, &st) && errno == ENOENT)
+             return 1;
+
+     tmp = read_gitfile_gently(path);

This will leak memory, no?

Quoted 5 lines

I don't think so: read_gitfile_gently() returns a value obtained by calling make_absolute_path() which returns a static buffer. Also, the path argument to include_repository() is obtained by calling mkpath() which returns another static buffer so I don't see any malloc()'s which should be free()'d. Is my code-reading flawed?

No, your code reading is good. And you spared me having to read the code myself ;-) Now, maybe a code comment is in order, to spare others, too?

Ciao,
Dscho

#6 lore raw

Re: [PATCH 1/2] tree.c: allow read_tree_recursive() to traverse gitlink entries

In reply to Lars Hjemli

Hi,

Quoted 3 lines · Lars Hjemli

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.

\n

Quoted 5 lines

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).

s/\(introduce\)s/\1d/

archive.c static int write_archive_entry(const unsigned char *sha1, const char *base, · line 135

Quoted 10 lines
archive.c +1 -1
index 9ac455d..e6de039 100644
@@ -132,7 +132,7 @@ static int write_archive_entry(const unsigned char *sha1, const char *base,
 		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);

You do not need the parentheses around the conditional:

	$ git grep 'return (.*?' *.c | wc -l
	14
	gene099@racer:~/git (rebase-i-p)$ git grep 'return [^(]*?' *.c | wc -l
	41

Note that the 14 matches include 9 false positives.

builtin-ls-tree.c static int show_tree(const unsigned char *sha1, const char *base, int baselen, · line 75

Quoted 13 lines
builtin-ls-tree.c +0 -5
index 5b63e6e..fca4631 100644
@@ -68,13 +68,8 @@ static int show_tree(const unsigned char *sha1, const char *base, int baselen,
 		 *
 		 * 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;

I wondered how that could ever have compiled...

Until I inspected the file (which is different in junio/next from what you based your patch on; your patch is vs junio/master).

builtin-ls-tree.c int read_tree_recursive(struct tree *tree, · line 136

Quoted 7 lines
builtin-ls-tree.c +3 -0
@@ -131,6 +131,34 @@ int read_tree_recursive(struct tree *tree,
 			if (retval)
 				return -1;
 			continue;
+		} else if (S_ISGITLINK(entry.mode)) {
+			int retval;
+			struct strbuf path;

s/;/ = STRBUF_INIT;/

builtin-ls-tree.c int read_tree_recursive(struct tree *tree, · line 144

Quoted 8 lines
builtin-ls-tree.c +8 -0
+			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, '/');

Why not

			strbuf_addf(&path, "%.*s%.*s/", baselen, base, 
				entrylen, entry.path);
Quoted 7 lines
builtin-ls-tree.c +7 -0
+
+			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))

builtin-ls-tree.c int read_tree_recursive(struct tree *tree, · line 161

Quoted 10 lines
builtin-ls-tree.c +10 -0
+				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;

I'd also place a comment above read_tree_recursive() stating that this function tries to traverse into submodules when READ_TREE_RECURSIVE is returned for submodule entries, but no attempt is made at including alternate object directories. (And it must be that way: think bare repositories -- they cannot just try to include a subdirectory's .git/objects/..)

Ciao,
Dscho

#7 lore raw

Re: [PATCH 1/2] tree.c: allow read_tree_recursive() to traverse gitlink entries

Quoted 9 lines · Johannes Schindelin
Quoted 5 lines · Lars Hjemli

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).

s/\(introduce\)s/\1d/

Thanks

Quoted 14 lines

archive.c static int write_archive_entry(const unsigned char *sha1, const char *base, · line 135

Quoted 11 lines
archive.c +1 -1
index 9ac455d..e6de039 100644
@@ -132,7 +132,7 @@ static int write_archive_entry(const unsigned char *sha1, const char *base,
              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);

You do not need the parentheses around the conditional:

Quoted 6 lines
       $ git grep 'return (.*?' *.c | wc -l
       14
       gene099@racer:~/git (rebase-i-p)$ git grep 'return [^(]*?' *.c | wc -l
       41

Note that the 14 matches include 9 false positives.

Ok, will fix.

Quoted 17 lines
Quoted 6 lines
builtin-ls-tree.c +0 -0
index 5b63e6e..fca4631 100644

builtin-ls-tree.c static int show_tree(const unsigned char *sha1, const char *base, int baselen, · line 75

Quoted 8 lines
builtin-ls-tree.c +0 -5
@@ -68,13 +68,8 @@ static int show_tree(const unsigned char *sha1, const char *base, int baselen,
               *
               * 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;

I wondered how that could ever have compiled...

Quoted 2 lines

Until I inspected the file (which is different in junio/next from what you based your patch on; your patch is vs junio/master).

Yes, sorry for not mentioning that.

Quoted 10 lines

builtin-ls-tree.c int read_tree_recursive(struct tree *tree, · line 136

Quoted 8 lines
builtin-ls-tree.c +3 -0
@@ -131,6 +131,34 @@ int read_tree_recursive(struct tree *tree,
                      if (retval)
                              return -1;
                      continue;
+             } else if (S_ISGITLINK(entry.mode)) {
+                     int retval;
+                     struct strbuf path;

s/;/ = STRBUF_INIT;/

I skipped the STRBUF_INIT since I used strbuf_init() below, but...

Quoted 10 lines

builtin-ls-tree.c int read_tree_recursive(struct tree *tree, · line 144

Quoted 9 lines
builtin-ls-tree.c +8 -0
+                     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, '/');
Quoted 3 lines

Why not

                       strbuf_addf(&path, "%.*s%.*s/", baselen, base,
                               entrylen, entry.path);

...with this cute fix the STRBUF_INIT is required. Will fix.

Thanks for the review.

--
larsh

#8 lore raw
In reply to Lars Hjemli

Quoting Lars Hjemli <[email protected]>:

Quoted 10 lines

This is a cleaned up version of my previous patches which allows git archive to include submodule content in the archive output.

The main difference between this series and the previous ones is that the behaviour of git archive --submodules are now predictable; the content included from submodules is defined by the gitlink entries found when traversing the <tree-ish> specified on the command line, and the set of submodules to include are defined by specifying either --submodules=all or --submodules=checkedout (which is the default mode of operation, i.e. what you get by only specifying --submodules).

I wanted to try this because I use submodules in a repository at my work, but your patches conflicted a lot with your previous series of patches that are already in the next branch of Junio's. What would I do to try this new series? Fork a branch from Junio's master branch, apply your new patches, and merge the result to Junio's next?

Signature · 2 lines
Nanako Shiraishi
http://ivory.ap.teacup.com/nanako3/
#9 lore raw
Quoted 2 lines · Nanako Shiraishi

What would I do to try this new series? Fork a branch from Junio's master branch, apply your new patches, and merge the result to Junio's next?

Yes, that sounds right (btw: the series is buildt on top of 5dc1308562 (Merge branch 'js/patience-diff') and can be pulled from
git://hjemli.net/pub/git/git lh/traverse-gitlinks).

But before merging with 'next', you'll need to git revert -m 1 bdf31cbc00.

--
larsh

#10 lore raw
Quoted 9 lines · Lars Hjemli
Quoted 2 lines · Nanako Shiraishi

What would I do to try this new series? Fork a branch from Junio's master branch, apply your new patches, and merge the result to Junio's next?

Yes, that sounds right (btw: the series is buildt on top of 5dc1308562 (Merge branch 'js/patience-diff') and can be pulled from
git://hjemli.net/pub/git/git lh/traverse-gitlinks).

But before merging with 'next', you'll need to git revert -m 1 bdf31cbc00.

Yuck, that is too much to ask for regular testers and users.

Could we switch to incremental refinements once a series hits next, pretty please?

#11 lore raw
Quoted 6 lines · Junio C Hamano
Quoted 4 lines · Lars Hjemli
Quoted 2 lines · Nanako Shiraishi

What would I do to try this new series? Fork a branch from Junio's master branch, apply your new patches, and merge the result to Junio's next?

Quoted 7 lines
Quoted 5 lines

Yes, that sounds right (btw: the series is buildt on top of 5dc1308562 (Merge branch 'js/patience-diff') and can be pulled from
git://hjemli.net/pub/git/git lh/traverse-gitlinks).

But before merging with 'next', you'll need to git revert -m 1 bdf31cbc00.

Yuck, that is too much to ask for regular testers and users.

Sorry about that.

Quoted 2 lines

Could we switch to incremental refinements once a series hits next, pretty please?

The problem in this particular case is that the design has changed so much since the first iteration that we're not really talking about incremental refinements but rather a different approach to the same problem.

If you want me to build on top of the series in next anyways, would it be acceptable if the first patch on top of ee306d2d59 reverts the previous attempt? I think the rest of the series will be easier to review that way.

--
larsh

#12 lore raw
Quoted 4 lines · Lars Hjemli

If you want me to build on top of the series in next anyways, would it be acceptable if the first patch on top of ee306d2d59 reverts the previous attempt? I think the rest of the series will be easier to review that way.

Ok, then I'll simply revert and then queue the new ones on top of it.

Thanks.

#13 lore raw
In reply to Lars Hjemli

Hi,

Quoted 10 lines · Lars Hjemli
Quoted 2 lines · Junio C Hamano

Could we switch to incremental refinements once a series hits next, pretty please?

The problem in this particular case is that the design has changed so much since the first iteration that we're not really talking about incremental refinements but rather a different approach to the same problem.

Quoted 4 lines

If you want me to build on top of the series in next anyways, would it be acceptable if the first patch on top of ee306d2d59 reverts the previous attempt? I think the rest of the series will be easier to review that way.

I'd appreciate that.

Since 'next' will be rewound eventually, that first iteration and the revert will disappear at some stage.

Ciao,
Dscho