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

Re: [PATCH] cleans up builtin-mv

From
DRDavid Rientjes <rientjes@google.com>
Date
Aug 18, 2006, 17:07 UTC
Message-ID
<Pine.LNX.4.63.0608180956100.29405@chino.corp.google.com>
In-Reply-To
<Pine.LNX.4.63.0608181137000.28360@wbgn013.biozentrum.uni-wuerzburg.de>
On Fri, 18 Aug 2006, Johannes Schindelin wrote:
Show 6 quoted lines
> First, it _was_ a perl script, which you probably could find out by 
> checking your old git.
> 
> Second, it was rewritten to use Git.pm, and because _that_ did not work, 
> git-mv was rewritten as a builtin.
> 

It shouldn't have ever been a perl script, it should have been /bin/sh. Any shell implementation of this would be significantly faster than the current implementation.

> Not slower? I beg to differ, admitting it is only a few percent. But your 
> statement is obviously uncorrect.
> 

It _is_ slower since it takes considerably more time to do its job than any corresponding shell script.

> Well, the patch has an improvement factor of almost none. I actually read 
> the patch, and asked myself: why would anybody fix a non-problem?
> 
Because it's _wrong_.  Secondly, it's WRONG.
Show 15 quoted lines
> > For example:
> > 	(length = strlen(source[i])) >= 0
> 
> Yes. Taken out of context, this sure sounds silly.
> 
> What you cleverly did not mention: It was inside a
> 
> 	if (!bad &&
> 		(length = strlen(source[i])) >= 0 &&
> 		!strncmp(destination[i], source[i], length) &&
> 		(destination[i][length] == 0 || destination[i][length] == '/'))
> 
> construct. So, we assign the "length" variable only if we have to. And the 
> ">= 0" trick is a common one. I could have done
> 		

This is not a plausible justification _at all_. The idea that "length" is assigned only on the condition that lstat(path, ...) failed does not justify its comparison to >= 0 since this comparison is always true, nor does it justify the assignment of

	char *dir = source[i];
	int len = strlen(dir);
later.
Show 5 quoted lines
> > strlen(source[i]) was assigned to a variable later in the function, this 
> > time called "len" instead.
> 
> Only if source[i] is a directory. So again, we only do it when we need to.
> 

You're completely ignoring the point, and more importantly, ignoring the code path. Your implementation would have _always_ assigned strlen(source[i]) to "length" if lstat returned 0. So at this point in the code, "length" is always equal to strlen(source[i]). But your code introduces another call to strlen, another variable, and another assignment.

> Having said that, I do not have anything against the patch being applied, 
> but if I see more of these i-would-like-the-cupboard-here-not-there 
> patches, I will just not review them any more.
> 

My patch is correct and improves your code. Any criticism for such a patch has purely personal motives, and not technical motives, assigned to it.

		David
Previous: Johannes SchindelinNext: Josef Weidendorfer
Message 4 of 8 in “cleans up builtin-mv”
  1. cleans up builtin-mvDavid Rientjes, Aug 18, 2006
  2. David RientjesAug 18, 2006
  3. Johannes SchindelinAug 18, 2006
  4. David RientjesAug 18, 2006
  5. Josef WeidendorferAug 18, 2006
  6. David RientjesAug 18, 2006
  7. Junio C HamanoAug 18, 2006
  8. Johannes SchindelinAug 19, 2006

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.