diff options
author | Andrew Cady <d@jerkface.net> | 2020-05-31 02:01:31 -0400 |
---|---|---|
committer | Andrew Cady <d@jerkface.net> | 2020-05-31 13:03:40 -0400 |
commit | a16c3eb057b307629e7969b9ce895bb0bed1de29 (patch) | |
tree | 775a07328b02fef1fa41f0d75a055e1e056f9d69 | |
parent | 64191f1729711acb68fcfe82cb4e1543b658942b (diff) |
git-ll-remote: show more info when -a is given
-rwxr-xr-x | dot/local/bin/git-ll-remote | 29 |
1 files changed, 23 insertions, 6 deletions
diff --git a/dot/local/bin/git-ll-remote b/dot/local/bin/git-ll-remote index aee13db..17a50d4 100755 --- a/dot/local/bin/git-ll-remote +++ b/dot/local/bin/git-ll-remote | |||
@@ -106,7 +106,7 @@ show_message() | |||
106 | git_fetch() | 106 | git_fetch() |
107 | { | 107 | { |
108 | local hash="$1" ref="$2" | 108 | local hash="$1" ref="$2" |
109 | have_ref "$hash" || git fetch "$remote" "$ref" | 109 | have_ref "$hash" || git fetch --depth=1 "$remote" "$ref" |
110 | } | 110 | } |
111 | 111 | ||
112 | is_same_ref() | 112 | is_same_ref() |
@@ -122,11 +122,23 @@ is_ancestor() | |||
122 | fi | 122 | fi |
123 | } | 123 | } |
124 | 124 | ||
125 | verdict() | ||
126 | { | ||
127 | if is_same_ref HEAD "$1" | ||
128 | then echo even | ||
129 | elif is_ancestor "$1" HEAD | ||
130 | then echo behind | ||
131 | elif is_ancestor HEAD "$1" | ||
132 | then echo ahead | ||
133 | else echo diverged | ||
134 | fi | ||
135 | } | ||
136 | |||
125 | show_this_remote_branch() | 137 | show_this_remote_branch() |
126 | { | 138 | { |
127 | local hash="$1" | 139 | local hash="$1" |
128 | case "$SHOW" in | 140 | case "$SHOW" in |
129 | all) true ;; | 141 | all) VERDICT=$(verdict "$hash") ;; |
130 | behind) is_ancestor "$hash" HEAD ;; | 142 | behind) is_ancestor "$hash" HEAD ;; |
131 | ahead) is_ancestor HEAD "$hash" ;; | 143 | ahead) is_ancestor HEAD "$hash" ;; |
132 | upto) is_same_ref HEAD "$hash" ;; | 144 | upto) is_same_ref HEAD "$hash" ;; |
@@ -145,7 +157,13 @@ handle_hash_ref() | |||
145 | show_message | 157 | show_message |
146 | fi | 158 | fi |
147 | 159 | ||
148 | >&2 printf 'remote: %s\n' "$ref" | 160 | if [ "$OPT_a" ] |
161 | then | ||
162 | >&2 printf 'remote: %s (%s)\n' "$ref" "$VERDICT" | ||
163 | else | ||
164 | >&2 printf 'remote: %s\n' "$ref" | ||
165 | fi | ||
166 | |||
149 | git show "$hash" | sed '/^$/q' | 167 | git show "$hash" | sed '/^$/q' |
150 | listed=$((listed + 1)) | 168 | listed=$((listed + 1)) |
151 | else | 169 | else |
@@ -156,9 +174,8 @@ handle_hash_ref() | |||
156 | read_hashes() | 174 | read_hashes() |
157 | { | 175 | { |
158 | while read hash ref; do | 176 | while read hash ref; do |
159 | case $ref in | 177 | [ "$hash" != From ] || continue |
160 | refs/namespaces/*) handle_hash_ref "$hash" "$ref" ;; | 178 | handle_hash_ref "$hash" "$ref" |
161 | esac | ||
162 | done | 179 | done |
163 | } | 180 | } |
164 | 181 | ||