git-submodule: Instead of using only annotated tags, use any tags.
Some repositories might not use/have annotated tags (for example the ones created with git-cvsimport) and git-submodule status might fail because git-describe might fail to find a tag. This change allows the status of a submodule to be described/displayed relative to lightweight tags as well. Signed-off-by: Emil Medve <Emilian.Medve@Freescale.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Emil Medve committed
Jun 26, 2007 at 18:40 UTC
bffe71f4cd44b8050e7561b9f9245febb8b21f0a
1 file changed
+17
-4
git-submodule.sh
+17
-4
@@ -199,6 +199,18 @@ modules_update()
199
done
200
}
201
202
+set_name_rev () {
203
+ revname=$( (
204
+ unset GIT_DIR &&
205
+ cd "$1" && {
206
+ git-describe "$2" 2>/dev/null ||
207
+ git-describe --tags "$2" 2>/dev/null ||
208
+ git-describe --contains --tags "$2"
209
+ }
210
+ ) )
211
+ test -z "$revname" || revname=" ($revname)"
212
+}
213
+
214
#
215
# List all submodules, prefixed with:
216
# - submodule not initialized
@@ -221,17 +233,18 @@ modules_list()
233
say "-$sha1 $path"
234
continue;
235
fi
224
- revname=$(unset GIT_DIR && cd "$path" && git-describe $sha1)
236
+ revname=$(unset GIT_DIR && cd "$path" && git-describe --tags $sha1)
237
+ set_name_rev "$path" $"sha1"
238
if git diff-files --quiet -- "$path"
239
then
227
- say " $sha1 $path ($revname)"
240
+ say " $sha1 $path$revname"
241
else
242
if test -z "$cached"
243
then
244
sha1=$(unset GIT_DIR && cd "$path" && git-rev-parse --verify HEAD)
232
- revname=$(unset GIT_DIR && cd "$path" && git-describe $sha1)
245
+ set_name_rev "$path" $"sha1"
246
fi
234
- say "+$sha1 $path ($revname)"
247
+ say "+$sha1 $path$revname"
248
fi
249
done
250
}