Skip to contentSkip to conversation

mergetools: add support for VS Code

PATCH In review Wen Bei Li 2 participants 4 messages Jun 3, 2019 – Jun 5, 2019

lore
Share & tools
lore

Wen Bei Li

author
#0 lore raw

PATCH 1/1 mergetools: add support for VS Code

Teach difftool and mergetool about VS Code.

---
 git-mergetool--lib.sh | 2 +-
 mergetools/code       | 7 +++++++
 2 files changed, 8 insertions(+), 1 deletion(-)
 create mode 100644 mergetools/code
git-mergetool--lib.sh +1 -1
index 204a5acd66..59512ae673 100644
@@ -283,7 +283,7 @@ list_merge_tool_candidates () {
 		fi
 		tools="$tools gvimdiff diffuse diffmerge ecmerge"
 		tools="$tools p4merge araxis bc codecompare"
-		tools="$tools smerge"
+		tools="$tools smerge code"
 	fi
 	case "${VISUAL:-$EDITOR}" in
 	*vim*)
mergetools/code new file +7 -0
new file mode 100644
index 0000000000..566a0d9d63
@@ -0,0 +1,7 @@
+diff_cmd () {
+	"$merge_tool_path" --wait --diff "$LOCAL" "$REMOTE"
+}
+
+merge_cmd () {
+	"$merge_tool_path" --wait "$MERGED"
+}
Signature · 1 line
2.21.0.windows.1
#1 lore raw

Hi Wen Bei Li,

Quoted 2 lines · Wen Bei Li

Teach difftool and mergetool about VS Code.
---

Even if it is a very short commit message (see e.g.
https://github.com/git-for-windows/git/commit/581d2fd9f2d6 for a typical commit message in Git's repository), I think it is okay.

Personally, I would have "lost" a few words about Visual Studio Code and how popular it is, but probably only because I like it so much (and maybe nobody wants to hear about that anymore).

However, in the Git project we do ask for your Sign-off:
https://git-scm.com/docs/SubmittingPatches#dco

git-mergetool--lib.sh list_merge_tool_candidates () { · line 286

Quoted 10 lines
git-mergetool--lib.sh +1 -1
index 204a5acd66..59512ae673 100644
@@ -283,7 +283,7 @@ list_merge_tool_candidates () {
 		fi
 		tools="$tools gvimdiff diffuse diffmerge ecmerge"
 		tools="$tools p4merge araxis bc codecompare"
-		tools="$tools smerge"
+		tools="$tools smerge code"

Do you also want to add support for code-insiders? (That's what I run a lot of the time because it allows me to develop code in my Windows Subsystem for Linux while the GUI runs on Windows.)

Quoted 9 lines
git-mergetool--lib.sh +0 -0
 	fi
 	case "${VISUAL:-$EDITOR}" in
 	*vim*)
mergetools/code new file +0 -0
new file mode 100644
index 0000000000..566a0d9d63

mergetools/code line 7

Quoted 7 lines
mergetools/code new file +7 -0
@@ -0,0 +1,7 @@
+diff_cmd () {
+	"$merge_tool_path" --wait --diff "$LOCAL" "$REMOTE"
+}
+
+merge_cmd () {
+	"$merge_tool_path" --wait "$MERGED"
+}

This looks good to me!

Thanks,
Johannes

author
#2 lore raw

PATCH 1/1 mergetools: add support for VS Code

Teach difftool and mergetool about VS Code and VS Code Insiders

---
Hello Johannes, thank you for reviewing my patch. It's the first time I've done this via email. I've added code-insiders as you suggested, but I wasn't sure if I should send it as a v2. I used this commit as a reference:
https://github.com/git/git/commit/5116eab70bf8a0c8b1c29a09c4b932c4d1cf2701

 contrib/completion/git-completion.bash | 2 +-
 git-mergetool--lib.sh                  | 2 +-
 mergetools/code                        | 7 +++++++
 mergetools/code-insiders               | 7 +++++++
 4 files changed, 16 insertions(+), 2 deletions(-)
 create mode 100644 mergetools/code
 create mode 100644 mergetools/code-insiders
contrib/completion/git-completion.bash +1 -1
index 3eefbabdb1..6eaa0df5b2 100644
@@ -1502,7 +1502,7 @@ _git_diff ()
 
 __git_mergetools_common="diffuse diffmerge ecmerge emerge kdiff3 meld opendiff
 			tkdiff vimdiff gvimdiff xxdiff araxis p4merge bc
-			codecompare smerge
+			codecompare smerge code code-insiders
 "
 
 _git_difftool ()
git-mergetool--lib.sh +1 -1
index 204a5acd66..44f1967c84 100644
@@ -283,7 +283,7 @@ list_merge_tool_candidates () {
 		fi
 		tools="$tools gvimdiff diffuse diffmerge ecmerge"
 		tools="$tools p4merge araxis bc codecompare"
-		tools="$tools smerge"
+		tools="$tools smerge code code-insiders"
 	fi
 	case "${VISUAL:-$EDITOR}" in
 	*vim*)
mergetools/code new file +7 -0
new file mode 100644
index 0000000000..566a0d9d63
@@ -0,0 +1,7 @@
+diff_cmd () {
+	"$merge_tool_path" --wait --diff "$LOCAL" "$REMOTE"
+}
+
+merge_cmd () {
+	"$merge_tool_path" --wait "$MERGED"
+}
mergetools/code-insiders new file +7 -0
new file mode 100644
index 0000000000..566a0d9d63
@@ -0,0 +1,7 @@
+diff_cmd () {
+	"$merge_tool_path" --wait --diff "$LOCAL" "$REMOTE"
+}
+
+merge_cmd () {
+	"$merge_tool_path" --wait "$MERGED"
+}
Signature · 1 line
2.21.0.windows.1
#3 lore raw

Hi Wen Bei Li,

Quoted 6 lines · Wen Bei Li

Teach difftool and mergetool about VS Code and VS Code Insiders

---
Hello Johannes, thank you for reviewing my patch. It's the first time I've done this via email.

Heh, I hear you. It makes me happy that we still can get contributions despite the slight hurdle to do it by email.

Quoted 2 lines

I've added code-insiders as you suggested, but I wasn't sure if I should send it as a v2.

Well, since this is the second revision of your patch, it *is* a v2, whether you mark it as such or not ;-)

Quoted 45 lines
contrib/completion/git-completion.bash +1 -1
index 3eefbabdb1..6eaa0df5b2 100644
@@ -1502,7 +1502,7 @@ _git_diff ()
 
 __git_mergetools_common="diffuse diffmerge ecmerge emerge kdiff3 meld opendiff
 			tkdiff vimdiff gvimdiff xxdiff araxis p4merge bc
-			codecompare smerge
+			codecompare smerge code code-insiders
 "
 
 _git_difftool ()
git-mergetool--lib.sh +1 -1
index 204a5acd66..44f1967c84 100644
@@ -283,7 +283,7 @@ list_merge_tool_candidates () {
 		fi
 		tools="$tools gvimdiff diffuse diffmerge ecmerge"
 		tools="$tools p4merge araxis bc codecompare"
-		tools="$tools smerge"
+		tools="$tools smerge code code-insiders"
 	fi
 	case "${VISUAL:-$EDITOR}" in
 	*vim*)
mergetools/code new file +7 -0
new file mode 100644
index 0000000000..566a0d9d63
@@ -0,0 +1,7 @@
+diff_cmd () {
+	"$merge_tool_path" --wait --diff "$LOCAL" "$REMOTE"
+}
+
+merge_cmd () {
+	"$merge_tool_path" --wait "$MERGED"
+}
mergetools/code-insiders new file +0 -0
new file mode 100644
index 0000000000..566a0d9d63

mergetools/code-insiders line 7

Quoted 7 lines
mergetools/code-insiders new file +7 -0
@@ -0,0 +1,7 @@
+diff_cmd () {
+	"$merge_tool_path" --wait --diff "$LOCAL" "$REMOTE"
+}
+
+merge_cmd () {
+	"$merge_tool_path" --wait "$MERGED"
+}

This looks good to me, thank you!
Johannes