]> git.droids-corp.org - git-central.git/commitdiff
Consolidate cat+grep calls into just grep.
authorStephen Haberman <stephen@exigencecorp.com>
Mon, 29 Sep 2008 08:45:08 +0000 (03:45 -0500)
committerStephen Haberman <stephen@exigencecorp.com>
Mon, 29 Sep 2008 08:45:08 +0000 (03:45 -0500)
server/post-receive-assign-commit-numbers

index 6ed313d01d45e760a0014790450b66c61e9def01..46cd45ac81d177def8df5e0b0980f1a67db482c4 100644 (file)
@@ -2,14 +2,14 @@
 
 . $(dirname $0)/functions
 
+touch "$GIT_DIR/commitnumbers"
+
 while read oldrev newrev refname ; do
        set_new_commits
        echo "$new_commits" | git rev-list --reverse --stdin | while read commit ; do
-               touch "$GIT_DIR/commitnumbers"
-               cat "$GIT_DIR/commitnumbers" | grep --quiet "$commit"
-               if [ $? -ne 0 ] ; then
+               if [[ $(grep "$commit" "$GIT_DIR/commitnumbers") == "" ]] ; then
                        echo "$commit" >> "$GIT_DIR/commitnumbers"
-                       number=$(cat "$GIT_DIR/commitnumbers" | grep --line-number "$commit" | grep -oP "^\d+(?=:)")
+                       number=$(grep --max-count=1 --line-number "$commit" "$GIT_DIR/commitnumbers" | grep -oP "^\d+(?=:)")
                        git tag "r/$number" "$commit"
                fi
        done