git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH v2 3/5] sha1_file: improve directories comparison method

From
Junio C Hamano <gitster@pobox.com>
Date
Sep 6, 2011, 16:32 UTC
Message-ID
<7vliu1aay2.fsf@alter.siamese.dyndns.org>
In-Reply-To
<1315304645-12009-4-git-send-email-Hui.Wang@windriver.com>
Wang Hui <Hui.Wang@windriver.com> writes:
Show 12 quoted lines
> From: Hui Wang <Hui.Wang@windriver.com>
>
> In the past, to check if two directory paths are same, we use memcmp()
> to directly compare their path strings, this method can't get an
> accurate result if paths include ".." or "." or redundant slash, e.g.
> current dir is /, "/a/b/c", "/a/b//c/d/e/../.." and "./a/b/f/../c"
> should be the same dir, but current method will identify they are
> different.
>
> Now add a global function is_same_directory() to replace the old
> memcmp() method, this function will change two input paths to real
> path first, then normalized them and compare them.

I do not like this patch _at all_. While it may result in correct result if you _always_ make it absolute before comparing two entities, if you will be storing the normalized result after running the comparison anyway, and if you are comparing against the existing and supposedly already normalized entities with a new candidate, why would anybody sane would want to keep paying for the normalization cost at such a low level?

IOW, you are proposing to do:
	given a new candidate;
	for existing entities:
		normalize existing
                normalize candiate
                compare the above two
                if they are equal:
                	ignore
	if no match found
        	add the normalized candidate to the list
Wouldn't it make much more sense to do this:
	given a new candidate;
        normalize it
	for existing entities:
                compare existing and normalized candidate
		there is no point in normalizing the existing one!
                if they are equal:
                	ignore
	if no match found
        	add the normalized candidate to the list
Previous: Wang HuiNext: Junio C Hamano
Message 7 of 11 in “sha1_file: remove only current repository can have relative path limitation”
  1. 0/5 sha1_file: remove only current repository can have relative path limitationWang Hui, Sep 6, 2011
  2. 1/5 sha1_file cleanup: remove redundant variable checkWang Hui, Sep 6, 2011
  3. 2/5 sha1_file: remove a buggy value settingWang Hui, Sep 6, 2011
  4. 3/5 sha1_file: improve directories comparison methodWang Hui, Sep 6, 2011
  5. 4/5 sha1_file: remove relative entries limitationWang Hui, Sep 6, 2011
  6. 5/5 t5710: add testcase for multi-level relative alternatesWang Hui, Sep 6, 2011
  7. Junio C HamanoSep 6, 2011
  8. Junio C HamanoSep 6, 2011
  9. wanghuiSep 7, 2011
  10. Junio C HamanoSep 6, 2011
  11. wanghuiSep 7, 2011

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.