git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* suggestion for git stash
@ 2007-09-30 18:50 Bruno Haible
  2007-09-30 19:59 ` Junio C Hamano
  0 siblings, 1 reply; 6+ messages in thread
From: Bruno Haible @ 2007-09-30 18:50 UTC (permalink / raw)
  To: git

Hi,

"git stash" has the effect of losing the distinction between untracked
changes and changes in the index.

To reproduce:
- Clone the gnulib repository or of any repository with at least 2 files.
- Make changes to two files, say, README and NEWS.
  $ git add README
- $ git status
  now reports:
# On branch master
# Changes to be committed:
#   (use "git reset HEAD <file>..." to unstage)
#
#       modified:   README
#
# Changed but not updated:
#   (use "git add <file>..." to update what will be committed)
#
#       modified:   NEWS
#

- $ git stash
- $ git stash apply
- $ git status
  now reports:
# On branch master
# Changed but not updated:
#   (use "git add <file>..." to update what will be committed)
#
#       modified:   NEWS
#       modified:   README
#
no changes added to commit (use "git add" and/or "git commit -a")

Could "git stash" be changed to memorize which changes were already
scheduled for commit and which didn't?

Bruno

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: suggestion for git stash
  2007-09-30 18:50 suggestion for git stash Bruno Haible
@ 2007-09-30 19:59 ` Junio C Hamano
  2007-09-30 20:28   ` Matthieu Moy
  2007-09-30 20:59   ` Bruno Haible
  0 siblings, 2 replies; 6+ messages in thread
From: Junio C Hamano @ 2007-09-30 19:59 UTC (permalink / raw)
  To: Bruno Haible; +Cc: git

Isn't "stash apply --index" what you talk about?

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: suggestion for git stash
  2007-09-30 19:59 ` Junio C Hamano
@ 2007-09-30 20:28   ` Matthieu Moy
  2007-09-30 20:59   ` Bruno Haible
  1 sibling, 0 replies; 6+ messages in thread
From: Matthieu Moy @ 2007-09-30 20:28 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Bruno Haible, git

Junio C Hamano <gitster@pobox.com> writes:

> Isn't "stash apply --index" what you talk about?

It doesn't seem to be documented in Documentation/git-stash.txt, but
seems to be the answer.

-- 
Matthieu

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: suggestion for git stash
  2007-09-30 19:59 ` Junio C Hamano
  2007-09-30 20:28   ` Matthieu Moy
@ 2007-09-30 20:59   ` Bruno Haible
  2007-09-30 21:29     ` Johannes Schindelin
  1 sibling, 1 reply; 6+ messages in thread
From: Bruno Haible @ 2007-09-30 20:59 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git

Junio C Hamano wrote:
> Isn't "stash apply --index" what you talk about?

Not really:

$ git status
# On branch master
# Changes to be committed:
#   (use "git reset HEAD <file>..." to unstage)
#
#       modified:   README
#
# Changed but not updated:
#   (use "git add <file>..." to update what will be committed)
#
#       modified:   NEWS
#
$ git stash
Saved "WIP on master: 61135ee... Use check_PROGRAMS instead of noinst_PROGRAMS."
HEAD is now at 61135ee... Use check_PROGRAMS instead of noinst_PROGRAMS.
$ git stash apply --index
error: No changes
Conflicts in index. Try without --index.

(This is git version 1.5.3.1.)

I don't know what "git stash apply --index" does, since it's not documented.

Bruno

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: suggestion for git stash
  2007-09-30 20:59   ` Bruno Haible
@ 2007-09-30 21:29     ` Johannes Schindelin
  2007-09-30 22:30       ` [PATCH] git stash: document apply's --index switch Miklos Vajna
  0 siblings, 1 reply; 6+ messages in thread
From: Johannes Schindelin @ 2007-09-30 21:29 UTC (permalink / raw)
  To: Bruno Haible; +Cc: Junio C Hamano, git

Hi,

On Sun, 30 Sep 2007, Bruno Haible wrote:

> I don't know what "git stash apply --index" does, since it's not 
> documented.

It's documented in code ;-)

No, really, what it does is trying to reinstate not only the working 
tree's changes, but also the index' ones.  However, this can fail, when 
you have conflicts (which are stored in the index, where you therefore can 
no longer apply the changes as they were originally).

Now that you know what --index is supposed to do, maybe you are nice 
enough to extend the documentation and post a patch?

Thanks,
Dscho

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH] git stash: document apply's --index switch
  2007-09-30 21:29     ` Johannes Schindelin
@ 2007-09-30 22:30       ` Miklos Vajna
  0 siblings, 0 replies; 6+ messages in thread
From: Miklos Vajna @ 2007-09-30 22:30 UTC (permalink / raw)
  To: git

---

On Sun, Sep 30, 2007 at 10:29:05PM +0100, Johannes Schindelin <Johannes.Schindelin@gmx.de> wrote:
> Now that you know what --index is supposed to do, maybe you are nice
> enough to extend the documentation and post a patch?

something like this?

VMiklos

 Documentation/git-stash.txt |    7 ++++++-
 1 files changed, 6 insertions(+), 1 deletions(-)

diff --git a/Documentation/git-stash.txt b/Documentation/git-stash.txt
index 05f40cf..5723bb0 100644
--- a/Documentation/git-stash.txt
+++ b/Documentation/git-stash.txt
@@ -63,7 +63,7 @@ show [<stash>]::
 	it will accept any format known to `git-diff` (e.g., `git-stash show
 	-p stash@\{1}` to view the second most recent stash in patch form).
 
-apply [<stash>]::
+apply [--index] [<stash>]::
 
 	Restore the changes recorded in the stash on top of the current
 	working tree state.  When no `<stash>` is given, applies the latest
@@ -71,6 +71,11 @@ apply [<stash>]::
 +
 This operation can fail with conflicts; you need to resolve them
 by hand in the working tree.
++
+If the `--index` option is used, then tries to reinstate not only the working
+tree's changes, but also the index's ones. However, this can fail, when you
+have conflicts (which are stored in the index, where you therefore can no
+longer apply the changes as they were originally).
 
 clear::
 	Remove all the stashed states. Note that those states will then
-- 
1.5.3.2.111.g5166-dirty

^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2007-09-30 22:30 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-09-30 18:50 suggestion for git stash Bruno Haible
2007-09-30 19:59 ` Junio C Hamano
2007-09-30 20:28   ` Matthieu Moy
2007-09-30 20:59   ` Bruno Haible
2007-09-30 21:29     ` Johannes Schindelin
2007-09-30 22:30       ` [PATCH] git stash: document apply's --index switch Miklos Vajna

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).