checkout: implement "-" abbreviation, add docs and tests

Have '-' mean the same as '@{-1}', i.e., the last branch we were on.

Signed-off-by: Thomas Rast <trast@student.ethz.ch>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Thomas Rast
2009-01-17 17:09:56 +01:00
committed by Junio C Hamano
parent d18ba22154
commit 696acf45f9
3 changed files with 57 additions and 0 deletions

View File

@ -679,6 +679,9 @@ int cmd_checkout(int argc, const char **argv, const char *prefix)
arg = argv[0];
has_dash_dash = (argc > 1) && !strcmp(argv[1], "--");
if (!strcmp(arg, "-"))
arg = "@{-1}";
if (get_sha1(arg, rev)) {
if (has_dash_dash) /* case (1) */
die("invalid reference: %s", arg);