From: Junio C Hamano Date: Fri, 22 Jul 2011 21:46:28 +0000 (-0700) Subject: Merge branch 'dc/stash-con-untracked' X-Git-Tag: v1.7.7-rc0~71 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=22f41286be2a07cf96d71a795eaee54b702bb570;p=git.git Merge branch 'dc/stash-con-untracked' * dc/stash-con-untracked: stash: Add --include-untracked option to stash and remove all untracked files Conflicts: git-stash.sh --- 22f41286be2a07cf96d71a795eaee54b702bb570 diff --cc git-stash.sh index 5619da5c1,7ffab6f26..f4e6f05ee --- a/git-stash.sh +++ b/git-stash.sh @@@ -77,8 -85,27 +86,27 @@@ create_stash () 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 @@@ -123,8 -150,8 +151,8 @@@ 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 () { @@@ -183,9 -211,9 +223,9 @@@ 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"