summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Beller <sbeller@google.com>2017-08-29 23:59:26 -0700
committerJunio C Hamano <gitster@pobox.com>2017-09-07 08:49:44 +0900
commit214a11eaa861cb59528a525821edf1e2eb768ba2 (patch)
tree4f395a94919517c715f342372a4e0bc54a0f8edf
parentad99b2f8cbfe82486b8fa2bebe652b159d05d9a5 (diff)
downloadgit-214a11eaa861cb59528a525821edf1e2eb768ba2.tar.gz
sha1_file: add repository argument to stat_sha1_file
Add a repository argument to allow the stat_sha1_file caller to be more specific about which repository to act on. This is a small mechanical change; it doesn't change the implementation to handle repositories other than the_repository yet. As with the previous commits, use a macro to catch callers passing a repository other than the_repository at compile time. Signed-off-by: Stefan Beller <sbeller@google.com> Signed-off-by: Jonathan Nieder <jrnieder@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
-rw-r--r--sha1_file.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/sha1_file.c b/sha1_file.c
index 7938bd2a6f..d3573cec62 100644
--- a/sha1_file.c
+++ b/sha1_file.c
@@ -815,8 +815,9 @@ int git_open_cloexec(const char *name, int flags)
* Note that it may point to static storage and is only valid until another
* call to sha1_file_name(), etc.
*/
-static int stat_sha1_file(const unsigned char *sha1, struct stat *st,
- const char **path)
+#define stat_sha1_file(r, s, st, p) stat_sha1_file_##r(s, st, p)
+static int stat_sha1_file_the_repository(const unsigned char *sha1,
+ struct stat *st, const char **path)
{
struct alternate_object_database *alt;
@@ -1114,7 +1115,7 @@ static int sha1_loose_object_info(const unsigned char *sha1,
if (!oi->typep && !oi->typename && !oi->sizep && !oi->contentp) {
const char *path;
struct stat st;
- if (stat_sha1_file(sha1, &st, &path) < 0)
+ if (stat_sha1_file(the_repository, sha1, &st, &path) < 0)
return -1;
if (oi->disk_sizep)
*oi->disk_sizep = st.st_size;
@@ -1306,7 +1307,7 @@ void *read_sha1_file_extended(const unsigned char *sha1,
die("replacement %s not found for %s",
sha1_to_hex(repl), sha1_to_hex(sha1));
- if (!stat_sha1_file(repl, &st, &path))
+ if (!stat_sha1_file(the_repository, repl, &st, &path))
die("loose object %s (stored in %s) is corrupt",
sha1_to_hex(repl), path);