Thread (2 messages) flat view 2 messages, 2 authors, 2016-09-09

Re: [PATCH v3 2/4] cat-file: introduce the --filters option

From: Johannes Schindelin <hidden>
Date: 2016-09-09 16:01:37

Hi Junio,

On Fri, 9 Sep 2016, Junio C Hamano wrote:
Johannes Schindelin [off-list ref] writes:
quoted
+static int filter_object(const char *path, unsigned mode,
+			 const unsigned char *sha1,
+			 char **buf, unsigned long *size)
+{
+	enum object_type type;
+
+	*buf = read_sha1_file(sha1, &type, size);
+	if (!*buf)
+		return error(_("cannot read object %s '%s'"),
+			sha1_to_hex(sha1), path);
+	if (type != OBJ_BLOB) {
+		free(*buf);
+		return error(_("blob expected for %s '%s'"),
+			sha1_to_hex(sha1), path);
+	}
+	if (S_ISREG(mode)) {
+		struct strbuf strbuf = STRBUF_INIT;
+		if (convert_to_working_tree(path, *buf, *size, &strbuf)) {
+			free(*buf);
+			*size = strbuf.len;
+			*buf = strbuf_detach(&strbuf, NULL);
+		}
+	}
This needs to error out when mode is not ISREG just like it errors
out when type is not BLOB.
Are you sure that this is desirable in batch mode?

Ciao,
Dscho
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help