author | Junio C Hamano <gitster@pobox.com> | |
Fri, 22 Jul 2011 21:46:28 +0000 (14:46 -0700) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Fri, 22 Jul 2011 21:46:28 +0000 (14:46 -0700) |
* dc/stash-con-untracked:
stash: Add --include-untracked option to stash and remove all untracked files
Conflicts:
git-stash.sh
stash: Add --include-untracked option to stash and remove all untracked files
Conflicts:
git-stash.sh
1 | 2 | |||
---|---|---|---|---|
git-stash.sh | patch | | diff1 | | diff2 | | blob | history |
diff --cc git-stash.sh
index 5619da5c10f968a7eaeeaafc497ed03e763c9439,7ffab6f26fff84c6ebbba7d185b4c69ee95588df..f4e6f05ee212f452a1b3e13c492960a9222029f7
--- 1/git-stash.sh
--- 2/git-stash.sh
+++ b/git-stash.sh
i_tree=$(git write-tree) &&
i_commit=$(printf 'index on %s\n' "$msg" |
git commit-tree $i_tree -p $b_commit) ||
- die "Cannot save the current index state"
+ die "$(gettext "Cannot save the current index state")"
+ if test -n "$untracked"
+ then
+ # Untracked files are stored by themselves in a parentless commit, for
+ # ease of unpacking later.
+ u_commit=$(
+ untracked_files | (
+ export GIT_INDEX_FILE="$TMPindex"
+ rm -f "$TMPindex" &&
+ git update-index -z --add --remove --stdin &&
+ u_tree=$(git write-tree) &&
+ printf 'untracked files on %s\n' "$msg" | git commit-tree $u_tree &&
+ rm -f "$TMPindex"
+ ) ) || die "Cannot save the untracked files"
+
+ untracked_commit_option="-p $u_commit";
+ else
+ untracked_commit_option=
+ fi
+
if test -z "$patch_mode"
then
stash_msg=$(printf 'On %s: %s' "$branch" "$stash_msg")
fi
w_commit=$(printf '%s\n' "$stash_msg" |
- git commit-tree $w_tree -p $b_commit -p $i_commit) ||
- die "$(gettext "Cannot record working tree state")"
- git commit-tree $w_tree -p $b_commit -p $i_commit $untracked_commit_option) ||
- die "Cannot record working tree state"
++ git commit-tree $w_tree -p $b_commit -p $i_commit $untracked_commit_option) ||
++ die "$(gettext "Cannot record working tree state")"
}
save_stash () {
exit 0
fi
test -f "$GIT_DIR/logs/$ref_stash" ||
- clear_stash || die "Cannot initialize stash"
+ clear_stash || die "$(gettext "Cannot initialize stash")"
- create_stash "$stash_msg"
+ create_stash "$stash_msg" $untracked
# Make sure the reflog for stash is kept.
: >>"$GIT_DIR/logs/$ref_stash"