From: "Johannes Schindelin via GitGitGadget" <gitgitgadget@gmail.com>
To: git@vger.kernel.org
Cc: Junio C Hamano <gitster@pobox.com>,
Johannes Schindelin <johannes.schindelin@gmx.de>
Subject: [PATCH 5/9] vscode: only overwrite C/C++ settings
Date: Mon, 23 Jul 2018 06:52:54 -0700 (PDT) [thread overview]
Message-ID: <06dcf6d974b67afcd599daa79b5820160ac42ed2.1532353966.git.gitgitgadget@gmail.com> (raw)
In-Reply-To: <pull.2.git.gitgitgadget@gmail.com>
From: Johannes Schindelin <johannes.schindelin@gmx.de>
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 <johannes.schindelin@gmx.de>
---
contrib/vscode/init.sh | 23 ++++++++++++++++++++---
1 file changed, 20 insertions(+), 3 deletions(-)
diff --git a/contrib/vscode/init.sh b/contrib/vscode/init.sh
index 494a51ac5..ba9469226 100755
--- a/contrib/vscode/init.sh
+++ b/contrib/vscode/init.sh
@@ -13,7 +13,7 @@ die "Could not create .vscode/"
# General settings
-cat >.vscode/settings.json <<\EOF ||
+cat >.vscode/settings.json.new <<\EOF ||
{
"C_Cpp.intelliSenseEngine": "Default",
"C_Cpp.intelliSenseEngineFallback": "Disabled",
@@ -51,7 +51,7 @@ esac
# Default build task
-cat >.vscode/tasks.json <<EOF ||
+cat >.vscode/tasks.json.new <<EOF ||
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// 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/launch.json.new <<EOF ||
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
@@ -175,3 +175,20 @@ vscode-init:
echo '}'
EOF
die "Could not write settings for the C/C++ extension"
+
+for file in .vscode/settings.json .vscode/tasks.json .vscode/launch.json
+do
+ if test -f $file
+ then
+ if git diff --no-index --quiet --exit-code $file $file.new
+ then
+ rm $file.new
+ else
+ printf "The file $file.new has these changes:\n\n"
+ git --no-pager diff --no-index $file $file.new
+ printf "\n\nMaybe \`mv $file.new $file\`?\n\n"
+ fi
+ else
+ mv $file.new $file
+ fi
+done
--
gitgitgadget
next prev parent reply other threads:[~2018-07-23 13:52 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-07-23 13:52 [PATCH 0/9] Add support to develop Git in Visual Studio Code Johannes Schindelin via GitGitGadget
2018-07-23 13:52 ` [PATCH 1/9] contrib: add a script to initialize VS Code configuration Johannes Schindelin via GitGitGadget
2018-07-23 16:57 ` Jonathan Nieder
2018-07-30 14:28 ` Johannes Schindelin
2018-07-23 19:48 ` Junio C Hamano
2018-07-23 21:37 ` Junio C Hamano
2018-07-30 14:42 ` Johannes Schindelin
2018-07-23 13:52 ` [PATCH 2/9] vscode: hard-code a couple defines Johannes Schindelin via GitGitGadget
2018-07-23 17:41 ` Jonathan Nieder
2018-07-30 14:46 ` Johannes Schindelin
2018-07-23 13:52 ` [PATCH 3/9] cache.h: extract enum declaration from inside a struct declaration Johannes Schindelin via GitGitGadget
2018-07-23 13:52 ` [PATCH 4/9] mingw: define WIN32 explicitly Johannes Schindelin via GitGitGadget
2018-07-23 13:52 ` Johannes Schindelin via GitGitGadget [this message]
2018-07-23 13:52 ` [PATCH 6/9] vscode: wrap commit messages at column 72 by default Johannes Schindelin via GitGitGadget
2018-07-23 13:52 ` [PATCH 7/9] vscode: use 8-space tabs, no trailing ws, etc for Git's source code Johannes Schindelin via GitGitGadget
2018-07-25 7:32 ` Johannes Sixt
2018-07-30 14:48 ` Johannes Schindelin
2018-07-23 13:52 ` [PATCH 8/9] vscode: add a dictionary for cSpell Johannes Schindelin via GitGitGadget
2018-07-23 13:53 ` [PATCH 9/9] vscode: let cSpell work on commit messages, too Johannes Schindelin via GitGitGadget
2018-07-30 15:42 ` [PATCH v2 0/9] Add support to develop Git in Visual Studio Code Johannes Schindelin via GitGitGadget
2018-07-30 15:42 ` [PATCH v2 1/9] contrib: add a script to initialize VS Code configuration Johannes Schindelin via GitGitGadget
2018-07-30 15:42 ` [PATCH v2 2/9] vscode: hard-code a couple defines Johannes Schindelin via GitGitGadget
2018-07-30 15:42 ` [PATCH v2 3/9] cache.h: extract enum declaration from inside a struct declaration Johannes Schindelin via GitGitGadget
2018-07-30 15:42 ` [PATCH v2 4/9] mingw: define WIN32 explicitly Johannes Schindelin via GitGitGadget
2018-07-30 15:42 ` [PATCH v2 5/9] vscode: only overwrite C/C++ settings Johannes Schindelin via GitGitGadget
2018-07-30 15:42 ` [PATCH v2 6/9] vscode: wrap commit messages at column 72 by default Johannes Schindelin via GitGitGadget
2018-07-30 15:42 ` [PATCH v2 7/9] vscode: use 8-space tabs, no trailing ws, etc for Git's source code Johannes Schindelin via GitGitGadget
2018-07-30 15:42 ` [PATCH v2 8/9] vscode: add a dictionary for cSpell Johannes Schindelin via GitGitGadget
2018-07-30 15:42 ` [PATCH v2 9/9] vscode: let cSpell work on commit messages, too Johannes Schindelin via GitGitGadget
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=06dcf6d974b67afcd599daa79b5820160ac42ed2.1532353966.git.gitgitgadget@gmail.com \
--to=gitgitgadget@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=johannes.schindelin@gmx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).