summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLibravatar Daniel Barkalow <barkalow@iabervon.org>2009-03-08 21:06:05 -0400
committerLibravatar Junio C Hamano <gitster@pobox.com>2009-03-09 15:41:16 -0700
commita9c37a72c4fbc8537de294d66b05bdfd7f9a4016 (patch)
tree117ca075b1b84094aaabc9e4145434868ab43228
parentbuiltin-remote.c: no "commented out" code, please (diff)
downloadtgif-a9c37a72c4fbc8537de294d66b05bdfd7f9a4016.tar.xz
Use a common function to get the pretty name of refs
The result should be consistent between fetch and push, so we ought to use the same code in both cases, even though it's short. Signed-off-by: Daniel Barkalow <barkalow@iabervon.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
-rw-r--r--builtin-fetch.c6
-rw-r--r--builtin-send-pack.c10
-rw-r--r--refs.c10
-rw-r--r--refs.h2
4 files changed, 13 insertions, 15 deletions
diff --git a/builtin-fetch.c b/builtin-fetch.c
index 1e4a3d9c51..f3bdeda059 100644
--- a/builtin-fetch.c
+++ b/builtin-fetch.c
@@ -197,11 +197,7 @@ static int update_local_ref(struct ref *ref,
struct commit *current = NULL, *updated;
enum object_type type;
struct branch *current_branch = branch_get(NULL);
- const char *pretty_ref = ref->name + (
- !prefixcmp(ref->name, "refs/heads/") ? 11 :
- !prefixcmp(ref->name, "refs/tags/") ? 10 :
- !prefixcmp(ref->name, "refs/remotes/") ? 13 :
- 0);
+ const char *pretty_ref = prettify_ref(ref);
*display = 0;
type = sha1_object_info(ref->new_sha1, NULL);
diff --git a/builtin-send-pack.c b/builtin-send-pack.c
index 9072905f10..43b89ece36 100644
--- a/builtin-send-pack.c
+++ b/builtin-send-pack.c
@@ -172,16 +172,6 @@ static void update_tracking_ref(struct remote *remote, struct ref *ref)
}
}
-static const char *prettify_ref(const struct ref *ref)
-{
- const char *name = ref->name;
- return name + (
- !prefixcmp(name, "refs/heads/") ? 11 :
- !prefixcmp(name, "refs/tags/") ? 10 :
- !prefixcmp(name, "refs/remotes/") ? 13 :
- 0);
-}
-
#define SUMMARY_WIDTH (2 * DEFAULT_ABBREV + 3)
static void print_ref_status(char flag, const char *summary, struct ref *to, struct ref *from, const char *msg)
diff --git a/refs.c b/refs.c
index b2a37e1185..8f968b51a1 100644
--- a/refs.c
+++ b/refs.c
@@ -736,6 +736,16 @@ int check_ref_format(const char *ref)
}
}
+const char *prettify_ref(const struct ref *ref)
+{
+ const char *name = ref->name;
+ return name + (
+ !prefixcmp(name, "refs/heads/") ? 11 :
+ !prefixcmp(name, "refs/tags/") ? 10 :
+ !prefixcmp(name, "refs/remotes/") ? 13 :
+ 0);
+}
+
const char *ref_rev_parse_rules[] = {
"%.*s",
"refs/%.*s",
diff --git a/refs.h b/refs.h
index 29bdcecd4e..68c2d16d53 100644
--- a/refs.h
+++ b/refs.h
@@ -79,6 +79,8 @@ extern int for_each_reflog(each_ref_fn, void *);
#define CHECK_REF_FORMAT_WILDCARD (-3)
extern int check_ref_format(const char *target);
+extern const char *prettify_ref(const struct ref *ref);
+
/** rename ref, return 0 on success **/
extern int rename_ref(const char *oldref, const char *newref, const char *logmsg);