# [PATCH] cg-commit chokes when given a very large list of files

2 messages from 2005-07-18 to 2005-07-18. Participants: Bryan Larsen.
Thread: https://gitlist.dev/t/1271

## Bryan Larsen, 2005-07-18 03:18

Subject: [PATCH] cg-commit chokes when given a very large list of files
Message-ID: <20050718031808.20247.43698.sendpatchset@bryan-larsens-ibook-g4.local>
URL: https://gitlist.dev/e/20050718031808.20247.43698.sendpatchset%40bryan-larsens-ibook-g4.local

```
cg-commit currently chokes when passed a very large list of files.
Fix it.

This patch depends on your filenames not containing line feeds.  No
big deal, other parts of cogito break on filenames containing line
feeds.

Resent because previous send appears to have been dropped.  This patch
is cleaner.

Signed-off-by: Bryan Larsen <bryan.larsen@gmail.com>
---

 cg-commit |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/cg-commit b/cg-commit
--- a/cg-commit
+++ b/cg-commit
@@ -289,9 +289,9 @@ precommit_update () {
 		eval "queue$op[\${#queue$op[@]}]=\"\$fname\""
 	done
 	# XXX: Do we even need to do the --add and --remove update-caches?
-	[ "$queueN" ] && { git-update-cache --add ${infoonly} -- "${queueN[@]}" || return 1; }
-	[ "$queueD" ] && { git-update-cache --force-remove -- "${queueD[@]}" || return 1; }
-	[ "$queueM" ] && { git-update-cache ${infoonly} -- "${queueM[@]}" || return 1; }
+	[ "$queueN" ] && { ( echo "${queueN[*]}" | tr \\n \\0 | IFS=$'\n' xargs -0 git-update-cache --add ${infoonly} -- ) || return 1; }
+	[ "$queueD" ] && { ( echo "${queueD[*]}" | tr \\n \\0 | IFS=$'\n' xargs -0 git-update-cache --force-remove -- ) || return 1;  }
+	[ "$queueM" ] && { ( echo "${queueM[*]}" | tr \\n \\0 | IFS=$'\n' xargs -0 git-update-cache ${infoonly} -- ) || return 1; }
 	return 0
 }
 

```

## Bryan Larsen, 2005-07-18 03:29

Subject: Re: [PATCH] cg-commit chokes when given a very large list of files
Message-ID: <42DB2225.2070207@gmail.com>
URL: https://gitlist.dev/e/42DB2225.2070207%40gmail.com
In-Reply-To: <20050718031808.20247.43698.sendpatchset@bryan-larsens-ibook-g4.local>

```
This patch is broken.  The original patch still works.

Bryan


Bryan Larsen wrote:
> cg-commit currently chokes when passed a very large list of files.
> Fix it.
> 
> This patch depends on your filenames not containing line feeds.  No
> big deal, other parts of cogito break on filenames containing line
> feeds.
> 
> Resent because previous send appears to have been dropped.  This patch
> is cleaner.
> 
> Signed-off-by: Bryan Larsen <bryan.larsen@gmail.com>
> ---
> 
>  cg-commit |    6 +++---
>  1 files changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/cg-commit b/cg-commit
> --- a/cg-commit
> +++ b/cg-commit
> @@ -289,9 +289,9 @@ precommit_update () {
>  		eval "queue$op[\${#queue$op[@]}]=\"\$fname\""
>  	done
>  	# XXX: Do we even need to do the --add and --remove update-caches?
> -	[ "$queueN" ] && { git-update-cache --add ${infoonly} -- "${queueN[@]}" || return 1; }
> -	[ "$queueD" ] && { git-update-cache --force-remove -- "${queueD[@]}" || return 1; }
> -	[ "$queueM" ] && { git-update-cache ${infoonly} -- "${queueM[@]}" || return 1; }
> +	[ "$queueN" ] && { ( echo "${queueN[*]}" | tr \\n \\0 | IFS=$'\n' xargs -0 git-update-cache --add ${infoonly} -- ) || return 1; }
> +	[ "$queueD" ] && { ( echo "${queueD[*]}" | tr \\n \\0 | IFS=$'\n' xargs -0 git-update-cache --force-remove -- ) || return 1;  }
> +	[ "$queueM" ] && { ( echo "${queueM[*]}" | tr \\n \\0 | IFS=$'\n' xargs -0 git-update-cache ${infoonly} -- ) || return 1; }
>  	return 0
>  }
>  
> 

```
