Andrew's git
/
gitweb.git
/ diff
summary
|
log
|
commit
| diff |
tree
commit
grep
author
committer
pickaxe
?
re
name-ref: factor out name shortening logic from name_ref()
author
Junio C Hamano
<gitster@pobox.com>
Sun, 7 Jul 2013 21:13:41 +0000
(14:13 -0700)
committer
Junio C Hamano
<gitster@pobox.com>
Sun, 7 Jul 2013 22:32:23 +0000
(15:32 -0700)
The logic will be used in a new codepath for showing exact matches.
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/name-rev.c
patch
|
blob
|
history
raw
|
patch
|
inline
| side by side (parent:
96ffd4c
)
diff --git
a/builtin/name-rev.c
b/builtin/name-rev.c
index 87d485496fd5556cbd0f24793ed7e48f11e9b292..1234ebb5d8ff3fb194b9d20f5497d5bfaeb6b5a8 100644
(file)
--- a/
builtin/name-rev.c
+++ b/
builtin/name-rev.c
@@
-96,6
+96,17
@@
static int subpath_matches(const char *path, const char *filter)
return -1;
}
return -1;
}
+static const char *name_ref_abbrev(const char *refname, int shorten_unambiguous)
+{
+ if (shorten_unambiguous)
+ refname = shorten_unambiguous_ref(refname, 0);
+ else if (!prefixcmp(refname, "refs/heads/"))
+ refname = refname + 11;
+ else if (!prefixcmp(refname, "refs/"))
+ refname = refname + 5;
+ return refname;
+}
+
struct name_ref_data {
int tags_only;
int name_only;
struct name_ref_data {
int tags_only;
int name_only;
@@
-134,13
+145,7
@@
static int name_ref(const char *path, const unsigned char *sha1, int flags, void
if (o && o->type == OBJ_COMMIT) {
struct commit *commit = (struct commit *)o;
if (o && o->type == OBJ_COMMIT) {
struct commit *commit = (struct commit *)o;
- if (can_abbreviate_output)
- path = shorten_unambiguous_ref(path, 0);
- else if (!prefixcmp(path, "refs/heads/"))
- path = path + 11;
- else if (!prefixcmp(path, "refs/"))
- path = path + 5;
-
+ path = name_ref_abbrev(path, can_abbreviate_output);
name_rev(commit, xstrdup(path), 0, 0, deref);
}
return 0;
name_rev(commit, xstrdup(path), 0, 0, deref);
}
return 0;