Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Haggerty <mhagger@alum.mit.edu>2016-09-04 19:08:20 +0300
committerJunio C Hamano <gitster@pobox.com>2016-09-10 01:28:12 +0300
commit34c7ad8ffc79c64d7f2261e6bcf6efd3adb16e7e (patch)
tree0840253cc0d710b741245c4b6f4223a799329161 /refs/files-backend.c
parentb9180c9d5d13366e228130eb0d2f1451f2e4dfd6 (diff)
read_raw_ref(): take a (struct ref_store *) argument
And make the function work for submodules. Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'refs/files-backend.c')
-rw-r--r--refs/files-backend.c18
1 files changed, 13 insertions, 5 deletions
diff --git a/refs/files-backend.c b/refs/files-backend.c
index 5a76f893e1..a743da4c1e 100644
--- a/refs/files-backend.c
+++ b/refs/files-backend.c
@@ -1349,11 +1349,12 @@ static int resolve_packed_ref(struct files_ref_store *refs,
return -1;
}
-int read_raw_ref(const char *refname, unsigned char *sha1,
+int read_raw_ref(struct ref_store *ref_store,
+ const char *refname, unsigned char *sha1,
struct strbuf *referent, unsigned int *type)
{
struct files_ref_store *refs =
- get_files_ref_store(NULL, "read_raw_ref");
+ files_downcast(ref_store, 1, "read_raw_ref");
struct strbuf sb_contents = STRBUF_INIT;
struct strbuf sb_path = STRBUF_INIT;
const char *path;
@@ -1365,7 +1366,12 @@ int read_raw_ref(const char *refname, unsigned char *sha1,
*type = 0;
strbuf_reset(&sb_path);
- strbuf_git_path(&sb_path, "%s", refname);
+
+ if (*refs->base.submodule)
+ strbuf_git_path_submodule(&sb_path, refs->base.submodule, "%s", refname);
+ else
+ strbuf_git_path(&sb_path, "%s", refname);
+
path = sb_path.buf;
stat_ref:
@@ -1592,8 +1598,9 @@ static int lock_raw_ref(const char *refname, int mustexist,
unsigned int *type,
struct strbuf *err)
{
+ struct ref_store *ref_store = get_ref_store(NULL);
struct files_ref_store *refs =
- get_files_ref_store(NULL, "lock_raw_ref");
+ files_downcast(ref_store, 0, "lock_raw_ref");
struct ref_lock *lock;
struct strbuf ref_file = STRBUF_INIT;
int attempts_remaining = 3;
@@ -1683,7 +1690,8 @@ retry:
* fear that its value will change.
*/
- if (read_raw_ref(refname, lock->old_oid.hash, referent, type)) {
+ if (read_raw_ref(ref_store, refname,
+ lock->old_oid.hash, referent, type)) {
if (errno == ENOENT) {
if (mustexist) {
/* Garden variety missing reference. */