threads / patch / 2991

patchLower priority of Cogito's default exclude patterns

Subject: [PATCH] Lower priority of Cogito's default exclude patterns

## tl;dr

4 messages between Jan 7, 2006 and Jan 21, 2006. Diffs are folded; open one to read it.

replies: 3people: 2as markdown or json

Karl Hasselström· Jan 7, 2006, 22:19 UTC · lore

Put the default exclude patterns in a file referenced with --exclude-from, instead of on the command line with --exclude. (The existing behavior was bad since --exclude has higher priority than --exclude-from and --exclude-per-directory, which made it impossible for the user to override the default patterns.)

Signed-off-by: Karl Hasselström <kha@treskal.com>
---
 Makefile           |   15 +++++++++++++--
 cg-Xlib            |    6 +++++-
 cg-default-exclude |    6 ++++++
 3 files changed, 24 insertions(+), 3 deletions(-)
Show changes to 3 files +24 −3

Makefile, cg-Xlib, cg-default-exclude

diff --git a/Makefile b/Makefile
index 700491f..9ec9d07 100644
--- a/Makefile
+++ b/Makefile
@@ -3,6 +3,7 @@ prefix=$(HOME)
 
 bindir=$(prefix)/bin
 libdir=$(prefix)/lib/cogito
+sharedir=$(prefix)/share/cogito
 
 INSTALL?=install
 
@@ -25,6 +26,8 @@ GEN_SCRIPT= cg-version
 
 VERSION= VERSION
 
+SHARE_FILES= cg-default-exclude
+
 
 
 ### Build rules
@@ -62,6 +65,7 @@ test: all
 ### Installation rules
 
 sedlibdir=$(shell echo $(libdir) | sed 's/\//\\\//g')
+sedsharedir=$(shell echo $(sharedir) | sed 's/\//\\\//g')
 
 .PHONY: install install-cogito install-doc
 install: install-cogito
@@ -83,14 +87,20 @@ install-cogito: $(SCRIPT) $(LIB_SCRIPT) 
 	$(INSTALL) $(LIB_SCRIPT) $(DESTDIR)$(libdir)
 	cd $(DESTDIR)$(bindir); \
 	for file in $(SCRIPT) $(GEN_SCRIPT); do \
-		sed -e 's/\$${COGITO_LIB}/"\$${COGITO_LIB:-$(sedlibdir)\/}"/g' $$file > $$file.new; \
+		sed -e 's/\$${COGITO_LIB}/"\$${COGITO_LIB:-$(sedlibdir)\/}"/g' $$file \
+		  | sed -e 's/\$${COGITO_SHARE}/"\$${COGITO_SHARE:-$(sedsharedir)\/}"/g' \
+		  > $$file.new; \
 		cat $$file.new > $$file; rm $$file.new; \
 	done
 	cd $(DESTDIR)$(libdir); \
 	for file in $(LIB_SCRIPT); do \
-		sed -e 's/\$${COGITO_LIB}/"\$${COGITO_LIB:-$(sedlibdir)\/}"/g' $$file > $$file.new; \
+		sed -e 's/\$${COGITO_LIB}/"\$${COGITO_LIB:-$(sedlibdir)\/}"/g' $$file \
+		  | sed -e 's/\$${COGITO_SHARE}/"\$${COGITO_SHARE:-$(sedsharedir)\/}"/g' \
+		  > $$file.new; \
 		cat $$file.new > $$file; rm $$file.new; \
 	done
+	$(INSTALL) -m755 -d $(DESTDIR)$(sharedir)
+	$(INSTALL) -m644 $(SHARE_FILES) $(DESTDIR)$(sharedir)
 
 install-doc:
 	$(MAKE) -C Documentation install
@@ -98,6 +108,7 @@ install-doc:
 uninstall:
 	cd $(DESTDIR)$(bindir) && rm -f $(SCRIPT) $(GEN_SCRIPT)
 	cd $(DESTDIR)$(libdir) && rm -f $(LIB_SCRIPT)
+	cd $(DESTDIR)$(sharedir) && rm -f $(SHARE_FILES)
 
 
 
diff --git a/cg-Xlib b/cg-Xlib
index 46a8a73..b1d1561 100755
--- a/cg-Xlib
+++ b/cg-Xlib
@@ -190,9 +190,13 @@ list_untracked_files()
 	excludeflag="$1"; shift
 	EXCLUDE=()
 	if [ "$excludeflag" != "no" -a "$excludeflag" != "noexclude" ]; then
-		for excl in '*.[ao]' '.*' '!.gitignore' tags '*~' '#*' "$@"; do
+		for excl in "$@"; do
 			EXCLUDE[${#EXCLUDE[@]}]="--exclude=$excl"
 		done
+		EXCLUDEFILE="${COGITO_SHARE}cg-default-exclude"
+		if [ -f "$EXCLUDEFILE" ]; then
+			EXCLUDE[${#EXCLUDE[@]}]="--exclude-from=$EXCLUDEFILE"
+		fi
 		EXCLUDEFILE="$_git/info/exclude"
 		if [ -f "$EXCLUDEFILE" ]; then
 			EXCLUDE[${#EXCLUDE[@]}]="--exclude-from=$EXCLUDEFILE"
diff --git a/cg-default-exclude b/cg-default-exclude
new file mode 100644
index 0000000..f24dad6
--- /dev/null
+++ b/cg-default-exclude
@@ -0,0 +1,6 @@
+*.[ao]
+.*
+!.gitignore
+tags
+*~
+#*
Petr Baudis· Jan 19, 2006, 12:42 UTC · lore

Re: [PATCH] Lower priority of Cogito's default exclude patterns

Dear diary, on Thu, Jan 19, 2006 at 11:07:12AM CET, I got a letter where Karl Hasselström <kha@treskal.com> said that...

Show 18 quoted lines
> On 2006-01-07 23:19:31 +0100, Karl Hasselström wrote:
> 
> > Put the default exclude patterns in a file referenced with
> > --exclude-from, instead of on the command line with --exclude. (The
> > existing behavior was bad since --exclude has higher priority than
> > --exclude-from and --exclude-per-directory, which made it impossible
> > for the user to override the default patterns.)
> >
> > Signed-off-by: Karl Hasselström <kha@treskal.com>
> >
> > ---
> >
> >  Makefile           |   15 +++++++++++++--
> >  cg-Xlib            |    6 +++++-
> >  cg-default-exclude |    6 ++++++
> >  3 files changed, 24 insertions(+), 3 deletions(-)
> 
> Did you miss this patch, or just not like it?

Just postponed for next sweep through my patch queue, due today or tomorrow. ;) I will rename cg-default-exclude to default-exclude, though.

Oh, now I remember - one my major concern is that now Cogito will not work if not make install'd, which is how I actually primarily use it on my machine.

Sorry for the delay,
-- 
				Petr "Pasky" Baudis
Stuff: http://pasky.or.cz/
Of the 3 great composers Mozart tells us what it's like to be human,
Beethoven tells us what it's like to be Beethoven and Bach tells us
what it's like to be the universe.  -- Douglas Adams
Karl Hasselström· Jan 19, 2006, 14:07 UTC · re: Petr Baudis · lore

Re: [PATCH] Lower priority of Cogito's default exclude patterns

On 2006-01-19 13:42:44 +0100, Petr Baudis wrote:
Show 26 quoted lines
> Dear diary, on Thu, Jan 19, 2006 at 11:07:12AM CET, I got a letter
> where Karl Hasselström <kha@treskal.com> said that...
>
> > On 2006-01-07 23:19:31 +0100, Karl Hasselström wrote:
> >
> > > Put the default exclude patterns in a file referenced with
> > > --exclude-from, instead of on the command line with --exclude.
> > > (The existing behavior was bad since --exclude has higher
> > > priority than --exclude-from and --exclude-per-directory, which
> > > made it impossible for the user to override the default
> > > patterns.)
> > >
> > > Signed-off-by: Karl Hasselström <kha@treskal.com>
> > >
> > > ---
> > >
> > >  Makefile           |   15 +++++++++++++--
> > >  cg-Xlib            |    6 +++++-
> > >  cg-default-exclude |    6 ++++++
> > >  3 files changed, 24 insertions(+), 3 deletions(-)
> >
> > Did you miss this patch, or just not like it?
>
> Just postponed for next sweep through my patch queue, due today or
> tomorrow. ;) I will rename cg-default-exclude to default-exclude,
> though.
Good point.
> Oh, now I remember - one my major concern is that now Cogito will
> not work if not make install'd, which is how I actually primarily
> use it on my machine.

The not-installed case could easily be worked around by users if cogito looked at /etc/cogito/exclude and ~/.cogito/exclude as well. (Or maybe that should be /etc/git/exclude and ~/.gitexclude, so that e.g. stgit can use the same files.) Would you accept a patch that did this?

-- 
Karl Hasselström, kha@treskal.com
      www.treskal.com/kalle
Petr Baudis· Jan 21, 2006, 02:04 UTC · re: Karl Hasselström · lore

Re: [PATCH] Lower priority of Cogito's default exclude patterns

Thanks, patch applied and pushed out.

Dear diary, on Thu, Jan 19, 2006 at 03:07:28PM CET, I got a letter where Karl Hasselström <kha@treskal.com> said that...

Show 10 quoted lines
> On 2006-01-19 13:42:44 +0100, Petr Baudis wrote:
> > Oh, now I remember - one my major concern is that now Cogito will
> > not work if not make install'd, which is how I actually primarily
> > use it on my machine.
> 
> The not-installed case could easily be worked around by users if
> cogito looked at /etc/cogito/exclude and ~/.cogito/exclude as well.
> (Or maybe that should be /etc/git/exclude and ~/.gitexclude, so that
> e.g. stgit can use the same files.) Would you accept a patch that did
> this?

Sorry, this doesn't make sense to me - how would that help? The user can as well just make install in that case, instead of manually copying out one file.

	if [ -n "${COGITO_SHARE}" ]; then
		COGITO_REAL_SHARE="${COGITO_SHARE}"
		return
	fi
	if [ "${0%/*}" != "$0" ]; then
		COGITO_REAL_SHARE="${0%/*}/"
		return
	fi
	# I'm not sure if the following normally ever gets triggered.
	# I can only do it by `sh cg-status`. --pasky
	COGITO_REAL_SHARE="./$_git_relpath/"
should work well, though.
-- 
				Petr "Pasky" Baudis
Stuff: http://pasky.or.cz/
Of the 3 great composers Mozart tells us what it's like to be human,
Beethoven tells us what it's like to be Beethoven and Bach tells us
what it's like to be the universe.  -- Douglas Adams

← back to recent threads