diff options
author | Josh Triplett <josh@freedesktop.org> | 2007-07-14 01:05:43 -0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2007-07-14 01:07:44 -0700 |
commit | 9d6f220cc8ffbd71b4c68765b52c3a7c41dd729b (patch) | |
tree | 618f04c4e0ebf509fc817a1e5c767c7f1d38ea9b | |
parent | bdecd9d41b3528e17aea2290344c584412e2424e (diff) | |
download | git-9d6f220cc8ffbd71b4c68765b52c3a7c41dd729b.tar.gz |
Remove useless uses of cat, and replace with filename arguments
Replace uses of cat that do nothing but writing the contents of
a single file to another command via pipe.
[jc: Original patch from Josh was somewhat buggy and rewrote
"cat $file | wc -l" to "wc -l $file", but this one should be Ok.]
Signed-off-by: Junio C Hamano <gitster@pobox.com>
-rwxr-xr-x | git-commit.sh | 2 | ||||
-rwxr-xr-x | git-filter-branch.sh | 4 | ||||
-rwxr-xr-x | git-ls-remote.sh | 2 | ||||
-rwxr-xr-x | git-quiltimport.sh | 7 |
4 files changed, 8 insertions, 7 deletions
diff --git a/git-commit.sh b/git-commit.sh index f3cd8ee978..3f3de1729e 100755 --- a/git-commit.sh +++ b/git-commit.sh @@ -593,7 +593,7 @@ then tree=$(GIT_INDEX_FILE="$TMP_INDEX" git write-tree) && rm -f "$TMP_INDEX" fi && - commit=$(cat "$GIT_DIR"/COMMIT_MSG | git commit-tree $tree $PARENTS) && + commit=$(git commit-tree $tree $PARENTS <"$GIT_DIR/COMMIT_MSG") && rlogm=$(sed -e 1q "$GIT_DIR"/COMMIT_MSG) && git update-ref -m "$GIT_REFLOG_ACTION: $rlogm" HEAD $commit "$current" && rm -f -- "$GIT_DIR/MERGE_HEAD" "$GIT_DIR/MERGE_MSG" && diff --git a/git-filter-branch.sh b/git-filter-branch.sh index d77902d34d..54019706dc 100755 --- a/git-filter-branch.sh +++ b/git-filter-branch.sh @@ -171,7 +171,7 @@ case "$filter_subdir" in git rev-list --reverse --topo-order --default HEAD \ --parents --full-history "$@" -- "$filter_subdir" esac > ../revs -commits=$(cat ../revs | wc -l | tr -d " ") +commits=$(wc -l <../revs | tr -d " ") test $commits -eq 0 && die "Found nothing to rewrite" @@ -241,7 +241,7 @@ case "$target_head" in ;; *) git update-ref refs/heads/"$dstbranch" $target_head - if [ $(cat ../map/$src_head | wc -l) -gt 1 ]; then + if [ $(wc -l <../map/$src_head) -gt 1 ]; then echo "WARNING: Your commit filter caused the head commit to expand to several rewritten commits. Only the first such commit was recorded as the current $dstbranch head but you will need to resolve the situation now (probably by manually merging the other commits). These are all the commits:" >&2 sed 's/^/ /' ../map/$src_head >&2 ret=1 diff --git a/git-ls-remote.sh b/git-ls-remote.sh index 3671f3433e..b7e5d04584 100755 --- a/git-ls-remote.sh +++ b/git-ls-remote.sh @@ -82,7 +82,7 @@ rsync://* ) (cd $tmpdir && find refs -type f) | while read path do - cat "$tmpdir/$path" | tr -d '\012' + tr -d '\012' <"$tmpdir/$path" echo " $path" done && rm -fr $tmpdir diff --git a/git-quiltimport.sh b/git-quiltimport.sh index 2124df9e4a..9de54d19fb 100755 --- a/git-quiltimport.sh +++ b/git-quiltimport.sh @@ -70,10 +70,11 @@ tmp_info="$tmp_dir/info" commit=$(git rev-parse HEAD) mkdir $tmp_dir || exit 2 -for patch_name in $(cat "$QUILT_PATCHES/series" | grep -v '^#'); do +for patch_name in $(grep -v '^#' < "$QUILT_PATCHES/series" ); do echo $patch_name - (cat $QUILT_PATCHES/$patch_name | git mailinfo "$tmp_msg" "$tmp_patch" > "$tmp_info") || exit 3 - test -s .dotest/patch || { + git mailinfo "$tmp_msg" "$tmp_patch" \ + <"$QUILT_PATCHES/$patch_name" >"$tmp_info" || exit 3 + test -s "$tmp_patch" || { echo "Patch is empty. Was it split wrong?" exit 1 } |