From 42ff8ad780522111fd597f94ee40beae5aeb6ac3 Mon Sep 17 00:00:00 2001
From: Andrew Rynhard <andrewrynhard@autonomy.io>
Date: Thu, 12 Nov 2015 15:10:56 -0800
Subject: [PATCH] Add help flag to nix-prefetch-git

---
 pkgs/build-support/fetchgit/nix-prefetch-git | 34 ++++++++++----------
 1 file changed, 17 insertions(+), 17 deletions(-)

diff --git a/pkgs/build-support/fetchgit/nix-prefetch-git b/pkgs/build-support/fetchgit/nix-prefetch-git
index 22d46257075e..736cf0194163 100755
--- a/pkgs/build-support/fetchgit/nix-prefetch-git
+++ b/pkgs/build-support/fetchgit/nix-prefetch-git
@@ -22,6 +22,22 @@ else
     leaveDotGit=true
 fi
 
+usage(){
+    echo  >&2 "syntax: nix-prefetch-git [options] [URL [REVISION [EXPECTED-HASH]]]
+
+Options:
+      --out path      Path where the output would be stored.
+      --url url       Any url understand by 'git clone'.
+      --rev ref       Any sha1 or references (such as refs/heads/master)
+      --hash h        Expected hash.
+      --deepClone     Clone submodules recursively.
+      --no-deepClone  Do not clone submodules.
+      --leave-dotGit  Keep the .git directories.
+      --fetch-submodules Fetch submodules.
+      --builder       Clone as fetchgit does, but url, rev, and out option are mandatory.
+"
+    exit 1
+}
 
 argi=0
 argfun=""
@@ -38,6 +54,7 @@ for arg; do
             --leave-dotGit) leaveDotGit=true;;
             --fetch-submodules) fetchSubmodules=true;;
             --builder) builder=true;;
+            --help) usage; exit;;
             *)
                 argi=$(($argi + 1))
                 case $argi in
@@ -59,23 +76,6 @@ for arg; do
     fi
 done
 
-usage(){
-    echo  >&2 "syntax: nix-prefetch-git [options] [URL [REVISION [EXPECTED-HASH]]]
-
-Options:
-      --out path      Path where the output would be stored.
-      --url url       Any url understand by 'git clone'.
-      --rev ref       Any sha1 or references (such as refs/heads/master)
-      --hash h        Expected hash.
-      --deepClone     Clone submodules recursively.
-      --no-deepClone  Do not clone submodules.
-      --leave-dotGit  Keep the .git directories.
-      --fetch-submodules Fetch submodules.
-      --builder       Clone as fetchgit does, but url, rev, and out option are mandatory.
-"
-    exit 1
-}
-
 if test -z "$url"; then
     usage
 fi