-
Notifications
You must be signed in to change notification settings - Fork 142
stash: add --include-untracked support to git stash create #1892
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -632,6 +632,47 @@ test_expect_success 'stash create - no changes' ' | |
test_must_be_empty actual | ||
' | ||
|
||
test_expect_success 'stash create with --include-untracked' ' | ||
git init repo && | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There should not be any need to initialize a repository; When |
||
cd repo && | ||
echo committed >file1 && | ||
git add file1 && | ||
git commit -m "initial commit" && | ||
Comment on lines
+638
to
+640
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It would be more concise to run Also, wouldn't it be possible to reuse what had already been set up by an earlier test case? |
||
echo staged >file2 && | ||
git add file2 && | ||
echo unstaged >file3 && | ||
echo untracked >untracked_file && | ||
STASH_ID=$(git stash create --include-untracked "test message") && | ||
git cat-file -p $STASH_ID >stash_commit && | ||
grep "test message" stash_commit && | ||
grep "parent" stash_commit | wc -l >parent_count && | ||
echo 3 >expect && | ||
test_cmp expect parent_count && | ||
Comment on lines
+648
to
+650
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @SBhojani As pointed out by the test failures, you will want to use |
||
UNTRACKED_TREE=$(git rev-parse $STASH_ID^3^{tree}) && | ||
git ls-tree $UNTRACKED_TREE >files && | ||
grep untracked_file files && | ||
test_path_is_file untracked_file | ||
' | ||
|
||
test_expect_success 'stash create without --include-untracked does not include untracked files' ' | ||
git init repo2 && | ||
cd repo2 && | ||
echo committed >file1 && | ||
git add file1 && | ||
git commit -m "initial commit" && | ||
echo staged >file2 && | ||
git add file2 && | ||
echo unstaged >file3 && | ||
echo untracked >untracked_file && | ||
STASH_ID=$(git stash create "test message") && | ||
git cat-file -p $STASH_ID >stash_commit && | ||
grep "test message" stash_commit && | ||
grep "parent" stash_commit | wc -l >parent_count && | ||
echo 2 >expect && | ||
test_cmp expect parent_count && | ||
test_path_is_file untracked_file | ||
' | ||
|
||
test_expect_success 'stash branch - no stashes on stack, stash-like argument' ' | ||
git stash clear && | ||
test_when_finished "git reset --hard HEAD" && | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wouldn't we want the
--include-untracked
option to be included in the message? In other words: