Skip to contentSkip to conversation

submodule show inline diff

PATCH Superseded Jacob Keller 4 participants 28 messages Aug 19, 2016 – Aug 23, 2016 Documentation

v8 of 12 Superseded Latest is v12 →

lore
Share & tools
lore
#0 lore raw

v8 cover submodule show inline diff

From: Jacob Keller <[email protected]>

v8 has changes suggested by Junio and Stefan Beller, as well as a few modifications of my own, plus more tests.

Series interdiff of v7 and v8:

builtin/rev-list.c +14 -14
index 1a75a83538f4..21cde8dd6b31 100644
@@ -129,20 +129,20 @@ static void show_commit(struct commit *commit, void *data)
 			graph_show_commit_msg(revs->graph, stdout, &buf);
 
 			/*
-				* Add a newline after the commit message.
-				*
-				* Usually, this newline produces a blank
-				* padding line between entries, in which case
-				* we need to add graph padding on this line.
-				*
-				* However, the commit message may not end in a
-				* newline.  In this case the newline simply
-				* ends the last line of the commit message,
-				* and we don't need any graph output.  (This
-				* always happens with CMIT_FMT_ONELINE, and it
-				* happens with CMIT_FMT_USERFORMAT when the
-				* format doesn't explicitly end in a newline.)
-				*/
+			* Add a newline after the commit message.
+			*
+			* Usually, this newline produces a blank
+			* padding line between entries, in which case
+			* we need to add graph padding on this line.
+			*
+			* However, the commit message may not end in a
+			* newline.  In this case the newline simply
+			* ends the last line of the commit message,
+			* and we don't need any graph output.  (This
+			* always happens with CMIT_FMT_ONELINE, and it
+			* happens with CMIT_FMT_USERFORMAT when the
+			* format doesn't explicitly end in a newline.)
+			*/
 			if (buf.len && buf.buf[buf.len - 1] == '\n')
 				graph_show_padding(revs->graph);
 			putchar('\n');
cache.h +2 -0
index f30a4417efdf..da9f0be67d7b 100644
@@ -964,6 +964,8 @@ static inline void oidclr(struct object_id *oid)
 #define EMPTY_BLOB_SHA1_BIN \
 	((const unsigned char *) EMPTY_BLOB_SHA1_BIN_LITERAL)
 
+extern const struct object_id empty_tree_oid;
+
 static inline int is_empty_blob_sha1(const unsigned char *sha1)
 {
 	return !hashcmp(sha1, EMPTY_BLOB_SHA1_BIN);
diff.c +2 -2
index e119758aba82..b38d95eb249c 100644
@@ -2318,7 +2318,7 @@ static void builtin_diff(const char *name_a,
 		const char *add = diff_get_color_opt(o, DIFF_FILE_NEW);
 		show_submodule_summary(o->file, one->path ? one->path : two->path,
 				line_prefix,
-				one->oid.hash, two->oid.hash,
+				&one->oid, &two->oid,
 				two->dirty_submodule,
 				meta, del, add, reset);
 		return;
@@ -2329,7 +2329,7 @@ static void builtin_diff(const char *name_a,
 		const char *add = diff_get_color_opt(o, DIFF_FILE_NEW);
 		show_submodule_inline_diff(o->file, one->path ? one->path : two->path,
 				line_prefix,
-				one->oid.hash, two->oid.hash,
+				&one->oid, &two->oid,
 				two->dirty_submodule,
 				meta, del, add, reset, o);
 		return;
graph.c +21 -23

96 lines not on this page · raw message

path.c +7 -2
index d1af029152a2..0cb30123e988 100644
@@ -477,11 +477,16 @@ static void do_submodule_path(struct strbuf *buf, const char *path,
 	strbuf_complete(buf, '/');
 	strbuf_addstr(buf, ".git");
 
-	git_dir = resolve_gitdir(buf->buf);
-	if (git_dir && git_dir != buf->buf) {
+	git_dir = read_gitfile(buf->buf);
+	if (git_dir) {
 		strbuf_reset(buf);
 		strbuf_addstr(buf, git_dir);
 	}
+	if (!is_git_directory(buf->buf)) {
+		strbuf_reset(buf);
+		strbuf_git_path(buf, "%s/%s", "modules", path);
+	}
+
 	strbuf_addch(buf, '/');
 	strbuf_addbuf(&git_submodule_dir, buf);
 
sha1_file.c +3 -0
index 1e23fc186a02..10883d56a600 100644
@@ -38,6 +38,9 @@ static inline uintmax_t sz_fmt(size_t s) { return s; }
 
 const unsigned char null_sha1[20];
 const struct object_id null_oid;
+const struct object_id empty_tree_oid = {
+	.hash = EMPTY_TREE_SHA1_BIN_LITERAL
+};
 
 /*
  * This is meant to hold a *small* number of objects that you would
submodule.c +28 -28

144 lines not on this page · raw message

submodule.h +2 -2
index e2ebc0756f6a..d9e197a948fd 100644
@@ -43,12 +43,12 @@ const char *submodule_strategy_to_string(const struct submodule_update_strategy
 void handle_ignore_submodules_arg(struct diff_options *diffopt, const char *);
 void show_submodule_summary(FILE *f, const char *path,
 		const char *line_prefix,
-		unsigned char one[20], unsigned char two[20],
+		struct object_id *one, struct object_id *two,
 		unsigned dirty_submodule, const char *meta,
 		const char *del, const char *add, const char *reset);
 void show_submodule_inline_diff(FILE *f, const char *path,
 		const char *line_prefix,
-		unsigned char one[20], unsigned char two[20],
+		struct object_id *one, struct object_id *two,
 		unsigned dirty_submodule, const char *meta,
 		const char *del, const char *add, const char *reset,
 		const struct diff_options *opt);
t/t4059-diff-submodule-not-initialized.sh new file +105 -0

105 lines not on this page · raw message

t/t4060-diff-submodule-option-diff-format.sh renamed from t/t4059-diff-submodule-option-diff-format.sh +29 -16

133 lines not on this page · raw message

------>8

Jacob Keller (7):
graph: add support for --line-prefix on all graph-aware output
diff: prepare for additional submodule formats
submodule: allow add_submodule_odb to work even if path is not checked
out
submodule: convert show_submodule_summary to use struct object_id *
submodule: refactor show_submodule_summary with helper function
cache: add empty_tree_oid object
diff: teach diff to display submodule difference with an inline diff

Junio C Hamano (1):
diff.c: remove output_prefix_length field

 Documentation/diff-config.txt                      |   9 +-
 Documentation/diff-options.txt                     |  20 +-
 builtin/rev-list.c                                 |  70 +-
 cache.h                                            |   2 +
 diff.c                                             |  64 +-
 diff.h                                             |  11 +-
 graph.c                                            | 100 ++-
 graph.h                                            |  22 +-
 log-tree.c                                         |   5 +-
 path.c                                             |   5 +
 sha1_file.c                                        |   3 +
 submodule.c                                        | 178 ++++-
 submodule.h                                        |   8 +-
 t/t4013-diff-various.sh                            |   6 +
 ...diff.diff_--line-prefix=abc_master_master^_side |  29 +
 t/t4013/diff.diff_--line-prefix_--cached_--_file0  |  15 +
 t/t4059-diff-submodule-not-initialized.sh          | 105 +++
 t/t4060-diff-submodule-option-diff-format.sh       | 746 +++++++++++++++++++++
 t/t4202-log.sh                                     | 323 +++++++++
 19 files changed, 1569 insertions(+), 152 deletions(-)
 create mode 100644 t/t4013/diff.diff_--line-prefix=abc_master_master^_side
 create mode 100644 t/t4013/diff.diff_--line-prefix_--cached_--_file0
 create mode 100755 t/t4059-diff-submodule-not-initialized.sh
 create mode 100755 t/t4060-diff-submodule-option-diff-format.sh
Signature · 1 line
2.10.0.rc0.217.g609f9e8.dirty
#1 lore raw

PATCH v8 1/8 diff.c: remove output_prefix_length field

From: Junio C Hamano <[email protected]>

"diff/log --stat" has a logic that determines the display columns available for the diffstat part of the output and apportions it for pathnames and diffstat graph automatically.

5e71a84a (Add output_prefix_length to diff_options, 2012-04-16) added the output_prefix_length field to diff_options structure to allow this logic to subtract the display columns used for the history graph part from the total "terminal width"; this matters when the "git log --graph -p" option is in use.

The field must be set to the number of display columns needed to show the output from the output_prefix() callback, which is error prone. As there is only one user of the field, and the user has the actual value of the prefix string, let's get rid of the field and have the user count the display width itself.

---
 diff.c  | 2 +-
 diff.h  | 1 -
 graph.c | 2 --
 3 files changed, 1 insertion(+), 4 deletions(-)
diff.c +1 -1
index 534c12e28ea8..50bef1f07658 100644
@@ -1625,7 +1625,7 @@ static void show_stats(struct diffstat_t *data, struct diff_options *options)
 	 */
 
 	if (options->stat_width == -1)
-		width = term_columns() - options->output_prefix_length;
+		width = term_columns() - strlen(line_prefix);
 	else
 		width = options->stat_width ? options->stat_width : 80;
 	number_width = decimal_width(max_change) > number_width ?
diff.h +0 -1
index 7883729edf10..747a204d75a4 100644
@@ -174,7 +174,6 @@ struct diff_options {
 	diff_format_fn_t format_callback;
 	void *format_callback_data;
 	diff_prefix_fn_t output_prefix;
-	int output_prefix_length;
 	void *output_prefix_data;
 
 	int diff_path_counter;
graph.c +0 -2
index dd1720148dc5..a46803840511 100644
@@ -197,7 +197,6 @@ static struct strbuf *diff_output_prefix_callback(struct diff_options *opt, void
 	assert(opt);
 	assert(graph);
 
-	opt->output_prefix_length = graph->width;
 	strbuf_reset(&msgbuf);
 	graph_padding_line(graph, &msgbuf);
 	return &msgbuf;
@@ -245,7 +244,6 @@ struct git_graph *graph_init(struct rev_info *opt)
 	 */
 	opt->diffopt.output_prefix = diff_output_prefix_callback;
 	opt->diffopt.output_prefix_data = graph;
-	opt->diffopt.output_prefix_length = 0;
 
 	return graph;
 }
Signature · 1 line
2.10.0.rc0.217.g609f9e8.dirty
#2 lore raw

PATCH v8 2/8 graph: add support for --line-prefix on all graph-aware output

In reply to Jacob Keller

From: Jacob Keller <[email protected]>

Add an extension to git-diff and git-log (and any other graph-aware displayable output) such that "--line-prefix=<string>" will print the additional line-prefix on every line of output.

To make this work, we have to fix a few bugs in the graph API that force graph_show_commit_msg to be used only when you have a valid graph. Additionally, we extend the default_diff_output_prefix handler to work even when no graph is enabled.

This is somewhat of a hack on top of the graph API, but I think it should be acceptable here.

This will be used by a future extension of submodule display which displays the submodule diff as the actual diff between the pre and post commit in the submodule project.

Add some tests for both git-log and git-diff to ensure that the prefix is honored correctly.

---
 Documentation/diff-options.txt                     |   3 +
 builtin/rev-list.c                                 |  70 ++---
 diff.c                                             |   7 +
 diff.h                                             |   2 +
 graph.c                                            |  98 ++++---
 graph.h                                            |  22 +-
 log-tree.c                                         |   5 +-
 t/t4013-diff-various.sh                            |   6 +
 ...diff.diff_--line-prefix=abc_master_master^_side |  29 ++
 t/t4013/diff.diff_--line-prefix_--cached_--_file0  |  15 +
 t/t4202-log.sh                                     | 323 +++++++++++++++++++++
 11 files changed, 502 insertions(+), 78 deletions(-)
 create mode 100644 t/t4013/diff.diff_--line-prefix=abc_master_master^_side
 create mode 100644 t/t4013/diff.diff_--line-prefix_--cached_--_file0
Documentation/diff-options.txt +3 -0
index 705a87394200..cc4342e2034d 100644
@@ -569,5 +569,8 @@ endif::git-format-patch[]
 --no-prefix::
 	Do not show any source or destination prefix.
 
+--line-prefix=<prefix>::
+	Prepend an additional prefix to every line of output.
+
 For more detailed explanation on these common options, see also
 linkgit:gitdiffcore[7].
builtin/rev-list.c +31 -39

79 lines not on this page · raw message

diff.c +7 -0
index 50bef1f07658..e57cf39ad109 100644
@@ -18,6 +18,7 @@
 #include "ll-merge.h"
 #include "string-list.h"
 #include "argv-array.h"
+#include "graph.h"
 
 #ifdef NO_FAST_WORKING_DIRECTORY
 #define FAST_WORKING_DIRECTORY 0
@@ -3966,6 +3967,12 @@ int diff_opt_parse(struct diff_options *options,
 		options->a_prefix = optarg;
 		return argcount;
 	}
+	else if ((argcount = parse_long_opt("line-prefix", av, &optarg))) {
+		options->line_prefix = optarg;
+		options->line_prefix_length = strlen(options->line_prefix);
+		graph_setup_line_prefix(options);
+		return argcount;
+	}
 	else if ((argcount = parse_long_opt("dst-prefix", av, &optarg))) {
 		options->b_prefix = optarg;
 		return argcount;
diff.h +2 -0
index 747a204d75a4..1f57aad25c71 100644
@@ -115,6 +115,8 @@ struct diff_options {
 	const char *pickaxe;
 	const char *single_follow;
 	const char *a_prefix, *b_prefix;
+	const char *line_prefix;
+	size_t line_prefix_length;
 	unsigned flags;
 	unsigned touched_flags;
 
graph.c +64 -34

206 lines not on this page · raw message

graph.h +21 -1
index 3f48c19b6208..af623390b605 100644
@@ -1,9 +1,22 @@
 #ifndef GRAPH_H
 #define GRAPH_H
+#include "diff.h"
 
 /* A graph is a pointer to this opaque structure */
 struct git_graph;
 
+/*
+ * Called to setup global display of line_prefix diff option.
+ *
+ * Passed a diff_options structure which indicates the line_prefix and the
+ * file to output the prefix to. This is sort of a hack used so that the
+ * line_prefix will be honored by all flows which also honor "--graph"
+ * regardless of whether a graph has actually been setup. The normal graph
+ * flow will honor the exact diff_options passed, but a NULL graph will cause
+ * display of a line_prefix to stdout.
+ */
+void graph_setup_line_prefix(struct diff_options *diffopt);
+
 /*
  * Set up a custom scheme for column colors.
  *
@@ -113,7 +126,14 @@ int graph_show_remainder(struct git_graph *graph);
  * missing a terminating newline (including if it is empty), the output
  * printed by graph_show_commit_msg() will also be missing a terminating
  * newline.
+ *
+ * Note that unlike some other graph display functions, you must pass the file
+ * handle directly. It is assumed that this is the same file handle as the
+ * file specified by the graph diff options. This is necessary so that
+ * graph_show_commit_msg can be called even with a NULL graph.
  */
-void graph_show_commit_msg(struct git_graph *graph, struct strbuf const *sb);
+void graph_show_commit_msg(struct git_graph *graph,
+			   FILE *file,
+			   struct strbuf const *sb);
 
 #endif /* GRAPH_H */
log-tree.c +1 -4
index bfb735c84556..8c2415747a26 100644
@@ -715,10 +715,7 @@ void show_log(struct rev_info *opt)
 	else
 		opt->missing_newline = 0;
 
-	if (opt->graph)
-		graph_show_commit_msg(opt->graph, &msgbuf);
-	else
-		fwrite(msgbuf.buf, sizeof(char), msgbuf.len, opt->diffopt.file);
+	graph_show_commit_msg(opt->graph, opt->diffopt.file, &msgbuf);
 	if (opt->use_terminator && !commit_format_is_empty(opt->commit_format)) {
 		if (!opt->missing_newline)
 			graph_show_padding(opt->graph);
t/t4013-diff-various.sh +6 -0
index 94ef5000e787..566817e2efdc 100755
@@ -306,6 +306,8 @@ diff --no-index --name-status dir2 dir
 diff --no-index --name-status -- dir2 dir
 diff --no-index dir dir3
 diff master master^ side
+# Can't use spaces...
+diff --line-prefix=abc master master^ side
 diff --dirstat master~1 master~2
 diff --dirstat initial rearrange
 diff --dirstat-by-file initial rearrange
@@ -325,6 +327,10 @@ test_expect_success 'diff --cached -- file on unborn branch' '
 	git diff --cached -- file0 >result &&
 	test_cmp "$TEST_DIRECTORY/t4013/diff.diff_--cached_--_file0" result
 '
+test_expect_success 'diff --line-prefix with spaces' '
+	git diff --line-prefix="| | | " --cached -- file0 >result &&
+	test_cmp "$TEST_DIRECTORY/t4013/diff.diff_--line-prefix_--cached_--_file0" result
+'
 
 test_expect_success 'diff-tree --stdin with log formatting' '
 	cat >expect <<-\EOF &&
t/t4013/diff.diff_--line-prefix=abc_master_master^_side new file +29 -0
new file mode 100644
index 000000000000..99f91e7f0e32
@@ -0,0 +1,29 @@
+$ git diff --line-prefix=abc master master^ side
+abcdiff --cc dir/sub
+abcindex cead32e,7289e35..992913c
+abc--- a/dir/sub
+abc+++ b/dir/sub
+abc@@@ -1,6 -1,4 +1,8 @@@
+abc  A
+abc  B
+abc +C
+abc +D
+abc +E
+abc +F
+abc+ 1
+abc+ 2
+abcdiff --cc file0
+abcindex b414108,f4615da..10a8a9f
+abc--- a/file0
+abc+++ b/file0
+abc@@@ -1,6 -1,6 +1,9 @@@
+abc  1
+abc  2
+abc  3
+abc +4
+abc +5
+abc +6
+abc+ A
+abc+ B
+abc+ C
+$
t/t4013/diff.diff_--line-prefix_--cached_--_file0 new file +15 -0
new file mode 100644
index 000000000000..f41ba4d36aa1
@@ -0,0 +1,15 @@
+| | | diff --git a/file0 b/file0
+| | | new file mode 100644
+| | | index 0000000..10a8a9f
+| | | --- /dev/null
+| | | +++ b/file0
+| | | @@ -0,0 +1,9 @@
+| | | +1
+| | | +2
+| | | +3
+| | | +4
+| | | +5
+| | | +6
+| | | +A
+| | | +B
+| | | +C
t/t4202-log.sh +323 -0

347 lines not on this page · raw message

Signature · 1 line
2.10.0.rc0.217.g609f9e8.dirty
#3 lore raw

PATCH v8 3/8 diff: prepare for additional submodule formats

In reply to Jacob Keller

From: Jacob Keller <[email protected]>

A future patch will add a new format for displaying the difference of a submodule. Make it easier by changing how we store the current selected format. Replace the DIFF_OPT flag with an enumeration, as each format will be mutually exclusive.

---
 diff.c | 12 ++++++------
 diff.h |  7 ++++++-
 2 files changed, 12 insertions(+), 7 deletions(-)
diff.c +6 -6
index e57cf39ad109..d6b321da3d1d 100644
@@ -132,9 +132,9 @@ static int parse_dirstat_params(struct diff_options *options, const char *params
 static int parse_submodule_params(struct diff_options *options, const char *value)
 {
 	if (!strcmp(value, "log"))
-		DIFF_OPT_SET(options, SUBMODULE_LOG);
+		options->submodule_format = DIFF_SUBMODULE_LOG;
 	else if (!strcmp(value, "short"))
-		DIFF_OPT_CLR(options, SUBMODULE_LOG);
+		options->submodule_format = DIFF_SUBMODULE_SHORT;
 	else
 		return -1;
 	return 0;
@@ -2300,9 +2300,9 @@ static void builtin_diff(const char *name_a,
 	struct strbuf header = STRBUF_INIT;
 	const char *line_prefix = diff_line_prefix(o);
 
-	if (DIFF_OPT_TST(o, SUBMODULE_LOG) &&
-			(!one->mode || S_ISGITLINK(one->mode)) &&
-			(!two->mode || S_ISGITLINK(two->mode))) {
+	if (o->submodule_format == DIFF_SUBMODULE_LOG &&
+	    (!one->mode || S_ISGITLINK(one->mode)) &&
+	    (!two->mode || S_ISGITLINK(two->mode))) {
 		const char *del = diff_get_color_opt(o, DIFF_FILE_OLD);
 		const char *add = diff_get_color_opt(o, DIFF_FILE_NEW);
 		show_submodule_summary(o->file, one->path ? one->path : two->path,
@@ -3916,7 +3916,7 @@ int diff_opt_parse(struct diff_options *options,
 		DIFF_OPT_SET(options, OVERRIDE_SUBMODULE_CONFIG);
 		handle_ignore_submodules_arg(options, arg);
 	} else if (!strcmp(arg, "--submodule"))
-		DIFF_OPT_SET(options, SUBMODULE_LOG);
+		options->submodule_format = DIFF_SUBMODULE_LOG;
 	else if (skip_prefix(arg, "--submodule=", &arg))
 		return parse_submodule_opt(options, arg);
 	else if (skip_prefix(arg, "--ws-error-highlight=", &arg))
diff.h +6 -1
index 1f57aad25c71..ea5aba668eaa 100644
@@ -83,7 +83,6 @@ typedef struct strbuf *(*diff_prefix_fn_t)(struct diff_options *opt, void *data)
 #define DIFF_OPT_DIRSTAT_BY_FILE     (1 << 20)
 #define DIFF_OPT_ALLOW_TEXTCONV      (1 << 21)
 #define DIFF_OPT_DIFF_FROM_CONTENTS  (1 << 22)
-#define DIFF_OPT_SUBMODULE_LOG       (1 << 23)
 #define DIFF_OPT_DIRTY_SUBMODULES    (1 << 24)
 #define DIFF_OPT_IGNORE_UNTRACKED_IN_SUBMODULES (1 << 25)
 #define DIFF_OPT_IGNORE_DIRTY_SUBMODULES (1 << 26)
@@ -110,6 +109,11 @@ enum diff_words_type {
 	DIFF_WORDS_COLOR
 };
 
+enum diff_submodule_format {
+	DIFF_SUBMODULE_SHORT = 0,
+	DIFF_SUBMODULE_LOG,
+};
+
 struct diff_options {
 	const char *orderfile;
 	const char *pickaxe;
@@ -157,6 +161,7 @@ struct diff_options {
 	int stat_count;
 	const char *word_regex;
 	enum diff_words_type word_diff;
+	enum diff_submodule_format submodule_format;
 
 	/* this is set by diffcore for DIFF_FORMAT_PATCH */
 	int found_changes;
Signature · 1 line
2.10.0.rc0.217.g609f9e8.dirty
#4 lore raw

Re: [PATCH v8 3/8] diff: prepare for additional submodule formats

diff.h enum diff_words_type { · line 115

Quoted 4 lines · Jacob Keller
diff.h +4 -0
+enum diff_submodule_format {
+	DIFF_SUBMODULE_SHORT = 0,
+	DIFF_SUBMODULE_LOG,
+};

Unlike definition of an array elements, enum {} did not allow trailing comma until recent versions of C, and we avoid it.

No need to resend only to fix this, as I have locally amended it.

Thanks.

#5 lore raw

PATCH v8 4/8 submodule: allow add_submodule_odb to work even if path is not checked out

In reply to Jacob Keller

From: Jacob Keller <[email protected]>

Currently, do_submodule_path will first try to locate the git directory using read_gitfile on <path to submodule>/.git. If this fails, it goes ahead and assumes the path is actually the git directory. This is good as it allows submodules which aren't stored in the superproject's .git directory to function correctly. However, in some cases the submodule is no longer locally checked out, but still has object data stored in the parent project's .git/modules/<path to submodule>.

To make this work, add code to check if we found a valid git directory. If we haven't, then try the standard location of module data instead. This has the advantage of allowing callers of do_submodule_path (add_submodule_odb) to correctly function even if the submodule isn't currently checked out, but was previously initialized.

Update the wording of the submodule log diff format to correctly display that the submodule is "not initialized" instead of "not checked out"

Add tests to ensure that even once we remove the submodule directory, it works by checking in the .git directory.

---
 path.c                                    |   5 ++
 submodule.c                               |   2 +-
 t/t4059-diff-submodule-not-initialized.sh | 105 ++++++++++++++++++++++++++++++
 3 files changed, 111 insertions(+), 1 deletion(-)
 create mode 100755 t/t4059-diff-submodule-not-initialized.sh
path.c +5 -0
index 17551c483476..0cb30123e988 100644
@@ -482,6 +482,11 @@ static void do_submodule_path(struct strbuf *buf, const char *path,
 		strbuf_reset(buf);
 		strbuf_addstr(buf, git_dir);
 	}
+	if (!is_git_directory(buf->buf)) {
+		strbuf_reset(buf);
+		strbuf_git_path(buf, "%s/%s", "modules", path);
+	}
+
 	strbuf_addch(buf, '/');
 	strbuf_addbuf(&git_submodule_dir, buf);
 
submodule.c +1 -1
index 1b5cdfb7e784..e1a51b7506ff 100644
@@ -348,7 +348,7 @@ void show_submodule_summary(FILE *f, const char *path,
 	if (is_null_sha1(two))
 		message = "(submodule deleted)";
 	else if (add_submodule_odb(path))
-		message = "(not checked out)";
+		message = "(not initialized)";
 	else if (is_null_sha1(one))
 		message = "(new submodule)";
 	else if (!(left = lookup_commit_reference(one)) ||
t/t4059-diff-submodule-not-initialized.sh new file +105 -0

105 lines not on this page · raw message

Signature · 1 line
2.10.0.rc0.217.g609f9e8.dirty
#6 lore raw

Re: [PATCH v8 4/8] submodule: allow add_submodule_odb to work even if path is not checked out

Quoted 5 lines · Jacob Keller
path.c +0 -0
index 17551c483476..0cb30123e988 100644

path.c static void do_submodule_path(struct strbuf *buf, const char *path, · line 491

Quoted 10 lines
path.c +5 -0
@@ -482,6 +482,11 @@ static void do_submodule_path(struct strbuf *buf, const char *path,
 		strbuf_reset(buf);
 		strbuf_addstr(buf, git_dir);
 	}
+	if (!is_git_directory(buf->buf)) {
+		strbuf_reset(buf);
+		strbuf_git_path(buf, "%s/%s", "modules", path);
+	}
+
 	strbuf_addch(buf, '/');
 	strbuf_addbuf(&git_submodule_dir, buf);

So, given submodule at $path, so far we have tried $path/.git and would have been happy if it was already a directory (i.e. an embedded repository in place), would have been happy if it was pointing at elsewhere (presumably at .git/modules/$name) that is a directory, and this is a fallback that covers the case where $path in the working tree of the superproject is missing.

I _think_ "path" needs to be mapped to the "name" of the submodule that should be at the "path". Other than that, this hunk looks correct to me.

submodule.c void show_submodule_summary(FILE *f, const char *path, · line 354

Quoted 13 lines
submodule.c +1 -1
index 1b5cdfb7e784..e1a51b7506ff 100644
@@ -348,7 +348,7 @@ void show_submodule_summary(FILE *f, const char *path,
 	if (is_null_sha1(two))
 		message = "(submodule deleted)";
 	else if (add_submodule_odb(path))
-		message = "(not checked out)";
+		message = "(not initialized)";
 	else if (is_null_sha1(one))
 		message = "(new submodule)";
 	else if (!(left = lookup_commit_reference(one)) ||

This is a change unrelated to the fix you made above, and should be done in its own separate patch, I would think.

Quoted 16 lines
t/t4059-diff-submodule-not-initialized.sh new file +10 -0
new file mode 100755
index 000000000000..cc787454033a
@@ -0,0 +1,105 @@
+#!/bin/sh
+#
+# Copyright (c) 2016 Jacob Keller, based on t4041 by Jens Lehmann
+#
+
+test_description='Test for submodule diff on non-checked out submodule
+
+This test tries to verify that add_submodule_odb works when the submodule was
+initialized previously but the checkout has since been removed.
+'

t/t4059-diff-submodule-not-initialized.sh line 20

Quoted 10 lines
t/t4059-diff-submodule-not-initialized.sh new file +10 -0
+
+TEST_NO_CREATE_REPO=1
+. ./test-lib.sh
+
+# Tested non-UTF-8 encoding
+test_encoding="ISO8859-1"
+
+# String "added" in German (translated with Google Translate), encoded in UTF-8,
+# used in sample commit log messages in add_file() function below.
+added=$(printf "hinzugef\303\274gt")

Have an empty line here?

Quoted 7 lines
t/t4059-diff-submodule-not-initialized.sh new file +7 -0
+add_file () {
+	(
+		cd "$1" &&
+		shift &&
+		for name
+		do
+			echo "$name" >"$name" &&

t/t4059-diff-submodule-not-initialized.sh line 37

Quoted 10 lines
t/t4059-diff-submodule-not-initialized.sh new file +10 -0
+			git add "$name" &&
+			test_tick &&
+			# "git commit -m" would break MinGW, as Windows refuse to pass
+			# $test_encoding encoded parameter to git.
+			echo "Add $name ($added $name)" | iconv -f utf-8 -t $test_encoding |
+			git -c "i18n.commitEncoding=$test_encoding" commit -F -
+		done >/dev/null &&
+		git rev-parse --short --verify HEAD
+	)
+}

Have an empty line here?

t/t4059-diff-submodule-not-initialized.sh line 41

Quoted 4 lines
t/t4059-diff-submodule-not-initialized.sh new file +4 -0
+commit_file () {
+	test_tick &&
+	git commit "$@" -m "Commit $*" >/dev/null
+}

Surround these ...

t/t4059-diff-submodule-not-initialized.sh line 47

Quoted 5 lines
t/t4059-diff-submodule-not-initialized.sh new file +5 -0
+test_create_repo sm1 &&
+test_create_repo sm2 &&
+add_file sm1 foo >/dev/null &&
+add_file sm2 foo1 foo2 >/dev/null &&
+smhead1=$(cd sm2; git rev-parse --short --verify HEAD) &&

... inside its own "test_expect_success setup"?

None of the ">/dev/null" we see in the above helper functions (and use of these helper functions) are necessary or desired, I would think.

The last one can become "$(git -C sm2 rev-parse ...)".

t/t4059-diff-submodule-not-initialized.sh line 48

Quoted 1 line
t/t4059-diff-submodule-not-initialized.sh new file +1 -0
+cd sm1

I can sort of see the attraction of doing it this way, but we avoid chdir'ing around outside subshells, especially in a newly added test script. It is very easy to go down and forget to come back up, or worse yet, stop going down and forget to remove matching "cd .." and end up being outside the $TEST_DIRECTORY by mistake.

t/t4059-diff-submodule-not-initialized.sh

Quoted 7 lines
t/t4059-diff-submodule-not-initialized.sh new file +7 -0
+test_expect_success 'setup - submodule directory' '
+...
+
+cd ..
+
+test_expect_success 'submodule not initialized in new clone' '
+...

The tests themselves looked sensible. Thanks.

#7 lore raw

Re: [PATCH v8 4/8] submodule: allow add_submodule_odb to work even if path is not checked out

Quoted 25 lines · Junio C Hamano
Quoted 5 lines · Jacob Keller
path.c +0 -0
index 17551c483476..0cb30123e988 100644

path.c static void do_submodule_path(struct strbuf *buf, const char *path, · line 491

Quoted 10 lines
path.c +5 -0
@@ -482,6 +482,11 @@ static void do_submodule_path(struct strbuf *buf, const char *path,
              strbuf_reset(buf);
              strbuf_addstr(buf, git_dir);
      }
+     if (!is_git_directory(buf->buf)) {
+             strbuf_reset(buf);
+             strbuf_git_path(buf, "%s/%s", "modules", path);
+     }
+
      strbuf_addch(buf, '/');
      strbuf_addbuf(&git_submodule_dir, buf);

So, given submodule at $path, so far we have tried $path/.git and would have been happy if it was already a directory (i.e. an embedded repository in place), would have been happy if it was pointing at elsewhere (presumably at .git/modules/$name) that is a directory, and this is a fallback that covers the case where $path in the working tree of the superproject is missing.

Quoted 3 lines

I _think_ "path" needs to be mapped to the "name" of the submodule that should be at the "path". Other than that, this hunk looks correct to me.

How do we do that? I tried to find a way to do that, couldn't, and decided it was probably already normalized. It seems to be, based on my tests, where I run git-log from within a subdirectory that has the submodule. I think we already have the complete path. Or is the name *not* equivalent to the path?

Quoted 18 lines
Quoted 6 lines
submodule.c +0 -0
index 1b5cdfb7e784..e1a51b7506ff 100644

submodule.c void show_submodule_summary(FILE *f, const char *path, · line 354

Quoted 8 lines
submodule.c +1 -1
@@ -348,7 +348,7 @@ void show_submodule_summary(FILE *f, const char *path,
      if (is_null_sha1(two))
              message = "(submodule deleted)";
      else if (add_submodule_odb(path))
-             message = "(not checked out)";
+             message = "(not initialized)";
      else if (is_null_sha1(one))
              message = "(new submodule)";
      else if (!(left = lookup_commit_reference(one)) ||

This is a change unrelated to the fix you made above, and should be done in its own separate patch, I would think.

It is the same change. The first hunk makes it so that "not checked out" is no longer what occurs. We change the behavior of add_submodule_odb into "work even if there is no check out, but only fail when the submodule isn't initialized at all, either in path/.git or ./git/modules/path/" so we need to change the message because we've changed behavior.

Quoted 20 lines
Quoted 20 lines
t/t4059-diff-submodule-not-initialized.sh new file +14 -0
new file mode 100755
index 000000000000..cc787454033a
@@ -0,0 +1,105 @@
+#!/bin/sh
+#
+# Copyright (c) 2016 Jacob Keller, based on t4041 by Jens Lehmann
+#
+
+test_description='Test for submodule diff on non-checked out submodule
+
+This test tries to verify that add_submodule_odb works when the submodule was
+initialized previously but the checkout has since been removed.
+'
+
+TEST_NO_CREATE_REPO=1
+. ./test-lib.sh
+
Quoted 9 lines

t/t4059-diff-submodule-not-initialized.sh line 20

Quoted 6 lines
t/t4059-diff-submodule-not-initialized.sh new file +6 -0
+# Tested non-UTF-8 encoding
+test_encoding="ISO8859-1"
+
+# String "added" in German (translated with Google Translate), encoded in UTF-8,
+# used in sample commit log messages in add_file() function below.
+added=$(printf "hinzugef\303\274gt")

Have an empty line here?

Makes sense I suppose.

Quoted 11 lines
Quoted 11 lines
t/t4059-diff-submodule-not-initialized.sh new file +11 -0
+add_file () {
+     (
+             cd "$1" &&
+             shift &&
+             for name
+             do
+                     echo "$name" >"$name" &&
+                     git add "$name" &&
+                     test_tick &&
+                     # "git commit -m" would break MinGW, as Windows refuse to pass
+                     # $test_encoding encoded parameter to git.
Quoted 9 lines

t/t4059-diff-submodule-not-initialized.sh line 37

Quoted 6 lines
t/t4059-diff-submodule-not-initialized.sh new file +6 -0
+                     echo "Add $name ($added $name)" | iconv -f utf-8 -t $test_encoding |
+                     git -c "i18n.commitEncoding=$test_encoding" commit -F -
+             done >/dev/null &&
+             git rev-parse --short --verify HEAD
+     )
+}

Have an empty line here?

There was no empty line in the place I copied from.

Quoted 15 lines

t/t4059-diff-submodule-not-initialized.sh line 41

Quoted 4 lines
t/t4059-diff-submodule-not-initialized.sh new file +4 -0
+commit_file () {
+     test_tick &&
+     git commit "$@" -m "Commit $*" >/dev/null
+}

Surround these ...

t/t4059-diff-submodule-not-initialized.sh line 47

Quoted 5 lines
t/t4059-diff-submodule-not-initialized.sh new file +5 -0
+test_create_repo sm1 &&
+test_create_repo sm2 &&
+add_file sm1 foo >/dev/null &&
+add_file sm2 foo1 foo2 >/dev/null &&
+smhead1=$(cd sm2; git rev-parse --short --verify HEAD) &&

... inside its own "test_expect_success setup"?

Quoted 3 lines

None of the ">/dev/null" we see in the above helper functions (and use of these helper functions) are necessary or desired, I would think.

If we put them in test_expect_success setup they aren't. They were because add_file returns the sha1 of the rev-parse on HEAD after adding.

Quoted 3 lines

The last one can become "$(git -C sm2 rev-parse ...)".

Yea.

Quoted 8 lines

t/t4059-diff-submodule-not-initialized.sh line 48

Quoted 1 line
t/t4059-diff-submodule-not-initialized.sh new file +1 -0
+cd sm1

I can sort of see the attraction of doing it this way, but we avoid chdir'ing around outside subshells, especially in a newly added test script. It is very easy to go down and forget to come back up, or worse yet, stop going down and forget to remove matching "cd .." and end up being outside the $TEST_DIRECTORY by mistake.

That would make a lot of tests problematic here.. but probably doable.

Quoted 9 lines

t/t4059-diff-submodule-not-initialized.sh

Quoted 7 lines
t/t4059-diff-submodule-not-initialized.sh new file +7 -0
+test_expect_success 'setup - submodule directory' '
+...
+
+cd ..
+
+test_expect_success 'submodule not initialized in new clone' '
+...

The tests themselves looked sensible. Thanks.

Thanks,
Jake

#8 lore raw

Re: [PATCH v8 4/8] submodule: allow add_submodule_odb to work even if path is not checked out

Quoted 2 lines · Jacob Keller

submodule. I think we already have the complete path. Or is the name *not* equivalent to the path?

A submodule that is bound to top-level at "path" originally gets "path" as its name. If you move it elsewhere, you do not want it to lose its identity (and its place in .git/modules/* of the top-level). so a submodule whose name is "path" can reside in the new place after such a move.

Quoted 1 line

There was no empty line in the place I copied from.

Is that "because I copied from a source that is mistaken, I refuse to make it right"? Or just an explanation why there is a mistake? Or something else (like "we should update the original one while we are at it as a pure clean-up")?

Quoted 1 line

If we put them in test_expect_success setup they aren't.

Yes, that is why I said they are unnecessary. Let's minimize the amount of random code that sits outside the control of the test framework (i.e. test_expect_{success,failure}).

Thanks.

#9 lore raw

Re: [PATCH v8 4/8] submodule: allow add_submodule_odb to work even if path is not checked out

Quoted 11 lines · Junio C Hamano
Quoted 2 lines · Jacob Keller

submodule. I think we already have the complete path. Or is the name *not* equivalent to the path?

A submodule that is bound to top-level at "path" originally gets "path" as its name. If you move it elsewhere, you do not want it to lose its identity (and its place in .git/modules/* of the top-level). so a submodule whose name is "path" can reside in the new place after such a move.

Is there a way to do this lookup? I couldn't find it.

Quoted 6 lines
Quoted 1 line

There was no empty line in the place I copied from.

Is that "because I copied from a source that is mistaken, I refuse to make it right"? Or just an explanation why there is a mistake? Or something else (like "we should update the original one while we are at it as a pure clean-up")?

That was an explanation for "I didn't understand that was a mistake" and a "if we fix this we might want to fix them also to avoid this same problem in the future".

Quoted 7 lines
Quoted 2 lines

If we put them in test_expect_success setup they aren't.

Yes, that is why I said they are unnecessary. Let's minimize the amount of random code that sits outside the control of the test framework (i.e. test_expect_{success,failure}).

Yes I agree.

Thanks,
Jake

Quoted 1 line

Thanks.

#10 lore raw

Re: [PATCH v8 4/8] submodule: allow add_submodule_odb to work even if path is not checked out

Quoted 1 line · Jacob Keller

Is there a way to do this lookup? I couldn't find it.

Perhaps submodule_from_path(), that is used to implement "git submodule--helper name $path"?

#11 lore raw

Re: [PATCH v8 4/8] submodule: allow add_submodule_odb to work even if path is not checked out

Quoted 6 lines · Junio C Hamano
Quoted 1 line · Jacob Keller

Is there a way to do this lookup? I couldn't find it.

Perhaps submodule_from_path(), that is used to implement "git submodule--helper name $path"?

Yep, thanks. I also added a test to show that the use of name works.

Regards,
Jake

#12 lore raw

PATCH v8 5/8 submodule: convert show_submodule_summary to use struct object_id *

In reply to Jacob Keller

From: Jacob Keller <[email protected]>

Since we're going to be changing this function in a future patch, lets go ahead and convert this to use object_id now.

---
 diff.c      |  2 +-
 submodule.c | 16 ++++++++--------
 submodule.h |  2 +-
 3 files changed, 10 insertions(+), 10 deletions(-)
diff.c +1 -1
index d6b321da3d1d..16253b191f53 100644
@@ -2307,7 +2307,7 @@ static void builtin_diff(const char *name_a,
 		const char *add = diff_get_color_opt(o, DIFF_FILE_NEW);
 		show_submodule_summary(o->file, one->path ? one->path : two->path,
 				line_prefix,
-				one->oid.hash, two->oid.hash,
+				&one->oid, &two->oid,
 				two->dirty_submodule,
 				meta, del, add, reset);
 		return;
submodule.c +8 -8
index e1a51b7506ff..422353ccf6cc 100644
@@ -335,7 +335,7 @@ static void print_submodule_summary(struct rev_info *rev, FILE *f,
 
 void show_submodule_summary(FILE *f, const char *path,
 		const char *line_prefix,
-		unsigned char one[20], unsigned char two[20],
+		struct object_id *one, struct object_id *two,
 		unsigned dirty_submodule, const char *meta,
 		const char *del, const char *add, const char *reset)
 {
@@ -345,14 +345,14 @@ void show_submodule_summary(FILE *f, const char *path,
 	struct strbuf sb = STRBUF_INIT;
 	int fast_forward = 0, fast_backward = 0;
 
-	if (is_null_sha1(two))
+	if (is_null_oid(two))
 		message = "(submodule deleted)";
 	else if (add_submodule_odb(path))
 		message = "(not initialized)";
-	else if (is_null_sha1(one))
+	else if (is_null_oid(one))
 		message = "(new submodule)";
-	else if (!(left = lookup_commit_reference(one)) ||
-		 !(right = lookup_commit_reference(two)))
+	else if (!(left = lookup_commit_reference(one->hash)) ||
+		 !(right = lookup_commit_reference(two->hash)))
 		message = "(commits not present)";
 	else if (prepare_submodule_summary(&rev, path, left, right,
 					   &fast_forward, &fast_backward))
@@ -365,16 +365,16 @@ void show_submodule_summary(FILE *f, const char *path,
 		fprintf(f, "%sSubmodule %s contains modified content\n",
 			line_prefix, path);
 
-	if (!hashcmp(one, two)) {
+	if (!oidcmp(one, two)) {
 		strbuf_release(&sb);
 		return;
 	}
 
 	strbuf_addf(&sb, "%s%sSubmodule %s %s..", line_prefix, meta, path,
-			find_unique_abbrev(one, DEFAULT_ABBREV));
+			find_unique_abbrev(one->hash, DEFAULT_ABBREV));
 	if (!fast_backward && !fast_forward)
 		strbuf_addch(&sb, '.');
-	strbuf_addf(&sb, "%s", find_unique_abbrev(two, DEFAULT_ABBREV));
+	strbuf_addf(&sb, "%s", find_unique_abbrev(two->hash, DEFAULT_ABBREV));
 	if (message)
 		strbuf_addf(&sb, " %s%s\n", message, reset);
 	else
submodule.h +1 -1
index 2af939099819..d83df57e24ff 100644
@@ -43,7 +43,7 @@ const char *submodule_strategy_to_string(const struct submodule_update_strategy
 void handle_ignore_submodules_arg(struct diff_options *diffopt, const char *);
 void show_submodule_summary(FILE *f, const char *path,
 		const char *line_prefix,
-		unsigned char one[20], unsigned char two[20],
+		struct object_id *one, struct object_id *two,
 		unsigned dirty_submodule, const char *meta,
 		const char *del, const char *add, const char *reset);
 void set_config_fetch_recurse_submodules(int value);
Signature · 1 line
2.10.0.rc0.217.g609f9e8.dirty
#13 lore raw

Re: [PATCH v8 5/8] submodule: convert show_submodule_summary to use struct object_id *

Quoted 7 lines · Jacob Keller

From: Jacob Keller <[email protected]>

Since we're going to be changing this function in a future patch, lets go ahead and convert this to use object_id now.

---

Sounds good. Thanks.

#14 lore raw

PATCH v8 6/8 submodule: refactor show_submodule_summary with helper function

In reply to Jacob Keller

From: Jacob Keller <[email protected]>

A future patch is going to add a new submodule diff format which displays an inline diff of the submodule changes. To make this easier, and to ensure that both submodule diff formats use the same initial header, factor out show_submodule_header() function which will print the current submodule header line, and then leave the show_submodule_summary function to lookup and print the submodule log format.

This does create one format change in that "(revision walker failed)" will now be displayed on its own line rather than as part of the message because we no longer perform this step directly in the header display flow. However, this is a rare case as most causes of the failure will be due to a missing commit which we already check for and avoid previously. flow. However, this is a rare case and shouldn't impact much.

---
 submodule.c | 108 ++++++++++++++++++++++++++++++++++++++++++------------------
 1 file changed, 76 insertions(+), 32 deletions(-)
submodule.c +76 -32
index 422353ccf6cc..7108b4786bc1 100644
@@ -277,8 +277,7 @@ void handle_ignore_submodules_arg(struct diff_options *diffopt,
 }
 
 static int prepare_submodule_summary(struct rev_info *rev, const char *path,
-		struct commit *left, struct commit *right,
-		int *fast_forward, int *fast_backward)
+		struct commit *left, struct commit *right)
 {
 	struct commit_list *merge_bases, *list;
 
@@ -290,12 +289,6 @@ static int prepare_submodule_summary(struct rev_info *rev, const char *path,
 	add_pending_object(rev, &left->object, path);
 	add_pending_object(rev, &right->object, path);
 	merge_bases = get_merge_bases(left, right);
-	if (merge_bases) {
-		if (merge_bases->item == left)
-			*fast_forward = 1;
-		else if (merge_bases->item == right)
-			*fast_backward = 1;
-	}
 	for (list = merge_bases; list; list = list->next) {
 		list->item->object.flags |= UNINTERESTING;
 		add_pending_object(rev, &list->item->object,
@@ -333,31 +326,23 @@ static void print_submodule_summary(struct rev_info *rev, FILE *f,
 	strbuf_release(&sb);
 }
 
-void show_submodule_summary(FILE *f, const char *path,
+/* Helper function to display the submodule header line prior to the full
+ * summary output. If it can locate the submodule objects directory it will
+ * attempt to lookup both the left and right commits and put them into the
+ * left and right pointers.
+ */
+static void show_submodule_header(FILE *f, const char *path,
 		const char *line_prefix,
 		struct object_id *one, struct object_id *two,
 		unsigned dirty_submodule, const char *meta,
-		const char *del, const char *add, const char *reset)
+		const char *reset,
+		struct commit **left, struct commit **right)
 {
-	struct rev_info rev;
-	struct commit *left = NULL, *right = NULL;
+	struct commit_list *merge_bases;
 	const char *message = NULL;
 	struct strbuf sb = STRBUF_INIT;
 	int fast_forward = 0, fast_backward = 0;
 
-	if (is_null_oid(two))
-		message = "(submodule deleted)";
-	else if (add_submodule_odb(path))
-		message = "(not initialized)";
-	else if (is_null_oid(one))
-		message = "(new submodule)";
-	else if (!(left = lookup_commit_reference(one->hash)) ||
-		 !(right = lookup_commit_reference(two->hash)))
-		message = "(commits not present)";
-	else if (prepare_submodule_summary(&rev, path, left, right,
-					   &fast_forward, &fast_backward))
-		message = "(revision walker failed)";
-
 	if (dirty_submodule & DIRTY_SUBMODULE_UNTRACKED)
 		fprintf(f, "%sSubmodule %s contains untracked content\n",
 			line_prefix, path);
@@ -365,11 +350,46 @@ void show_submodule_summary(FILE *f, const char *path,
 		fprintf(f, "%sSubmodule %s contains modified content\n",
 			line_prefix, path);
 
+	if (is_null_oid(one))
+		message = "(new submodule)";
+	else if (is_null_oid(two))
+		message = "(submodule deleted)";
+
+	if (add_submodule_odb(path)) {
+		if (!message)
+			message = "(not initialized)";
+		goto output_header;
+	}
+
+	/*
+	 * Attempt to lookup the commit references, and determine if this is
+	 * a fast forward or fast backwards update.
+	 */
+	*left = lookup_commit_reference(one->hash);
+	*right = lookup_commit_reference(two->hash);
+
+	/*
+	 * Warn about missing commits in the submodule project, but only if
+	 * they aren't null.
+	 */
+	if ((!is_null_oid(one) && !*left) ||
+	     (!is_null_oid(two) && !*right))
+		message = "(commits not present)";
+
+	merge_bases = get_merge_bases(*left, *right);
+	if (merge_bases) {
+		if (merge_bases->item == *left)
+			fast_forward = 1;
+		else if (merge_bases->item == *right)
+			fast_backward = 1;
+	}
+
 	if (!oidcmp(one, two)) {
 		strbuf_release(&sb);
 		return;
 	}
 
+output_header:
 	strbuf_addf(&sb, "%s%sSubmodule %s %s..", line_prefix, meta, path,
 			find_unique_abbrev(one->hash, DEFAULT_ABBREV));
 	if (!fast_backward && !fast_forward)
@@ -381,16 +401,40 @@ void show_submodule_summary(FILE *f, const char *path,
 		strbuf_addf(&sb, "%s:%s\n", fast_backward ? " (rewind)" : "", reset);
 	fwrite(sb.buf, sb.len, 1, f);
 
-	if (!message) /* only NULL if we succeeded in setting up the walk */
-		print_submodule_summary(&rev, f, line_prefix, del, add, reset);
-	if (left)
-		clear_commit_marks(left, ~0);
-	if (right)
-		clear_commit_marks(right, ~0);
-
 	strbuf_release(&sb);
 }
 
+void show_submodule_summary(FILE *f, const char *path,
+		const char *line_prefix,
+		struct object_id *one, struct object_id *two,
+		unsigned dirty_submodule, const char *meta,
+		const char *del, const char *add, const char *reset)
+{
+	struct rev_info rev;
+	struct commit *left = NULL, *right = NULL;
+
+	show_submodule_header(f, path, line_prefix, one, two, dirty_submodule,
+			      meta, reset, &left, &right);
+
+	/*
+	 * If we don't have both a left and a right pointer, there is no
+	 * reason to try and display a summary. The header line should contain
+	 * all the information the user needs.
+	 */
+	if (!left || !right)
+		return;
+
+	/* Treat revision walker failure the same as missing commits */
+	if (prepare_submodule_summary(&rev, path, left, right)) {
+		fprintf(f, "%s(revision walker failed)\n", line_prefix);
+		return;
+	}
+
+	print_submodule_summary(&rev, f, line_prefix, del, add, reset);
+	clear_commit_marks(left, ~0);
+	clear_commit_marks(right, ~0);
+}
+
 void set_config_fetch_recurse_submodules(int value)
 {
 	config_fetch_recurse_submodules = value;
Signature · 1 line
2.10.0.rc0.217.g609f9e8.dirty
#15 lore raw

Re: [PATCH v8 6/8] submodule: refactor show_submodule_summary with helper function

submodule.c static int prepare_submodule_summary(struct rev_info *rev, const char *path, · line 294

Quoted 13 lines · Jacob Keller
submodule.c +0 -6
@@ -290,12 +289,6 @@ static int prepare_submodule_summary(struct rev_info *rev, const char *path,
 	add_pending_object(rev, &left->object, path);
 	add_pending_object(rev, &right->object, path);
 	merge_bases = get_merge_bases(left, right);
-	if (merge_bases) {
-		if (merge_bases->item == left)
-			*fast_forward = 1;
-		else if (merge_bases->item == right)
-			*fast_backward = 1;
-	}
 	for (list = merge_bases; list; list = list->next) {
 		list->item->object.flags |= UNINTERESTING;
 		add_pending_object(rev, &list->item->object,

Not a new issue with this patch, but I wonder if this commit_list is leaking here.

Quoted 5 lines
submodule.c +5 -0
+	/*
+	 * Warn about missing commits in the submodule project, but only if
+	 * they aren't null.
+	 */
+	if ((!is_null_oid(one) && !*left) ||

submodule.c void show_submodule_summary(FILE *f, const char *path, · line 385

Quoted 10 lines
submodule.c +10 -0
+	     (!is_null_oid(two) && !*right))
+		message = "(commits not present)";
+
+	merge_bases = get_merge_bases(*left, *right);
+	if (merge_bases) {
+		if (merge_bases->item == *left)
+			fast_forward = 1;
+		else if (merge_bases->item == *right)
+			fast_backward = 1;
+	}

And probably merge_bases also leaks here.

It is not cheap to compute merge bases, but show_submodule_summary() makes two calls to get_merge_bases(), one in show_submodule_header() and then another inside prepare_submodule_summary() to compute exactly the same set of merge bases. We somehow need to reduce it to just one.

#16 lore raw

Re: [PATCH v8 6/8] submodule: refactor show_submodule_summary with helper function

Quoted 8 lines · Junio C Hamano

And probably merge_bases also leaks here.

It is not cheap to compute merge bases, but show_submodule_summary() makes two calls to get_merge_bases(), one in show_submodule_header() and then another inside prepare_submodule_summary() to compute exactly the same set of merge bases. We somehow need to reduce it to just one.

I can make show_submodule_headers take another parameter which we pass, and then pass that into prepare_submodule_summary...?

Thanks,
Jake

#17 lore raw

PATCH v8 7/8 cache: add empty_tree_oid object

In reply to Jacob Keller

From: Jacob Keller <[email protected]>

Add an empty_tree_oid object which can be used in place of EMPTY_TREE_SHA1_BIN_LITERAL for code which is being converted to struct object_id.

---
 cache.h     | 2 ++
 sha1_file.c | 3 +++
 2 files changed, 5 insertions(+)
cache.h +2 -0
index f30a4417efdf..da9f0be67d7b 100644
@@ -964,6 +964,8 @@ static inline void oidclr(struct object_id *oid)
 #define EMPTY_BLOB_SHA1_BIN \
 	((const unsigned char *) EMPTY_BLOB_SHA1_BIN_LITERAL)
 
+extern const struct object_id empty_tree_oid;
+
 static inline int is_empty_blob_sha1(const unsigned char *sha1)
 {
 	return !hashcmp(sha1, EMPTY_BLOB_SHA1_BIN);
sha1_file.c +3 -0
index 1e23fc186a02..10883d56a600 100644
@@ -38,6 +38,9 @@ static inline uintmax_t sz_fmt(size_t s) { return s; }
 
 const unsigned char null_sha1[20];
 const struct object_id null_oid;
+const struct object_id empty_tree_oid = {
+	.hash = EMPTY_TREE_SHA1_BIN_LITERAL
+};
 
 /*
  * This is meant to hold a *small* number of objects that you would
Signature · 1 line
2.10.0.rc0.217.g609f9e8.dirty
#18 lore raw

Re: [PATCH v8 7/8] cache: add empty_tree_oid object

Quoted 5 lines · Jacob Keller

From: Jacob Keller <[email protected]>

Add an empty_tree_oid object which can be used in place of EMPTY_TREE_SHA1_BIN_LITERAL for code which is being converted to struct object_id.

How widely do you envision the users of this symbol would be spread across the entire codebase? I am debating myself if we need a singleton in-core copy like this (if we end up referring to it from everywhere), or we only need one level higher abstraction, e.g. "is_empty_tree_oid()" helper (in which case I do not think we even need a singleton; just imitate how is_empty_blob_sha1() is implemented).

Even if we need such a singleton, I think we avoid ".field = value" struct initializations in our code.

Quoted 34 lines
---
 cache.h     | 2 ++
 sha1_file.c | 3 +++
 2 files changed, 5 insertions(+)
cache.h +2 -0
index f30a4417efdf..da9f0be67d7b 100644
@@ -964,6 +964,8 @@ static inline void oidclr(struct object_id *oid)
 #define EMPTY_BLOB_SHA1_BIN \
 	((const unsigned char *) EMPTY_BLOB_SHA1_BIN_LITERAL)
 
+extern const struct object_id empty_tree_oid;
+
 static inline int is_empty_blob_sha1(const unsigned char *sha1)
 {
 	return !hashcmp(sha1, EMPTY_BLOB_SHA1_BIN);
sha1_file.c +3 -0
index 1e23fc186a02..10883d56a600 100644
@@ -38,6 +38,9 @@ static inline uintmax_t sz_fmt(size_t s) { return s; }
 
 const unsigned char null_sha1[20];
 const struct object_id null_oid;
+const struct object_id empty_tree_oid = {
+	.hash = EMPTY_TREE_SHA1_BIN_LITERAL
+};
 
 /*
  * This is meant to hold a *small* number of objects that you would
#19 lore raw

Re: [PATCH v8 7/8] cache: add empty_tree_oid object

Quoted 8 lines · Junio C Hamano
Quoted 5 lines · Jacob Keller

From: Jacob Keller <[email protected]>

Add an empty_tree_oid object which can be used in place of EMPTY_TREE_SHA1_BIN_LITERAL for code which is being converted to struct object_id.

Quoted 7 lines

How widely do you envision the users of this symbol would be spread across the entire codebase? I am debating myself if we need a singleton in-core copy like this (if we end up referring to it from everywhere), or we only need one level higher abstraction, e.g. "is_empty_tree_oid()" helper (in which case I do not think we even need a singleton; just imitate how is_empty_blob_sha1() is implemented).

If I do this, I'd also add an "is_empty_tree_sha1()" as well?

Quoted 4 lines

Even if we need such a singleton, I think we avoid ".field = value" struct initializations in our code.

Is there a reason for that? I've found that .field = value is safer because it ensures that you don't end up initializing the wrong values? Or is it a compatibility thing?

Thanks,
Jake

#20 lore raw

Re: [PATCH v8 7/8] cache: add empty_tree_oid object

Quoted 3 lines · Jacob Keller

Is there a reason for that? I've found that .field = value is safer because it ensures that you don't end up initializing the wrong values? Or is it a compatibility thing?

Yes.

#21 lore raw

Re: [PATCH v8 7/8] cache: add empty_tree_oid object

Quoted 7 lines · Junio C Hamano
Quoted 3 lines · Jacob Keller

Is there a reason for that? I've found that .field = value is safer because it ensures that you don't end up initializing the wrong values? Or is it a compatibility thing?

Yes.

That was a bit too terse. The answers to all three questions are "Yes", "Yes", and "Yes".

Together with enum ... = { A, B, C, }; we may want to consider not worrying about ancient compilers at some point, and it might be this year or next year, but I do not think we want to do that as part of this series.

#22 lore raw

Re: [PATCH v8 7/8] cache: add empty_tree_oid object

Quoted 10 lines · Junio C Hamano
Quoted 7 lines · Junio C Hamano
Quoted 3 lines · Jacob Keller

Is there a reason for that? I've found that .field = value is safer because it ensures that you don't end up initializing the wrong values? Or is it a compatibility thing?

Yes.

Quoted 7 lines

That was a bit too terse. The answers to all three questions are "Yes", "Yes", and "Yes".

Together with enum ... = { A, B, C, }; we may want to consider not worrying about ancient compilers at some point, and it might be this year or next year, but I do not think we want to do that as part of this series.

Thanks, it makes sense. It is hard to remember when some feature got added.

Regards,
Jake

#23 lore raw

Re: [PATCH v8 7/8] cache: add empty_tree_oid object

In reply to Junio C Hamano
Quoted 8 lines · Junio C Hamano
Quoted 5 lines · Jacob Keller

From: Jacob Keller <[email protected]>

Add an empty_tree_oid object which can be used in place of EMPTY_TREE_SHA1_BIN_LITERAL for code which is being converted to struct object_id.

Quoted 7 lines

How widely do you envision the users of this symbol would be spread across the entire codebase? I am debating myself if we need a singleton in-core copy like this (if we end up referring to it from everywhere), or we only need one level higher abstraction, e.g. "is_empty_tree_oid()" helper (in which case I do not think we even need a singleton; just imitate how is_empty_blob_sha1() is implemented).

I suspect we need more than just the "is_empty" query. At least for the blob case, we do hashcpy() it into a struct (which should eventually become oidcpy). The empty-tree case even more so, as we pass it to random functions like lookup_tree().

Our EMPTY_TREE_SHA1_BIN_LITERAL effectively ends up as a singleton in-core, too; it's just handled transparently by the compiler, since it's a literal. This effectively gives us _two_ singletons. We could do:

  const struct object_id empty_blob_oid = {
	  "\xe6\x9d\xe2\x9b\xb2\xd1\xd6\x43\x4b\x8b"
	  "\x29\xae\x77\x5a\xd8\xc2\xe4\x8c\x53\x91"

};
#define EMPTY_BLOB_SHA1_BIN (empty_blob_oid.hash)

It's possible the use of an actual string literal lets the compiler do more optimizations, but I'd doubt it matters in practice. Probably it is just sticking that literal somewhere in BSS and filling in the pointer to it.

-Peff

#24 lore raw

Re: [PATCH v8 7/8] cache: add empty_tree_oid object

Quoted 12 lines · Jeff King

I suspect we need more than just the "is_empty" query. At least for the blob case, we do hashcpy() it into a struct (which should eventually become oidcpy). The empty-tree case even more so, as we pass it to random functions like lookup_tree().

Our EMPTY_TREE_SHA1_BIN_LITERAL effectively ends up as a singleton in-core, too; it's just handled transparently by the compiler, since it's a literal. This effectively gives us _two_ singletons. We could do:

  const struct object_id empty_blob_oid = {
	  "\xe6\x9d\xe2\x9b\xb2\xd1\xd6\x43\x4b\x8b"
	  "\x29\xae\x77\x5a\xd8\xc2\xe4\x8c\x53\x91"
Quoted 7 lines

};
#define EMPTY_BLOB_SHA1_BIN (empty_blob_oid.hash)

It's possible the use of an actual string literal lets the compiler do more optimizations, but I'd doubt it matters in practice. Probably it is just sticking that literal somewhere in BSS and filling in the pointer to it.

Makes sense; thanks.

#25 lore raw

PATCH v8 8/8 diff: teach diff to display submodule difference with an inline diff

In reply to Jacob Keller

From: Jacob Keller <[email protected]>

Teach git-diff and friends a new format for displaying the difference of a submodule. The new format is an inline diff of the contents of the submodule between the commit range of the update. This allows the user to see the actual code change caused by a submodule update.

Add tests for the new format and option.

---
 Documentation/diff-config.txt                |   9 +-
 Documentation/diff-options.txt               |  17 +-
 diff.c                                       |  31 +-
 diff.h                                       |   1 +
 submodule.c                                  |  62 +++
 submodule.h                                  |   6 +
 t/t4060-diff-submodule-option-diff-format.sh | 746 +++++++++++++++++++++++++++
 7 files changed, 852 insertions(+), 20 deletions(-)
 create mode 100755 t/t4060-diff-submodule-option-diff-format.sh
Documentation/diff-config.txt +5 -4
index d5a5b17d5088..0eded24034b5 100644
@@ -122,10 +122,11 @@ diff.suppressBlankEmpty::
 
 diff.submodule::
 	Specify the format in which differences in submodules are
-	shown.  The "log" format lists the commits in the range like
-	linkgit:git-submodule[1] `summary` does.  The "short" format
-	format just shows the names of the commits at the beginning
-	and end of the range.  Defaults to short.
+	shown.  The "short" format just shows the names of the commits
+	at the beginning and end of the range. The "log" format lists
+	the commits in the range like linkgit:git-submodule[1] `summary`
+	does. The "diff" format shows an inline diff of the changed
+	contents of the submodule. Defaults to "short".
 
 diff.wordRegex::
 	A POSIX Extended Regular Expression used to determine what is a "word"
Documentation/diff-options.txt +10 -7
index cc4342e2034d..7805a0ccadf2 100644
@@ -210,13 +210,16 @@ any of those replacements occurred.
 	of the `--diff-filter` option on what the status letters mean.
 
 --submodule[=<format>]::
-	Specify how differences in submodules are shown.  When `--submodule`
-	or `--submodule=log` is given, the 'log' format is used.  This format lists
-	the commits in the range like linkgit:git-submodule[1] `summary` does.
-	Omitting the `--submodule` option or specifying `--submodule=short`,
-	uses the 'short' format. This format just shows the names of the commits
-	at the beginning and end of the range.  Can be tweaked via the
-	`diff.submodule` configuration variable.
+	Specify how differences in submodules are shown.  When specifying
+	`--submodule=short` the 'short' format is used.  This format just
+	shows the names of the commits at the beginning and end of the range.
+	When `--submodule` or `--submodule=log` is specified, the 'log'
+	format is used.  This format lists the commits in the range like
+	linkgit:git-submodule[1] `summary` does.  When `--submodule=diff`
+	is specified, the 'diff' format is used.  This format shows an
+	inline diff of the changes in the submodule contents between the
+	commit range.  Defaults to `diff.submodule` or the 'short' format
+	if the config option is unset.
 
 --color[=<when>]::
 	Show colored diff.
diff.c +22 -9
index 16253b191f53..b38d95eb249c 100644
@@ -135,6 +135,8 @@ static int parse_submodule_params(struct diff_options *options, const char *valu
 		options->submodule_format = DIFF_SUBMODULE_LOG;
 	else if (!strcmp(value, "short"))
 		options->submodule_format = DIFF_SUBMODULE_SHORT;
+	else if (!strcmp(value, "diff"))
+		options->submodule_format = DIFF_SUBMODULE_INLINE_DIFF;
 	else
 		return -1;
 	return 0;
@@ -2300,6 +2302,15 @@ static void builtin_diff(const char *name_a,
 	struct strbuf header = STRBUF_INIT;
 	const char *line_prefix = diff_line_prefix(o);
 
+	diff_set_mnemonic_prefix(o, "a/", "b/");
+	if (DIFF_OPT_TST(o, REVERSE_DIFF)) {
+		a_prefix = o->b_prefix;
+		b_prefix = o->a_prefix;
+	} else {
+		a_prefix = o->a_prefix;
+		b_prefix = o->b_prefix;
+	}
+
 	if (o->submodule_format == DIFF_SUBMODULE_LOG &&
 	    (!one->mode || S_ISGITLINK(one->mode)) &&
 	    (!two->mode || S_ISGITLINK(two->mode))) {
@@ -2311,6 +2322,17 @@ static void builtin_diff(const char *name_a,
 				two->dirty_submodule,
 				meta, del, add, reset);
 		return;
+	} else if (o->submodule_format == DIFF_SUBMODULE_INLINE_DIFF &&
+		   (!one->mode || S_ISGITLINK(one->mode)) &&
+		   (!two->mode || S_ISGITLINK(two->mode))) {
+		const char *del = diff_get_color_opt(o, DIFF_FILE_OLD);
+		const char *add = diff_get_color_opt(o, DIFF_FILE_NEW);
+		show_submodule_inline_diff(o->file, one->path ? one->path : two->path,
+				line_prefix,
+				&one->oid, &two->oid,
+				two->dirty_submodule,
+				meta, del, add, reset, o);
+		return;
 	}
 
 	if (DIFF_OPT_TST(o, ALLOW_TEXTCONV)) {
@@ -2318,15 +2340,6 @@ static void builtin_diff(const char *name_a,
 		textconv_two = get_textconv(two);
 	}
 
-	diff_set_mnemonic_prefix(o, "a/", "b/");
-	if (DIFF_OPT_TST(o, REVERSE_DIFF)) {
-		a_prefix = o->b_prefix;
-		b_prefix = o->a_prefix;
-	} else {
-		a_prefix = o->a_prefix;
-		b_prefix = o->b_prefix;
-	}
-
 	/* Never use a non-valid filename anywhere if at all possible */
 	name_a = DIFF_FILE_VALID(one) ? name_a : name_b;
 	name_b = DIFF_FILE_VALID(two) ? name_b : name_a;
diff.h +1 -0
index ea5aba668eaa..192c0eedd0ff 100644
@@ -112,6 +112,7 @@ enum diff_words_type {
 enum diff_submodule_format {
 	DIFF_SUBMODULE_SHORT = 0,
 	DIFF_SUBMODULE_LOG,
+	DIFF_SUBMODULE_INLINE_DIFF,
 };
 
 struct diff_options {
submodule.c +62 -0

68 lines not on this page · raw message

submodule.h +6 -0
index d83df57e24ff..d9e197a948fd 100644
@@ -46,6 +46,12 @@ void show_submodule_summary(FILE *f, const char *path,
 		struct object_id *one, struct object_id *two,
 		unsigned dirty_submodule, const char *meta,
 		const char *del, const char *add, const char *reset);
+void show_submodule_inline_diff(FILE *f, const char *path,
+		const char *line_prefix,
+		struct object_id *one, struct object_id *two,
+		unsigned dirty_submodule, const char *meta,
+		const char *del, const char *add, const char *reset,
+		const struct diff_options *opt);
 void set_config_fetch_recurse_submodules(int value);
 void check_for_new_submodule_commits(unsigned char new_sha1[20]);
 int fetch_populated_submodules(const struct argv_array *options,
t/t4060-diff-submodule-option-diff-format.sh new file +746 -0

746 lines not on this page · raw message

Signature · 1 line
2.10.0.rc0.217.g609f9e8.dirty
#26 lore raw

Re: [PATCH v8 8/8] diff: teach diff to display submodule difference with an inline diff

diff.h enum diff_words_type { · line 115

Quoted 9 lines · Jacob Keller
diff.h +1 -0
index ea5aba668eaa..192c0eedd0ff 100644
@@ -112,6 +112,7 @@ enum diff_words_type {
 enum diff_submodule_format {
 	DIFF_SUBMODULE_SHORT = 0,
 	DIFF_SUBMODULE_LOG,
+	DIFF_SUBMODULE_INLINE_DIFF,

Same trailing comma.

Quoted 34 lines
diff.h +0 -0
 };
 
 struct diff_options {
submodule.c +23 -0
index 7108b4786bc1..cecd3cd98de4 100644
@@ -435,6 +435,68 @@ void show_submodule_summary(FILE *f, const char *path,
 	clear_commit_marks(right, ~0);
 }
 
+void show_submodule_inline_diff(FILE *f, const char *path,
+		const char *line_prefix,
+		struct object_id *one, struct object_id *two,
+		unsigned dirty_submodule, const char *meta,
+		const char *del, const char *add, const char *reset,
+		const struct diff_options *o)
+{
+	const struct object_id *old = &empty_tree_oid, *new = &empty_tree_oid;
+	struct commit *left = NULL, *right = NULL;
+	struct strbuf submodule_dir = STRBUF_INIT;
+	struct child_process cp = CHILD_PROCESS_INIT;
+
+	show_submodule_header(f, path, line_prefix, one, two, dirty_submodule,
+			      meta, reset, &left, &right);
+
+	/* We need a valid left and right commit to display a difference */
+	if (!(left || is_null_oid(one)) ||
+	    !(right || is_null_oid(two)))
+		goto done;
+
+	if (left)
+		old = one;
+	if (right)

submodule.c void show_submodule_summary(FILE *f, const char *path, · line 470

Quoted 10 lines
submodule.c +10 -0
+		new = two;
+
+	fflush(f);
+	cp.git_cmd = 1;
+	cp.dir = path;
+	cp.out = dup(fileno(f));
+	cp.no_stdin = 1;
+
+	/* TODO: other options may need to be passed here. */
+	argv_array_pushl(&cp.args, "diff");

I think you meant argv_array_push() here. Or ", NULL" at the end if you anticipate you would grow more args after "diff" later and keep using pushl().

#27 lore raw

Re: [PATCH v8 8/8] diff: teach diff to display submodule difference with an inline diff

Quoted 54 lines · Junio C Hamano

diff.h enum diff_words_type { · line 115

Quoted 9 lines · Jacob Keller
diff.h +1 -0
index ea5aba668eaa..192c0eedd0ff 100644
@@ -112,6 +112,7 @@ enum diff_words_type {
 enum diff_submodule_format {
      DIFF_SUBMODULE_SHORT = 0,
      DIFF_SUBMODULE_LOG,
+     DIFF_SUBMODULE_INLINE_DIFF,

Same trailing comma.

Quoted 40 lines
diff.h +0 -0
 };
 
 struct diff_options {
submodule.c +29 -0
index 7108b4786bc1..cecd3cd98de4 100644
@@ -435,6 +435,68 @@ void show_submodule_summary(FILE *f, const char *path,
      clear_commit_marks(right, ~0);
 }
 
+void show_submodule_inline_diff(FILE *f, const char *path,
+             const char *line_prefix,
+             struct object_id *one, struct object_id *two,
+             unsigned dirty_submodule, const char *meta,
+             const char *del, const char *add, const char *reset,
+             const struct diff_options *o)
+{
+     const struct object_id *old = &empty_tree_oid, *new = &empty_tree_oid;
+     struct commit *left = NULL, *right = NULL;
+     struct strbuf submodule_dir = STRBUF_INIT;
+     struct child_process cp = CHILD_PROCESS_INIT;
+
+     show_submodule_header(f, path, line_prefix, one, two, dirty_submodule,
+                           meta, reset, &left, &right);
+
+     /* We need a valid left and right commit to display a difference */
+     if (!(left || is_null_oid(one)) ||
+         !(right || is_null_oid(two)))
+             goto done;
+
+     if (left)
+             old = one;
+     if (right)
+             new = two;
+
+     fflush(f);
+     cp.git_cmd = 1;
+     cp.dir = path;
+     cp.out = dup(fileno(f));
Quoted 8 lines

submodule.c void show_submodule_summary(FILE *f, const char *path, · line 470

Quoted 4 lines
submodule.c +4 -0
+     cp.no_stdin = 1;
+
+     /* TODO: other options may need to be passed here. */
+     argv_array_pushl(&cp.args, "diff");

I think you meant argv_array_push() here. Or ", NULL" at the end if you anticipate you would grow more args after "diff" later and keep using pushl().

I had added an argument at one point and accidentally forgot to convert back to push(). Oops!

Regards,
Jake