threads / patch / 605

patch, 2 partsupdate cg-* to use cg-Xignore

Subject: [PATCH 2/2] update cg-* to use cg-Xignore

## tl;dr

6 messages between May 13, 2005 and May 14, 2005. Diffs are folded; open one to read it.

replies: 5people: 2as markdown or json

David Greaves· May 13, 2005, 22:32 UTC · lore
Updated
    cg-add
    cg-commit
    cg-init
    cg-status
to use the cg-Xignore
Signed-off-by: David Greaves <david@dgreaves.com>

--- commit 80e8dbdd3cf5e8d4ca0b6e446911d1ac17c5064e tree 03662df7d089d4a84987ef9edb50a017b8b42439 parent 2fca920e6d3ccb92e9782bcf02f860b8333e23d9 author David Greaves <david@dgreaves.com> Fri, 13 May 2005 23:18:20 +0100 committer David Greaves <david@ash.(none)> Fri, 13 May 2005 23:18:20 +0100

 cg-add    |   13 +++++--------
 cg-commit |    9 +++++++++
 cg-init   |    7 ++++++-
 cg-status |   14 ++------------
 4 files changed, 22 insertions(+), 21 deletions(-)
Show changes to diff +22 −21
Index: cg-add
===================================================================
--- d2490ad0bc8b38647c6baff9da3e72c0f25e9f35/cg-add  (mode:100755)
+++ 03662df7d089d4a84987ef9edb50a017b8b42439/cg-add  (mode:100755)
@@ -11,11 +11,8 @@
 [ "$1" ] || die "usage: cg-add FILE..."
 
 for file in "$@"; do
-	if [ -f "$file" ] || [ -h "$file" ]; then
-		echo "Adding file $file"
-	else
-		die "$file does not exist"
-	fi
-done
-
-git-update-cache --add -- "$@"
+    if [ -f "$file" ] || [ -h "$file" ]; then
+	echo "Adding file $file" >&2
+    fi
+    echo "$file"
+done | cg-Xignore -f -h | xargs git-update-cache --add --
Index: cg-commit
===================================================================
--- d2490ad0bc8b38647c6baff9da3e72c0f25e9f35/cg-commit  (mode:100755)
+++ 03662df7d089d4a84987ef9edb50a017b8b42439/cg-commit  (mode:100755)
@@ -65,6 +65,15 @@
 	[ -s $_git/merging ] && merging=$(cat $_git/merging | sed 's/^/-p /')
 fi
 
+# strip ignored files - *1 at a time* - any attempt to stream from 1
+# while loop to another uses a subprocess and can't pass the variable
+# back
+# Also I don't know if this can be put in a shell function
+for file in ${commitfiles[@]}
+  do
+  commitfiles[$i]=`echo $file | cg-Xignore`
+  ((i++))
+done
 
 LOGMSG=$(mktemp -t gitci.XXXXXX)
 LOGMSG2=$(mktemp -t gitci.XXXXXX)
Index: cg-init
===================================================================
--- d2490ad0bc8b38647c6baff9da3e72c0f25e9f35/cg-init  (mode:100755)
+++ 03662df7d089d4a84987ef9edb50a017b8b42439/cg-init  (mode:100755)
@@ -7,6 +7,9 @@
 # remote repository. Note that this usage is DEPRECATED - use cg-clone
 # (possibly with the -s parameter) for doing this. This functionality
 # will go away from cg-init soon.
+#
+# if there is a file called cogito.ignore then it is used to prime the
+# .git/ignore patterns
 
 . ${COGITO_LIB}cg-Xlib
 
@@ -19,6 +22,8 @@
 touch $_git/refs/heads/master
 ln -s refs/heads/master $_git/HEAD
 
+[ -f cogito.ignore ] && mv cogito.ignore .git/ignore
+
 if [ "$uri" ]; then
 	echo "$uri" >$_git/branches/origin
 	cg-pull origin || die "pull failed"
@@ -31,7 +36,7 @@
 	echo "Cloned (origin $uri available as branch \"origin\")"
 else
 	git-read-tree # Seed the dircache
-	find * -type f | xargs cg-add
+	find * | cg-Xignore -f -h | xargs cg-add
 	cg-commit -C -m"Initial commit" -e
 fi
 exit 0
Index: cg-status
===================================================================
--- d2490ad0bc8b38647c6baff9da3e72c0f25e9f35/cg-status  (mode:100755)
+++ 03662df7d089d4a84987ef9edb50a017b8b42439/cg-status  (mode:100755)
@@ -15,21 +15,11 @@
 
 {
 	git-ls-files -z -t --others --deleted --unmerged $EXCLUDE
-} | sort -z -k 2 | xargs -0 sh -c '
-while [ "$1" ]; do
-	tag=${1% *};
-	filename=${1#* };
-	case "$filename" in
-	*.[ao] | tags | ,,merge*) ;;
-	*)   echo "$tag $filename";;
-	esac
-	shift
-done
-' padding
+} | sort -z -k 2 | cg-Xignore -0 -t | tr "\000" "\n"
 
 {
 	git-update-cache --refresh
-} | cut -f 1 -d ":" | xargs sh -c '
+} | cut -f 1 -d ":" | cg-Xignore | xargs sh -c '
 while [ "$1" ]; do
 	tag="M";
 	filename=${1%: *};
Petr Baudis· May 13, 2005, 22:55 UTC · re: David Greaves · lore

Re: [PATCH 2/2] update cg-* to use cg-Xignore

Dear diary, on Sat, May 14, 2005 at 12:32:22AM CEST, I got a letter where David Greaves <david@dgreaves.com> told me that...

> Updated
>     cg-add
>     cg-commit

I consider this Bad Thing (tm). Or could you please point a situation where this would be actually useful? If you explicitly cg-add, you likely know what are you doing, and same thing with cg-commit - if it's already added, it should be watches, no matter what ignore patterns, I think.

Show 18 quoted lines
> --- d2490ad0bc8b38647c6baff9da3e72c0f25e9f35/cg-commit  (mode:100755)
> +++ 03662df7d089d4a84987ef9edb50a017b8b42439/cg-commit  (mode:100755)
> @@ -65,6 +65,15 @@
>  	[ -s $_git/merging ] && merging=$(cat $_git/merging | sed 's/^/-p /')
>  fi
>  
> +# strip ignored files - *1 at a time* - any attempt to stream from 1
> +# while loop to another uses a subprocess and can't pass the variable
> +# back
> +# Also I don't know if this can be put in a shell function
> +for file in ${commitfiles[@]}
> +  do
> +  commitfiles[$i]=`echo $file | cg-Xignore`
> +  ((i++))
> +done
>  
>  LOGMSG=$(mktemp -t gitci.XXXXXX)
>  LOGMSG2=$(mktemp -t gitci.XXXXXX)
The variable? What variable?
Show 20 quoted lines
> Index: cg-status
> ===================================================================
> --- d2490ad0bc8b38647c6baff9da3e72c0f25e9f35/cg-status  (mode:100755)
> +++ 03662df7d089d4a84987ef9edb50a017b8b42439/cg-status  (mode:100755)
> @@ -15,21 +15,11 @@
>  
>  {
>  	git-ls-files -z -t --others --deleted --unmerged $EXCLUDE
> -} | sort -z -k 2 | xargs -0 sh -c '
> -while [ "$1" ]; do
> -	tag=${1% *};
> -	filename=${1#* };
> -	case "$filename" in
> -	*.[ao] | tags | ,,merge*) ;;
> -	*)   echo "$tag $filename";;
> -	esac
> -	shift
> -done
> -' padding
> +} | sort -z -k 2 | cg-Xignore -0 -t | tr "\000" "\n"
So you have two ignores now - exclude and Xignore.
-- 
				Petr "Pasky" Baudis
Stuff: http://pasky.or.cz/
C++: an octopus made by nailing extra legs onto a dog. -- Steve Taylor
David Greaves· May 14, 2005, 08:24 UTC · re: Petr Baudis · lore

Re: [PATCH 2/2] update cg-* to use cg-Xignore

Petr Baudis wrote:
Show 17 quoted lines
>Dear diary, on Sat, May 14, 2005 at 12:32:22AM CEST, I got a letter
>where David Greaves <david@dgreaves.com> told me that...
>  
>
>>Updated
>>    cg-add
>>    cg-commit
>>    
>>
>
>I consider this Bad Thing (tm). Or could you please point a situation
>where this would be actually useful? If you explicitly cg-add, you
>likely know what are you doing, and same thing with cg-commit - if it's
>already added, it should be watches, no matter what ignore patterns, I
>think.
>  
>

OK, lets say I'm clever and know what an ignore pattern is. I can find * | xargs cg-add my laziness something my hubris acknowledges :)

And in fact this has come up a few times on the list already - it was that code snippet in cg-init that caused me to create cg-Xignore because as someone pointed out, even finding files/links would still cause probs with files beginning with '.' does that sway you?

Show 24 quoted lines
>>--- d2490ad0bc8b38647c6baff9da3e72c0f25e9f35/cg-commit  (mode:100755)
>>+++ 03662df7d089d4a84987ef9edb50a017b8b42439/cg-commit  (mode:100755)
>>@@ -65,6 +65,15 @@
>> 	[ -s $_git/merging ] && merging=$(cat $_git/merging | sed 's/^/-p /')
>> fi
>> 
>>+# strip ignored files - *1 at a time* - any attempt to stream from 1
>>+# while loop to another uses a subprocess and can't pass the variable
>>+# back
>>+# Also I don't know if this can be put in a shell function
>>+for file in ${commitfiles[@]}
>>+  do
>>+  commitfiles[$i]=`echo $file | cg-Xignore`
>>+  ((i++))
>>+done
>> 
>> LOGMSG=$(mktemp -t gitci.XXXXXX)
>> LOGMSG2=$(mktemp -t gitci.XXXXXX)
>>    
>>
>
>The variable? What variable?
>  
>

well basically we want to edit the commitfiles variable - perl map() a more efficient method in shell appears to be: foreach file in commitfiles; echo file | filter | read into commitfiles I spent ages trying not to exec a cg-Ignore process per file comparison

Show 26 quoted lines
>>Index: cg-status
>>===================================================================
>>--- d2490ad0bc8b38647c6baff9da3e72c0f25e9f35/cg-status  (mode:100755)
>>+++ 03662df7d089d4a84987ef9edb50a017b8b42439/cg-status  (mode:100755)
>>@@ -15,21 +15,11 @@
>> 
>> {
>> 	git-ls-files -z -t --others --deleted --unmerged $EXCLUDE
>>-} | sort -z -k 2 | xargs -0 sh -c '
>>-while [ "$1" ]; do
>>-	tag=${1% *};
>>-	filename=${1#* };
>>-	case "$filename" in
>>-	*.[ao] | tags | ,,merge*) ;;
>>-	*)   echo "$tag $filename";;
>>-	esac
>>-	shift
>>-done
>>-' padding
>>+} | sort -z -k 2 | cg-Xignore -0 -t | tr "\000" "\n"
>>    
>>
>
>So you have two ignores now - exclude and Xignore.
>  
>

No, cogito has an ignore. git has a less powerful exclude. cogito users won't need exclude but power-users aren't barred from it.

David
Petr Baudis· May 14, 2005, 12:18 UTC · re: David Greaves · lore

Re: [PATCH 2/2] update cg-* to use cg-Xignore

Dear diary, on Sat, May 14, 2005 at 10:24:42AM CEST, I got a letter where David Greaves <david@dgreaves.com> told me that...

Show 23 quoted lines
> Petr Baudis wrote:
> 
> >Dear diary, on Sat, May 14, 2005 at 12:32:22AM CEST, I got a letter
> >where David Greaves <david@dgreaves.com> told me that...
> >  
> >
> >>Updated
> >>    cg-add
> >>    cg-commit
> >>    
> >>
> >
> >I consider this Bad Thing (tm). Or could you please point a situation
> >where this would be actually useful? If you explicitly cg-add, you
> >likely know what are you doing, and same thing with cg-commit - if it's
> >already added, it should be watches, no matter what ignore patterns, I
> >think.
> >  
> >
> OK, lets say I'm clever and know what an ignore pattern is.
> I can
> find * | xargs cg-add
> my laziness something my hubris acknowledges :)
Makes sense, ok.
What about cg-commit? You already even added it.
Show 29 quoted lines
> >>Index: cg-status
> >>===================================================================
> >>--- d2490ad0bc8b38647c6baff9da3e72c0f25e9f35/cg-status  (mode:100755)
> >>+++ 03662df7d089d4a84987ef9edb50a017b8b42439/cg-status  (mode:100755)
> >>@@ -15,21 +15,11 @@
> >> 
> >> {
> >> 	git-ls-files -z -t --others --deleted --unmerged $EXCLUDE
> >>-} | sort -z -k 2 | xargs -0 sh -c '
> >>-while [ "$1" ]; do
> >>-	tag=${1% *};
> >>-	filename=${1#* };
> >>-	case "$filename" in
> >>-	*.[ao] | tags | ,,merge*) ;;
> >>-	*)   echo "$tag $filename";;
> >>-	esac
> >>-	shift
> >>-done
> >>-' padding
> >>+} | sort -z -k 2 | cg-Xignore -0 -t | tr "\000" "\n"
> >>    
> >>
> >
> >So you have two ignores now - exclude and Xignore.
> >  
> >
> No, cogito has an ignore.
> git has a less powerful exclude.
> cogito users won't need exclude but power-users aren't barred from it.

I think having two essentially redundant things is useless. But you'll be able to use the --exclude powers now since you have to fall back to good ol' globs.

-- 
				Petr "Pasky" Baudis
Stuff: http://pasky.or.cz/
C++: an octopus made by nailing extra legs onto a dog. -- Steve Taylor
David Greaves· May 14, 2005, 14:44 UTC · re: Petr Baudis · lore

Re: [PATCH 2/2] update cg-* to use cg-Xignore

Petr Baudis wrote:
Show 12 quoted lines
>Dear diary, on Sat, May 14, 2005 at 10:24:42AM CEST, I got a letter
>where David Greaves <david@dgreaves.com> told me that...
>  
>
>>Petr Baudis wrote:
>>    
>>
>Makes sense, ok.
>
>What about cg-commit? You already even added it.
>  
>

I'd use the same argument - you want to commit files changed in a directory: find src | xargs cg-commit find Documentation | xargs cg-commit

I agree it's less compelling. I admit I was primarily just making sure that all cg-* commands behaved the same way. I also don't have an ignore-override - do you think we need one?

Show 11 quoted lines
>>No, cogito has an ignore.
>>git has a less powerful exclude.
>>cogito users won't need exclude but power-users aren't barred from it.
>>    
>>
>
>I think having two essentially redundant things is useless. But you'll
>be able to use the --exclude powers now since you have to fall back to
>good ol' globs.
>  
>
unless...
Petr Baudis· May 14, 2005, 15:14 UTC · re: David Greaves · lore

Re: [PATCH 2/2] update cg-* to use cg-Xignore

Dear diary, on Sat, May 14, 2005 at 04:44:00PM CEST, I got a letter where David Greaves <david@dgreaves.com> told me that...

Show 21 quoted lines
> Petr Baudis wrote:
> 
> >Dear diary, on Sat, May 14, 2005 at 10:24:42AM CEST, I got a letter
> >where David Greaves <david@dgreaves.com> told me that...
> >  
> >
> >>Petr Baudis wrote:
> >>    
> >>
> >Makes sense, ok.
> >
> >What about cg-commit? You already even added it.
> >  
> >
> 
> I'd use the same argument - you want to commit files changed in a directory:
> find src | xargs cg-commit
> find Documentation | xargs cg-commit
> I agree it's less compelling.
> I admit I was primarily just making sure that all cg-* commands behaved
> the same way.

Thinking about it, I think we can actually live with it. I agree that it's more consistent.

> I also don't have an ignore-override - do you think we need one?

I'd prefer CVS-like format. That is, lines starting with ! are exceptions to previous ignore rules.

Show 12 quoted lines
> >>No, cogito has an ignore.
> >>git has a less powerful exclude.
> >>cogito users won't need exclude but power-users aren't barred from it.
> >>    
> >>
> >
> >I think having two essentially redundant things is useless. But you'll
> >be able to use the --exclude powers now since you have to fall back to
> >good ol' globs.
> >  
> >
> unless...

See my other mail that I'd prefer globs as the main ignoring mechanism anyway. ;-)

-- 
				Petr "Pasky" Baudis
Stuff: http://pasky.or.cz/
C++: an octopus made by nailing extra legs onto a dog. -- Steve Taylor

← back to recent threads