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

Re: [PATCH] Teach rm to remove submodules when given with a trailing '/'

From
Jens Lehmann <jens.lehmann@web.de>
Date
Oct 30, 2012, 21:28 UTC
Message-ID
<50904677.2020308@web.de>
In-Reply-To
<508E2C05.9010109@viscovery.net>
Am 29.10.2012 08:11, schrieb Johannes Sixt:
Show 13 quoted lines
> Am 10/29/2012 0:28, schrieb Jens Lehmann:
>> +	/* Remove trailing '/' from directories to find submodules in the index */
>> +	for (i = 0; i < argc; i++) {
>> +		size_t pathlen = strlen(argv[i]);
>> +		if (pathlen && is_directory(argv[i]) && (argv[i][pathlen - 1] == '/'))
>> +			argv[i] = xmemdupz(argv[i], pathlen - 1);
>> +	}
>> +
>>  	pathspec = get_pathspec(prefix, argv);
>>  	refresh_index(&the_index, REFRESH_QUIET, pathspec, NULL, NULL);
> 
> That's wrong: Either move the check below get_pathspec() (which normalizes
> backslashes to forward-slashes on Windows) or use is_dir_sep().
Thanks for bringing this up.
> But isn't it somewhat dangerous to check pathspec for existance in the
> worktree without interpreting them? Think of magic pathspec syntax (that
> we do not have yet, but which may materialize sometime in the future).

I have to admit I'm not aware of magic pathspec syntax. Do you happen to have any pointers where I could look at code doing similar things right?

Previous: Johannes SixtNext: Johannes Sixt
Message 3 of 5 in “Teach rm to remove submodules when given with a trailing '/'”
  1. Teach rm to remove submodules when given with a trailing '/'Jens Lehmann, Oct 28, 2012
  2. Johannes SixtOct 29, 2012
  3. Jens LehmannOct 30, 2012
  4. Johannes SixtOct 31, 2012
  5. Teach rm to remove submodules when given with a trailing '/'Jens Lehmann, Nov 22, 2012

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.