From 4d4c0e3a5cf0930619317b473259177bc5b79f41 Mon Sep 17 00:00:00 2001 From: Paolo 'Blaisorblade' Giarrusso Date: Fri, 2 Sep 2005 11:25:17 +0200 Subject: [PATCH] [PATCH] Support .gitignore Add support in stgit for .git/exclude like cogito does. Additionally, add -x option to avoid excluding any file from listing, as in cogito. Signed-off-by: Paolo 'Blaisorblade' Giarrusso --- stgit/commands/status.py | 5 ++++- stgit/git.py | 17 ++++++++++------- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/stgit/commands/status.py b/stgit/commands/status.py index 15fbcf3..c0b1a8e 100644 --- a/stgit/commands/status.py +++ b/stgit/commands/status.py @@ -54,6 +54,9 @@ options = [make_option('-m', '--modified', action = 'store_true'), make_option('-u', '--unknown', help = 'show unknown files only', + action = 'store_true'), + make_option('-x', '--noexclude', + help = 'do not exclude any files from listing', action = 'store_true')] @@ -61,4 +64,4 @@ def func(parser, options, args): """Show the tree status """ git.status(args, options.modified, options.new, options.deleted, - options.conflict, options.unknown) + options.conflict, options.unknown, options.noexclude) diff --git a/stgit/git.py b/stgit/git.py index 5abe902..c8339e0 100644 --- a/stgit/git.py +++ b/stgit/git.py @@ -155,7 +155,7 @@ def __run(cmd, args=None): def __check_base_dir(): return os.path.isdir(base_dir) -def __tree_status(files = [], tree_id = 'HEAD', unknown = False): +def __tree_status(files = [], tree_id = 'HEAD', unknown = False, noexclude = True): """Returns a list of pairs - [status, filename] """ os.system('git-update-cache --refresh > /dev/null') @@ -165,13 +165,16 @@ def __tree_status(files = [], tree_id = 'HEAD', unknown = False): # unknown files if unknown: exclude_file = os.path.join(base_dir, 'exclude') + base_exclude = [ '--exclude=*.[ao]', '--exclude=.*' '--exclude=TAGS', + '--exclude=tags', '--exclude=*~', '--exclude=#*', + '--exclude-per-directory=.gitignore' ] extra_exclude = [] if os.path.exists(exclude_file): extra_exclude.append('--exclude-from=%s' % exclude_file) - lines = _output_lines(['git-ls-files', '--others', - '--exclude=*.[ao]', '--exclude=.*' - '--exclude=TAGS', '--exclude=tags', '--exclude=*~', - '--exclude=#*'] + extra_exclude) + if noexclude: + extra_exclude = base_exclude = [] + lines = _output_lines(['git-ls-files', '--others' ] + base_exclude + + extra_exclude) cache_files += [('?', line.strip()) for line in lines] # conflicted files @@ -343,10 +346,10 @@ def merge(base, head1, head2): raise GitException, 'git-merge-cache failed (possible conflicts)' def status(files = [], modified = False, new = False, deleted = False, - conflict = False, unknown = False): + conflict = False, unknown = False, noexclude = False): """Show the tree status """ - cache_files = __tree_status(files, unknown = True) + cache_files = __tree_status(files, unknown = True, noexclude = noexclude) all = not (modified or new or deleted or conflict or unknown) if not all: -- 2.11.0