Skip to content

Commit e0ba5fa

Browse files
committed
unpack-trees: suggesting 'git checkout -m' with its repercussions
This comment is an extention to the already existing stash comment. Added updated comment over the already existing function "setup_unpack_trees_porcelain" with "git checkout -m" and its repercussions I have also mentioned the repercussions of using "-m". Signed-off-by: Arsh Srivastava arshsrivastava00@gmail.com
1 parent d181b93 commit e0ba5fa

File tree

3 files changed

+16
-2
lines changed

3 files changed

+16
-2
lines changed

t/t6439-merge-co-error-msgs.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,9 @@ error: Your local changes to the following files would be overwritten by checkou
7777
rep/one
7878
rep/two
7979
Please commit your changes or stash them before you switch branches.
80+
Try using 'git checkout -m <branch>' for a quick fix.
81+
Please Note :- that using -m (merge) will not save your changes, rather would directly merge them.
82+
Meaning if you are not able to resolve conflicts and does --hard reset your local changes would be gone.
8083
Aborting
8184
EOF
8285

@@ -99,6 +102,9 @@ error: Your local changes to the following files would be overwritten by checkou
99102
rep/one
100103
rep/two
101104
Please commit your changes or stash them before you switch branches.
105+
Try using 'git checkout -m <branch>' for a quick fix.
106+
Please Note :- that using -m (merge) will not save your changes, rather would directly merge them.
107+
Meaning if you are not able to resolve conflicts and does --hard reset your local changes would be gone.
102108
Aborting
103109
EOF
104110

t/t7406-submodule-update.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,9 @@ test_expect_success 'submodule update should fail due to local changes' '
212212
> error: Your local changes to the following files would be overwritten by checkout:
213213
> file
214214
> Please commit your changes or stash them before you switch branches.
215+
> Try using '\''git checkout -m <branch>'\'' for a quick fix.
216+
> Please Note :- that using -m (merge) will not save your changes, rather would directly merge them.
217+
> Meaning if you are not able to resolve conflicts and does --hard reset your local changes would be gone.
215218
> Aborting
216219
> fatal: Unable to checkout OID in submodule path '\''submodule'\''
217220
EOF

unpack-trees.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,8 +128,13 @@ void setup_unpack_trees_porcelain(struct unpack_trees_options *opts,
128128
if (!strcmp(cmd, "checkout"))
129129
msg = advice_enabled(ADVICE_COMMIT_BEFORE_MERGE)
130130
? _("Your local changes to the following files would be overwritten by checkout:\n%%s"
131-
"Please commit your changes or stash them before you switch branches.")
132-
: _("Your local changes to the following files would be overwritten by checkout:\n%%s");
131+
"Please commit your changes or stash them before you switch branches.\n"
132+
"Try using 'git checkout -m <branch>' for a quick fix.\n"
133+
"Please Note :- that using -m (merge) will not save your changes, rather would directly merge them.\n"
134+
"Meaning if you are not able to resolve conflicts and does --hard reset your local changes would be gone."
135+
)
136+
: _("Your local changes to the following files would be overwritten by checkout:\n%%s"
137+
"Please commit your changes or stash them before you switch branches.");
133138
else if (!strcmp(cmd, "merge"))
134139
msg = advice_enabled(ADVICE_COMMIT_BEFORE_MERGE)
135140
? _("Your local changes to the following files would be overwritten by merge:\n%%s"

0 commit comments

Comments
 (0)