From: Antonio Ospite <ao2@ao2.it>
To: git@vger.kernel.org
Cc: Richard Hartmann <richih.mailinglist@gmail.com>,
Antonio Ospite <ao2@ao2.it>
Subject: [RFC 03/10] submodule: use the 'submodules_file' variable in output messages
Date: Fri, 13 Apr 2018 00:20:40 +0200 [thread overview]
Message-ID: <20180412222047.5716-4-ao2@ao2.it> (raw)
In-Reply-To: <20180412222047.5716-1-ao2@ao2.it>
The gitmodules file path can be customized by setting the
'core.submodulesFile' config option.
Use the 'submodules_file' variable instead of the hardcoded
'.gitmodules' in output messages, to reflect the actual path of the
gitmodules file.
NOTE: the default git configuration has to be initialized in
'builtin/submodule--helper.c' to make the actual value of
'submodules_file', overridden by 'core.submodulesFile', available to the
helper command.
Signed-off-by: Antonio Ospite <ao2@ao2.it>
---
builtin/mv.c | 3 ++-
builtin/rm.c | 3 ++-
builtin/submodule--helper.c | 18 ++++++++++--------
submodule-config.c | 4 ++--
submodule.c | 14 +++++++-------
5 files changed, 23 insertions(+), 19 deletions(-)
diff --git a/builtin/mv.c b/builtin/mv.c
index 6d141f7a5..ec8f139c4 100644
--- a/builtin/mv.c
+++ b/builtin/mv.c
@@ -82,7 +82,8 @@ static void prepare_move_submodule(const char *src, int first,
if (!S_ISGITLINK(active_cache[first]->ce_mode))
die(_("Directory %s is in index and no submodule?"), src);
if (!is_staging_gitmodules_ok(&the_index))
- die(_("Please stage your changes to .gitmodules or stash them to proceed"));
+ die(_("Please stage your changes to %s or stash them to proceed"),
+ submodules_file);
strbuf_addf(&submodule_dotgit, "%s/.git", src);
*submodule_gitfile = read_gitfile(submodule_dotgit.buf);
if (*submodule_gitfile)
diff --git a/builtin/rm.c b/builtin/rm.c
index 5b6fc7ee8..6fd015d86 100644
--- a/builtin/rm.c
+++ b/builtin/rm.c
@@ -286,7 +286,8 @@ int cmd_rm(int argc, const char **argv, const char *prefix)
list.entry[list.nr].is_submodule = S_ISGITLINK(ce->ce_mode);
if (list.entry[list.nr++].is_submodule &&
!is_staging_gitmodules_ok(&the_index))
- die (_("Please stage your changes to .gitmodules or stash them to proceed"));
+ die (_("Please stage your changes to %s or stash them to proceed"),
+ submodules_file);
}
if (pathspec.nr) {
diff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c
index a404df3ea..72b95d27b 100644
--- a/builtin/submodule--helper.c
+++ b/builtin/submodule--helper.c
@@ -458,8 +458,8 @@ static void init_submodule(const char *path, const char *prefix,
sub = submodule_from_path(&null_oid, path);
if (!sub)
- die(_("No url found for submodule path '%s' in .gitmodules"),
- displaypath);
+ die(_("No url found for submodule path '%s' in %s"),
+ displaypath, submodules_file);
/*
* NEEDSWORK: In a multi-working-tree world, this needs to be
@@ -481,8 +481,8 @@ static void init_submodule(const char *path, const char *prefix,
strbuf_addf(&sb, "submodule.%s.url", sub->name);
if (git_config_get_string(sb.buf, &url)) {
if (!sub->url)
- die(_("No url found for submodule path '%s' in .gitmodules"),
- displaypath);
+ die(_("No url found for submodule path '%s' in %s"),
+ displaypath, submodules_file);
url = xstrdup(sub->url);
@@ -623,8 +623,8 @@ static void status_submodule(const char *path, const struct object_id *ce_oid,
int diff_files_result;
if (!submodule_from_path(&null_oid, path))
- die(_("no submodule mapping found in .gitmodules for path '%s'"),
- path);
+ die(_("no submodule mapping found in %s for path '%s'"),
+ submodules_file, path);
displaypath = get_submodule_displaypath(path, prefix);
@@ -749,8 +749,8 @@ static int module_name(int argc, const char **argv, const char *prefix)
sub = submodule_from_path(&null_oid, argv[1]);
if (!sub)
- die(_("no submodule mapping found in .gitmodules for path '%s'"),
- argv[1]);
+ die(_("no submodule mapping found in %s for path '%s'"),
+ submodules_file, argv[1]);
printf("%s\n", sub->name);
@@ -1855,6 +1855,8 @@ int cmd_submodule__helper(int argc, const char **argv, const char *prefix)
if (argc < 2 || !strcmp(argv[1], "-h"))
usage("git submodule--helper <command>");
+ git_config(git_default_config, NULL);
+
for (i = 0; i < ARRAY_SIZE(commands); i++) {
if (!strcmp(argv[1], commands[i].cmd)) {
if (get_super_prefix() &&
diff --git a/submodule-config.c b/submodule-config.c
index 8a3396ade..620d522ee 100644
--- a/submodule-config.c
+++ b/submodule-config.c
@@ -347,9 +347,9 @@ static void warn_multiple_config(const unsigned char *treeish_name,
const char *commit_string = "WORKTREE";
if (treeish_name)
commit_string = sha1_to_hex(treeish_name);
- warning("%s:.gitmodules, multiple configurations found for "
+ warning("%s:%s, multiple configurations found for "
"'submodule.%s.%s'. Skipping second one!",
- commit_string, name, option);
+ commit_string, submodules_file, name, option);
}
struct parse_config_parameter {
diff --git a/submodule.c b/submodule.c
index 2afbdb644..97213b549 100644
--- a/submodule.c
+++ b/submodule.c
@@ -94,11 +94,11 @@ int update_path_in_gitmodules(const char *oldpath, const char *newpath)
return -1;
if (is_gitmodules_unmerged(&the_index))
- die(_("Cannot change unmerged .gitmodules, resolve merge conflicts first"));
+ die(_("Cannot change unmerged %s, resolve merge conflicts first"), submodules_file);
submodule = submodule_from_path(&null_oid, oldpath);
if (!submodule || !submodule->name) {
- warning(_("Could not find section in .gitmodules where path=%s"), oldpath);
+ warning(_("Could not find section in %s where path=%s"), submodules_file, oldpath);
return -1;
}
strbuf_addstr(&entry, "submodule.");
@@ -106,7 +106,7 @@ int update_path_in_gitmodules(const char *oldpath, const char *newpath)
strbuf_addstr(&entry, ".path");
if (git_config_set_in_file_gently(submodules_file, entry.buf, newpath) < 0) {
/* Maybe the user already did that, don't error out here */
- warning(_("Could not update .gitmodules entry %s"), entry.buf);
+ warning(_("Could not update %s entry %s"), submodules_file, entry.buf);
strbuf_release(&entry);
return -1;
}
@@ -128,18 +128,18 @@ int remove_path_from_gitmodules(const char *path)
return -1;
if (is_gitmodules_unmerged(&the_index))
- die(_("Cannot change unmerged .gitmodules, resolve merge conflicts first"));
+ die(_("Cannot change unmerged %s, resolve merge conflicts first"), submodules_file);
submodule = submodule_from_path(&null_oid, path);
if (!submodule || !submodule->name) {
- warning(_("Could not find section in .gitmodules where path=%s"), path);
+ warning(_("Could not find section in %s where path=%s"), submodules_file, path);
return -1;
}
strbuf_addstr(§, "submodule.");
strbuf_addstr(§, submodule->name);
if (git_config_rename_section_in_file(submodules_file, sect.buf, NULL) < 0) {
/* Maybe the user already did that, don't error out here */
- warning(_("Could not remove .gitmodules entry for %s"), path);
+ warning(_("Could not remove %s entry for %s"), submodules_file, path);
strbuf_release(§);
return -1;
}
@@ -150,7 +150,7 @@ int remove_path_from_gitmodules(const char *path)
void stage_updated_gitmodules(struct index_state *istate)
{
if (add_file_to_index(istate, submodules_file, 0))
- die(_("staging updated .gitmodules failed"));
+ die(_("staging updated %s failed"), submodules_file);
}
static int add_submodule_odb(const char *path)
--
2.17.0
next prev parent reply other threads:[~2018-04-12 22:57 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-04-12 22:20 [RFC 00/10] Make .the gitmodules file path configurable Antonio Ospite
2018-04-12 22:20 ` [RFC 01/10] submodule: add 'core.submodulesFile' to override the '.gitmodules' path Antonio Ospite
2018-04-12 23:50 ` Stefan Beller
2018-04-16 16:37 ` Antonio Ospite
2018-04-16 21:22 ` Stefan Beller
2018-04-18 11:43 ` Antonio Ospite
2018-04-18 18:44 ` Stefan Beller
2018-04-12 22:20 ` [RFC 02/10] submodule: fix getting custom gitmodule file in fetch command Antonio Ospite
2018-04-12 23:55 ` Stefan Beller
2018-04-16 16:18 ` Antonio Ospite
2018-04-16 19:23 ` Stefan Beller
2018-04-16 20:46 ` Antonio Ospite
2018-04-12 22:20 ` Antonio Ospite [this message]
2018-04-12 22:20 ` [RFC 04/10] submodule: document 'core.submodulesFile' and fix references to '.gitmodules' Antonio Ospite
2018-04-12 22:20 ` [RFC 05/10] submodule: adjust references to '.gitmodules' in comments Antonio Ospite
2018-04-12 22:20 ` [RFC 06/10] completion: add 'core.submodulesfile' to the git-completion.bash file Antonio Ospite
2018-04-12 23:36 ` [RFC 00/10] Make .the gitmodules file path configurable Stefan Beller
2018-04-16 11:33 ` Antonio Ospite
2018-04-16 19:22 ` Stefan Beller
2018-04-13 8:07 ` Antonio Ospite
2018-04-13 8:07 ` [RFC 07/10] FIXME: wrap-for-bin.sh: set 'core.submodulesFile' for each git invocation Antonio Ospite
2018-04-13 8:07 ` [RFC 08/10] FIXME: submodule: fix t1300-repo-config.sh to take into account the new config Antonio Ospite
2018-04-13 8:07 ` [RFC 09/10] FIXME: submodule: pass custom gitmodules file to 'test-tool submodule-config' Antonio Ospite
2018-04-13 8:07 ` [RFC 10/10] FIXME: add a hacky script to test the changes with a patched test suite Antonio Ospite
2018-04-13 20:05 ` [RFC 07/10] FIXME: wrap-for-bin.sh: set 'core.submodulesFile' for each git invocation Stefan Beller
2018-04-16 11:36 ` Antonio Ospite
2018-04-23 17:47 ` [RFC 00/10] Make .the gitmodules file path configurable Jonathan Nieder
2018-04-30 12:51 ` Antonio Ospite
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180412222047.5716-4-ao2@ao2.it \
--to=ao2@ao2.it \
--cc=git@vger.kernel.org \
--cc=richih.mailinglist@gmail.com \
/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.
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 NNTP newsgroup(s).