Skip to contentSkip to conversation

Remove unused var

PATCH Superseded David Turner 2 participants 4 messages Aug 12, 2021 – Aug 30, 2021

v3 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

PATCH v3 1/3 Remove unused var

---
 t/t4060-diff-submodule-option-diff-format.sh | 1 -
 1 file changed, 1 deletion(-)
t/t4060-diff-submodule-option-diff-format.sh +0 -1
index dc7b242697..69b9946931 100755
@@ -361,7 +361,6 @@ test_expect_success 'typechanged submodule(submodule->blob)' '
 rm -f sm1 &&
 test_create_repo sm1 &&
 head6=$(add_file sm1 foo6 foo7)
-fullhead6=$(cd sm1; git rev-parse --verify HEAD)
 test_expect_success 'nonexistent commit' '
 	git diff-index -p --submodule=diff HEAD >actual &&
 	cat >expected <<-EOF &&
Signature · 1 line
2.11.GIT
#1 lore raw

PATCH v3 2/3 diff --submodule=diff: do not fail on ever-initialied deleted submodules

If you have ever initialized a submodule, open_submodule will open it. If you then delete the submodule's worktree directory (but don't remove it from .gitmodules), git diff --submodule=diff would error out as it attempted to chdir into the now-deleted working tree directory.

Instead, we chdir into the submodule's git directory and run the diff from there.

---
 submodule.c                                  |  10 ++
 t/t4060-diff-submodule-option-diff-format.sh | 158 +++++++++++++++++++++++++--
 2 files changed, 161 insertions(+), 7 deletions(-)
submodule.c +10 -0
index 0b1d9c1dde..d13d103975 100644
@@ -710,6 +710,16 @@ void show_submodule_inline_diff(struct diff_options *o, const char *path,
 		strvec_push(&cp.args, oid_to_hex(new_oid));
 
 	prepare_submodule_repo_env(&cp.env_array);
+
+	if (!is_directory(path)) {
+		// fall back to absorbed git dir, if any
+		if (!sub)
+			goto done;
+		cp.dir = sub->gitdir;
+		strvec_push(&cp.env_array, GIT_DIR_ENVIRONMENT "=.");
+		strvec_push(&cp.env_array, GIT_WORK_TREE_ENVIRONMENT "=.");
+	}
+
 	if (start_command(&cp))
 		diff_emit_submodule_error(o, "(diff failed)\n");
 
t/t4060-diff-submodule-option-diff-format.sh +151 -7

195 lines not on this page · raw message

Signature · 1 line
2.11.GIT
#2 lore raw

PATCH v3 3/3 diff --submodule=diff: Don't print failure message twice

In reply to David Turner

When we fail to start a diff command inside a submodule, immediately exit the routine rather than trying to finish the command and printing a second message.

---
 submodule.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
submodule.c +3 -1
index d13d103975..2e98e840af 100644
@@ -720,8 +720,10 @@ void show_submodule_inline_diff(struct diff_options *o, const char *path,
 		strvec_push(&cp.env_array, GIT_WORK_TREE_ENVIRONMENT "=.");
 	}
 
-	if (start_command(&cp))
+	if (start_command(&cp)) {
 		diff_emit_submodule_error(o, "(diff failed)\n");
+		goto done;
+	}
 
 	while (strbuf_getwholeline_fd(&sb, cp.out, '\n') != EOF)
 		diff_emit_submodule_pipethrough(o, sb.buf, sb.len);
Signature · 1 line
2.11.GIT
#3 lore raw

Re: [PATCH v3 3/3] diff --submodule=diff: Don't print failure message twice

I keep seeing these as "will merge to next?" in the "what's cooking" emails. But I don't see any direct replies, and they don't seem to be merged. Is there something I need to do to get these merged?

Thanks.

Quoted 28 lines · David Turner

When we fail to start a diff command inside a submodule, immediately exit the routine rather than trying to finish the command and printing
a second message.

---
 submodule.c | 4 +++-

 1 file changed, 3 insertions(+), 1 deletion(-)
submodule.c +0 -0
index d13d103975..2e98e840af 100644
@@ -720,8 +720,10 @@ void show_submodule_inline_diff(struct
 diff_options *o, const char *path,

                strvec_push(&cp.env_array, GIT_WORK_TREE_ENVIRONMENT "=.");
        }

-       if (start_command(&cp))
+       if (start_command(&cp)) { diff_emit_submodule_error(o, "(diff failed)\n"); +               goto done;
+       }

        while (strbuf_getwholeline_fd(&sb, cp.out, '\n') != EOF) diff_emit_submodule_pipethrough(o, sb.buf, sb.len);