summaryrefslogtreecommitdiff
path: root/src/util.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/util.c')
-rw-r--r--src/util.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/util.c b/src/util.c
index 3093cd767..90bb3d02a 100644
--- a/src/util.c
+++ b/src/util.c
@@ -435,3 +435,21 @@ int git__parse_bool(int *out, const char *value)
return -1;
}
+
+size_t git__unescape(char *str)
+{
+ char *scan, *pos = str;
+
+ for (scan = str; *scan; pos++, scan++) {
+ if (*scan == '\\' && *(scan + 1) != '\0')
+ scan++; /* skip '\' but include next char */
+ if (pos != scan)
+ *pos = *scan;
+ }
+
+ if (pos != scan) {
+ *pos = '\0';
+ }
+
+ return (pos - str);
+}