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

Re: "groups of files" in Git?

From
IDIgor Djordjevic <igor.d.djordjevic@gmail.com>
Date
Jul 13, 2017, 22:39 UTC
Message-ID
<27a3c650-5843-d446-1f59-64fabe5434a3@gmail.com>
In-Reply-To
<xmqqzic8t4oi.fsf@gitster.mtv.corp.google.com>
On 13/07/2017 23:20, Junio C Hamano wrote:
Show 8 quoted lines
> Nikolay Shustov <nikolay.shustov@gmail.com> writes:
>> My question was about how to robustly handle "multiple pending
>> commits" which in Perforce are represented by concept of pending
>> changelists.
> 
> And in Git, they are represented by concept of commits that are not
> yet pushed out to the public repository to become the final history
> carved in stone.

If I may, I don`t think "multiple pending commits" is the issue here (as that is indeed what a private branch is), but more something like "multiple branches pending/live merge branch", or something.

To illustrate, let`s say this is our starting position:
(1)      o---o---o (featureA)
        /         \
    ---o---o---o---M (master, HEAD)
        \         /
         o---o---o (featureB)

We`re currently on commit "M", being a merge commit between our "master" and two feature branches.

Now, what seems lacking, while still possible through a series of steps, is an easy (single step) way to modify current state and commit the change to the _feature branch_, while still being on the "master" branch, still having everything merged in.

So after I make a "featureA" related change while on "M", to be able 
to issue a single command, for example:
 
    $ git commit --branch=featureA
... or:
 
    $ git commit -b featureA 
 
..., where "featureA" would need to be one of the parents of the 
current commit we are at (commit "M", in our case), and get a 
situation like this:
(2)      o---o---o---A (featureA)
        /             \
    ---o---o---o-------M' (master, HEAD)
        \             /
         o---o---o---/ (featureB)

Here, "A" is a new commit/change I`ve just made (while still being on the "master" branch), and it is automatically commited to related "featureA" branch, with merge commit "M" now recreated into "M'" to hold the new "featureA" commit "A" as well.

I guess it would be a kind of alias to doing:
    $ git checkout featureA
    $ git add ...
    $ git commit
    $ git checkout master
    $ git reset --hard HEAD^
    $ git merge featureA featureB

... or something, where last merge step would need to remember previous merge commit "M" parent branches and merge them again to produce an updated "M'" merge commit.

In the same manner, it should be possible to drop a commit from the feature branch in a single step, for example returning to the state as shown in (1), or even "port" it from one branch to the other, like this (without a need for it to be the last commit, even):

(3)      o---o---o---\ (featureA)
        /             \
    ---o---o---o-------M' (master, HEAD)
        \             /
         o---o---A'--o (featureB)

Something like "rebase on steroids", lol, keeping the HEAD where it is, and its merge commit beneath updated.

This indeed seems similar to Mercurial`s patch "queues", except being 
much better as everything is still version controlled at all times, 
no additional tools needed to version control the patches (unless 
that`s already been addressed in Mercurial as well, dunno).
 
And it still seems to be following Git`s "multiple commits per 
feature, single feature per branch" spirit, just allowing for 
easier/faster branch integration testing.

p.s. Even if my short sample might be flawed in one way or the other, it should show the essence of the functionality we`re discussing here, I think.

Regards, Buga

Previous: Junio C HamanoNext: Igor Djordjevic
Message 7 of 26 in “"groups of files" in Git?”
  1. Nikolay ShustovJul 11, 2017
  2. Stefan BellerJul 11, 2017
  3. Nikolay ShustovJul 11, 2017
  4. Junio C HamanoJul 13, 2017
  5. Nikolay ShustovJul 13, 2017
  6. Junio C HamanoJul 13, 2017
  7. Igor DjordjevicJul 13, 2017
  8. Igor DjordjevicJul 13, 2017
  9. Igor DjordjevicJul 13, 2017
  10. Randall S. BeckerJul 11, 2017
  11. Junio C HamanoJul 11, 2017
  12. Nikolay ShustovJul 11, 2017
  13. Stefan BellerJul 11, 2017
  14. Nikolay ShustovJul 11, 2017
  15. Lars SchneiderJul 11, 2017
  16. Nikolay ShustovJul 11, 2017
  17. Lars SchneiderJul 11, 2017
  18. Nikolay ShustovJul 13, 2017
  19. Igor DjordjevicJul 11, 2017
  20. Nikolay ShustovJul 13, 2017
  21. Junio C HamanoJul 13, 2017
  22. Nikolay ShustovJul 13, 2017
  23. Fredrik GustafssonJul 11, 2017
  24. astianJul 11, 2017
  25. Nikolay ShustovJul 13, 2017
  26. Igor DjordjevicJul 13, 2017

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.