Andrew's git
/
gitweb.git
/ diff
summary
|
log
|
commit
| diff |
tree
commit
grep
author
committer
pickaxe
?
re
refs: add refs_head_ref()
author
Nguyễn Thái Ngọc Duy
<pclouds@gmail.com>
Wed, 23 Aug 2017 12:36:55 +0000
(19:36 +0700)
committer
Junio C Hamano
<gitster@pobox.com>
Thu, 24 Aug 2017 21:47:31 +0000
(14:47 -0700)
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
refs.c
patch
|
blob
|
history
refs.h
patch
|
blob
|
history
raw
|
patch
|
inline
| side by side (parent:
29babbe
)
diff --git
a/refs.c
b/refs.c
index ea8e6b9f427eebb873b15f7bb47e917f60eaa4ea..b3a0a244695e13fe00082a2f2c2b52d11dd99fa4 100644
(file)
--- a/
refs.c
+++ b/
refs.c
@@
-1248,27
+1248,30
@@
int refs_rename_ref_available(struct ref_store *refs,
return ok;
}
return ok;
}
-int
head_ref_submodule(const char *submodule
, each_ref_fn fn, void *cb_data)
+int
refs_head_ref(struct ref_store *refs
, each_ref_fn fn, void *cb_data)
{
struct object_id oid;
int flag;
{
struct object_id oid;
int flag;
- if (submodule) {
- if (resolve_gitlink_ref(submodule, "HEAD", oid.hash) == 0)
- return fn("HEAD", &oid, 0, cb_data);
-
- return 0;
- }
-
- if (!read_ref_full("HEAD", RESOLVE_REF_READING, oid.hash, &flag))
+ if (!refs_read_ref_full(refs, "HEAD", RESOLVE_REF_READING,
+ oid.hash, &flag))
return fn("HEAD", &oid, flag, cb_data);
return 0;
}
return fn("HEAD", &oid, flag, cb_data);
return 0;
}
+int head_ref_submodule(const char *submodule, each_ref_fn fn, void *cb_data)
+{
+ struct ref_store *refs = get_submodule_ref_store(submodule);
+
+ if (!refs)
+ return -1;
+ return refs_head_ref(refs, fn, cb_data);
+}
+
int head_ref(each_ref_fn fn, void *cb_data)
{
int head_ref(each_ref_fn fn, void *cb_data)
{
- return
head_ref_submodule(NULL
, fn, cb_data);
+ return
refs_head_ref(get_main_ref_store()
, fn, cb_data);
}
struct ref_iterator *refs_ref_iterator_begin(
}
struct ref_iterator *refs_ref_iterator_begin(
diff --git
a/refs.h
b/refs.h
index 6daa78eb50ddc195c6d5bfb568d0b05ab08f7923..8073f8ab566ba36c4ae8dc97e6ebfee23ed26521 100644
(file)
--- a/
refs.h
+++ b/
refs.h
@@
-275,6
+275,8
@@
typedef int each_ref_fn(const char *refname,
* modifies the reference also returns a nonzero value to immediately
* stop the iteration. Returned references are sorted.
*/
* modifies the reference also returns a nonzero value to immediately
* stop the iteration. Returned references are sorted.
*/
+int refs_head_ref(struct ref_store *refs,
+ each_ref_fn fn, void *cb_data);
int refs_for_each_ref(struct ref_store *refs,
each_ref_fn fn, void *cb_data);
int refs_for_each_ref_in(struct ref_store *refs, const char *prefix,
int refs_for_each_ref(struct ref_store *refs,
each_ref_fn fn, void *cb_data);
int refs_for_each_ref_in(struct ref_store *refs, const char *prefix,