File tree Expand file tree Collapse file tree 3 files changed +25
-21
lines changed Expand file tree Collapse file tree 3 files changed +25
-21
lines changed Original file line number Diff line number Diff line change @@ -1213,6 +1213,26 @@ int normalize_path_copy(char *dst, const char *src)
1213
1213
return normalize_path_copy_len (dst , src , NULL );
1214
1214
}
1215
1215
1216
+ int strbuf_normalize_path (struct strbuf * src )
1217
+ {
1218
+ struct strbuf dst = STRBUF_INIT ;
1219
+
1220
+ strbuf_grow (& dst , src -> len );
1221
+ if (normalize_path_copy (dst .buf , src -> buf ) < 0 ) {
1222
+ strbuf_release (& dst );
1223
+ return -1 ;
1224
+ }
1225
+
1226
+ /*
1227
+ * normalize_path does not tell us the new length, so we have to
1228
+ * compute it by looking for the new NUL it placed
1229
+ */
1230
+ strbuf_setlen (& dst , strlen (dst .buf ));
1231
+ strbuf_swap (src , & dst );
1232
+ strbuf_release (& dst );
1233
+ return 0 ;
1234
+ }
1235
+
1216
1236
/*
1217
1237
* path = Canonical absolute path
1218
1238
* prefixes = string_list containing normalized, absolute paths without
Original file line number Diff line number Diff line change @@ -191,6 +191,11 @@ const char *remove_leading_path(const char *in, const char *prefix);
191
191
const char * relative_path (const char * in , const char * prefix , struct strbuf * sb );
192
192
int normalize_path_copy_len (char * dst , const char * src , int * prefix_len );
193
193
int normalize_path_copy (char * dst , const char * src );
194
+ /**
195
+ * Normalize in-place the path contained in the strbuf. If an error occurs,
196
+ * the contents of "sb" are left untouched, and -1 is returned.
197
+ */
198
+ int strbuf_normalize_path (struct strbuf * src );
194
199
int longest_ancestor_length (const char * path , struct string_list * prefixes );
195
200
char * strip_path_suffix (const char * path , const char * suffix );
196
201
int daemon_avoid_alias (const char * path );
Original file line number Diff line number Diff line change 3
3
#include "environment.h"
4
4
#include "gettext.h"
5
5
#include "hex.h"
6
- #include "repository.h"
7
6
#include "strbuf.h"
8
7
#include "string-list.h"
9
8
#include "utf8.h"
@@ -1089,26 +1088,6 @@ void strbuf_stripspace(struct strbuf *sb, int skip_comments)
1089
1088
strbuf_setlen (sb , j );
1090
1089
}
1091
1090
1092
- int strbuf_normalize_path (struct strbuf * src )
1093
- {
1094
- struct strbuf dst = STRBUF_INIT ;
1095
-
1096
- strbuf_grow (& dst , src -> len );
1097
- if (normalize_path_copy (dst .buf , src -> buf ) < 0 ) {
1098
- strbuf_release (& dst );
1099
- return -1 ;
1100
- }
1101
-
1102
- /*
1103
- * normalize_path does not tell us the new length, so we have to
1104
- * compute it by looking for the new NUL it placed
1105
- */
1106
- strbuf_setlen (& dst , strlen (dst .buf ));
1107
- strbuf_swap (src , & dst );
1108
- strbuf_release (& dst );
1109
- return 0 ;
1110
- }
1111
-
1112
1091
void strbuf_strip_file_from_path (struct strbuf * sb )
1113
1092
{
1114
1093
char * path_sep = find_last_dir_sep (sb -> buf );
You can’t perform that action at this time.
0 commit comments