Skip to content

Instantly share code, notes, and snippets.

@giddie
Created March 17, 2009 13:09
Show Gist options
  • Save giddie/80530 to your computer and use it in GitHub Desktop.
Save giddie/80530 to your computer and use it in GitHub Desktop.
diff --git a/OMakefile b/OMakefile
index 92de085..dc34346 100644
--- a/OMakefile
+++ b/OMakefile
@@ -25,8 +25,8 @@ OCAML_CLIBS += ometastore_stub
OCAML_OTHER_LIBS += unix str
OCamlProgram(ometastore, folddir util ometastore)
-OCamlProgram(find-git-repos, folddir util find-git-repos)
-OCamlProgram(find-git-files, folddir util find-git-files)
+OCamlProgram(find-git-repos, folddir util findrepos)
+OCamlProgram(find-git-files, folddir util find)
.DEFAULT: ometastore find-git-files find-git-repos
diff --git a/find-git-files.ml b/find-git-files.ml
deleted file mode 100644
index f2881aa..0000000
--- a/find-git-files.ml
+++ /dev/null
@@ -1,43 +0,0 @@
-(* Copyright (C) 2008 Mauricio Fernandez <mfp@acm.org> http//eigenclass.org
- * See README.txt and LICENSE for the redistribution and modification terms *)
-
-open Printf
-open Folddir
-open Util
-open Unix
-
-let debug = ref false
-
-module Find(F : Folddir.S) =
-struct
- let find ?(debug=false) ?(sorted=false) path =
- let aux l name stat =
- let dir = join path name in
- match stat.st_kind with
- | S_DIR -> begin
- try access (join dir ".git") [F_OK]; Prune (name :: l)
- with Unix_error _ -> Continue (name :: l)
- end
- | _ -> Continue (name :: l)
- in List.rev (F.fold_directory ~debug ~sorted aux [] path "")
-end
-
-module Gitignored = Find(Folddir.Make(Folddir.Gitignore))
-
-let main () =
- let usage = "Usage: find-git-files <options>" in
- let path = ref "." in
- let zerosep = ref false in
- let sorted = ref false in
- let specs = [
- "--path", Arg.Set_string path, "Set base path (default: .)";
- "-z", Arg.Set zerosep, "Use \\0 to separate filenames.";
- "-s", Arg.Set sorted, "Sort output.";
- "--debug", Arg.Set debug, "Debug mode"
- ]
- in
- Arg.parse specs ignore usage;
- let print = if !zerosep then printf "%s\000" else printf "%s\n" in
- List.iter print (Gitignored.find ~debug:!debug ~sorted:!sorted !path)
-
-let () = main ()
diff --git a/find-git-repos.ml b/find-git-repos.ml
deleted file mode 100644
index 6db674b..0000000
--- a/find-git-repos.ml
+++ /dev/null
@@ -1,47 +0,0 @@
-(* Copyright (C) 2008 Mauricio Fernandez <mfp@acm.org> http//eigenclass.org
- * See README.txt and LICENSE for the redistribution and modification terms *)
-
-open Printf
-open Folddir
-open Util
-open Unix
-
-let debug = ref false
-
-module Findrepos(F : Folddir.S) =
-struct
- let find_repositories ?(debug=false) path =
- let aux l name stat =
- let dir = join path name in
- match stat.st_kind with
- | S_DIR -> begin
- try access (join dir ".git") [F_OK]; Prune (name :: l)
- with Unix_error _ -> Continue l
- end
- | _ -> Continue l
- in List.sort compare (F.fold_directory ~debug aux [] path "")
-end
-
-module All = Findrepos(Folddir.Make(Folddir.Ignore_none))
-module Gitignored = Findrepos(Folddir.Make(Folddir.Gitignore))
-
-let main () =
- let usage = "Usage: find-git-repos <options>" in
- let path = ref "." in
- let find_repos = ref All.find_repositories in
- let zerosep = ref false in
- let sorted = ref false in
- let specs = [
- "--path", Arg.Set_string path, "Set base path (default: .)";
- "-i", Arg.Unit (fun () -> find_repos := Gitignored.find_repositories),
- "Mimic git semantics (honor .gitignore, don't scan git submodules)";
- "-z", Arg.Set zerosep, "Use \\0 to separate filenames.";
- "-s", Arg.Set sorted, "Sort output.";
- "--debug", Arg.Set debug, "Debug mode"
- ]
- in Arg.parse specs ignore usage;
- let print = if !zerosep then printf "%s\000" else printf "%s\n" in
- let l = !find_repos ~debug:!debug !path in
- List.iter print (if !sorted then List.sort compare l else l)
-
-let () = main ()
diff --git a/find.ml b/find.ml
new file mode 100644
index 0000000..f2881aa
--- /dev/null
+++ b/find.ml
@@ -0,0 +1,43 @@
+(* Copyright (C) 2008 Mauricio Fernandez <mfp@acm.org> http//eigenclass.org
+ * See README.txt and LICENSE for the redistribution and modification terms *)
+
+open Printf
+open Folddir
+open Util
+open Unix
+
+let debug = ref false
+
+module Find(F : Folddir.S) =
+struct
+ let find ?(debug=false) ?(sorted=false) path =
+ let aux l name stat =
+ let dir = join path name in
+ match stat.st_kind with
+ | S_DIR -> begin
+ try access (join dir ".git") [F_OK]; Prune (name :: l)
+ with Unix_error _ -> Continue (name :: l)
+ end
+ | _ -> Continue (name :: l)
+ in List.rev (F.fold_directory ~debug ~sorted aux [] path "")
+end
+
+module Gitignored = Find(Folddir.Make(Folddir.Gitignore))
+
+let main () =
+ let usage = "Usage: find-git-files <options>" in
+ let path = ref "." in
+ let zerosep = ref false in
+ let sorted = ref false in
+ let specs = [
+ "--path", Arg.Set_string path, "Set base path (default: .)";
+ "-z", Arg.Set zerosep, "Use \\0 to separate filenames.";
+ "-s", Arg.Set sorted, "Sort output.";
+ "--debug", Arg.Set debug, "Debug mode"
+ ]
+ in
+ Arg.parse specs ignore usage;
+ let print = if !zerosep then printf "%s\000" else printf "%s\n" in
+ List.iter print (Gitignored.find ~debug:!debug ~sorted:!sorted !path)
+
+let () = main ()
diff --git a/findrepos.ml b/findrepos.ml
new file mode 100644
index 0000000..6db674b
--- /dev/null
+++ b/findrepos.ml
@@ -0,0 +1,47 @@
+(* Copyright (C) 2008 Mauricio Fernandez <mfp@acm.org> http//eigenclass.org
+ * See README.txt and LICENSE for the redistribution and modification terms *)
+
+open Printf
+open Folddir
+open Util
+open Unix
+
+let debug = ref false
+
+module Findrepos(F : Folddir.S) =
+struct
+ let find_repositories ?(debug=false) path =
+ let aux l name stat =
+ let dir = join path name in
+ match stat.st_kind with
+ | S_DIR -> begin
+ try access (join dir ".git") [F_OK]; Prune (name :: l)
+ with Unix_error _ -> Continue l
+ end
+ | _ -> Continue l
+ in List.sort compare (F.fold_directory ~debug aux [] path "")
+end
+
+module All = Findrepos(Folddir.Make(Folddir.Ignore_none))
+module Gitignored = Findrepos(Folddir.Make(Folddir.Gitignore))
+
+let main () =
+ let usage = "Usage: find-git-repos <options>" in
+ let path = ref "." in
+ let find_repos = ref All.find_repositories in
+ let zerosep = ref false in
+ let sorted = ref false in
+ let specs = [
+ "--path", Arg.Set_string path, "Set base path (default: .)";
+ "-i", Arg.Unit (fun () -> find_repos := Gitignored.find_repositories),
+ "Mimic git semantics (honor .gitignore, don't scan git submodules)";
+ "-z", Arg.Set zerosep, "Use \\0 to separate filenames.";
+ "-s", Arg.Set sorted, "Sort output.";
+ "--debug", Arg.Set debug, "Debug mode"
+ ]
+ in Arg.parse specs ignore usage;
+ let print = if !zerosep then printf "%s\000" else printf "%s\n" in
+ let l = !find_repos ~debug:!debug !path in
+ List.iter print (if !sorted then List.sort compare l else l)
+
+let () = main ()
--
1.6.2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment