All of lore.kernel.org
 help / color / mirror / Atom feed
From: Lars Hjemli <hjemli@gmail.com>
To: Johannes Schindelin <Johannes.Schindelin@gmx.de>
Cc: Junio C Hamano <gitster@pobox.com>, git@vger.kernel.org
Subject: [PATCH] sha1_file: add function to insert alternate object db
Date: Sun, 18 Jan 2009 16:55:30 +0100	[thread overview]
Message-ID: <1232294130-11409-1-git-send-email-hjemli@gmail.com> (raw)
In-Reply-To: <alpine.DEB.1.00.0901181629590.3586@pacific.mpi-cbg.de>

This function will be used when implementing traversal into submodules.

Signed-off-by: Lars Hjemli <hjemli@gmail.com>
---

On Sun, Jan 18, 2009 at 16:32, Johannes Schindelin <Johannes.Schindelin@gmx.de> wrote:
>
> On Sun, 18 Jan 2009, Lars Hjemli wrote:
>> +int add_alt_odb(const char *path)
>> +{
>> +     return link_alt_odb_entry(path, strlen(path), NULL, 0);
>
> This function can return the error message "object directory %s does not
> exist; check .git/objects/info/alternates."  Maybe you want to change
> that, even if the user you are introducing might not hit that code path.

Something like this, maybe?


 cache.h     |    1 +
 sha1_file.c |   17 ++++++++++++-----
 2 files changed, 13 insertions(+), 5 deletions(-)

diff --git a/cache.h b/cache.h
index 8e1af26..0dbe2a6 100644
--- a/cache.h
+++ b/cache.h
@@ -724,6 +724,7 @@ extern struct alternate_object_database {
 	char base[FLEX_ARRAY]; /* more */
 } *alt_odb_list;
 extern void prepare_alt_odb(void);
+extern int add_alt_odb(const char *path, int quiet);
 extern void add_to_alternates_file(const char *reference);
 typedef int alt_odb_fn(struct alternate_object_database *, void *);
 extern void foreach_alt_odb(alt_odb_fn, void*);
diff --git a/sha1_file.c b/sha1_file.c
index f08493f..4b7e691 100644
--- a/sha1_file.c
+++ b/sha1_file.c
@@ -252,7 +252,8 @@ static void read_info_alternates(const char * alternates, int depth);
  * SHA1, an extra slash for the first level indirection, and the
  * terminating NUL.
  */
-static int link_alt_odb_entry(const char * entry, int len, const char * relative_base, int depth)
+static int link_alt_odb_entry(const char * entry, int len,
+			      const char * relative_base, int depth, int quiet)
 {
 	const char *objdir = get_object_directory();
 	struct alternate_object_database *ent;
@@ -285,9 +286,10 @@ static int link_alt_odb_entry(const char * entry, int len, const char * relative
 
 	/* Detect cases where alternate disappeared */
 	if (!is_directory(ent->base)) {
-		error("object directory %s does not exist; "
-		      "check .git/objects/info/alternates.",
-		      ent->base);
+		if (!quiet)
+			error("object directory %s does not exist; "
+			      "check .git/objects/info/alternates.",
+			      ent->base);
 		free(ent);
 		return -1;
 	}
@@ -347,7 +349,7 @@ static void link_alt_odb_entries(const char *alt, const char *ep, int sep,
 						relative_base, last);
 			} else {
 				link_alt_odb_entry(last, cp - last,
-						relative_base, depth);
+						relative_base, depth, 0);
 			}
 		}
 		while (cp < ep && *cp == sep)
@@ -356,6 +358,11 @@ static void link_alt_odb_entries(const char *alt, const char *ep, int sep,
 	}
 }
 
+int add_alt_odb(const char *path, int quiet)
+{
+	return link_alt_odb_entry(path, strlen(path), NULL, 0, quiet);
+}
+
 static void read_info_alternates(const char * relative_base, int depth)
 {
 	char *map;
-- 
1.6.1.150.g5e733b

      reply	other threads:[~2009-01-18 15:57 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-01-18 10:53 [PATCH 0/3] Implement 'git archive --submodules' Lars Hjemli
2009-01-18 10:53 ` [PATCH 1/3] sha1_file: add function to insert alternate object db Lars Hjemli
2009-01-18 10:53   ` [PATCH 2/3] Teach read_tree_recursive() how to traverse into submodules Lars Hjemli
2009-01-18 10:53     ` [PATCH 3/3] git-archive: add support for --submodules Lars Hjemli
2009-01-18 15:51       ` Johannes Schindelin
2009-01-18 15:48     ` [PATCH 2/3] Teach read_tree_recursive() how to traverse into submodules Johannes Schindelin
2009-01-18 17:45       ` Lars Hjemli
2009-01-18 18:33         ` Johannes Schindelin
2009-01-18 19:45           ` Lars Hjemli
2009-01-18 21:02             ` Johannes Schindelin
2009-01-18 21:31               ` Lars Hjemli
2009-01-18 21:55                 ` Johannes Schindelin
2009-01-18 22:46                   ` Lars Hjemli
2009-01-19  1:24                     ` Johannes Schindelin
2009-01-19  2:01                       ` [PATCH/RFC v1 1/1] bug fix, diff whitespace ignore options Keith Cascio
2009-01-19  3:53                         ` Johannes Schindelin
2009-01-19 18:03                           ` [PATCH/RFC v2 " Keith Cascio
2009-01-19 18:36                             ` Johannes Schindelin
2009-01-20  7:04                             ` Junio C Hamano
2009-01-19  3:02         ` [PATCH 2/3] Teach read_tree_recursive() how to traverse into submodules Junio C Hamano
2009-01-18 16:13     ` René Scharfe
2009-01-18 16:37       ` Lars Hjemli
2009-01-18 19:00         ` Junio C Hamano
2009-01-18 19:50           ` Lars Hjemli
2009-01-18 15:32   ` [PATCH 1/3] sha1_file: add function to insert alternate object db Johannes Schindelin
2009-01-18 15:55     ` Lars Hjemli [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1232294130-11409-1-git-send-email-hjemli@gmail.com \
    --to=hjemli@gmail.com \
    --cc=Johannes.Schindelin@gmx.de \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.