From: Erik Faye-Lund <kusmabite@gmail.com>
To: git@vger.kernel.org
Subject: [PATCH/RFC] add: listen to --ignore-errors for submodule-errors
Date: Tue, 26 Jun 2012 01:21:59 +0200 [thread overview]
Message-ID: <1340666519-41804-1-git-send-email-kusmabite@gmail.com> (raw)
"git add --ignore-errors -- some-submodule/foo" surprisingly
throws an error saying "fatal: Path 'some-submodule/foo' is in
submodule 'some-submodule/foo'".
Fix this by making sure we consult the flag, and propagate the
error code properly.
Signed-off-by: Erik Faye-Lund <kusmabite@gmail.com>
---
I recently tried to do the following in the msysGit-repo:
$ git add --ignore-errors -- */.gitignore
fatal: Path 'src/git-cheetah/.gitignore' is in submodule 'src/git-cheetah'
I was a bit puzzled by this; I explicitly specified --ignore-errors
because I did not want to be stopped due to src/git-cheetah/.gitignore
being located in a submodule.
The documentation seems to suggest that this is what is supposed to
happen, and this seems like the most likely behavior that the user
wanted. After all, there's no good reason submodules are special
in this regard, no?
builtin/add.c | 15 +++++++++------
1 file changed, 9 insertions(+), 6 deletions(-)
diff --git a/builtin/add.c b/builtin/add.c
index 87446cf..6e6feb0 100644
--- a/builtin/add.c
+++ b/builtin/add.c
@@ -20,7 +20,7 @@ static const char * const builtin_add_usage[] = {
NULL
};
static int patch_interactive, add_interactive, edit_interactive;
-static int take_worktree_changes;
+static int take_worktree_changes, ignore_add_errors;
struct update_callback_data {
int flags;
@@ -153,9 +153,9 @@ static char *prune_directory(struct dir_struct *dir, const char **pathspec, int
return seen;
}
-static void treat_gitlinks(const char **pathspec)
+static int treat_gitlinks(const char **pathspec)
{
- int i;
+ int i, exit_status = 0;
if (!pathspec || !*pathspec)
return;
@@ -172,12 +172,15 @@ static void treat_gitlinks(const char **pathspec)
if (len2 == len + 1)
/* strip trailing slash */
pathspec[j] = xstrndup(ce->name, len);
- else
+ else if (!ignore_add_errors)
die (_("Path '%s' is in submodule '%.*s'"),
pathspec[j], len, ce->name);
+ else
+ exit_status = 1;
}
}
}
+ return exit_status;
}
static void refresh(int verbose, const char **pathspec)
@@ -312,7 +315,7 @@ static const char ignore_error[] =
N_("The following paths are ignored by one of your .gitignore files:\n");
static int verbose = 0, show_only = 0, ignored_too = 0, refresh_only = 0;
-static int ignore_add_errors, addremove, intent_to_add, ignore_missing = 0;
+static int addremove, intent_to_add, ignore_missing = 0;
static struct option builtin_add_options[] = {
OPT__DRY_RUN(&show_only, "dry run"),
@@ -418,7 +421,7 @@ int cmd_add(int argc, const char **argv, const char *prefix)
if (read_cache() < 0)
die(_("index file corrupt"));
- treat_gitlinks(pathspec);
+ exit_status |= treat_gitlinks(pathspec);
if (add_new_files) {
int baselen;
--
1.7.11.msysgit.0.3.g3006a55
next reply other threads:[~2012-06-25 23:22 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-06-25 23:21 Erik Faye-Lund [this message]
2012-06-26 2:41 ` [PATCH/RFC] add: listen to --ignore-errors for submodule-errors Junio C Hamano
2012-06-26 4:09 ` Junio C Hamano
2012-06-26 8:25 ` Erik Faye-Lund
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=1340666519-41804-1-git-send-email-kusmabite@gmail.com \
--to=kusmabite@gmail.com \
--cc=git@vger.kernel.org \
/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).