* StGIT refreshes all added files - limitation of git-write-tree?
@ 2006-02-15 4:42 Pavel Roskin
2006-02-15 6:20 ` Junio C Hamano
2006-02-15 6:28 ` Shawn Pearce
0 siblings, 2 replies; 4+ messages in thread
From: Pavel Roskin @ 2006-02-15 4:42 UTC (permalink / raw)
To: Catalin Marinas, git
Hello!
Current StGIT would refresh all added files on "stg refresh", even if
they are not specified on the command line. I believe the same is true
for removed files.
That's when it can hurt. I apply a large patch that modifies and adds
several files. I want to split the patch into several StGIT patches by
selecting which files belong to which patch. All files that need to be
modified are already modifies. It's natural that I add new files using
"stg add" at this stage. To me, adding files looks very similar to
modifying them. However, then I create a patch by "stg new" and commit
_some_ files to it using "stg refresh" with those files on the command
line, I discover that _all_ added files have been refreshed.
The only workaround seems to be to add only those files that will be
included in the current patch. The same should be true for renamed
files.
Debugging StGIT shows that it builds correct lists of the files to be
included in the current patch (update_cache in git.py), but they are
never used. Instead, StGIT runs "git-write-tree" without arguments
(commit in git.py). While StGIT is careful to only add user-specified
modified files to the directory cache, it does nothing to the added
files, which are in the cache already.
Purely StGIT way of handling this problem would be to remove added files
from the directory cache if they are not being committed. The problem
is, "stg add" uses the cache, so this would undo "stg add" on files
unused in the current operation. Either StGIT should restore files in
the cache after the refresh, or there should be a separate StGIT cache
that "stg add" would work on. The former is potentially unreliable
(what if refresh is interrupted), the later creates an extra layer,
another directory cache no less, this reducing usability of the pure git
commands.
Another approach would be to get rid of "stg add" and "stg rm" and use
"stg refresh --add" and "stg refresh --rm" to add files to the current
patch or to remove them. It does feel like removal of a useful feature,
since "stg diff" without arguments will no longer show added or removed
files. Adding and removing files would be too immediate compared to
modifying them.
What I really hope to hear is that there is or there will be a git based
solution. Either git-write-tree could be changed to only process files
specified on the command line, or there should be some other command
doing that.
Or maybe git-write-tree and other utilities could be changed to work on
a copy of the index file? I would prefer not to move the
actual .git/index away, but to make a copy for the current "stg refresh"
operation.
--
Regards,
Pavel Roskin
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: StGIT refreshes all added files - limitation of git-write-tree?
2006-02-15 4:42 StGIT refreshes all added files - limitation of git-write-tree? Pavel Roskin
@ 2006-02-15 6:20 ` Junio C Hamano
2006-02-15 9:06 ` Pavel Roskin
2006-02-15 6:28 ` Shawn Pearce
1 sibling, 1 reply; 4+ messages in thread
From: Junio C Hamano @ 2006-02-15 6:20 UTC (permalink / raw)
To: Pavel Roskin; +Cc: git
Pavel Roskin <proski@gnu.org> writes:
> Or maybe git-write-tree and other utilities could be changed to work on
> a copy of the index file? I would prefer not to move the
> actual .git/index away, but to make a copy for the current "stg refresh"
> operation.
There is no need to change the core side.
GIT_INDEX_FILE=temporary-index git-write-tree
would do the job. See the current round of git-commit and how
it handles "git commit --only these files" case.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: StGIT refreshes all added files - limitation of git-write-tree?
2006-02-15 4:42 StGIT refreshes all added files - limitation of git-write-tree? Pavel Roskin
2006-02-15 6:20 ` Junio C Hamano
@ 2006-02-15 6:28 ` Shawn Pearce
1 sibling, 0 replies; 4+ messages in thread
From: Shawn Pearce @ 2006-02-15 6:28 UTC (permalink / raw)
To: Pavel Roskin; +Cc: Catalin Marinas, git
Pavel Roskin <proski@gnu.org> wrote:
> Or maybe git-write-tree and other utilities could be changed to work on
> a copy of the index file? I would prefer not to move the
> actual .git/index away, but to make a copy for the current "stg refresh"
> operation.
git-write-tree pays attention to the GIT_INDEX_FILE environment
variable; if this, GIT_DIR and GIT_OBJECT_DIRECTORY are set you can
redirect git-write-tree to look at a different index. One way to
create a tree from a mixture of your current index and the current
HEAD's tree is to set GIT_INDEX_FILE to a temporary file name
(which doesn't exist), use git-read-tree to load the current tree
unmodified into that index, copy the modified records of interest
from the current index to the temporary index, then git-write-tree
from the temporary index. But now you need to update your current
index with the real SHA1s of the written files.
Somewhat convoluted. I think that git-commit.sh and cg-commit.sh
play such games to do partial commits based on what the user has
passed on the command line or modified in their editor (which is
actually a rather cool feature of Cogito). I'm using a similar
trick in pg to load binary objects from a patch directory (for a
specific use case that I have). git-am.sh uses a similar trick
to perform a 3 way merge if git-apply fails.
--
Shawn.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: StGIT refreshes all added files - limitation of git-write-tree?
2006-02-15 6:20 ` Junio C Hamano
@ 2006-02-15 9:06 ` Pavel Roskin
0 siblings, 0 replies; 4+ messages in thread
From: Pavel Roskin @ 2006-02-15 9:06 UTC (permalink / raw)
To: Junio C Hamano; +Cc: git
On Tue, 2006-02-14 at 22:20 -0800, Junio C Hamano wrote:
> Pavel Roskin <proski@gnu.org> writes:
>
> > Or maybe git-write-tree and other utilities could be changed to work on
> > a copy of the index file? I would prefer not to move the
> > actual .git/index away, but to make a copy for the current "stg refresh"
> > operation.
>
> There is no need to change the core side.
>
> GIT_INDEX_FILE=temporary-index git-write-tree
>
> would do the job. See the current round of git-commit and how
> it handles "git commit --only these files" case.
Thank you! It's comforting to know that the issue is not unique to
StGIT.
--
Regards,
Pavel Roskin
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2006-02-15 9:06 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-02-15 4:42 StGIT refreshes all added files - limitation of git-write-tree? Pavel Roskin
2006-02-15 6:20 ` Junio C Hamano
2006-02-15 9:06 ` Pavel Roskin
2006-02-15 6:28 ` Shawn Pearce
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).