Merge branch 'jc/report-path-error-to-dir' into maint
authorJunio C Hamano <gitster@pobox.com>
Tue, 31 Mar 2015 21:53:08 +0000 (14:53 -0700)
committerJunio C Hamano <gitster@pobox.com>
Tue, 31 Mar 2015 21:53:08 +0000 (14:53 -0700)
Code clean-up.

* jc/report-path-error-to-dir:
report_path_error(): move to dir.c

builtin/ls-files.c
cache.h
dir.c
dir.h
index 99cee20fb07ce7ed03da230bfa031c277f584fc1..19063ebc64af2378d69b31933367a0d01d8a2630 100644 (file)
@@ -354,49 +354,6 @@ void overlay_tree_on_cache(const char *tree_name, const char *prefix)
        }
 }
 
-int report_path_error(const char *ps_matched,
-                     const struct pathspec *pathspec,
-                     const char *prefix)
-{
-       /*
-        * Make sure all pathspec matched; otherwise it is an error.
-        */
-       struct strbuf sb = STRBUF_INIT;
-       int num, errors = 0;
-       for (num = 0; num < pathspec->nr; num++) {
-               int other, found_dup;
-
-               if (ps_matched[num])
-                       continue;
-               /*
-                * The caller might have fed identical pathspec
-                * twice.  Do not barf on such a mistake.
-                * FIXME: parse_pathspec should have eliminated
-                * duplicate pathspec.
-                */
-               for (found_dup = other = 0;
-                    !found_dup && other < pathspec->nr;
-                    other++) {
-                       if (other == num || !ps_matched[other])
-                               continue;
-                       if (!strcmp(pathspec->items[other].original,
-                                   pathspec->items[num].original))
-                               /*
-                                * Ok, we have a match already.
-                                */
-                               found_dup = 1;
-               }
-               if (found_dup)
-                       continue;
-
-               error("pathspec '%s' did not match any file(s) known to git.",
-                     pathspec->items[num].original);
-               errors++;
-       }
-       strbuf_release(&sb);
-       return errors;
-}
-
 static const char * const ls_files_usage[] = {
        N_("git ls-files [options] [<file>...]"),
        NULL
diff --git a/cache.h b/cache.h
index 23806394eb5089f480d5300ac23e616eccd604db..28d769fcaa3088d761c31550234057ef2333ec0e 100644 (file)
--- a/cache.h
+++ b/cache.h
@@ -1577,7 +1577,6 @@ extern int ws_blank_line(const char *line, int len, unsigned ws_rule);
 #define ws_tab_width(rule)     ((rule) & WS_TAB_WIDTH_MASK)
 
 /* ls-files */
-int report_path_error(const char *ps_matched, const struct pathspec *pathspec, const char *prefix);
 void overlay_tree_on_cache(const char *tree_name, const char *prefix);
 
 char *alias_lookup(const char *alias);
diff --git a/dir.c b/dir.c
index 3f7a0256b61552c6c3f80f710bd042b697d79da9..0943a81964ddb7b5b1d83c9c8eafe2b3b2b9da09 100644 (file)
--- a/dir.c
+++ b/dir.c
@@ -377,6 +377,49 @@ int match_pathspec(const struct pathspec *ps,
        return negative ? 0 : positive;
 }
 
+int report_path_error(const char *ps_matched,
+                     const struct pathspec *pathspec,
+                     const char *prefix)
+{
+       /*
+        * Make sure all pathspec matched; otherwise it is an error.
+        */
+       struct strbuf sb = STRBUF_INIT;
+       int num, errors = 0;
+       for (num = 0; num < pathspec->nr; num++) {
+               int other, found_dup;
+
+               if (ps_matched[num])
+                       continue;
+               /*
+                * The caller might have fed identical pathspec
+                * twice.  Do not barf on such a mistake.
+                * FIXME: parse_pathspec should have eliminated
+                * duplicate pathspec.
+                */
+               for (found_dup = other = 0;
+                    !found_dup && other < pathspec->nr;
+                    other++) {
+                       if (other == num || !ps_matched[other])
+                               continue;
+                       if (!strcmp(pathspec->items[other].original,
+                                   pathspec->items[num].original))
+                               /*
+                                * Ok, we have a match already.
+                                */
+                               found_dup = 1;
+               }
+               if (found_dup)
+                       continue;
+
+               error("pathspec '%s' did not match any file(s) known to git.",
+                     pathspec->items[num].original);
+               errors++;
+       }
+       strbuf_release(&sb);
+       return errors;
+}
+
 /*
  * Return the length of the "simple" part of a path match limiter.
  */
diff --git a/dir.h b/dir.h
index 6c45e9d4b9a9055539e443ba30166b0b5384bac5..72b73c65dcfc6f31004a032d0706626424ac2241 100644 (file)
--- a/dir.h
+++ b/dir.h
@@ -137,6 +137,7 @@ extern char *common_prefix(const struct pathspec *pathspec);
 extern int match_pathspec(const struct pathspec *pathspec,
                          const char *name, int namelen,
                          int prefix, char *seen, int is_dir);
+extern int report_path_error(const char *ps_matched, const struct pathspec *pathspec, const char *prefix);
 extern int within_depth(const char *name, int namelen, int depth, int max_depth);
 
 extern int fill_directory(struct dir_struct *dir, const struct pathspec *pathspec);