Change prettify_ref to prettify_refname

In preparation to be used when the ref object is not available

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
Acked-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Felipe Contreras 2009-05-14 00:22:04 +03:00 коммит произвёл Junio C Hamano
Родитель f01f1099f4
Коммит 4577e48364
5 изменённых файлов: 7 добавлений и 8 удалений

Просмотреть файл

@ -197,7 +197,7 @@ static int update_local_ref(struct ref *ref,
struct commit *current = NULL, *updated; struct commit *current = NULL, *updated;
enum object_type type; enum object_type type;
struct branch *current_branch = branch_get(NULL); struct branch *current_branch = branch_get(NULL);
const char *pretty_ref = prettify_ref(ref); const char *pretty_ref = prettify_refname(ref->name);
*display = 0; *display = 0;
type = sha1_object_info(ref->new_sha1, NULL); type = sha1_object_info(ref->new_sha1, NULL);

Просмотреть файл

@ -174,9 +174,9 @@ static void print_ref_status(char flag, const char *summary, struct ref *to, str
{ {
fprintf(stderr, " %c %-*s ", flag, SUMMARY_WIDTH, summary); fprintf(stderr, " %c %-*s ", flag, SUMMARY_WIDTH, summary);
if (from) if (from)
fprintf(stderr, "%s -> %s", prettify_ref(from), prettify_ref(to)); fprintf(stderr, "%s -> %s", prettify_refname(from->name), prettify_refname(to->name));
else else
fputs(prettify_ref(to), stderr); fputs(prettify_refname(to->name), stderr);
if (msg) { if (msg) {
fputs(" (", stderr); fputs(" (", stderr);
fputs(msg, stderr); fputs(msg, stderr);

3
refs.c
Просмотреть файл

@ -750,9 +750,8 @@ int check_ref_format(const char *ref)
} }
} }
const char *prettify_ref(const struct ref *ref) const char *prettify_refname(const char *name)
{ {
const char *name = ref->name;
return name + ( return name + (
!prefixcmp(name, "refs/heads/") ? 11 : !prefixcmp(name, "refs/heads/") ? 11 :
!prefixcmp(name, "refs/tags/") ? 10 : !prefixcmp(name, "refs/tags/") ? 10 :

2
refs.h
Просмотреть файл

@ -80,7 +80,7 @@ extern int for_each_reflog(each_ref_fn, void *);
#define CHECK_REF_FORMAT_WILDCARD (-3) #define CHECK_REF_FORMAT_WILDCARD (-3)
extern int check_ref_format(const char *target); extern int check_ref_format(const char *target);
extern const char *prettify_ref(const struct ref *ref); extern const char *prettify_refname(const char *refname);
extern char *shorten_unambiguous_ref(const char *ref, int strict); extern char *shorten_unambiguous_ref(const char *ref, int strict);
/** rename ref, return 0 on success **/ /** rename ref, return 0 on success **/

Просмотреть файл

@ -732,9 +732,9 @@ static void print_ref_status(char flag, const char *summary, struct ref *to, str
{ {
fprintf(stderr, " %c %-*s ", flag, SUMMARY_WIDTH, summary); fprintf(stderr, " %c %-*s ", flag, SUMMARY_WIDTH, summary);
if (from) if (from)
fprintf(stderr, "%s -> %s", prettify_ref(from), prettify_ref(to)); fprintf(stderr, "%s -> %s", prettify_refname(from->name), prettify_refname(to->name));
else else
fputs(prettify_ref(to), stderr); fputs(prettify_refname(to->name), stderr);
if (msg) { if (msg) {
fputs(" (", stderr); fputs(" (", stderr);
fputs(msg, stderr); fputs(msg, stderr);