Thread (1 message) 1 message, 1 author, 2016-12-22

Re: [PATCH bw/realpath-wo-chdir] real_path: canonicalize directory separators in root parts

From: Junio C Hamano <hidden>
Date: 2016-12-22 19:33:53

Brandon Williams [off-list ref] writes:
On 12/22, Johannes Sixt wrote:
quoted
Am 21.12.2016 um 23:33 schrieb Brandon Williams:
quoted
On 12/21, Johannes Sixt wrote:
quoted
+/* copies root part from remaining to resolved, canonicalizing it on the way */
+static void get_root_part(struct strbuf *resolved, struct strbuf *remaining)
+{
+	int offset = offset_1st_component(remaining->buf);
+
+	strbuf_reset(resolved);
+	strbuf_add(resolved, remaining->buf, offset);
+#ifdef GIT_WINDOWS_NATIVE
+	convert_slashes(resolved->buf);
+#endif
So then the only extra cononicalization that is happening here is
converting '\\server\share' to '//server/share'? (or 'c:\' to 'c:/')
Correct. All other directory separators are canonicalized by the
primary function, strbuf_realpath.
Sounds good. Logically everything looks good to me.  And I like that
setting 'resolved' to the root of an abs path is pulled out into a
helper function.  It took me a couple extra seconds to realize that
offset_1st_component returns 0 with a relative path, which makes causes
the call to get_root_part to essentially be a noop (ie nothing is
resolved).

Thanks for helping get this to work on windows!
Thanks, both.  

Let's move the topic with this patch to 'next'.  Further
micro-optimization can be done incrementally if desired.


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