aboutsummaryrefslogtreecommitdiff
path: root/builtin-check-ref-format.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2009-10-12 16:39:43 -0700
committerJunio C Hamano <gitster@pobox.com>2009-10-12 16:39:59 -0700
commit38eedc634bc5d30e8a7a2356d9eb3ae95d9b1d75 (patch)
tree4ed08365e305beb2dc7a2e7344124cdfeee69d2a /builtin-check-ref-format.c
parent58a05c74e7a9341af80eb98731d6b0dafe1b5c29 (diff)
downloadgit-38eedc634bc5d30e8a7a2356d9eb3ae95d9b1d75.tar.gz
git-38eedc634bc5d30e8a7a2356d9eb3ae95d9b1d75.tar.xz
git check-ref-format --print
Tolerating empty path components in ref names means each ref does not have a unique name. This creates difficulty for porcelains that want to see if two branches are equal. Add a helper associating to each ref a canonical name. If a user asks a porcelain to create a ref "refs/heads//master", the porcelain can run "git check-ref-format --print refs/heads//master" and only deal with "refs/heads/master" from then on. Signed-off-by: Jonathan Nieder <jrnieder@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin-check-ref-format.c')
-rw-r--r--builtin-check-ref-format.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/builtin-check-ref-format.c b/builtin-check-ref-format.c
index f9381e07e..b97b61a0a 100644
--- a/builtin-check-ref-format.c
+++ b/builtin-check-ref-format.c
@@ -17,6 +17,16 @@ int cmd_check_ref_format(int argc, const char **argv, const char *prefix)
printf("%s\n", sb.buf + 11);
exit(0);
}
+ if (argc == 3 && !strcmp(argv[1], "--print")) {
+ char *refname = xmalloc(strlen(argv[2]) + 1);
+
+ if (check_ref_format(argv[2]))
+ exit(1);
+ if (normalize_path_copy(refname, argv[2]))
+ die("Could not normalize ref name '%s'", argv[2]);
+ printf("%s\n", refname);
+ exit(0);
+ }
if (argc != 2)
usage("git check-ref-format refname");
return !!check_ref_format(argv[1]);