Andrew's git
/
gitweb.git
/ diff
summary
|
log
|
commit
| diff |
tree
commit
grep
author
committer
pickaxe
?
re
builtin/show-branch: rewrite functions to take object_id arguments
author
Michael Haggerty
<mhagger@alum.mit.edu>
Mon, 25 May 2015 18:38:46 +0000
(18:38 +0000)
committer
Junio C Hamano
<gitster@pobox.com>
Mon, 25 May 2015 19:19:31 +0000
(12:19 -0700)
Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/show-branch.c
patch
|
blob
|
history
raw
|
patch
|
inline
| side by side (parent:
a00595f
)
diff --git
a/builtin/show-branch.c
b/builtin/show-branch.c
index b06f9668eef0de6c74dc02a61ce177ab34c21ca9..7e006577e26752d3741ebd97ea6d3722e6b8db9f 100644
(file)
--- a/
builtin/show-branch.c
+++ b/
builtin/show-branch.c
@@
-394,39
+394,42
@@
static int append_ref(const char *refname, const unsigned char *sha1,
return 0;
}
return 0;
}
-static int append_head_ref(const char *refname, const unsigned char *sha1, int flag, void *cb_data)
+static int append_head_ref(const char *refname, const struct object_id *oid,
+ int flag, void *cb_data)
{
{
-
unsigned char tmp[20]
;
+
struct object_id tmp
;
int ofs = 11;
if (!starts_with(refname, "refs/heads/"))
return 0;
/* If both heads/foo and tags/foo exists, get_sha1 would
* get confused.
*/
int ofs = 11;
if (!starts_with(refname, "refs/heads/"))
return 0;
/* If both heads/foo and tags/foo exists, get_sha1 would
* get confused.
*/
- if (get_sha1(refname + ofs, tmp
) || hashcmp(tmp, sha1
))
+ if (get_sha1(refname + ofs, tmp
.hash) || oidcmp(&tmp, oid
))
ofs = 5;
ofs = 5;
- return append_ref(refname + ofs,
sha1
, 0);
+ return append_ref(refname + ofs,
oid->hash
, 0);
}
}
-static int append_remote_ref(const char *refname, const unsigned char *sha1, int flag, void *cb_data)
+static int append_remote_ref(const char *refname, const struct object_id *oid,
+ int flag, void *cb_data)
{
{
-
unsigned char tmp[20]
;
+
struct object_id tmp
;
int ofs = 13;
if (!starts_with(refname, "refs/remotes/"))
return 0;
/* If both heads/foo and tags/foo exists, get_sha1 would
* get confused.
*/
int ofs = 13;
if (!starts_with(refname, "refs/remotes/"))
return 0;
/* If both heads/foo and tags/foo exists, get_sha1 would
* get confused.
*/
- if (get_sha1(refname + ofs, tmp
) || hashcmp(tmp, sha1
))
+ if (get_sha1(refname + ofs, tmp
.hash) || oidcmp(&tmp, oid
))
ofs = 5;
ofs = 5;
- return append_ref(refname + ofs,
sha1
, 0);
+ return append_ref(refname + ofs,
oid->hash
, 0);
}
}
-static int append_tag_ref(const char *refname, const unsigned char *sha1, int flag, void *cb_data)
+static int append_tag_ref(const char *refname, const struct object_id *oid,
+ int flag, void *cb_data)
{
if (!starts_with(refname, "refs/tags/"))
return 0;
{
if (!starts_with(refname, "refs/tags/"))
return 0;
- return append_ref(refname + 5,
sha1
, 0);
+ return append_ref(refname + 5,
oid->hash
, 0);
}
static const char *match_ref_pattern = NULL;
}
static const char *match_ref_pattern = NULL;
@@
-457,9
+460,9
@@
static int append_matching_ref(const char *refname, const struct object_id *oid,
if (wildmatch(match_ref_pattern, tail, 0, NULL))
return 0;
if (starts_with(refname, "refs/heads/"))
if (wildmatch(match_ref_pattern, tail, 0, NULL))
return 0;
if (starts_with(refname, "refs/heads/"))
- return append_head_ref(refname, oid
->hash
, flag, cb_data);
+ return append_head_ref(refname, oid, flag, cb_data);
if (starts_with(refname, "refs/tags/"))
if (starts_with(refname, "refs/tags/"))
- return append_tag_ref(refname, oid
->hash
, flag, cb_data);
+ return append_tag_ref(refname, oid, flag, cb_data);
return append_ref(refname, oid->hash, 0);
}
return append_ref(refname, oid->hash, 0);
}
@@
-467,18
+470,14
@@
static void snarf_refs(int head, int remotes)
{
if (head) {
int orig_cnt = ref_name_cnt;
{
if (head) {
int orig_cnt = ref_name_cnt;
- struct each_ref_fn_sha1_adapter wrapped_append_head_ref =
- {append_head_ref, NULL};
- for_each_ref(
each_ref_fn_adapter, &wrapped_append_head_ref
);
+ for_each_ref(
append_head_ref, NULL
);
sort_ref_range(orig_cnt, ref_name_cnt);
}
if (remotes) {
int orig_cnt = ref_name_cnt;
sort_ref_range(orig_cnt, ref_name_cnt);
}
if (remotes) {
int orig_cnt = ref_name_cnt;
- struct each_ref_fn_sha1_adapter wrapped_append_remote_ref =
- {append_remote_ref, NULL};
- for_each_ref(
each_ref_fn_adapter, &wrapped_append_remote_ref
);
+ for_each_ref(
append_remote_ref, NULL
);
sort_ref_range(orig_cnt, ref_name_cnt);
}
}
sort_ref_range(orig_cnt, ref_name_cnt);
}
}