about summary refs log tree commit diff
path: root/third_party/git/strbuf.c
diff options
context:
space:
mode:
Diffstat (limited to 'third_party/git/strbuf.c')
-rw-r--r--third_party/git/strbuf.c58
1 files changed, 7 insertions, 51 deletions
diff --git a/third_party/git/strbuf.c b/third_party/git/strbuf.c
index bb0065ccaf5b..d30f91685888 100644
--- a/third_party/git/strbuf.c
+++ b/third_party/git/strbuf.c
@@ -479,21 +479,6 @@ void strbuf_addbuf_percentquote(struct strbuf *dst, const struct strbuf *src)
 	}
 }
 
-#define URL_UNSAFE_CHARS " <>\"%{}|\\^`:/?#[]@!$&'()*+,;="
-
-void strbuf_add_percentencode(struct strbuf *dst, const char *src)
-{
-	size_t i, len = strlen(src);
-
-	for (i = 0; i < len; i++) {
-		unsigned char ch = src[i];
-		if (ch <= 0x1F || ch >= 0x7F || strchr(URL_UNSAFE_CHARS, ch))
-			strbuf_addf(dst, "%%%02X", (unsigned char)ch);
-		else
-			strbuf_addch(dst, ch);
-	}
-}
-
 size_t strbuf_fread(struct strbuf *sb, size_t size, FILE *f)
 {
 	size_t res;
@@ -789,10 +774,8 @@ void strbuf_addstr_xml_quoted(struct strbuf *buf, const char *s)
 	}
 }
 
-int is_rfc3986_reserved_or_unreserved(char ch)
+static int is_rfc3986_reserved(char ch)
 {
-	if (is_rfc3986_unreserved(ch))
-		return 1;
 	switch (ch) {
 		case '!': case '*': case '\'': case '(': case ')': case ';':
 		case ':': case '@': case '&': case '=': case '+': case '$':
@@ -802,19 +785,20 @@ int is_rfc3986_reserved_or_unreserved(char ch)
 	return 0;
 }
 
-int is_rfc3986_unreserved(char ch)
+static int is_rfc3986_unreserved(char ch)
 {
 	return isalnum(ch) ||
 		ch == '-' || ch == '_' || ch == '.' || ch == '~';
 }
 
 static void strbuf_add_urlencode(struct strbuf *sb, const char *s, size_t len,
-				 char_predicate allow_unencoded_fn)
+				 int reserved)
 {
 	strbuf_grow(sb, len);
 	while (len--) {
 		char ch = *s++;
-		if (allow_unencoded_fn(ch))
+		if (is_rfc3986_unreserved(ch) ||
+		    (!reserved && is_rfc3986_reserved(ch)))
 			strbuf_addch(sb, ch);
 		else
 			strbuf_addf(sb, "%%%02x", (unsigned char)ch);
@@ -822,9 +806,9 @@ static void strbuf_add_urlencode(struct strbuf *sb, const char *s, size_t len,
 }
 
 void strbuf_addstr_urlencode(struct strbuf *sb, const char *s,
-			     char_predicate allow_unencoded_fn)
+			     int reserved)
 {
-	strbuf_add_urlencode(sb, s, strlen(s), allow_unencoded_fn);
+	strbuf_add_urlencode(sb, s, strlen(s), reserved);
 }
 
 static void strbuf_humanise(struct strbuf *buf, off_t bytes,
@@ -1140,31 +1124,3 @@ int strbuf_normalize_path(struct strbuf *src)
 	strbuf_release(&dst);
 	return 0;
 }
-
-int strbuf_edit_interactively(struct strbuf *buffer, const char *path,
-			      const char *const *env)
-{
-	char *path2 = NULL;
-	int fd, res = 0;
-
-	if (!is_absolute_path(path))
-		path = path2 = xstrdup(git_path("%s", path));
-
-	fd = open(path, O_WRONLY | O_CREAT | O_TRUNC, 0666);
-	if (fd < 0)
-		res = error_errno(_("could not open '%s' for writing"), path);
-	else if (write_in_full(fd, buffer->buf, buffer->len) < 0) {
-		res = error_errno(_("could not write to '%s'"), path);
-		close(fd);
-	} else if (close(fd) < 0)
-		res = error_errno(_("could not close '%s'"), path);
-	else {
-		strbuf_reset(buffer);
-		if (launch_editor(path, buffer, env) < 0)
-			res = error_errno(_("could not edit '%s'"), path);
-		unlink(path);
-	}
-
-	free(path2);
-	return res;
-}