Re: Why is pushing to stash not allowed without an initial commit?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Oct 17, 2024 at 08:51:29PM +0530, Abhijeet Sonar wrote:
> I see that the stash commit has two parents: the initial commit and the
> commit that actually holds the files that were stashed.
>
> If git were to allow a stash entry with no initial commit, it would have to
> create a stash commit with only one parent (i.e. the commit labeled with
> 'index on <branch>'). I wonder if there is a reason this would be bad and
> therefore not allowed?

Right, each stash entry has two parents:

  - The first parent is the state of HEAD in your repository when you
    created the stash entry,

  - The second parent is the state of the index at the same point

So there would be no reasonable value to substitute in for the first
parent in the case where your repository does not yet have any commits.

As a concept, stashing without any commits in your repository doesn't
seem fundamentally flawed, but it would make interpreting other stash
entries substantially more awkward. The current model ensures that if
you look at any stash entry S, then S^1 is the state of HEAD when S was
created, and S^2 is likewise the state of the index.

That changes if you don't have a commit to store in S^1, since now the
interpretation of S^1 depends on how many parents S has to begin with.

Thanks,
Taylor




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux