* [PATCH v2 2/3] stash: Don't overwrite files that have gone from the index
[not found] <9eaa7a4672f2010c9e6e3b3f473f1c09abcfcc45.1271614677.git.charles@hashpling.org>
@ 2010-04-18 18:28 ` Charles Bailey
2010-04-18 23:11 ` Junio C Hamano
2010-04-18 18:28 ` [PATCH v2 3/3] Documentation: Describe other situations where -z affects git diff Charles Bailey
1 sibling, 1 reply; 4+ messages in thread
From: Charles Bailey @ 2010-04-18 18:28 UTC (permalink / raw)
To: git, Junio C Hamano, Thomas Rast, Jeff King
The use of git add -u in create_stash isn't always complete. In
particular, if a file has been removed from the index but changed in the
work tree it will not be added to the stash's saved work tree tree
object. When stash then resets the work tree to match HEAD, any changes
will be lost.
To be complete, any work tree file which differs from HEAD needs to be
saved, regardless of whether it still appears in the index or not.
This is achieved with a combination of a diff against HEAD and a call to
update-index with an explicit list of paths that have changed.
Signed-off-by: Charles Bailey <charles@hashpling.org>
---
Since the last version of this patch I've followed Jeff King's advice
and used update-index. This should be much more portable and reliable.
I believe the fix is now complete as it is, although as I noted we
still have an issue when stashing file <-> directory changes.
git-stash.sh | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/git-stash.sh b/git-stash.sh
index 908aab2..1d95447 100755
--- a/git-stash.sh
+++ b/git-stash.sh
@@ -86,7 +86,7 @@ create_stash () {
GIT_INDEX_FILE="$TMP-index" &&
export GIT_INDEX_FILE &&
git read-tree -m $i_tree &&
- git add -u &&
+ git diff --name-only -z HEAD | git update-index -z --add --remove --stdin &&
git write-tree &&
rm -f "$TMP-index"
) ) ||
--
1.7.1.rc1.241.g4e72f
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH v2 3/3] Documentation: Describe other situations where -z affects git diff
[not found] <9eaa7a4672f2010c9e6e3b3f473f1c09abcfcc45.1271614677.git.charles@hashpling.org>
2010-04-18 18:28 ` [PATCH v2 2/3] stash: Don't overwrite files that have gone from the index Charles Bailey
@ 2010-04-18 18:28 ` Charles Bailey
2010-04-18 20:44 ` Junio C Hamano
1 sibling, 1 reply; 4+ messages in thread
From: Charles Bailey @ 2010-04-18 18:28 UTC (permalink / raw)
To: git, Junio C Hamano, Thomas Rast, Jeff King
-z also alters the behaviour of --name-only and --name-status.
Signed-off-by: Charles Bailey <charles@hashpling.org>
---
As I'm relying on diff --name-only -z "doing the right thing", I quite
wanted it to be part of the documented interface.
Documentation/diff-options.txt | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/Documentation/diff-options.txt b/Documentation/diff-options.txt
index 60e922e..c9c6c2b 100644
--- a/Documentation/diff-options.txt
+++ b/Documentation/diff-options.txt
@@ -94,8 +94,8 @@ Also, when `--raw` or `--numstat` has been given, do not munge
pathnames and use NULs as output field terminators.
endif::git-log[]
ifndef::git-log[]
- When `--raw` or `--numstat` has been given, do not munge
- pathnames and use NULs as output field terminators.
+ When `--raw`, `--numstat`, `--name-only` or `--name-status` has been
+ given, do not munge pathnames and use NULs as output field terminators.
endif::git-log[]
+
Without this option, each pathname output will have TAB, LF, double quotes,
--
1.7.1.rc1.241.g4e72f
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH v2 3/3] Documentation: Describe other situations where -z affects git diff
2010-04-18 18:28 ` [PATCH v2 3/3] Documentation: Describe other situations where -z affects git diff Charles Bailey
@ 2010-04-18 20:44 ` Junio C Hamano
0 siblings, 0 replies; 4+ messages in thread
From: Junio C Hamano @ 2010-04-18 20:44 UTC (permalink / raw)
To: Charles Bailey; +Cc: git, Junio C Hamano, Thomas Rast, Jeff King
Charles Bailey <charles@hashpling.org> writes:
> -z also alters the behaviour of --name-only and --name-status.
>
> Signed-off-by: Charles Bailey <charles@hashpling.org>
Thanks; this is good, independent from the other patches, for 'maint'.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v2 2/3] stash: Don't overwrite files that have gone from the index
2010-04-18 18:28 ` [PATCH v2 2/3] stash: Don't overwrite files that have gone from the index Charles Bailey
@ 2010-04-18 23:11 ` Junio C Hamano
0 siblings, 0 replies; 4+ messages in thread
From: Junio C Hamano @ 2010-04-18 23:11 UTC (permalink / raw)
To: Charles Bailey; +Cc: git, Thomas Rast, Jeff King
Charles Bailey <charles@hashpling.org> writes:
> To be complete, any work tree file which differs from HEAD needs to be
> saved, regardless of whether it still appears in the index or not.
Sounds quite sane.
> - git add -u &&
> + git diff --name-only -z HEAD | git update-index -z --add --remove --stdin &&
Paths that exist in HEAD but not in the index will be caught with this;
what about paths that do not exist in HEAD but is in the index---they will
be kept in the index so they are fine as well. Good.
Thanks.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2010-04-18 23:11 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <9eaa7a4672f2010c9e6e3b3f473f1c09abcfcc45.1271614677.git.charles@hashpling.org>
2010-04-18 18:28 ` [PATCH v2 2/3] stash: Don't overwrite files that have gone from the index Charles Bailey
2010-04-18 23:11 ` Junio C Hamano
2010-04-18 18:28 ` [PATCH v2 3/3] Documentation: Describe other situations where -z affects git diff Charles Bailey
2010-04-18 20:44 ` Junio C Hamano
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).