From: Kapil Jain <jkapil.cs@gmail.com>
To: git <git@vger.kernel.org>, Thomas Gummerer <t.gummerer@gmail.com>,
Johannes Schindelin <Johannes.Schindelin@gmx.de>
Subject: [GSoC] [RFC] Proposal: Teach git stash to handle unmerged index entries.
Date: Tue, 9 Apr 2019 21:09:25 +0530 [thread overview]
Message-ID: <CAMknYEMh=CN6GGRPD_fkafHy84e49JY5dK2dAgX6Z7542dJ-Uw@mail.gmail.com> (raw)
Plan to implement the project.
Objective:
Teach git stash to handle unmerged index entries.
Description:
When the index is unmerged, git stash refuses to do anything. That is
unnecessary, though, as it could easily craft e.g. an octopus merge of
the various stages. A subsequent git stash apply can detect that
octopus and re-generate the unmerged index.
Implementation Idea:
Performing an octopus merge of all `stage n` (n>0) unmerged index
entries, could solve the problem, but
What if there are conflicts in merging ?
In this case, we would store(commit) the conflicted state, so they can
be regenerated when git stash is applied.
How to store the conflicted files ?
create a tree from the merge using `git-write-tree`
and then commit that tree using `git-commit-tree`.
Relevant Discussions:
https://colabti.org/irclogger/irclogger_log/git-devel?date=2019-04-05#l92
https://colabti.org/irclogger/irclogger_log/git-devel?date=2019-04-09#l47
Idea Execution Plan: Divided into 2 parts.
Part 1: Store the unmerged index entries this part will work with `git
stash push`
stash.sh: file would be changed to accommodate the below implementation.
Step 1:
Extract all the unmerged entries from index file and store them in a
temporary index file.
read-cache.c: this file is responsible for reading index file,
probably this implementation will end up in this file.
Step 2:
cache-tree.c: study and implement a slightly modified version of the
function `write_index_as_tree()`
int write_index_as_tree(struct object_id *oid, struct index_state
*index_state, const char *index_path, int flags, const char *prefix);
this function is responsible for writing tree from index file.
Currently in this function, the index must be in a fully merged state,
and we are dealing with its exact opposite. So a version to write tree
for unmerged index entries will be implemented.
Step 3:
write-tree.c: some possible changes will go here, so as to use the
modified version of write_index_as_tree() function.
Step 4:
use git-commit-tree to commit the written tree and store the hash in
some file say `stash_conflicting_merge`
Step 5:
Write tests for all implementation till this point.
Part 2: Retrieve the tree hash and regenerate the state of repository
as it was earlier.
Step 6:
Modify implementation of `git stash apply` for regenerating the committed tree.
Step 7:
Write tests.
next reply other threads:[~2019-04-09 15:39 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-04-09 15:39 Kapil Jain [this message]
2019-04-10 4:40 ` [GSoC] [RFC] Proposal: Teach git stash to handle unmerged index entries Junio C Hamano
2019-04-10 5:09 ` Junio C Hamano
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CAMknYEMh=CN6GGRPD_fkafHy84e49JY5dK2dAgX6Z7542dJ-Uw@mail.gmail.com' \
--to=jkapil.cs@gmail.com \
--cc=Johannes.Schindelin@gmx.de \
--cc=git@vger.kernel.org \
--cc=t.gummerer@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).