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

Re: [PATCH] Fix calling parse_pathspec with no paths nor PATHSPEC_PREFER_* flags

From
Junio C Hamano <gitster@pobox.com>
Date
Oct 22, 2013, 18:16 UTC
Message-ID
<xmqqd2mxtbm8.fsf@gitster.dls.corp.google.com>
In-Reply-To
<xmqq38ntusq6.fsf@gitster.dls.corp.google.com>
Junio C Hamano <gitster@pobox.com> writes:
Show 18 quoted lines
> Nguyễn Thái Ngọc Duy  <pclouds@gmail.com> writes:
>
>> When parse_pathspec() is called with no paths, the behavior could be
>> either return no paths, or return one path that is cwd. Some commands
>> do the former, some the latter. parse_pathspec() itself does not make
>> either the default and requires the caller to specify either flag if
>> it may run into this situation.
>>
>> I've grep'd through all parse_pathspec() call sites. Some pass
>> neither, but those are guaranteed never pass empty path to
>> parse_pathspec(). There are two call sites that may pass empty path
>> and are fixed with this patch.
>>
>> Reported-by: Antoine Pelisse <apelisse@gmail.com>
>> Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
>> ---
>
> Thanks.

I've amended it with the following taken from Antoine's initial report.

diff --git a/t/t4208-log-magic-pathspec.sh b/t/t4208-log-magic-pathspec.sh
index 72300b5..d8f23f4 100755
--- a/t/t4208-log-magic-pathspec.sh
+++ b/t/t4208-log-magic-pathspec.sh
@@ -46,4 +46,19 @@ test_expect_success 'git log HEAD -- :/' '
 	test_cmp expected actual
 '
 
+test_expect_success 'command line pathspec parsing for "git log"' '
+	git reset --hard &&
+	>a &&
+	git add a &&
+	git commit -m "add an empty a" --allow-empty &&
+	echo 1 >a &&
+	git commit -a -m "update a to 1" &&
+	git checkout HEAD^ &&
+	echo 2 >a &&
+	git commit -a -m "update a to 2" &&
+	test_must_fail git merge master &&
+	git add a &&
+	git log --merge -- a
+'
+
 test_done
Previous: Junio C Hamano
Message 4 of 4 in “BUG: PATHSPEC_PREFER_CWD requires arguments”
  1. Antoine PelisseOct 18, 2013
  2. Fix calling parse_pathspec with no paths nor PATHSPEC_PREFER_* flagsNguyễn Thái Ngọc Duy, Oct 19, 2013
  3. Junio C HamanoOct 22, 2013
  4. Junio C HamanoOct 22, 2013

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.