@matheusbsbs / matheus-bagliano / commits / 9d6f220cc8
Fork 0

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>

Josh Triplett committed Jul 14, 2007 at 01:05 UTC 9d6f220cc8ffbd71b4c68765b52c3a7c41dd729b
4 files changed +8 -7
git-commit.sh
+1 -1
@@ -593,7 +593,7 @@ then
593 tree=$(GIT_INDEX_FILE="$TMP_INDEX" git write-tree) &&
594 rm -f "$TMP_INDEX"
595 fi &&
596 - commit=$(cat "$GIT_DIR"/COMMIT_MSG | git commit-tree $tree $PARENTS) &&
596 + commit=$(git commit-tree $tree $PARENTS <"$GIT_DIR/COMMIT_MSG") &&
597 rlogm=$(sed -e 1q "$GIT_DIR"/COMMIT_MSG) &&
598 git update-ref -m "$GIT_REFLOG_ACTION: $rlogm" HEAD $commit "$current" &&
599 rm -f -- "$GIT_DIR/MERGE_HEAD" "$GIT_DIR/MERGE_MSG" &&
git-filter-branch.sh
+2 -2
@@ -171,7 +171,7 @@ case "$filter_subdir" in
171 git rev-list --reverse --topo-order --default HEAD \
172 --parents --full-history "$@" -- "$filter_subdir"
173 esac > ../revs
174 -commits=$(cat ../revs | wc -l | tr -d " ")
174 +commits=$(wc -l <../revs | tr -d " ")
175
176 test $commits -eq 0 && die "Found nothing to rewrite"
177
@@ -241,7 +241,7 @@ case "$target_head" in
241 ;;
242 *)
243 git update-ref refs/heads/"$dstbranch" $target_head
244 - if [ $(cat ../map/$src_head | wc -l) -gt 1 ]; then
244 + if [ $(wc -l <../map/$src_head) -gt 1 ]; then
245 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
246 sed 's/^/ /' ../map/$src_head >&2
247 ret=1
git-ls-remote.sh
+1 -1
@@ -82,7 +82,7 @@ rsync://* )
82 (cd $tmpdir && find refs -type f) |
83 while read path
84 do
85 - cat "$tmpdir/$path" | tr -d '\012'
85 + tr -d '\012' <"$tmpdir/$path"
86 echo " $path"
87 done &&
88 rm -fr $tmpdir
git-quiltimport.sh
+4 -3
@@ -70,10 +70,11 @@ tmp_info="$tmp_dir/info"
70 commit=$(git rev-parse HEAD)
71
72 mkdir $tmp_dir || exit 2
73 -for patch_name in $(cat "$QUILT_PATCHES/series" | grep -v '^#'); do
73 +for patch_name in $(grep -v '^#' < "$QUILT_PATCHES/series" ); do
74 echo $patch_name
75 - (cat $QUILT_PATCHES/$patch_name | git mailinfo "$tmp_msg" "$tmp_patch" > "$tmp_info") || exit 3
76 - test -s .dotest/patch || {
75 + git mailinfo "$tmp_msg" "$tmp_patch" \
76 + <"$QUILT_PATCHES/$patch_name" >"$tmp_info" || exit 3
77 + test -s "$tmp_patch" || {
78 echo "Patch is empty. Was it split wrong?"
79 exit 1
80 }