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

Re: [PATCH 0/2] git-p4: Improve client path detection

From
Junio C Hamano <gitster@pobox.com>
Date
Apr 13, 2015, 03:40 UTC
Message-ID
<xmqqsic44rw5.fsf@gitster.dls.corp.google.com>
In-Reply-To
<20150405235759.392c0f2b@pt-vhugo>
Vitor Antunes <vitor.hda@gmail.com> writes:
Show 23 quoted lines
> Luke Diamand <luke@diamand.org> wrote on Sun, 05 Apr 2015 20:27:11 +0100
>> On 28/03/15 12:28, Vitor Antunes wrote:
>> > I'm adding a test case for a scenario I was confronted with when using branch
>> > detection and a client view specification. It is possible that the implemented
>> > fix may not cover all possible scenarios, but there is no regression in the
>> > available tests.
>>
>> Vitor, one thing I wondered about with this part of the change:
>>
>> -            if entry["depotFile"] == depotPath:
>> +            if entry["depotFile"].find(depotPath) >= 0:
>>
>> Does this mean that if 'p4 where' produces multiple lines of output that
>> this will get confused, as it's just going to search for an instance of
>> depotPath.
>
> The reason why I introduced that was because in the test case I implemented (and
> which reflects a scenario I am confronted with in my workplace) the branches
> have a base directory that is removed in the client view mapping.
> As such, we will have a situation where depotPath is //depot/branch1/ while
> runninng "p4 where" will result in //depot/branch1/base/. To overcome this I
> used find() instead of a direct comparison. Now that I think about that, I could
> probably have used the simpler `if depotPath in entry["depotFile"]`...

Hmph, is this find() under discussion the string.find() that finds a substring? You are doing >=0 comparison here, but with your example that entry["depotFile"] may have "base/" appended to what you expect, the result of running string.find() must yield "0", i.e. no extra prefix string, no? I kind of find it hard to believe that it is OK to have any extra prefix is fine ...

Show 9 quoted lines
>> The example in the Perforce man page for 'p4 where' would trigger this
>> for example:
>>
>> http://www.perforce.com/perforce/r14.2/manuals/cmdref/p4_where.html
>>
>> -//a/b/file.txt //client/a/b/file.txt //home/user/root/a/b/file.txt
>> //a/b/file.txt //client/b/file.txt /home/user/root/b/file.txt
>
> These are examples where a simple comparison as was implemented would work.

... so is this "find()" an attempt to catch prefix like "-"? Even if it that were the reason why you do not limit the acceptable return value from find() to zero, it feels a bit too loose to allow anything if the only thing you want to allow is a single "-" prefix.

Can you explain this a bit better? I cannot quite tell what is going on from what was written in the log message.

Show 8 quoted lines
>> As an experiment, I hacked git-p4 to always use p4Where rather than
>> getClientRoot(), which I would have thought ought to work, but while
>> most of the tests passed, Pete's client-spec torture tests failed.
>
> That was exactly my first approach and got to the same conclusion. I would have
> investigated it further but since I haven't had much free time to invest in
> solving this problem I decided to implement an intermediary solution that would
> not introduce any regressions.
Thanks.
Previous: Vitor AntunesNext: Vitor Antunes
Message 13 of 18 in “git-p4: Improve client path detection”
  1. 0/2 git-p4: Improve client path detectionVitor Antunes, Mar 28, 2015
  2. 1/2 git-p4: Check branch detection and client view togetherVitor Antunes, Mar 28, 2015
  3. 2/2 git-p4: Improve client path detection when branches are usedVitor Antunes, Mar 28, 2015
  4. t9814: Guarantee only one source exists in git-p4 copy testsVitor Antunes, Mar 29, 2015
  5. Junio C HamanoMar 30, 2015
  6. Luke DiamandMar 31, 2015
  7. t9814: Guarantee only one source exists in git-p4 copy testsVitor Antunes, Mar 31, 2015
  8. Luke DiamandApr 4, 2015
  9. Junio C HamanoApr 4, 2015
  10. t9814: Guarantee only one source exists in git-p4 copy testsVitor Antunes, Apr 5, 2015
  11. Luke DiamandApr 5, 2015
  12. Vitor AntunesApr 5, 2015
  13. Junio C HamanoApr 13, 2015
  14. Vitor AntunesApr 18, 2015
  15. git-p4: Improve client path detection when branches are usedVitor Antunes, Apr 18, 2015
  16. Junio C HamanoApr 19, 2015
  17. Vitor AntunesApr 19, 2015
  18. Junio C HamanoApr 20, 2015

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.