* Patch: git-add --exclude=pattern
@ 2006-12-02 21:29 Adam J. Richter
0 siblings, 0 replies; only message in thread
From: Adam J. Richter @ 2006-12-02 21:29 UTC (permalink / raw)
To: git
[-- Attachment #1: Type: text/plain, Size: 1479 bytes --]
git-ls-files has an argument "--exclude=<pattern>". I have
copied the relevant code snippets to do the same for git-add-files.
I want this facility so that I can disable processing of
.gitignore files for some shell scripts that I've cobbled together
to update git repositories from tar files of new versions of software
packages. Adding "!*" to .git/info/exclude does not achieve this,
because the .gitignore files have priority, and I can see arguments
why this should be so, so that .git/info/exclude can just encode
defaults and individual directories can have more specific rules.
In comparison, passing "--exclude='!*'" apparently does have priority
over the .gitignore files.
By the way, the particular situation where I had this problem
was in linux-2.6.19, which shoots itself in the foot a bit by including
.gitignore files that exclude source files like arch/*/kernel/vmlinux.ld.S,
include/asm-*/{alternative-asm,frame}.i and the .cvsignore files themselves.
However, fixing this linux kernel problem is not the point of this email.
I want a facility that can reliably add files from source trees even if
they have minor bugs like this in their .gitignore rules.
Many thanks to ShadeHawk on the git IRC channel for pointing
out to me that the git-find-ls manual page actually describes the problem
and a fix for the case of vmlinux.ld.S in the linux kernel tree, and for
suggesting --exclude=pattern instead of --exclude-per-directory=filename.
Adam Richter
[-- Attachment #2: add-exclude.diff --]
[-- Type: text/plain, Size: 1187 bytes --]
diff --git a/src/builtin-add.c b/src/builtin-add.c
index febb75e..a501b50 100644
--- a/src/builtin-add.c
+++ b/src/builtin-add.c
@@ -11,7 +11,7 @@
#include "cache-tree.h"
static const char builtin_add_usage[] =
-"git-add [-n] [-v] <filepattern>...";
+"git-add [--exclude=<pattern>] [-n] [-v] <filepattern>...";
static void prune_directory(struct dir_struct *dir, const char **pathspec, int prefix)
{
@@ -55,7 +55,6 @@ static void fill_directory(struct dir_st
int baselen;
/* Set up the default git porcelain excludes */
- memset(dir, 0, sizeof(*dir));
dir->exclude_per_dir = ".gitignore";
path = git_path("info/exclude");
if (!access(path, R_OK))
@@ -90,6 +89,7 @@ int cmd_add(int argc, const char **argv,
const char **pathspec;
struct dir_struct dir;
+ memset(&dir, 0, sizeof(dir));
git_config(git_default_config);
newfd = hold_lock_file_for_update(&lock_file, get_index_file(), 1);
@@ -106,6 +106,10 @@ int cmd_add(int argc, const char **argv,
i++;
break;
}
+ if (!strncmp(arg, "--exclude=", 10)) {
+ add_exclude(arg+10, "", 0, &dir.exclude_list[EXC_CMDL]);
+ continue;
+ }
if (!strcmp(arg, "-n")) {
show_only = 1;
continue;
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2006-12-02 21:25 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-12-02 21:29 Patch: git-add --exclude=pattern Adam J. Richter
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).