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

Re: [PATCH 1/1] git-p4: add unshelve command

From
Luke Diamand <luke@diamand.org>
Date
Feb 23, 2018, 17:22 UTC
Message-ID
<CAE5ih7_=0Vn2J+TRnUfzT8TsyfmUa5PYpzviOf_DD+NTZtUZPA@mail.gmail.com>
In-Reply-To
<CAE5ih79E1Z8h+hAgr8zCw7=Dtec6sxT7Xf4cWn8zOLNs=mY1jg@mail.gmail.com>
On 22 February 2018 at 22:28, Luke Diamand <luke@diamand.org> wrote:
Show 29 quoted lines
> On 22 February 2018 at 21:39, Miguel Torroja <miguel.torroja@gmail.com> wrote:
>> Hi Luke,
>>
>> I really like the idea of creating a branch based on a shelved CL (We
>> particularly use shelves all the time), I tested your change and I
>> have some comments.
>>
>>  - I have some concerns about having the same "[git-p4...change =
>> .....]" as if it were a real submitted CL.
>>     One use case I foresee of the new implementation could be to
>> cherry-pick that change on another branch (or current branch) prior to
>> a git p4 submit.
>
> OK, I think we could just not add that in the case of an unshelved commit.
>
>>
>>  - I see that the new p4/unshelve... branch is based on the tip of
>> p4/master by default. what if we set the default to the current HEAD?
>
> There's a "--origin" option you can use to set it to whatever you want.
>
> I started out with HEAD as the default, but then found that to get a
> sensible diff you have to both sync and rebase, which can be quite
> annoying.
>
> In my case, in my early testing, I ended up with a git commit which
> included both the creation of a file, and a subsequent change, even
> though I had only unshelved the subsequent change. That was because
> HEAD didn't include the file creation change (but p4/master _did_).

Discussing this with some of my colleagues, and playing around with it, it seems that what it really needs to do is to figure out the parent commit of the shelved changelist, and use that as the basis for the diff.

Unfortunately, Perforce doesn't have any concept of a "parent commit". One option that would be possible to implement though is to look at the shelved changelist, and foreach file, find the original revision number ("//depot/foo.c#97"). Then "p4 changes //depot/foo.c" would give you the changelist number for that file. Find the most recent P4 changelist, find the git commit corresponding to that, and do the diff against that.

It's pretty clunky, and I'm quite glad I didn't try to do that in the initial revision, as I would surely have given up!

To do it properly of course you need to handle the case where the shelved changelist author had some files at one changelist, and others at another. But I think that's just far too complicated to deal with.

Luke
Previous: Luke DiamandNext: Miguel Torroja
Message 5 of 6 in “git-p4: add unshelve command”
  1. 0/1 git-p4: add unshelve commandLuke Diamand, Feb 22, 2018
  2. 1/1 git-p4: add unshelve commandLuke Diamand, Feb 22, 2018
  3. Miguel TorrojaFeb 22, 2018
  4. Luke DiamandFeb 22, 2018
  5. Luke DiamandFeb 23, 2018
  6. Miguel TorrojaFeb 24, 2018

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.