path: root/contrib/vscode
diff options
authorJohannes Schindelin <>2018-07-30 15:42:52 (GMT)
committerJunio C Hamano <>2018-07-30 20:14:39 (GMT)
commit0f47f78e02d16e6edd0448285815ccc1744294e8 (patch)
treed9c1b5dba4114de511e8dd17ea8557efb97aad8d /contrib/vscode
parentb4d991d1a2e2f5da6d3f08d82d1fa9ef45605e07 (diff)
vscode: only overwrite C/C++ settings
The C/C++ settings are special, as they are the only generated VS Code configurations that *will* change over the course of Git's development, e.g. when a new constant is defined. Therefore, let's only update the C/C++ settings, also to prevent user modifications from being overwritten. Ideally, we would keep user modifications in the C/C++ settings, but that would require parsing JSON, a task for which a Unix shell script is distinctly unsuited. So we write out .new files instead, and warn the user if they may want to reconcile their changes. Signed-off-by: Johannes Schindelin <> Signed-off-by: Junio C Hamano <>
Diffstat (limited to 'contrib/vscode')
1 files changed, 20 insertions, 3 deletions
diff --git a/contrib/vscode/ b/contrib/vscode/
index 494a51a..ba94692 100755
--- a/contrib/vscode/
+++ b/contrib/vscode/
@@ -13,7 +13,7 @@ die "Could not create .vscode/"
# General settings
-cat >.vscode/settings.json <<\EOF ||
+cat >.vscode/ <<\EOF ||
"C_Cpp.intelliSenseEngine": "Default",
"C_Cpp.intelliSenseEngineFallback": "Disabled",
@@ -51,7 +51,7 @@ esac
# Default build task
-cat >.vscode/tasks.json <<EOF ||
+cat >.vscode/ <<EOF ||
// See
// for the documentation about the tasks.json format
@@ -73,7 +73,7 @@ die "Could not install default build task"
# Debugger settings
-cat >.vscode/launch.json <<EOF ||
+cat >.vscode/ <<EOF ||
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
@@ -175,3 +175,20 @@ vscode-init:
echo '}'
die "Could not write settings for the C/C++ extension"
+for file in .vscode/settings.json .vscode/tasks.json .vscode/launch.json
+ if test -f $file
+ then
+ if git diff --no-index --quiet --exit-code $file $
+ then
+ rm $
+ else
+ printf "The file $ has these changes:\n\n"
+ git --no-pager diff --no-index $file $
+ printf "\n\nMaybe \`mv $ $file\`?\n\n"
+ fi
+ else
+ mv $ $file
+ fi