Code

git-svn: add 'clone' command, an alias for init + fetch
[git.git] / builtin-grep.c
index 9873e3d1dbf0e8735641cc178d687a9d5194487e..f35f2d023cf56cb3c75c817455cfc53a98175f54 100644 (file)
 #include "tag.h"
 #include "tree-walk.h"
 #include "builtin.h"
-#include <regex.h>
 #include "grep.h"
-#include <fnmatch.h>
-#include <sys/wait.h>
 
 /*
  * git grep pathspecs are somewhat different from diff-tree pathspecs;
@@ -139,7 +136,7 @@ static int grep_file(struct grep_opt *opt, const char *filename)
        if (i < 0)
                goto err_ret;
        data = xmalloc(st.st_size + 1);
-       if (st.st_size != xread(i, data, st.st_size)) {
+       if (st.st_size != read_in_full(i, data, st.st_size)) {
                error("'%s': short read %s", filename, strerror(errno));
                close(i);
                free(data);
@@ -530,9 +527,9 @@ int cmd_grep(int argc, const char **argv, const char *prefix)
                        opt.word_regexp = 1;
                        continue;
                }
-               if (!strncmp("-A", arg, 2) ||
-                   !strncmp("-B", arg, 2) ||
-                   !strncmp("-C", arg, 2) ||
+               if (!prefixcmp(arg, "-A") ||
+                   !prefixcmp(arg, "-B") ||
+                   !prefixcmp(arg, "-C") ||
                    (arg[0] == '-' && '1' <= arg[1] && arg[1] <= '9')) {
                        unsigned num;
                        const char *scan;