From f4a338fd708e3cea8439987529b492658dfb8499 Mon Sep 17 00:00:00 2001 From: Edwin Kofler Date: Tue, 16 May 2023 19:22:45 -0700 Subject: [PATCH 1/7] feat: Add `git-get` command --- Commands.md | 10 +++ bin/git-get | 35 ++++++++++ etc/git-extras-completion.zsh | 1 + etc/git-extras.fish | 1 + man/git-extras.md | 1 + man/git-get.1 | 27 ++++++++ man/git-get.html | 118 ++++++++++++++++++++++++++++++++++ man/git-get.md | 34 ++++++++++ man/index.txt | 1 + 9 files changed, 228 insertions(+) create mode 100755 bin/git-get create mode 100644 man/git-get.1 create mode 100644 man/git-get.html create mode 100644 man/git-get.md diff --git a/Commands.md b/Commands.md index 4cca302ee..75204ba56 100644 --- a/Commands.md +++ b/Commands.md @@ -28,6 +28,7 @@ - [`git force-clone`](#git-force-clone) - [`git fork`](#git-fork) - [`git fresh-branch`](#git-fresh-branch) + - [`git get`](#git-get) - [`git gh-pages`](#git-gh-pages) - [`git graft`](#git-graft) - [`git guilt`](#git-guilt) @@ -889,6 +890,15 @@ Create empty local branch `name`: $ git fresh-branch docs ``` +## git get + +Clone repository into `"$GIT_EXTRA_DEFAULT_CLONE_PATH/"`: + +```bash +$ export GIT_EXTRA_DEFAULT_CLONE_PATH="$HOME/some-dir" +$ git-get 'https://github.com/hyperupcall/bake' +``` + ## git guilt Calculate the change in blame between two revisions diff --git a/bin/git-get b/bin/git-get new file mode 100755 index 000000000..8f0ea3ffb --- /dev/null +++ b/bin/git-get @@ -0,0 +1,35 @@ +#!/usr/bin/env bash + +_usage() { + printf '%s\n' "usage: ${0##*/} +usage: ${0##*/} --help + +Clone a repository in a particular directory." +} + +url=$1 + +if (( $# == 0)); then + _usage + exit 0 +fi + +for arg; do + if [ "$arg" = '-h' ] || [ "$arg" = '--help' ]; then + _usage + exit 0 + fi +done + + +if [ -z "$GIT_EXTRA_DEFAULT_CLONE_PATH" ]; then + printf 'ERROR: %s\n' "Environment variable 'GIT_EXTRA_DEFAULT_CLONE_PATH' must be set to a directory to clone under" >&2 + exit 1 +fi + +dirname=${url%/} +dirname=${url%.git} +dirname=${dirname##*/} + +mkdir -p "$GIT_EXTRA_DEFAULT_CLONE_PATH" +git clone "$url" "$GIT_EXTRA_DEFAULT_CLONE_PATH/$dirname" diff --git a/etc/git-extras-completion.zsh b/etc/git-extras-completion.zsh index 8535a1cac..001a7c6d6 100644 --- a/etc/git-extras-completion.zsh +++ b/etc/git-extras-completion.zsh @@ -372,6 +372,7 @@ zstyle ':completion:*:*:git:*' user-commands $existing_user_commands \ force-clone:'overwrite local repositories with clone' \ fork:'fork a repo on github' \ fresh-branch:'create fresh branches' \ + get:'clone a repository in a directory' \ gh-pages:'create the github pages branch' \ graft:'merge and destroy a given branch' \ guilt:'calculate change between two revisions' \ diff --git a/etc/git-extras.fish b/etc/git-extras.fish index 17bcdfa80..ac0c5bde1 100644 --- a/etc/git-extras.fish +++ b/etc/git-extras.fish @@ -27,6 +27,7 @@ set __fish_git_extras_commands \ "force-clone:overwrite local repositories with clone" \ "fork:Fork a repo on github" \ "fresh-branch:Create fresh branches" \ + "get:Clone a repository in a directory" \ "gh-pages:Create the GitHub Pages branch" \ "graft:Merge and destroy a given branch" \ "guilt:calculate change between two revisions" \ diff --git a/man/git-extras.md b/man/git-extras.md index aa77cfe27..196491757 100644 --- a/man/git-extras.md +++ b/man/git-extras.md @@ -55,6 +55,7 @@ git-extras(1) -- Awesome GIT utilities - **git-force-clone(1)** overwrite local repositories with clone - **git-fork(1)** Fork a repo on github - **git-fresh-branch(1)** Create fresh branches + - **git-get(1)** Clone a Git repository under a directory - **git-gh-pages(1)** Create the GitHub Pages branch - **git-graft(1)** Merge and destroy a given branch - **git-guilt(1)** calculate change between two revisions diff --git a/man/git-get.1 b/man/git-get.1 new file mode 100644 index 000000000..b9b3f629d --- /dev/null +++ b/man/git-get.1 @@ -0,0 +1,27 @@ +.\" generated with Ronn-NG/v0.9.1 +.\" http://github.com/apjanke/ronn-ng/tree/0.9.1 +.TH "GIT\-GET" "1" "May 2023" "" "Git Extras" +.SH "NAME" +\fBgit\-get\fR \- Clone a Git repository under a directory +.SH "SYNOPSIS" +\fBgit\-get\fR +.SH "DESCRIPTION" +Clones a Git repository under the directory specified by the environment variable \fBGIT_EXTRA_DEFAULT_CLONE_PATH\fR +.SH "EXAMPLES" +.nf +$ GIT_EXTRA_DEFAULT_CLONE_PATH="$HOME/some\-dir" git\-get 'https://github\.com/hyperupcall/bake' +Cloning into '/home//some\-dir/bake'\|\.\|\.\|\. +remote: Enumerating objects: 1199, done\. +remote: Counting objects: 100% (378/378), done\. +remote: Compressing objects: 100% (174/174), done\. +remote: Total 1199 (delta 163), reused 357 (delta 146), pack\-reused 821 +Receiving objects: 100% (1199/1199), 3\.05 MiB | 9\.85 MiB/s, done\. +Resolving deltas: 100% (515/515), done\. +$ +.fi +.SH "AUTHOR" +Written by Edwin Kofler <\fIedwin@kofler\.dev\fR> +.SH "REPORTING BUGS" +<\fIhttps://github\.com/tj/git\-extras/issues\fR> +.SH "SEE ALSO" +<\fIhttps://github\.com/tj/git\-extras\fR> diff --git a/man/git-get.html b/man/git-get.html new file mode 100644 index 000000000..f2faed8f4 --- /dev/null +++ b/man/git-get.html @@ -0,0 +1,118 @@ + + + + + + git-get(1) - Clone a Git repository under a directory + + + + +
+ + + +
    +
  1. git-get(1)
  2. +
  3. Git Extras
  4. +
  5. git-get(1)
  6. +
+ + + +

NAME

+

+ git-get - Clone a Git repository under a directory +

+

SYNOPSIS

+ +

git-get

+ +

DESCRIPTION

+ +

Clones a Git repository under the directory specified by the environment variable GIT_EXTRA_DEFAULT_CLONE_PATH

+ +

EXAMPLES

+ +
$ GIT_EXTRA_DEFAULT_CLONE_PATH="$HOME/some-dir" git-get 'https://github.com/hyperupcall/bake'
+Cloning into '/home/<user>/some-dir/bake'...
+remote: Enumerating objects: 1199, done.
+remote: Counting objects: 100% (378/378), done.
+remote: Compressing objects: 100% (174/174), done.
+remote: Total 1199 (delta 163), reused 357 (delta 146), pack-reused 821
+Receiving objects: 100% (1199/1199), 3.05 MiB | 9.85 MiB/s, done.
+Resolving deltas: 100% (515/515), done.
+$
+
+ +

AUTHOR

+ +

Written by Edwin Kofler <edwin@kofler.dev>

+ +

REPORTING BUGS

+ +

<https://github.com/tj/git-extras/issues>

+ +

SEE ALSO

+ +

<https://github.com/tj/git-extras>

+ +
    +
  1. +
  2. May 2023
  3. +
  4. git-get(1)
  5. +
+ +
+ + diff --git a/man/git-get.md b/man/git-get.md new file mode 100644 index 000000000..eff82097f --- /dev/null +++ b/man/git-get.md @@ -0,0 +1,34 @@ +git-get(1) -- Clone a Git repository under a directory +================================================= + +## SYNOPSIS + +`git-get` + +## DESCRIPTION + + Clones a Git repository under the directory specified by the environment variable `GIT_EXTRA_DEFAULT_CLONE_PATH` + +## EXAMPLES + + $ GIT_EXTRA_DEFAULT_CLONE_PATH="$HOME/some-dir" git-get 'https://github.com/hyperupcall/bake' + Cloning into '/home//some-dir/bake'... + remote: Enumerating objects: 1199, done. + remote: Counting objects: 100% (378/378), done. + remote: Compressing objects: 100% (174/174), done. + remote: Total 1199 (delta 163), reused 357 (delta 146), pack-reused 821 + Receiving objects: 100% (1199/1199), 3.05 MiB | 9.85 MiB/s, done. + Resolving deltas: 100% (515/515), done. + $ + +## AUTHOR + +Written by Edwin Kofler <> + +## REPORTING BUGS + +<> + +## SEE ALSO + +<> diff --git a/man/index.txt b/man/index.txt index 0e0381696..f54005e5b 100644 --- a/man/index.txt +++ b/man/index.txt @@ -28,6 +28,7 @@ git-feature(1) git-feature git-force-clone(1) git-force-clone git-fork(1) git-fork git-fresh-branch(1) git-fresh-branch +git-get(1) git-get git-gh-pages(1) git-gh-pages git-graft(1) git-graft git-guilt(1) git-guilt From b063719d614925734e03fa0898e9c169db183e46 Mon Sep 17 00:00:00 2001 From: Edwin Kofler Date: Tue, 16 May 2023 20:26:24 -0700 Subject: [PATCH 2/7] Update Commands.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: 罗泽轩 --- Commands.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Commands.md b/Commands.md index 75204ba56..192f62303 100644 --- a/Commands.md +++ b/Commands.md @@ -896,7 +896,7 @@ Clone repository into `"$GIT_EXTRA_DEFAULT_CLONE_PATH/"`: ```bash $ export GIT_EXTRA_DEFAULT_CLONE_PATH="$HOME/some-dir" -$ git-get 'https://github.com/hyperupcall/bake' +$ git get 'https://github.com/hyperupcall/bake' ``` ## git guilt From 2e88438c2d2beafb030e24a0c8a1d720c8558688 Mon Sep 17 00:00:00 2001 From: Edwin Kofler Date: Sat, 20 May 2023 22:49:41 -0700 Subject: [PATCH 3/7] fix: Use Git config to store value --- Commands.md | 4 ++-- bin/git-get | 9 +++++---- man/git-get.1 | 5 +++-- man/git-get.html | 5 +++-- man/git-get.md | 5 +++-- not_need_git_repo | 1 + 6 files changed, 17 insertions(+), 12 deletions(-) diff --git a/Commands.md b/Commands.md index 192f62303..7a58f0c52 100644 --- a/Commands.md +++ b/Commands.md @@ -892,10 +892,10 @@ $ git fresh-branch docs ## git get -Clone repository into `"$GIT_EXTRA_DEFAULT_CLONE_PATH/"`: +Clone repository into `"$HOME/some-dir/"`: ```bash -$ export GIT_EXTRA_DEFAULT_CLONE_PATH="$HOME/some-dir" +$ git config --add git-extras.get.clone-path "$HOME/some-dir" $ git get 'https://github.com/hyperupcall/bake' ``` diff --git a/bin/git-get b/bin/git-get index 8f0ea3ffb..d44cab266 100755 --- a/bin/git-get +++ b/bin/git-get @@ -21,9 +21,10 @@ for arg; do fi done +clone_path=$(git config --get git-extras.get.clone-path) -if [ -z "$GIT_EXTRA_DEFAULT_CLONE_PATH" ]; then - printf 'ERROR: %s\n' "Environment variable 'GIT_EXTRA_DEFAULT_CLONE_PATH' must be set to a directory to clone under" >&2 +if [ -z "$clone_path" ]; then + printf 'ERROR: %s\n' "Git configuration key 'git-extras.get.clone-path' must be set to a directory to clone under" >&2 exit 1 fi @@ -31,5 +32,5 @@ dirname=${url%/} dirname=${url%.git} dirname=${dirname##*/} -mkdir -p "$GIT_EXTRA_DEFAULT_CLONE_PATH" -git clone "$url" "$GIT_EXTRA_DEFAULT_CLONE_PATH/$dirname" +mkdir -p "$clone_path" +git clone "$url" "$clone_path/$dirname" diff --git a/man/git-get.1 b/man/git-get.1 index b9b3f629d..c27851743 100644 --- a/man/git-get.1 +++ b/man/git-get.1 @@ -6,10 +6,11 @@ .SH "SYNOPSIS" \fBgit\-get\fR .SH "DESCRIPTION" -Clones a Git repository under the directory specified by the environment variable \fBGIT_EXTRA_DEFAULT_CLONE_PATH\fR +Clones a Git repository under the directory specified by the Git configuration \fBgit\-extras\.get\.clone\-path\fR .SH "EXAMPLES" .nf -$ GIT_EXTRA_DEFAULT_CLONE_PATH="$HOME/some\-dir" git\-get 'https://github\.com/hyperupcall/bake' +$ git config \-\-add git\-extras\.get\.clone\-path "$HOME/some\-dir" +$ git get 'https://github\.com/hyperupcall/bake' Cloning into '/home//some\-dir/bake'\|\.\|\.\|\. remote: Enumerating objects: 1199, done\. remote: Counting objects: 100% (378/378), done\. diff --git a/man/git-get.html b/man/git-get.html index f2faed8f4..8ae59156d 100644 --- a/man/git-get.html +++ b/man/git-get.html @@ -80,11 +80,12 @@

SYNOPSIS

DESCRIPTION

-

Clones a Git repository under the directory specified by the environment variable GIT_EXTRA_DEFAULT_CLONE_PATH

+

Clones a Git repository under the directory specified by the Git configuration git-extras.get.clone-path

EXAMPLES

-
$ GIT_EXTRA_DEFAULT_CLONE_PATH="$HOME/some-dir" git-get 'https://github.com/hyperupcall/bake'
+
$ git config --add git-extras.get.clone-path "$HOME/some-dir"
+$ git get 'https://github.com/hyperupcall/bake'
 Cloning into '/home/<user>/some-dir/bake'...
 remote: Enumerating objects: 1199, done.
 remote: Counting objects: 100% (378/378), done.
diff --git a/man/git-get.md b/man/git-get.md
index eff82097f..25aea0d6c 100644
--- a/man/git-get.md
+++ b/man/git-get.md
@@ -7,11 +7,12 @@ git-get(1) -- Clone a Git repository under a directory
 
 ## DESCRIPTION
 
-  Clones a Git repository under the directory specified by the environment variable `GIT_EXTRA_DEFAULT_CLONE_PATH`
+  Clones a Git repository under the directory specified by the Git configuration `git-extras.get.clone-path`
 
 ## EXAMPLES
 
-    $ GIT_EXTRA_DEFAULT_CLONE_PATH="$HOME/some-dir" git-get 'https://github.com/hyperupcall/bake'
+    $ git config --add git-extras.get.clone-path "$HOME/some-dir"
+    $ git get 'https://github.com/hyperupcall/bake'
     Cloning into '/home//some-dir/bake'...
     remote: Enumerating objects: 1199, done.
     remote: Counting objects: 100% (378/378), done.
diff --git a/not_need_git_repo b/not_need_git_repo
index 7bec3620c..a3499d2e4 100644
--- a/not_need_git_repo
+++ b/not_need_git_repo
@@ -7,3 +7,4 @@ git-force-clone
 git-fork
 git-setup
 git-standup
+git-get

From dbdc29ddaf8b4b0557f0aebf7db18b911a7b1e28 Mon Sep 17 00:00:00 2001
From: Edwin Kofler 
Date: Sat, 27 May 2023 00:41:17 -0700
Subject: [PATCH 4/7] improve `git-get` description

---
 Commands.md         |  2 +-
 man/git-extras.1    | 14 +++++++++-----
 man/git-extras.html |  7 ++++++-
 man/git-extras.md   |  2 +-
 man/git-get.md      |  2 +-
 not_need_git_repo   |  2 +-
 6 files changed, 19 insertions(+), 10 deletions(-)

diff --git a/Commands.md b/Commands.md
index 7a58f0c52..880cce04e 100644
--- a/Commands.md
+++ b/Commands.md
@@ -892,7 +892,7 @@ $ git fresh-branch docs
 
 ## git get
 
-Clone repository into `"$HOME/some-dir/"`:
+Clone repository into a subdirectory of the configured path, `"$HOME/some-dir"`:
 
 ```bash
 $ git config --add git-extras.get.clone-path "$HOME/some-dir"
diff --git a/man/git-extras.1 b/man/git-extras.1
index 957f18851..c922217bf 100644
--- a/man/git-extras.1
+++ b/man/git-extras.1
@@ -1,6 +1,6 @@
 .\" generated with Ronn-NG/v0.9.1
 .\" http://github.com/apjanke/ronn-ng/tree/0.9.1
-.TH "GIT\-EXTRAS" "1" "December 2021" "" "Git Extras"
+.TH "GIT\-EXTRAS" "1" "May 2023" "" "Git Extras"
 .SH "NAME"
 \fBgit\-extras\fR \- Awesome GIT utilities
 .SH "SYNOPSIS"
@@ -20,7 +20,7 @@ Self update\.
 .SH "ENVIRONMENT AND CONFIGURATION VARIABLES"
 \fBgit config \-\-add git\-extras\.default\-branch $BRANCH\fR
 .P
-Change the default branch to \fB$BRANCH\fR\. If \fBgit\-extras\.default\-branch\fR isn\'t set, \fBinit\.defaultBranch\fR is used instead\. If none of them are set it defaults to \fBmain\fR\.
+Change the default branch to \fB$BRANCH\fR\. If \fBgit\-extras\.default\-branch\fR isn't set, \fBinit\.defaultBranch\fR is used instead\. If none of them are set it defaults to \fBmain\fR\.
 .SH "COMMANDS"
 .IP "\[ci]" 4
 \fBgit\-abort(1)\fR Abort current git operation
@@ -31,6 +31,8 @@ Change the default branch to \fB$BRANCH\fR\. If \fBgit\-extras\.default\-branch\
 .IP "\[ci]" 4
 \fBgit\-authors(1)\fR Generate authors report
 .IP "\[ci]" 4
+\fBgit\-browse\-ci(1)\fR \fIView the web page for the current repository\fR
+.IP "\[ci]" 4
 \fBgit\-browse(1)\fR \fIView the web page for the current repository\fR
 .IP "\[ci]" 4
 \fBgit\-brv(1)\fR List branches sorted by their last commit date
@@ -47,7 +49,7 @@ Change the default branch to \fB$BRANCH\fR\. If \fBgit\-extras\.default\-branch\
 .IP "\[ci]" 4
 \fBgit\-commits\-since(1)\fR Show commit logs since some date
 .IP "\[ci]" 4
-\fBgit\-contrib(1)\fR Show user\'s contributions
+\fBgit\-contrib(1)\fR Show user's contributions
 .IP "\[ci]" 4
 \fBgit\-count(1)\fR Show commit count
 .IP "\[ci]" 4
@@ -77,6 +79,8 @@ Change the default branch to \fB$BRANCH\fR\. If \fBgit\-extras\.default\-branch\
 .IP "\[ci]" 4
 \fBgit\-fresh\-branch(1)\fR Create fresh branches
 .IP "\[ci]" 4
+\fBgit\-get(1)\fR Clone a Git repository under a configured directory
+.IP "\[ci]" 4
 \fBgit\-gh\-pages(1)\fR Create the GitHub Pages branch
 .IP "\[ci]" 4
 \fBgit\-graft(1)\fR Merge and destroy a given branch
@@ -115,7 +119,7 @@ Change the default branch to \fB$BRANCH\fR\. If \fBgit\-extras\.default\-branch\
 .IP "\[ci]" 4
 \fBgit\-pull\-request(1)\fR Create pull request for GitHub project
 .IP "\[ci]" 4
-\fBgit\-reauthor(1)\fR Rewrite history to change author\'s identity
+\fBgit\-reauthor(1)\fR Rewrite history to change author's identity
 .IP "\[ci]" 4
 \fBgit\-rebase\-patch(1)\fR Rebases a patch
 .IP "\[ci]" 4
@@ -145,7 +149,7 @@ Change the default branch to \fB$BRANCH\fR\. If \fBgit\-extras\.default\-branch\
 .IP "\[ci]" 4
 \fBgit\-show\-unmerged\-branches(1)\fR Show unmerged branches
 .IP "\[ci]" 4
-\fBgit\-squash(1)\fR squash N last changes up to a ref\'ed commit
+\fBgit\-squash(1)\fR squash N last changes up to a ref'ed commit
 .IP "\[ci]" 4
 \fBgit\-stamp(1)\fR Stamp the last commit message
 .IP "\[ci]" 4
diff --git a/man/git-extras.html b/man/git-extras.html
index 09da1a48f..d1fb5489b 100644
--- a/man/git-extras.html
+++ b/man/git-extras.html
@@ -111,6 +111,9 @@ 

COMMANDS

  • git-authors(1) Generate authors report
  • +git-browse-ci(1) View the web page for the current repository +
  • +
  • git-browse(1) View the web page for the current repository
  • @@ -158,6 +161,8 @@

    COMMANDS

  • git-fresh-branch(1) Create fresh branches
  • +git-get(1) Clone a Git repository under a configured directory
  • +
  • git-gh-pages(1) Create the GitHub Pages branch
  • git-graft(1) Merge and destroy a given branch
  • @@ -260,7 +265,7 @@

    SEE ALSO

    1. -
    2. December 2021
    3. +
    4. May 2023
    5. git-extras(1)
    diff --git a/man/git-extras.md b/man/git-extras.md index 196491757..7ee272249 100644 --- a/man/git-extras.md +++ b/man/git-extras.md @@ -55,7 +55,7 @@ git-extras(1) -- Awesome GIT utilities - **git-force-clone(1)** overwrite local repositories with clone - **git-fork(1)** Fork a repo on github - **git-fresh-branch(1)** Create fresh branches - - **git-get(1)** Clone a Git repository under a directory + - **git-get(1)** Clone a Git repository under a configured directory - **git-gh-pages(1)** Create the GitHub Pages branch - **git-graft(1)** Merge and destroy a given branch - **git-guilt(1)** calculate change between two revisions diff --git a/man/git-get.md b/man/git-get.md index 25aea0d6c..cdb3497a5 100644 --- a/man/git-get.md +++ b/man/git-get.md @@ -1,4 +1,4 @@ -git-get(1) -- Clone a Git repository under a directory +git-get(1) -- Clone a Git repository under a configured directory ================================================= ## SYNOPSIS diff --git a/not_need_git_repo b/not_need_git_repo index a3499d2e4..d7f3e542c 100644 --- a/not_need_git_repo +++ b/not_need_git_repo @@ -5,6 +5,6 @@ git-bulk git-extras git-force-clone git-fork +git-get git-setup git-standup -git-get From 160bce1d17bc48e425f3842f357484abf9f4c487 Mon Sep 17 00:00:00 2001 From: Edwin Kofler Date: Tue, 11 Jul 2023 11:19:02 -0700 Subject: [PATCH 5/7] fix: Add `--global` to git invocation --- Commands.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Commands.md b/Commands.md index 880cce04e..1299447fa 100644 --- a/Commands.md +++ b/Commands.md @@ -895,7 +895,7 @@ $ git fresh-branch docs Clone repository into a subdirectory of the configured path, `"$HOME/some-dir"`: ```bash -$ git config --add git-extras.get.clone-path "$HOME/some-dir" +$ git config --global --add git-extras.get.clone-path "$HOME/some-dir" $ git get 'https://github.com/hyperupcall/bake' ``` From fbb95a6e8125f434f35dc0bf276cbc98efc17161 Mon Sep 17 00:00:00 2001 From: Edwin Kofler Date: Wed, 19 Jul 2023 15:11:26 -0700 Subject: [PATCH 6/7] Enable passing options to `git clone` --- bin/git-get | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/bin/git-get b/bin/git-get index d44cab266..73010bbd4 100755 --- a/bin/git-get +++ b/bin/git-get @@ -14,6 +14,11 @@ if (( $# == 0)); then exit 0 fi +if ! shift; then + printf 'ERROR: Failed to shift' >&2 + exit 1 +fi + for arg; do if [ "$arg" = '-h' ] || [ "$arg" = '--help' ]; then _usage @@ -33,4 +38,4 @@ dirname=${url%.git} dirname=${dirname##*/} mkdir -p "$clone_path" -git clone "$url" "$clone_path/$dirname" +git clone "$url" "$clone_path/$dirname" "$@" From 3458e98e4caf33f368f2e47eb4f1d81d7cc64dd2 Mon Sep 17 00:00:00 2001 From: Edwin Kofler Date: Thu, 10 Aug 2023 07:18:53 -0700 Subject: [PATCH 7/7] fix: Ordering of checks --- bin/git-get | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/bin/git-get b/bin/git-get index 73010bbd4..978badd9b 100755 --- a/bin/git-get +++ b/bin/git-get @@ -7,18 +7,11 @@ usage: ${0##*/} --help Clone a repository in a particular directory." } -url=$1 - -if (( $# == 0)); then +if (( $# == 0 )); then _usage exit 0 fi -if ! shift; then - printf 'ERROR: Failed to shift' >&2 - exit 1 -fi - for arg; do if [ "$arg" = '-h' ] || [ "$arg" = '--help' ]; then _usage @@ -26,6 +19,12 @@ for arg; do fi done +url=$1 +if ! shift; then + printf 'ERROR: Failed to shift' >&2 + exit 1 +fi + clone_path=$(git config --get git-extras.get.clone-path) if [ -z "$clone_path" ]; then