Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 17 additions & 4 deletions git-branchless-lib/src/core/check_out.rs
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Core changes are in this file. Changes in other files are mainly simple replacement of test ground truth string.

Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,11 @@ pub fn check_out_commit(

if *reset {
if let Some(target) = &target {
try_exit_code!(git_run_info.run(effects, Some(event_tx_id), &["reset", target])?);
try_exit_code!(git_run_info.run(
effects,
Some(event_tx_id),
&["reset", target, "--"]
)?);
}
} else {
let checkout_args = {
Expand All @@ -156,6 +160,7 @@ pub fn check_out_commit(
args.push(OsStr::new(target.as_str()));
}
args.extend(additional_args.iter().map(OsStr::new));
args.push(OsStr::new("--"));
args
};
match git_run_info.run(effects, Some(event_tx_id), checkout_args.as_slice())? {
Expand Down Expand Up @@ -258,7 +263,11 @@ pub fn restore_snapshot(
// Discard any working copy changes. The caller is responsible for having
// snapshotted them if necessary.
try_exit_code!(git_run_info
.run(effects, Some(event_tx_id), &["reset", "--hard", "HEAD"])
.run(
effects,
Some(event_tx_id),
&["reset", "--hard", "HEAD", "--"]
)
.wrap_err("Discarding working copy changes")?);

// Check out the unstaged changes. Note that we don't call `git reset --hard
Expand All @@ -271,7 +280,11 @@ pub fn restore_snapshot(
.run(
effects,
Some(event_tx_id),
&["checkout", &snapshot.commit_unstaged.get_oid().to_string()],
&[
"checkout",
&snapshot.commit_unstaged.get_oid().to_string(),
"--"
],
)
.wrap_err("Checking out unstaged changes (fail if conflict)")?);

Expand All @@ -283,7 +296,7 @@ pub fn restore_snapshot(
.run(
effects,
Some(event_tx_id),
&["reset", &head_commit.get_oid().to_string()],
&["reset", &head_commit.get_oid().to_string(), "--"],
)
.wrap_err("Update HEAD for unstaged changes")?);
}
Expand Down
10 changes: 5 additions & 5 deletions git-branchless-record/tests/test_record.rs
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ fn test_record_stash() -> eyre::Result<()> {
1 file changed, 1 insertion(+)
create mode 100644 test1.txt
branchless: running command: <git-executable> branch -f master f777ecc9b0db5ed372b2615695191a8a17f79f24
branchless: running command: <git-executable> checkout master
branchless: running command: <git-executable> checkout master --
"###);
}

Expand All @@ -322,7 +322,7 @@ fn test_record_stash() -> eyre::Result<()> {
[master 9b6164c] foo
1 file changed, 1 insertion(+), 1 deletion(-)
branchless: running command: <git-executable> branch -f master 62fc20d2a290daea0d52bdc2ed2ad4be6491010e
branchless: running command: <git-executable> checkout master
branchless: running command: <git-executable> checkout master --
"###);
}

Expand Down Expand Up @@ -371,7 +371,7 @@ fn test_record_stash_detached_head() -> eyre::Result<()> {
insta::assert_snapshot!(stdout, @r###"
[detached HEAD 9b6164c] foo
1 file changed, 1 insertion(+), 1 deletion(-)
branchless: running command: <git-executable> checkout 62fc20d2a290daea0d52bdc2ed2ad4be6491010e
branchless: running command: <git-executable> checkout 62fc20d2a290daea0d52bdc2ed2ad4be6491010e --
"###);
}

Expand Down Expand Up @@ -408,7 +408,7 @@ fn test_record_stash_default_message() -> eyre::Result<()> {
[master fd2ffa4] stash: test1.txt (+1/-1)
1 file changed, 1 insertion(+), 1 deletion(-)
branchless: running command: <git-executable> branch -f master 62fc20d2a290daea0d52bdc2ed2ad4be6491010e
branchless: running command: <git-executable> checkout master
branchless: running command: <git-executable> checkout master --
"###);
}

Expand All @@ -435,7 +435,7 @@ fn test_record_create_branch() -> eyre::Result<()> {
{
let (stdout, _stderr) = git.branchless("record", &["-c", "foo", "-m", "Update"])?;
insta::assert_snapshot!(stdout, @r###"
branchless: running command: <git-executable> checkout master -b foo
branchless: running command: <git-executable> checkout master -b foo --
M test1.txt
[foo 836023f] Update
1 file changed, 1 insertion(+), 1 deletion(-)
Expand Down
2 changes: 1 addition & 1 deletion git-branchless-submit/tests/test_github_forge.rs
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ fn test_github_forge_mock_client_closes_pull_requests() -> eyre::Result<()> {
Attempting rebase in-memory...
[1/2] Skipped commit (was already applied upstream): 62fc20d create test1.txt
[2/2] Committed as: fa46633 create test2.txt
branchless: running command: <git-executable> checkout mock-github-username/create-test2-txt
branchless: running command: <git-executable> checkout mock-github-username/create-test2-txt --
Your branch and 'origin/mock-github-username/create-test2-txt' have diverged,
and have 2 and 2 different commits each, respectively.
In-memory rebase succeeded.
Expand Down
6 changes: 3 additions & 3 deletions git-branchless-submit/tests/test_phabricator_forge.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ fn test_submit_phabricator_strategy_working_copy() -> eyre::Result<()> {
[1/2] Committed as: 55af3db create test1.txt
[2/2] Committed as: ccb7fd5 create test2.txt
branchless: processing 2 rewritten commits
branchless: running command: <git-executable> checkout ccb7fd5d90c1888bea906a41c197e9215d6b9bb3
branchless: running command: <git-executable> checkout ccb7fd5d90c1888bea906a41c197e9215d6b9bb3 --
In-memory rebase succeeded.
Setting D0002 as stack root (no dependencies)
Stacking D0003 on top of D0002
Expand Down Expand Up @@ -144,7 +144,7 @@ fn test_submit_phabricator_strategy_worktree() -> eyre::Result<()> {
[1/2] Committed as: 55af3db create test1.txt
[2/2] Committed as: ccb7fd5 create test2.txt
branchless: processing 2 rewritten commits
branchless: running command: <git-executable> checkout ccb7fd5d90c1888bea906a41c197e9215d6b9bb3
branchless: running command: <git-executable> checkout ccb7fd5d90c1888bea906a41c197e9215d6b9bb3 --
In-memory rebase succeeded.
Setting D0002 as stack root (no dependencies)
Stacking D0003 on top of D0002
Expand Down Expand Up @@ -195,7 +195,7 @@ fn test_submit_phabricator_update() -> eyre::Result<()> {
[1/2] Committed as: 55af3db create test1.txt
[2/2] Committed as: ccb7fd5 create test2.txt
branchless: processing 2 rewritten commits
branchless: running command: <git-executable> checkout ccb7fd5d90c1888bea906a41c197e9215d6b9bb3
branchless: running command: <git-executable> checkout ccb7fd5d90c1888bea906a41c197e9215d6b9bb3 --
In-memory rebase succeeded.
Setting D0002 as stack root (no dependencies)
Stacking D0003 on top of D0002
Expand Down
4 changes: 2 additions & 2 deletions git-branchless-test/tests/test_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -867,7 +867,7 @@ done
[2/3] Committed as: 2ee3aea create test2.txt
[3/3] Committed as: 6f48e0a create test3.txt
branchless: processing 3 rewritten commits
branchless: running command: <git-executable> checkout 6f48e0a628753731739619f27107c57f5d0cc1e0
branchless: running command: <git-executable> checkout 6f48e0a628753731739619f27107c57f5d0cc1e0 --
In-memory rebase succeeded.
Fixed 3 commits with bash test.sh:
62fc20d -> 300cb54 create test1.txt
Expand Down Expand Up @@ -1130,7 +1130,7 @@ done
[1/2] Committed as: 300cb54 create test1.txt
[2/2] Committed as: f15b423 descendant commit
branchless: processing 2 rewritten commits
branchless: running command: <git-executable> checkout f15b423404bbebfe4b09e305e074b525d008f44a
branchless: running command: <git-executable> checkout f15b423404bbebfe4b09e305e074b525d008f44a --
In-memory rebase succeeded.
Fixed 2 commits with bash test.sh:
62fc20d -> 300cb54 create test1.txt
Expand Down
Loading
Loading