{"thread":{"id":"65195","subject":"[PATCH 0/5] Advice on checkout dirty files","startedAt":"2026-03-10T08:51:21Z","lastAt":"2026-03-14T04:27:19Z","messageCount":62,"participants":["Arsh Srivastava via GitGitGadget","LorenzoPegorari via GitGitGadget","K Jayatheerth via GitGitGadget","Junio C Hamano via GitGitGadget","Phillip Wood","Arsh Srivastava","Patrick Steinhardt","Junio C Hamano","Karthik Nayak","Konstantin Ryabitsev"],"isPatch":true,"patchVersion":1,"patchTotal":5},"messages":[{"id":"538365","messageId":"pull.2233.git.git.1773132678.gitgitgadget@gmail.com","threadId":"65195","inReplyTo":null,"subject":"[PATCH 0/5] Advice on checkout dirty files","fromName":"Arsh Srivastava via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2026-03-10T08:51:13Z","receivedAt":"2026-03-10T08:51:21Z","isPatch":true,"sender":{"key":"arshsrivastava00@gmail.com","avatar":"https://gravatar.com/avatar/31a57f3c18a3d49c0601d1863b1cea06242a5d6808b9bcc8fa8a801195d04cc7?d=mp&s=160"},"body":"This is my submission for microproject [GSOC]\n\nThis patch adds a new advice type ADVICE_STASH_BEFORE_CHECKOUT to help users\nwhen they attempt to switch branches with local modifications that would be\noverwritten by the operation.\n\nThe new advice follows the same patterns established by existing advice\nfunctions such as advise_on_updating_sparse_paths(). When triggered, it\nlists the affected files and suggests using git stash push/pop to save and\nrestore local changes.\n\nThe advice can be silenced with:\n\ngit config set advice.stashBeforeCheckout false\n\nChanges:\n\n> advice.h: add ADVICE_STASH_BEFORE_CHECKOUT enum value advice.c: add\n> \"stashBeforeCheckout\" to advice_setting[] and implement\n> advise_on_checkout_dirty_files() function\n> Documentation/config/advice.adoc: document the new advice key\n\nSigned-off-by: Arsh Srivastava arshsrivastava00@gmail.com\n\nArsh Srivastava (1):\n  advice: add stashBeforeCheckout advice for dirty branch switches\n\nJunio C Hamano (1):\n  The 13th batch\n\nK Jayatheerth (1):\n  repo: remove unnecessary variable shadow\n\nLorenzoPegorari (2):\n  diff: handle ANSI escape codes in prefix when calculating diffstat\n    width\n  t4052: test for diffstat width when prefix contains ANSI escape codes\n\n Documentation/RelNotes/2.54.0.adoc | 14 +++++++++++++\n Documentation/config/advice.adoc   |  5 +++++\n advice.c                           | 27 +++++++++++++++++++++++++\n advice.h                           |  2 ++\n builtin/repo.c                     |  1 -\n diff.c                             | 12 ++++-------\n t/t4052-stat-output.sh             | 32 ++++++++++++++++++++++++++++++\n 7 files changed, 84 insertions(+), 9 deletions(-)\n\n\nbase-commit: 3fe08b8fd1f7731edabeab8138547ec88d6407de\nPublished-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-2233%2FArsh123344423%2Fadvice_on_checkout_dirty_files-v1\nFetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-2233/Arsh123344423/advice_on_checkout_dirty_files-v1\nPull-Request: https://github.com/git/git/pull/2233\n-- \ngitgitgadget\n"},{"id":"538366","messageId":"0ed992956e9db5eb6d3172d7a0aebd05f87cdf32.1773132678.git.gitgitgadget@gmail.com","threadId":"65195","inReplyTo":"pull.2233.git.git.1773132678.gitgitgadget@gmail.com","subject":"[PATCH 1/5] diff: handle ANSI escape codes in prefix when calculating diffstat width","fromName":"LorenzoPegorari via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2026-03-10T08:51:14Z","receivedAt":"2026-03-10T08:51:23Z","isPatch":true,"sender":{"key":"lorenzo.pegorari2002@gmail.com","avatar":"https://avatars.githubusercontent.com/u/132087553?v=4"},"body":"From: LorenzoPegorari <lorenzo.pegorari2002@gmail.com>\n\nThe diffstat width is calculated by taking the terminal width and\nincorrectly subtracting the `strlen()` of `line_prefix`, instead of the\nactual display width of `line_prefix`, which may contain ANSI escape\ncodes (e.g., ANSI-colored strings in `log --graph --stat`).\n\nUtilize the display width instead, obtained via `utf8_strnwidth()` with\nthe flag `skip_ansi`.\n\nSigned-off-by: LorenzoPegorari <lorenzo.pegorari2002@gmail.com>\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\n---\n diff.c | 12 ++++--------\n 1 file changed, 4 insertions(+), 8 deletions(-)\n\ndiff --git a/diff.c b/diff.c\nindex 501648a5c4..da6e9e7f49 100644\n--- a/diff.c\n+++ b/diff.c\n@@ -2756,7 +2756,9 @@ static void show_stats(struct diffstat_t *data, struct diff_options *options)\n \tcount = i; /* where we can stop scanning in data->files[] */\n \n \t/*\n-\t * We have width = stat_width or term_columns() columns total.\n+\t * We have width = stat_width or term_columns() columns total minus the\n+\t * length of line_prefix skipping ANSI escape codes to get the display\n+\t * width (e.g., skip ANSI-colored strings in \"log --graph --stat\").\n \t * We want a maximum of min(max_len, stat_name_width) for the name part.\n \t * We want a maximum of min(max_change, stat_graph_width) for the +- part.\n \t * We also need 1 for \" \" and 4 + decimal_width(max_change)\n@@ -2783,14 +2785,8 @@ static void show_stats(struct diffstat_t *data, struct diff_options *options)\n \t * separators and this message, this message will \"overflow\"\n \t * making the line longer than the maximum width.\n \t */\n-\n-\t/*\n-\t * NEEDSWORK: line_prefix is often used for \"log --graph\" output\n-\t * and contains ANSI-colored string.  utf8_strnwidth() should be\n-\t * used to correctly count the display width instead of strlen().\n-\t */\n \tif (options->stat_width == -1)\n-\t\twidth = term_columns() - strlen(line_prefix);\n+\t\twidth = term_columns() - utf8_strnwidth(line_prefix, strlen(line_prefix), 1);\n \telse\n \t\twidth = options->stat_width ? options->stat_width : 80;\n \tnumber_width = decimal_width(max_change) > number_width ?\n-- \ngitgitgadget\n\n"},{"id":"538367","messageId":"c70043a2c0d4e33286508b5699a8bf0285b2f51f.1773132678.git.gitgitgadget@gmail.com","threadId":"65195","inReplyTo":"pull.2233.git.git.1773132678.gitgitgadget@gmail.com","subject":"[PATCH 2/5] t4052: test for diffstat width when prefix contains ANSI escape codes","fromName":"LorenzoPegorari via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2026-03-10T08:51:15Z","receivedAt":"2026-03-10T08:51:24Z","isPatch":true,"sender":{"key":"lorenzo.pegorari2002@gmail.com","avatar":"https://avatars.githubusercontent.com/u/132087553?v=4"},"body":"From: LorenzoPegorari <lorenzo.pegorari2002@gmail.com>\n\nAdd test checking the calculation of the diffstat display width when the\n`line_prefix`, which is text that goes before the diffstat, contains\nANSI escape codes.\n\nThis situation happens, for example, when `git log --stat --graph` is\nexecuted:\n* `--stat` will create a diffstat for each commit\n* `--graph` will stuff `line_prefix` with the graph portion of the log,\n  which contains ANSI escape codes to color the text\n\nSigned-off-by: LorenzoPegorari <lorenzo.pegorari2002@gmail.com>\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\n---\n t/t4052-stat-output.sh | 32 ++++++++++++++++++++++++++++++++\n 1 file changed, 32 insertions(+)\n\ndiff --git a/t/t4052-stat-output.sh b/t/t4052-stat-output.sh\nindex 740bb97091..7c749062e2 100755\n--- a/t/t4052-stat-output.sh\n+++ b/t/t4052-stat-output.sh\n@@ -413,4 +413,36 @@ test_expect_success 'merge --stat respects COLUMNS with long name' '\n \ttest_cmp expect actual\n '\n \n+# We want git-log to print only 1 commit containing a single branch graph and a\n+# diffstat (the diffstat display width, when not manually set through the\n+# option \"--stat-width\", will be automatically calculated).\n+# The diffstat will be only one file, with a placeholder FILENAME, that, with\n+# enough terminal display width, will contain the following line:\n+#     \"<RED>|<RESET>  ${FILENAME} | 0\"\n+# where \"<RED>\" and \"<RESET>\" are ANSI escape codes to color the text.\n+# To calculate the minimium terminal display width MIN_TERM_WIDTH so that the\n+# FILENAME in the diffstat will not be shortened, we take the FILENAME length\n+# and add 9 to it.\n+# To check if the diffstat width, when the line_prefix (the \"<RED>|<RESET>\" of\n+# the graph) contains ANSI escape codes (the ANSI escape codes to color the\n+# text), is calculated correctly, we:\n+#     1. check if it contains the line defined before when using MIN_TERM_WIDTH\n+#     2. check if it contains the line defined before, but with the FILENAME\n+#        shortened by only one character, when using MIN_TERM_WIDTH - 1\n+\n+test_expect_success 'diffstat where line_prefix contains ANSI escape codes is correct width' '\n+\tFILENAME=\"placeholder-text-placeholder-text\" &&\n+\tFILENAME_TRIMMED=\"...eholder-text-placeholder-text\" &&\n+\tMIN_TERM_WIDTH=$((${#FILENAME} + 9)) &&\n+\ttest_config color.diff always &&\n+\tgit commit --allow-empty --allow-empty-message &&\n+\t>${FILENAME} &&\n+\tgit add ${FILENAME} &&\n+\tgit commit --allow-empty-message &&\n+\tCOLUMNS=$((MIN_TERM_WIDTH)) git log --graph --stat -n1 | test_decode_color >out &&\n+\ttest_grep \"<RED>|<RESET>  ${FILENAME} | 0\" out &&\n+\tCOLUMNS=$((MIN_TERM_WIDTH - 1)) git log --graph --stat -n1 | test_decode_color >out &&\n+\ttest_grep \"<RED>|<RESET>  ${FILENAME_TRIMMED} | 0\" out\n+'\n+\n test_done\n-- \ngitgitgadget\n\n"},{"id":"538368","messageId":"185356a454ce8074ee8be5ebfee9e9086ab88b7b.1773132678.git.gitgitgadget@gmail.com","threadId":"65195","inReplyTo":"pull.2233.git.git.1773132678.gitgitgadget@gmail.com","subject":"[PATCH 3/5] repo: remove unnecessary variable shadow","fromName":"K Jayatheerth via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2026-03-10T08:51:16Z","receivedAt":"2026-03-10T08:51:26Z","isPatch":true,"sender":{"key":"jayatheerthkulkarni2005@gmail.com","avatar":"https://avatars.githubusercontent.com/u/148841023?v=4"},"body":"From: K Jayatheerth <jayatheerthkulkarni2005@gmail.com>\n\nAvoid redeclaring `entry` inside the conditional block, removing\nunnecessary variable shadowing and improving code clarity without\nchanging behavior.\n\nSigned-off-by: K Jayatheerth <jayatheerthkulkarni2005@gmail.com>\nAcked-by: Justin Tobler <jltobler@gmail.com>\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\n---\n builtin/repo.c | 1 -\n 1 file changed, 1 deletion(-)\n\ndiff --git a/builtin/repo.c b/builtin/repo.c\nindex f943be7451..fae1141cff 100644\n--- a/builtin/repo.c\n+++ b/builtin/repo.c\n@@ -445,7 +445,6 @@ static void stats_table_print_structure(const struct stats_table *table)\n \t\tconst char *unit = \"\";\n \n \t\tif (entry) {\n-\t\t\tstruct stats_table_entry *entry = item->util;\n \t\t\tvalue = entry->value;\n \t\t\tif (entry->unit)\n \t\t\t\tunit = entry->unit;\n-- \ngitgitgadget\n\n"},{"id":"538369","messageId":"acebdd714ba1e195c0c8a10d936a5075802157f5.1773132678.git.gitgitgadget@gmail.com","threadId":"65195","inReplyTo":"pull.2233.git.git.1773132678.gitgitgadget@gmail.com","subject":"[PATCH 4/5] The 13th batch","fromName":"Junio C Hamano via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2026-03-10T08:51:17Z","receivedAt":"2026-03-10T08:51:27Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"From: Junio C Hamano <gitster@pobox.com>\n\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\n---\n Documentation/RelNotes/2.54.0.adoc | 14 ++++++++++++++\n 1 file changed, 14 insertions(+)\n\ndiff --git a/Documentation/RelNotes/2.54.0.adoc b/Documentation/RelNotes/2.54.0.adoc\nindex fa6e42f3bb..ed5231f82c 100644\n--- a/Documentation/RelNotes/2.54.0.adoc\n+++ b/Documentation/RelNotes/2.54.0.adoc\n@@ -60,6 +60,10 @@ UI, Workflows & Features\n  * \"git config list\" is taught to show the values interpreted for\n    specific type with \"--type=<X>\" option.\n \n+ * \"git add <submodule>\" has been taught to honor\n+   submodule.<name>.ignore that is set to \"all\" (and requires \"git add\n+   -f\" to override it).\n+\n \n Performance, Internal Implementation, Development Support etc.\n --------------------------------------------------------------\n@@ -143,6 +147,11 @@ Performance, Internal Implementation, Development Support etc.\n    were kept track of by a single global variable in-core, which has\n    been corrected by moving it to per-repository data structure.\n \n+ * Use the hook API to replace ad-hoc invocation of hook scripts via\n+   the run_command() API.\n+\n+ * Code refactoring around refs-for-each-* API functions.\n+\n \n Fixes since v2.53\n -----------------\n@@ -234,6 +243,10 @@ Fixes since v2.53\n    to access pack data by \"fsck\" has been updated to avoid this.\n    (merge 13eb65d366 ps/fsck-stream-from-the-right-object-instance later to maint).\n \n+ * \"git log --graph --stat\" did not count the display width of colored\n+   graph part of its own output correctly, which has been corrected.\n+   (merge 064b869efc lp/diff-stat-utf8-display-width-fix later to maint).\n+\n  * Other code cleanup, docfix, build fix, etc.\n    (merge d79fff4a11 jk/remote-tracking-ref-leakfix later to maint).\n    (merge 7a747f972d dd/t5403-modernise later to maint).\n@@ -264,3 +277,4 @@ Fixes since v2.53\n    (merge ed84bc1c0d kh/doc-patch-id-4 later to maint).\n    (merge 7451864bfa sc/pack-redundant-leakfix later to maint).\n    (merge f87593ab1a cx/fetch-display-ubfix later to maint).\n+   (merge a66c8c7f91 jk/repo-structure-cleanup later to maint).\n-- \ngitgitgadget\n\n"},{"id":"538370","messageId":"9ec447e3cb1d5fb0a1fbb76369e186be23efab1a.1773132678.git.gitgitgadget@gmail.com","threadId":"65195","inReplyTo":"pull.2233.git.git.1773132678.gitgitgadget@gmail.com","subject":"[PATCH 5/5] advice: add stashBeforeCheckout advice for dirty branch switches","fromName":"Arsh Srivastava via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2026-03-10T08:51:18Z","receivedAt":"2026-03-10T08:51:29Z","isPatch":true,"sender":{"key":"arshsrivastava00@gmail.com","avatar":"https://gravatar.com/avatar/31a57f3c18a3d49c0601d1863b1cea06242a5d6808b9bcc8fa8a801195d04cc7?d=mp&s=160"},"body":"From: Arsh Srivastava <arshsrivastava00@gmail.com>\n\nAdd a new advice type ADVICE_STASH_BEFORE_CHECKOUT to guide users\nwhen they attempt to switch branches with local modifications that\nwould be overwritten by the operation.\n\nThis includes:\n> New ADVICE_STASH_BEFORE_CHECKOUT enum value in advice.h\n> Corresponding \"stashBeforeCheckout\" entry in advice_setting[]\n> New advise_on_checkout_dirty_files() function that lists the\n  affected files and suggests using git stash push/pop\n> Documentation entry in Documentation/config/advice.txt\n\nThe advice follows existing patterns established by\nadvise_on_updating_sparse_paths() and can be silenced with:\n\n  git config set advice.stashBeforeCheckout false\n\nSigned-off-by: Arsh Srivastava <arshsrivastava00@gmail.com>\n---\n Documentation/config/advice.adoc |  5 +++++\n advice.c                         | 27 +++++++++++++++++++++++++++\n advice.h                         |  2 ++\n 3 files changed, 34 insertions(+)\n\ndiff --git a/Documentation/config/advice.adoc b/Documentation/config/advice.adoc\nindex 257db58918..8752e05636 100644\n--- a/Documentation/config/advice.adoc\n+++ b/Documentation/config/advice.adoc\n@@ -126,6 +126,11 @@ all advice messages.\n \t\tShown when a sparse index is expanded to a full index, which is likely\n \t\tdue to an unexpected set of files existing outside of the\n \t\tsparse-checkout.\n+\tstashBeforeCheckout::\n+\t\tShown when the user attempts to switch branches but has\n+\t\tlocal modifications that would be overwritten by the\n+\t\toperation, to suggest using linkgit:git-stash[1] to\n+\t\tsave changes before switching.\n \tstatusAheadBehind::\n \t\tShown when linkgit:git-status[1] computes the ahead/behind\n \t\tcounts for a local ref compared to its remote tracking ref,\ndiff --git a/advice.c b/advice.c\nindex 0018501b7b..e1264f525c 100644\n--- a/advice.c\n+++ b/advice.c\n@@ -81,6 +81,7 @@ static struct {\n \t[ADVICE_SET_UPSTREAM_FAILURE]\t\t\t= { \"setUpstreamFailure\" },\n \t[ADVICE_SKIPPED_CHERRY_PICKS]\t\t\t= { \"skippedCherryPicks\" },\n \t[ADVICE_SPARSE_INDEX_EXPANDED]\t\t\t= { \"sparseIndexExpanded\" },\n+\t[ADVICE_STASH_BEFORE_CHECKOUT] = { \"stashBeforeCheckout\" },\n \t[ADVICE_STATUS_AHEAD_BEHIND_WARNING]\t\t= { \"statusAheadBehindWarning\" },\n \t[ADVICE_STATUS_HINTS]\t\t\t\t= { \"statusHints\" },\n \t[ADVICE_STATUS_U_OPTION]\t\t\t= { \"statusUoption\" },\n@@ -312,3 +313,29 @@ void advise_on_moving_dirty_path(struct string_list *pathspec_list)\n \t\t\t    \"* Use \\\"git add --sparse <paths>\\\" to update the index\\n\"\n \t\t\t    \"* Use \\\"git sparse-checkout reapply\\\" to apply the sparsity rules\"));\n }\n+\n+void advise_on_checkout_dirty_files(struct string_list *file_list)\n+{\n+    struct string_list_item *item;\n+\n+    if (!file_list->nr)\n+\treturn;\n+\n+    fprintf(stderr, _(\"The following files have local modifications that would\\n\"\n+\t\t      \"be overwritten by switching branches:\\n\"));\n+    for_each_string_list_item(item, file_list)\n+\tfprintf(stderr, \"\\t%s\\n\", item->string);\n+\n+    advise_if_enabled(ADVICE_STASH_BEFORE_CHECKOUT,\n+\t\t      _(\"You can save your local changes before switching by running:\\n\"\n+\t\t\t\"\\n\"\n+\t\t\t\"\\tgit stash push\\n\"\n+\t\t\t\"\\n\"\n+\t\t\t\"Then restore them after switching with:\\n\"\n+\t\t\t\"\\n\"\n+\t\t\t\"\\tgit stash pop\\n\"\n+\t\t\t\"\\n\"\n+\t\t\t\"Or to discard your local changes, use:\\n\"\n+\t\t\t\"\\n\"\n+\t\t\t\"\\tgit checkout -- <file>\"));\n+}\ndiff --git a/advice.h b/advice.h\nindex 8def280688..c035b5d8e3 100644\n--- a/advice.h\n+++ b/advice.h\n@@ -48,6 +48,7 @@ enum advice_type {\n \tADVICE_SET_UPSTREAM_FAILURE,\n \tADVICE_SKIPPED_CHERRY_PICKS,\n \tADVICE_SPARSE_INDEX_EXPANDED,\n+\tADVICE_STASH_BEFORE_CHECKOUT,\n \tADVICE_STATUS_AHEAD_BEHIND_WARNING,\n \tADVICE_STATUS_HINTS,\n \tADVICE_STATUS_U_OPTION,\n@@ -83,5 +84,6 @@ void NORETURN die_ff_impossible(void);\n void advise_on_updating_sparse_paths(struct string_list *pathspec_list);\n void detach_advice(const char *new_name);\n void advise_on_moving_dirty_path(struct string_list *pathspec_list);\n+void advise_on_checkout_dirty_files(struct string_list *file_list);\n \n #endif /* ADVICE_H */\n-- \ngitgitgadget\n"},{"id":"538377","messageId":"5f100fe0-d601-4ee3-adb9-a2458203d10d@gmail.com","threadId":"65195","inReplyTo":"pull.2233.git.git.1773132678.gitgitgadget@gmail.com","subject":"Re: [PATCH 0/5] Advice on checkout dirty files","fromName":"Phillip Wood","fromEmail":"phillip.wood123@gmail.com","sentAt":"2026-03-10T10:33:13Z","receivedAt":"2026-03-10T10:33:20Z","isPatch":true,"sender":{"key":"phillip.wood@dunelm.org.uk","avatar":null},"body":"Hi Arsh\n\nOn 10/03/2026 08:51, Arsh Srivastava via GitGitGadget wrote:\n> This is my submission for microproject [GSOC]\n> \n> This patch adds a new advice type ADVICE_STASH_BEFORE_CHECKOUT to help users\n> when they attempt to switch branches with local modifications that would be\n> overwritten by the operation.\n\nIf the intent is for the user to carry over the changes to the new \nbranch then recommending \"git checkout -m\" might be more convenient \nrather than having to stash, checkout and unstash as three separate steps.\n\nSomething seems to have gone awry with your branch as there are other \npatches in this series. You should rebase your branch onto the upstream \nmaster branch with\n\n     git rebase --onto origin/master HEAD^\n\nand then when you push it double check how many commits there are in the \nsummary of the pull request before submitting.\n\nThanks\n\nPhillip\n\n> The new advice follows the same patterns established by existing advice\n> functions such as advise_on_updating_sparse_paths(). When triggered, it\n> lists the affected files and suggests using git stash push/pop to save and\n> restore local changes.\n> \n> The advice can be silenced with:\n> \n> git config set advice.stashBeforeCheckout false\n> \n> Changes:\n> \n>> advice.h: add ADVICE_STASH_BEFORE_CHECKOUT enum value advice.c: add\n>> \"stashBeforeCheckout\" to advice_setting[] and implement\n>> advise_on_checkout_dirty_files() function\n>> Documentation/config/advice.adoc: document the new advice key\n> \n> Signed-off-by: Arsh Srivastava arshsrivastava00@gmail.com\n> \n> Arsh Srivastava (1):\n>    advice: add stashBeforeCheckout advice for dirty branch switches\n> \n> Junio C Hamano (1):\n>    The 13th batch\n> \n> K Jayatheerth (1):\n>    repo: remove unnecessary variable shadow\n> \n> LorenzoPegorari (2):\n>    diff: handle ANSI escape codes in prefix when calculating diffstat\n>      width\n>    t4052: test for diffstat width when prefix contains ANSI escape codes\n> \n>   Documentation/RelNotes/2.54.0.adoc | 14 +++++++++++++\n>   Documentation/config/advice.adoc   |  5 +++++\n>   advice.c                           | 27 +++++++++++++++++++++++++\n>   advice.h                           |  2 ++\n>   builtin/repo.c                     |  1 -\n>   diff.c                             | 12 ++++-------\n>   t/t4052-stat-output.sh             | 32 ++++++++++++++++++++++++++++++\n>   7 files changed, 84 insertions(+), 9 deletions(-)\n> \n> \n> base-commit: 3fe08b8fd1f7731edabeab8138547ec88d6407de\n> Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-2233%2FArsh123344423%2Fadvice_on_checkout_dirty_files-v1\n> Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-2233/Arsh123344423/advice_on_checkout_dirty_files-v1\n> Pull-Request: https://github.com/git/git/pull/2233\n\n"},{"id":"538378","messageId":"CAOAgETPnZww2vB1zz37nRNEJnmnDjwWyEPDHjRFuijin3memyg@mail.gmail.com","threadId":"65195","inReplyTo":"5f100fe0-d601-4ee3-adb9-a2458203d10d@gmail.com","subject":"Re: [PATCH 0/5] Advice on checkout dirty files","fromName":"Arsh Srivastava","fromEmail":"arshsrivastava00@gmail.com","sentAt":"2026-03-10T10:42:43Z","receivedAt":"2026-03-10T10:42:55Z","isPatch":true,"sender":{"key":"arshsrivastava00@gmail.com","avatar":"https://gravatar.com/avatar/31a57f3c18a3d49c0601d1863b1cea06242a5d6808b9bcc8fa8a801195d04cc7?d=mp&s=160"},"body":"Thank you so much for the advice I will\n> rebase my file’s pointer head\nAnd just wanted to know what do you recommend should be my changed\napproach for me over this pr to make that function useful\n\n\nOn Tue, 10 Mar 2026 at 4:03 PM, Phillip Wood <phillip.wood123@gmail.com> wrote:\n>\n> Hi Arsh\n>\n> On 10/03/2026 08:51, Arsh Srivastava via GitGitGadget wrote:\n> > This is my submission for microproject [GSOC]\n> >\n> > This patch adds a new advice type ADVICE_STASH_BEFORE_CHECKOUT to help users\n> > when they attempt to switch branches with local modifications that would be\n> > overwritten by the operation.\n>\n> If the intent is for the user to carry over the changes to the new\n> branch then recommending \"git checkout -m\" might be more convenient\n> rather than having to stash, checkout and unstash as three separate steps.\n>\n> Something seems to have gone awry with your branch as there are other\n> patches in this series. You should rebase your branch onto the upstream\n> master branch with\n>\n>      git rebase --onto origin/master HEAD^\n>\n> and then when you push it double check how many commits there are in the\n> summary of the pull request before submitting.\n>\n> Thanks\n>\n> Phillip\n>\n> > The new advice follows the same patterns established by existing advice\n> > functions such as advise_on_updating_sparse_paths(). When triggered, it\n> > lists the affected files and suggests using git stash push/pop to save and\n> > restore local changes.\n> >\n> > The advice can be silenced with:\n> >\n> > git config set advice.stashBeforeCheckout false\n> >\n> > Changes:\n> >\n> >> advice.h: add ADVICE_STASH_BEFORE_CHECKOUT enum value advice.c: add\n> >> \"stashBeforeCheckout\" to advice_setting[] and implement\n> >> advise_on_checkout_dirty_files() function\n> >> Documentation/config/advice.adoc: document the new advice key\n> >\n> > Signed-off-by: Arsh Srivastava arshsrivastava00@gmail.com\n> >\n> > Arsh Srivastava (1):\n> >    advice: add stashBeforeCheckout advice for dirty branch switches\n> >\n> > Junio C Hamano (1):\n> >    The 13th batch\n> >\n> > K Jayatheerth (1):\n> >    repo: remove unnecessary variable shadow\n> >\n> > LorenzoPegorari (2):\n> >    diff: handle ANSI escape codes in prefix when calculating diffstat\n> >      width\n> >    t4052: test for diffstat width when prefix contains ANSI escape codes\n> >\n> >   Documentation/RelNotes/2.54.0.adoc | 14 +++++++++++++\n> >   Documentation/config/advice.adoc   |  5 +++++\n> >   advice.c                           | 27 +++++++++++++++++++++++++\n> >   advice.h                           |  2 ++\n> >   builtin/repo.c                     |  1 -\n> >   diff.c                             | 12 ++++-------\n> >   t/t4052-stat-output.sh             | 32 ++++++++++++++++++++++++++++++\n> >   7 files changed, 84 insertions(+), 9 deletions(-)\n> >\n> >\n> > base-commit: 3fe08b8fd1f7731edabeab8138547ec88d6407de\n> > Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-2233%2FArsh123344423%2Fadvice_on_checkout_dirty_files-v1\n> > Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-2233/Arsh123344423/advice_on_checkout_dirty_files-v1\n> > Pull-Request: https://github.com/git/git/pull/2233\n>\n"},{"id":"538379","messageId":"CAOAgETMM_TTQYb618va9knEcwWMwVKmnY7L6FNVcRvnso8JoWQ@mail.gmail.com","threadId":"65195","inReplyTo":"CAOAgETPnZww2vB1zz37nRNEJnmnDjwWyEPDHjRFuijin3memyg@mail.gmail.com","subject":"Re: [PATCH 0/5] Advice on checkout dirty files","fromName":"Arsh Srivastava","fromEmail":"arshsrivastava00@gmail.com","sentAt":"2026-03-10T10:45:41Z","receivedAt":"2026-03-10T10:45:53Z","isPatch":true,"sender":{"key":"arshsrivastava00@gmail.com","avatar":"https://gravatar.com/avatar/31a57f3c18a3d49c0601d1863b1cea06242a5d6808b9bcc8fa8a801195d04cc7?d=mp&s=160"},"body":"Hi,\n\nThank you for the feedback!\n\nThat's a great point. Using \"git checkout -m\" is indeed more convenient\nwhen the user wants to carry their changes over to the new branch, as it\nmerges the local modifications into the new branch in a single step\nrather than requiring stash, checkout, and unstash separately.\n\nI will update the advice message to mention \"git checkout -m\" as the\nprimary suggestion when the intent is to carry changes over, and keep\ngit stash push/pop as an alternative for when the user wants to\ntemporarily set changes aside.\n\nWill send a v2 shortly.\n\nSigned-off-by: Arsh Srivastava <arshsrivastava00@gmail.com>\n"},{"id":"538380","messageId":"pull.2233.v2.git.git.1773140364525.gitgitgadget@gmail.com","threadId":"65195","inReplyTo":"pull.2233.git.git.1773132678.gitgitgadget@gmail.com","subject":"[PATCH v2] advice: add stashBeforeCheckout advice for dirty branch switches","fromName":"Arsh Srivastava via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2026-03-10T10:59:24Z","receivedAt":"2026-03-10T10:59:27Z","isPatch":true,"sender":{"key":"arshsrivastava00@gmail.com","avatar":"https://gravatar.com/avatar/31a57f3c18a3d49c0601d1863b1cea06242a5d6808b9bcc8fa8a801195d04cc7?d=mp&s=160"},"body":"From: Arsh Srivastava <arshsrivastava00@gmail.com>\n\nAdd a new advice type ADVICE_STASH_BEFORE_CHECKOUT to guide users\nwhen they attempt to switch branches with local modifications that\nwould be overwritten by the operation.\n\nThis includes:\n> New ADVICE_STASH_BEFORE_CHECKOUT enum value in advice.h\n> Corresponding \"stashBeforeCheckout\" entry in advice_setting[]\n> New advise_on_checkout_dirty_files() function that lists the\n  affected files and suggests using git stash push/pop\n> Documentation entry in Documentation/config/advice.txt\n\nThe advice follows existing patterns established by\nadvise_on_updating_sparse_paths() and can be silenced with:\n\n  git config set advice.stashBeforeCheckout false\n\nSigned-off-by: Arsh Srivastava <arshsrivastava00@gmail.com>\n---\n    Advice on checkout dirty files\n    \n    This is my submission for microproject [GSOC]\n    \n    This patch adds a new advice type ADVICE_STASH_BEFORE_CHECKOUT to help\n    users when they attempt to switch branches with local modifications that\n    would be overwritten by the operation.\n    \n    The new advice follows the same patterns established by existing advice\n    functions such as advise_on_updating_sparse_paths(). When triggered, it\n    lists the affected files and suggests using git stash push/pop to save\n    and restore local changes.\n    \n    The advice can be silenced with:\n    \n    git config set advice.stashBeforeCheckout false\n    \n    Changes:\n    \n    > advice.h: add ADVICE_STASH_BEFORE_CHECKOUT enum value advice.c: add\n    > \"stashBeforeCheckout\" to advice_setting[] and implement\n    > advise_on_checkout_dirty_files() function\n    > Documentation/config/advice.adoc: document the new advice key\n    \n    Signed-off-by: Arsh Srivastava arshsrivastava00@gmail.com\n\nPublished-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-2233%2FArsh123344423%2Fadvice_on_checkout_dirty_files-v2\nFetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-2233/Arsh123344423/advice_on_checkout_dirty_files-v2\nPull-Request: https://github.com/git/git/pull/2233\n\nRange-diff vs v1:\n\n 1:  0ed992956e < -:  ---------- diff: handle ANSI escape codes in prefix when calculating diffstat width\n 2:  c70043a2c0 < -:  ---------- t4052: test for diffstat width when prefix contains ANSI escape codes\n 3:  185356a454 < -:  ---------- repo: remove unnecessary variable shadow\n 4:  acebdd714b < -:  ---------- The 13th batch\n 5:  9ec447e3cb = 1:  eb5639dbc3 advice: add stashBeforeCheckout advice for dirty branch switches\n\n\n Documentation/config/advice.adoc |  5 +++++\n advice.c                         | 27 +++++++++++++++++++++++++++\n advice.h                         |  2 ++\n 3 files changed, 34 insertions(+)\n\ndiff --git a/Documentation/config/advice.adoc b/Documentation/config/advice.adoc\nindex 257db58918..8752e05636 100644\n--- a/Documentation/config/advice.adoc\n+++ b/Documentation/config/advice.adoc\n@@ -126,6 +126,11 @@ all advice messages.\n \t\tShown when a sparse index is expanded to a full index, which is likely\n \t\tdue to an unexpected set of files existing outside of the\n \t\tsparse-checkout.\n+\tstashBeforeCheckout::\n+\t\tShown when the user attempts to switch branches but has\n+\t\tlocal modifications that would be overwritten by the\n+\t\toperation, to suggest using linkgit:git-stash[1] to\n+\t\tsave changes before switching.\n \tstatusAheadBehind::\n \t\tShown when linkgit:git-status[1] computes the ahead/behind\n \t\tcounts for a local ref compared to its remote tracking ref,\ndiff --git a/advice.c b/advice.c\nindex 0018501b7b..e1264f525c 100644\n--- a/advice.c\n+++ b/advice.c\n@@ -81,6 +81,7 @@ static struct {\n \t[ADVICE_SET_UPSTREAM_FAILURE]\t\t\t= { \"setUpstreamFailure\" },\n \t[ADVICE_SKIPPED_CHERRY_PICKS]\t\t\t= { \"skippedCherryPicks\" },\n \t[ADVICE_SPARSE_INDEX_EXPANDED]\t\t\t= { \"sparseIndexExpanded\" },\n+\t[ADVICE_STASH_BEFORE_CHECKOUT] = { \"stashBeforeCheckout\" },\n \t[ADVICE_STATUS_AHEAD_BEHIND_WARNING]\t\t= { \"statusAheadBehindWarning\" },\n \t[ADVICE_STATUS_HINTS]\t\t\t\t= { \"statusHints\" },\n \t[ADVICE_STATUS_U_OPTION]\t\t\t= { \"statusUoption\" },\n@@ -312,3 +313,29 @@ void advise_on_moving_dirty_path(struct string_list *pathspec_list)\n \t\t\t    \"* Use \\\"git add --sparse <paths>\\\" to update the index\\n\"\n \t\t\t    \"* Use \\\"git sparse-checkout reapply\\\" to apply the sparsity rules\"));\n }\n+\n+void advise_on_checkout_dirty_files(struct string_list *file_list)\n+{\n+    struct string_list_item *item;\n+\n+    if (!file_list->nr)\n+\treturn;\n+\n+    fprintf(stderr, _(\"The following files have local modifications that would\\n\"\n+\t\t      \"be overwritten by switching branches:\\n\"));\n+    for_each_string_list_item(item, file_list)\n+\tfprintf(stderr, \"\\t%s\\n\", item->string);\n+\n+    advise_if_enabled(ADVICE_STASH_BEFORE_CHECKOUT,\n+\t\t      _(\"You can save your local changes before switching by running:\\n\"\n+\t\t\t\"\\n\"\n+\t\t\t\"\\tgit stash push\\n\"\n+\t\t\t\"\\n\"\n+\t\t\t\"Then restore them after switching with:\\n\"\n+\t\t\t\"\\n\"\n+\t\t\t\"\\tgit stash pop\\n\"\n+\t\t\t\"\\n\"\n+\t\t\t\"Or to discard your local changes, use:\\n\"\n+\t\t\t\"\\n\"\n+\t\t\t\"\\tgit checkout -- <file>\"));\n+}\ndiff --git a/advice.h b/advice.h\nindex 8def280688..c035b5d8e3 100644\n--- a/advice.h\n+++ b/advice.h\n@@ -48,6 +48,7 @@ enum advice_type {\n \tADVICE_SET_UPSTREAM_FAILURE,\n \tADVICE_SKIPPED_CHERRY_PICKS,\n \tADVICE_SPARSE_INDEX_EXPANDED,\n+\tADVICE_STASH_BEFORE_CHECKOUT,\n \tADVICE_STATUS_AHEAD_BEHIND_WARNING,\n \tADVICE_STATUS_HINTS,\n \tADVICE_STATUS_U_OPTION,\n@@ -83,5 +84,6 @@ void NORETURN die_ff_impossible(void);\n void advise_on_updating_sparse_paths(struct string_list *pathspec_list);\n void detach_advice(const char *new_name);\n void advise_on_moving_dirty_path(struct string_list *pathspec_list);\n+void advise_on_checkout_dirty_files(struct string_list *file_list);\n \n #endif /* ADVICE_H */\n\nbase-commit: d181b9354cf85b44455ce3ca9e6af0b9559e0ae2\n-- \ngitgitgadget\n"},{"id":"538381","messageId":"CAOAgETOQzQceHbevFa_uTQ6rm=9NzsruPqDOJhnj_E_vUp0Bfg@mail.gmail.com","threadId":"65195","inReplyTo":"CAOAgETOebObfZNWA5LWMDxYv8YXYpbrb9L3_ASs_AbQjiQZYZw@mail.gmail.com","subject":"Re: [PATCH v2] advice: add stashBeforeCheckout advice for dirty branch switches","fromName":"Arsh Srivastava","fromEmail":"arshsrivastava00@gmail.com","sentAt":"2026-03-10T11:04:31Z","receivedAt":"2026-03-10T11:04:44Z","isPatch":true,"sender":{"key":"arshsrivastava00@gmail.com","avatar":"https://gravatar.com/avatar/31a57f3c18a3d49c0601d1863b1cea06242a5d6808b9bcc8fa8a801195d04cc7?d=mp&s=160"},"body":"I have as you mentioned changed\n> Rebased my files pointer\n> Changed advice to git checkout -m\nThank you\n\nSigned-off-by: Arsh Srivastava <arshsrivastava00@gmail.com>\n\nOn Tue, 10 Mar 2026 at 16:33, Arsh Srivastava\n<arshsrivastava00@gmail.com> wrote:\n>\n> I have as you mentioned changed\n> > Rebased my files pointer\n> > Changed advice to git checkout -m\n> Thank you\n>\n> Signed-off-by: Arsh Srivastava <arshsrivastava00@gmail.com>\n>\n> On Tue, 10 Mar 2026 at 4:29 PM, Arsh Srivastava via GitGitGadget <gitgitgadget@gmail.com> wrote:\n>>\n>> From: Arsh Srivastava <arshsrivastava00@gmail.com>\n>>\n>> Add a new advice type ADVICE_STASH_BEFORE_CHECKOUT to guide users\n>> when they attempt to switch branches with local modifications that\n>> would be overwritten by the operation.\n>>\n>> This includes:\n>> > New ADVICE_STASH_BEFORE_CHECKOUT enum value in advice.h\n>> > Corresponding \"stashBeforeCheckout\" entry in advice_setting[]\n>> > New advise_on_checkout_dirty_files() function that lists the\n>>   affected files and suggests using git stash push/pop\n>> > Documentation entry in Documentation/config/advice.txt\n>>\n>> The advice follows existing patterns established by\n>> advise_on_updating_sparse_paths() and can be silenced with:\n>>\n>>   git config set advice.stashBeforeCheckout false\n>>\n>> Signed-off-by: Arsh Srivastava <arshsrivastava00@gmail.com>\n>> ---\n>>     Advice on checkout dirty files\n>>\n>>     This is my submission for microproject [GSOC]\n>>\n>>     This patch adds a new advice type ADVICE_STASH_BEFORE_CHECKOUT to help\n>>     users when they attempt to switch branches with local modifications that\n>>     would be overwritten by the operation.\n>>\n>>     The new advice follows the same patterns established by existing advice\n>>     functions such as advise_on_updating_sparse_paths(). When triggered, it\n>>     lists the affected files and suggests using git stash push/pop to save\n>>     and restore local changes.\n>>\n>>     The advice can be silenced with:\n>>\n>>     git config set advice.stashBeforeCheckout false\n>>\n>>     Changes:\n>>\n>>     > advice.h: add ADVICE_STASH_BEFORE_CHECKOUT enum value advice.c: add\n>>     > \"stashBeforeCheckout\" to advice_setting[] and implement\n>>     > advise_on_checkout_dirty_files() function\n>>     > Documentation/config/advice.adoc: document the new advice key\n>>\n>>     Signed-off-by: Arsh Srivastava arshsrivastava00@gmail.com\n>>\n>> Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-2233%2FArsh123344423%2Fadvice_on_checkout_dirty_files-v2\n>> Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-2233/Arsh123344423/advice_on_checkout_dirty_files-v2\n>> Pull-Request: https://github.com/git/git/pull/2233\n>>\n>> Range-diff vs v1:\n>>\n>>  1:  0ed992956e < -:  ---------- diff: handle ANSI escape codes in prefix when calculating diffstat width\n>>  2:  c70043a2c0 < -:  ---------- t4052: test for diffstat width when prefix contains ANSI escape codes\n>>  3:  185356a454 < -:  ---------- repo: remove unnecessary variable shadow\n>>  4:  acebdd714b < -:  ---------- The 13th batch\n>>  5:  9ec447e3cb = 1:  eb5639dbc3 advice: add stashBeforeCheckout advice for dirty branch switches\n>>\n>>\n>>  Documentation/config/advice.adoc |  5 +++++\n>>  advice.c                         | 27 +++++++++++++++++++++++++++\n>>  advice.h                         |  2 ++\n>>  3 files changed, 34 insertions(+)\n>>\n>> diff --git a/Documentation/config/advice.adoc b/Documentation/config/advice.adoc\n>> index 257db58918..8752e05636 100644\n>> --- a/Documentation/config/advice.adoc\n>> +++ b/Documentation/config/advice.adoc\n>> @@ -126,6 +126,11 @@ all advice messages.\n>>                 Shown when a sparse index is expanded to a full index, which is likely\n>>                 due to an unexpected set of files existing outside of the\n>>                 sparse-checkout.\n>> +       stashBeforeCheckout::\n>> +               Shown when the user attempts to switch branches but has\n>> +               local modifications that would be overwritten by the\n>> +               operation, to suggest using linkgit:git-stash[1] to\n>> +               save changes before switching.\n>>         statusAheadBehind::\n>>                 Shown when linkgit:git-status[1] computes the ahead/behind\n>>                 counts for a local ref compared to its remote tracking ref,\n>> diff --git a/advice.c b/advice.c\n>> index 0018501b7b..e1264f525c 100644\n>> --- a/advice.c\n>> +++ b/advice.c\n>> @@ -81,6 +81,7 @@ static struct {\n>>         [ADVICE_SET_UPSTREAM_FAILURE]                   = { \"setUpstreamFailure\" },\n>>         [ADVICE_SKIPPED_CHERRY_PICKS]                   = { \"skippedCherryPicks\" },\n>>         [ADVICE_SPARSE_INDEX_EXPANDED]                  = { \"sparseIndexExpanded\" },\n>> +       [ADVICE_STASH_BEFORE_CHECKOUT] = { \"stashBeforeCheckout\" },\n>>         [ADVICE_STATUS_AHEAD_BEHIND_WARNING]            = { \"statusAheadBehindWarning\" },\n>>         [ADVICE_STATUS_HINTS]                           = { \"statusHints\" },\n>>         [ADVICE_STATUS_U_OPTION]                        = { \"statusUoption\" },\n>> @@ -312,3 +313,29 @@ void advise_on_moving_dirty_path(struct string_list *pathspec_list)\n>>                             \"* Use \\\"git add --sparse <paths>\\\" to update the index\\n\"\n>>                             \"* Use \\\"git sparse-checkout reapply\\\" to apply the sparsity rules\"));\n>>  }\n>> +\n>> +void advise_on_checkout_dirty_files(struct string_list *file_list)\n>> +{\n>> +    struct string_list_item *item;\n>> +\n>> +    if (!file_list->nr)\n>> +       return;\n>> +\n>> +    fprintf(stderr, _(\"The following files have local modifications that would\\n\"\n>> +                     \"be overwritten by switching branches:\\n\"));\n>> +    for_each_string_list_item(item, file_list)\n>> +       fprintf(stderr, \"\\t%s\\n\", item->string);\n>> +\n>> +    advise_if_enabled(ADVICE_STASH_BEFORE_CHECKOUT,\n>> +                     _(\"You can save your local changes before switching by running:\\n\"\n>> +                       \"\\n\"\n>> +                       \"\\tgit stash push\\n\"\n>> +                       \"\\n\"\n>> +                       \"Then restore them after switching with:\\n\"\n>> +                       \"\\n\"\n>> +                       \"\\tgit stash pop\\n\"\n>> +                       \"\\n\"\n>> +                       \"Or to discard your local changes, use:\\n\"\n>> +                       \"\\n\"\n>> +                       \"\\tgit checkout -- <file>\"));\n>> +}\n>> diff --git a/advice.h b/advice.h\n>> index 8def280688..c035b5d8e3 100644\n>> --- a/advice.h\n>> +++ b/advice.h\n>> @@ -48,6 +48,7 @@ enum advice_type {\n>>         ADVICE_SET_UPSTREAM_FAILURE,\n>>         ADVICE_SKIPPED_CHERRY_PICKS,\n>>         ADVICE_SPARSE_INDEX_EXPANDED,\n>> +       ADVICE_STASH_BEFORE_CHECKOUT,\n>>         ADVICE_STATUS_AHEAD_BEHIND_WARNING,\n>>         ADVICE_STATUS_HINTS,\n>>         ADVICE_STATUS_U_OPTION,\n>> @@ -83,5 +84,6 @@ void NORETURN die_ff_impossible(void);\n>>  void advise_on_updating_sparse_paths(struct string_list *pathspec_list);\n>>  void detach_advice(const char *new_name);\n>>  void advise_on_moving_dirty_path(struct string_list *pathspec_list);\n>> +void advise_on_checkout_dirty_files(struct string_list *file_list);\n>>\n>>  #endif /* ADVICE_H */\n>>\n>> base-commit: d181b9354cf85b44455ce3ca9e6af0b9559e0ae2\n>> --\n>> gitgitgadget\n"},{"id":"538419","messageId":"abAZw-Z1mKf4tAuH@pks.im","threadId":"65195","inReplyTo":"pull.2233.v2.git.git.1773140364525.gitgitgadget@gmail.com","subject":"Re: [PATCH v2] advice: add stashBeforeCheckout advice for dirty branch switches","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2026-03-10T13:16:51Z","receivedAt":"2026-03-10T13:16:58Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"On Tue, Mar 10, 2026 at 10:59:24AM +0000, Arsh Srivastava via GitGitGadget wrote:\n> diff --git a/advice.c b/advice.c\n> index 0018501b7b..e1264f525c 100644\n> --- a/advice.c\n> +++ b/advice.c\n> @@ -81,6 +81,7 @@ static struct {\n>  \t[ADVICE_SET_UPSTREAM_FAILURE]\t\t\t= { \"setUpstreamFailure\" },\n>  \t[ADVICE_SKIPPED_CHERRY_PICKS]\t\t\t= { \"skippedCherryPicks\" },\n>  \t[ADVICE_SPARSE_INDEX_EXPANDED]\t\t\t= { \"sparseIndexExpanded\" },\n> +\t[ADVICE_STASH_BEFORE_CHECKOUT] = { \"stashBeforeCheckout\" },\n>  \t[ADVICE_STATUS_AHEAD_BEHIND_WARNING]\t\t= { \"statusAheadBehindWarning\" },\n>  \t[ADVICE_STATUS_HINTS]\t\t\t\t= { \"statusHints\" },\n>  \t[ADVICE_STATUS_U_OPTION]\t\t\t= { \"statusUoption\" },\n> @@ -312,3 +313,29 @@ void advise_on_moving_dirty_path(struct string_list *pathspec_list)\n>  \t\t\t    \"* Use \\\"git add --sparse <paths>\\\" to update the index\\n\"\n>  \t\t\t    \"* Use \\\"git sparse-checkout reapply\\\" to apply the sparsity rules\"));\n>  }\n> +\n> +void advise_on_checkout_dirty_files(struct string_list *file_list)\n\nHuh. So this patch wires up a new function and advice, but we don't ever\nseem to use it. Am I missing something?\n\nPatrick\n"},{"id":"538431","messageId":"pull.2233.v3.git.git.1773149337.gitgitgadget@gmail.com","threadId":"65195","inReplyTo":"pull.2233.v2.git.git.1773140364525.gitgitgadget@gmail.com","subject":"[PATCH v3 0/2] Advice on checkout dirty files","fromName":"Arsh Srivastava via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2026-03-10T13:28:55Z","receivedAt":"2026-03-10T13:29:00Z","isPatch":true,"sender":{"key":"arshsrivastava00@gmail.com","avatar":"https://gravatar.com/avatar/31a57f3c18a3d49c0601d1863b1cea06242a5d6808b9bcc8fa8a801195d04cc7?d=mp&s=160"},"body":"This is my submission for microproject [GSOC]\n\nThis patch adds a new advice type ADVICE_STASH_BEFORE_CHECKOUT to help users\nwhen they attempt to switch branches with local modifications that would be\noverwritten by the operation.\n\nThe new advice follows the same patterns established by existing advice\nfunctions such as advise_on_updating_sparse_paths(). When triggered, it\nlists the affected files and suggests using git stash push/pop to save and\nrestore local changes.\n\nThe advice can be silenced with:\n\ngit config set advice.stashBeforeCheckout false\n\nChanges:\n\n> advice.h: add ADVICE_STASH_BEFORE_CHECKOUT enum value advice.c: add\n> \"stashBeforeCheckout\" to advice_setting[] and implement\n> advise_on_checkout_dirty_files() function\n> Documentation/config/advice.adoc: document the new advice key\n\nSigned-off-by: Arsh Srivastava arshsrivastava00@gmail.com\n\nArsh Srivastava (2):\n  advice: add stashBeforeCheckout advice for dirty branch switches\n  advice: add stashBeforeCheckout advice for dirty branch switches\n    [GSOC]\n\n Documentation/config/advice.adoc |  5 +++++\n advice.c                         | 20 ++++++++++++++++++++\n advice.h                         |  2 ++\n 3 files changed, 27 insertions(+)\n\n\nbase-commit: d181b9354cf85b44455ce3ca9e6af0b9559e0ae2\nPublished-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-2233%2FArsh123344423%2Fadvice_on_checkout_dirty_files-v3\nFetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-2233/Arsh123344423/advice_on_checkout_dirty_files-v3\nPull-Request: https://github.com/git/git/pull/2233\n\nRange-diff vs v2:\n\n 1:  eb5639dbc3 = 1:  eb5639dbc3 advice: add stashBeforeCheckout advice for dirty branch switches\n -:  ---------- > 2:  e88c851701 advice: add stashBeforeCheckout advice for dirty branch switches [GSOC]\n\n-- \ngitgitgadget\n"},{"id":"538432","messageId":"eb5639dbc3571fde15f2d93cf2d137b8df775d2f.1773149337.git.gitgitgadget@gmail.com","threadId":"65195","inReplyTo":"pull.2233.v3.git.git.1773149337.gitgitgadget@gmail.com","subject":"[PATCH v3 1/2] advice: add stashBeforeCheckout advice for dirty branch switches","fromName":"Arsh Srivastava via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2026-03-10T13:28:56Z","receivedAt":"2026-03-10T13:29:02Z","isPatch":true,"sender":{"key":"arshsrivastava00@gmail.com","avatar":"https://gravatar.com/avatar/31a57f3c18a3d49c0601d1863b1cea06242a5d6808b9bcc8fa8a801195d04cc7?d=mp&s=160"},"body":"From: Arsh Srivastava <arshsrivastava00@gmail.com>\n\nAdd a new advice type ADVICE_STASH_BEFORE_CHECKOUT to guide users\nwhen they attempt to switch branches with local modifications that\nwould be overwritten by the operation.\n\nThis includes:\n> New ADVICE_STASH_BEFORE_CHECKOUT enum value in advice.h\n> Corresponding \"stashBeforeCheckout\" entry in advice_setting[]\n> New advise_on_checkout_dirty_files() function that lists the\n  affected files and suggests using git stash push/pop\n> Documentation entry in Documentation/config/advice.txt\n\nThe advice follows existing patterns established by\nadvise_on_updating_sparse_paths() and can be silenced with:\n\n  git config set advice.stashBeforeCheckout false\n\nSigned-off-by: Arsh Srivastava <arshsrivastava00@gmail.com>\n---\n Documentation/config/advice.adoc |  5 +++++\n advice.c                         | 27 +++++++++++++++++++++++++++\n advice.h                         |  2 ++\n 3 files changed, 34 insertions(+)\n\ndiff --git a/Documentation/config/advice.adoc b/Documentation/config/advice.adoc\nindex 257db58918..8752e05636 100644\n--- a/Documentation/config/advice.adoc\n+++ b/Documentation/config/advice.adoc\n@@ -126,6 +126,11 @@ all advice messages.\n \t\tShown when a sparse index is expanded to a full index, which is likely\n \t\tdue to an unexpected set of files existing outside of the\n \t\tsparse-checkout.\n+\tstashBeforeCheckout::\n+\t\tShown when the user attempts to switch branches but has\n+\t\tlocal modifications that would be overwritten by the\n+\t\toperation, to suggest using linkgit:git-stash[1] to\n+\t\tsave changes before switching.\n \tstatusAheadBehind::\n \t\tShown when linkgit:git-status[1] computes the ahead/behind\n \t\tcounts for a local ref compared to its remote tracking ref,\ndiff --git a/advice.c b/advice.c\nindex 0018501b7b..e1264f525c 100644\n--- a/advice.c\n+++ b/advice.c\n@@ -81,6 +81,7 @@ static struct {\n \t[ADVICE_SET_UPSTREAM_FAILURE]\t\t\t= { \"setUpstreamFailure\" },\n \t[ADVICE_SKIPPED_CHERRY_PICKS]\t\t\t= { \"skippedCherryPicks\" },\n \t[ADVICE_SPARSE_INDEX_EXPANDED]\t\t\t= { \"sparseIndexExpanded\" },\n+\t[ADVICE_STASH_BEFORE_CHECKOUT] = { \"stashBeforeCheckout\" },\n \t[ADVICE_STATUS_AHEAD_BEHIND_WARNING]\t\t= { \"statusAheadBehindWarning\" },\n \t[ADVICE_STATUS_HINTS]\t\t\t\t= { \"statusHints\" },\n \t[ADVICE_STATUS_U_OPTION]\t\t\t= { \"statusUoption\" },\n@@ -312,3 +313,29 @@ void advise_on_moving_dirty_path(struct string_list *pathspec_list)\n \t\t\t    \"* Use \\\"git add --sparse <paths>\\\" to update the index\\n\"\n \t\t\t    \"* Use \\\"git sparse-checkout reapply\\\" to apply the sparsity rules\"));\n }\n+\n+void advise_on_checkout_dirty_files(struct string_list *file_list)\n+{\n+    struct string_list_item *item;\n+\n+    if (!file_list->nr)\n+\treturn;\n+\n+    fprintf(stderr, _(\"The following files have local modifications that would\\n\"\n+\t\t      \"be overwritten by switching branches:\\n\"));\n+    for_each_string_list_item(item, file_list)\n+\tfprintf(stderr, \"\\t%s\\n\", item->string);\n+\n+    advise_if_enabled(ADVICE_STASH_BEFORE_CHECKOUT,\n+\t\t      _(\"You can save your local changes before switching by running:\\n\"\n+\t\t\t\"\\n\"\n+\t\t\t\"\\tgit stash push\\n\"\n+\t\t\t\"\\n\"\n+\t\t\t\"Then restore them after switching with:\\n\"\n+\t\t\t\"\\n\"\n+\t\t\t\"\\tgit stash pop\\n\"\n+\t\t\t\"\\n\"\n+\t\t\t\"Or to discard your local changes, use:\\n\"\n+\t\t\t\"\\n\"\n+\t\t\t\"\\tgit checkout -- <file>\"));\n+}\ndiff --git a/advice.h b/advice.h\nindex 8def280688..c035b5d8e3 100644\n--- a/advice.h\n+++ b/advice.h\n@@ -48,6 +48,7 @@ enum advice_type {\n \tADVICE_SET_UPSTREAM_FAILURE,\n \tADVICE_SKIPPED_CHERRY_PICKS,\n \tADVICE_SPARSE_INDEX_EXPANDED,\n+\tADVICE_STASH_BEFORE_CHECKOUT,\n \tADVICE_STATUS_AHEAD_BEHIND_WARNING,\n \tADVICE_STATUS_HINTS,\n \tADVICE_STATUS_U_OPTION,\n@@ -83,5 +84,6 @@ void NORETURN die_ff_impossible(void);\n void advise_on_updating_sparse_paths(struct string_list *pathspec_list);\n void detach_advice(const char *new_name);\n void advise_on_moving_dirty_path(struct string_list *pathspec_list);\n+void advise_on_checkout_dirty_files(struct string_list *file_list);\n \n #endif /* ADVICE_H */\n-- \ngitgitgadget\n\n"},{"id":"538433","messageId":"e88c85170147a7c5d44640cba0c48aa686e23f17.1773149337.git.gitgitgadget@gmail.com","threadId":"65195","inReplyTo":"pull.2233.v3.git.git.1773149337.gitgitgadget@gmail.com","subject":"[PATCH v3 2/2] advice: add stashBeforeCheckout advice for dirty branch switches [GSOC]","fromName":"Arsh Srivastava via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2026-03-10T13:28:57Z","receivedAt":"2026-03-10T13:29:05Z","isPatch":true,"sender":{"key":"arshsrivastava00@gmail.com","avatar":"https://gravatar.com/avatar/31a57f3c18a3d49c0601d1863b1cea06242a5d6808b9bcc8fa8a801195d04cc7?d=mp&s=160"},"body":"From: Arsh Srivastava <arshsrivastava00@gmail.com>\n\nAdd a new advice type ADVICE_STASH_BEFORE_CHECKOUT to guide users\nwhen they attempt to switch branches with local modifications that\nwould be overwritten by the operation.\n\nThe advice suggests using \"git checkout -m\" to carry local changes\nover to the new branch in a single step.\n\nThe advice can be silenced with:\n\n  git config set advice.stashBeforeCheckout false\n\nChanges:\n- advice.h: add ADVICE_STASH_BEFORE_CHECKOUT enum value\n- advice.c: add \"stashBeforeCheckout\" to advice_setting[] and implement\n  advise_on_checkout_dirty_files() function\n- Documentation/config/advice.adoc: document the new advice key\n\nSigned-off-by: Arsh Srivastava <arshsrivastava00@gmail.com>\n---\n advice.c | 13 +++----------\n 1 file changed, 3 insertions(+), 10 deletions(-)\n\ndiff --git a/advice.c b/advice.c\nindex e1264f525c..ba290d3760 100644\n--- a/advice.c\n+++ b/advice.c\n@@ -327,15 +327,8 @@ void advise_on_checkout_dirty_files(struct string_list *file_list)\n \tfprintf(stderr, \"\\t%s\\n\", item->string);\n \n     advise_if_enabled(ADVICE_STASH_BEFORE_CHECKOUT,\n-\t\t      _(\"You can save your local changes before switching by running:\\n\"\n+\t\t      _(\"To carry your local changes over to the new branch, use:\\n\"\n \t\t\t\"\\n\"\n-\t\t\t\"\\tgit stash push\\n\"\n-\t\t\t\"\\n\"\n-\t\t\t\"Then restore them after switching with:\\n\"\n-\t\t\t\"\\n\"\n-\t\t\t\"\\tgit stash pop\\n\"\n-\t\t\t\"\\n\"\n-\t\t\t\"Or to discard your local changes, use:\\n\"\n-\t\t\t\"\\n\"\n-\t\t\t\"\\tgit checkout -- <file>\"));\n+\t\t\t\"\\tgit checkout -m <branch>\\n\"\n+\t\t\t));\n }\n-- \ngitgitgadget\n"},{"id":"538437","messageId":"xmqqzf4fx0vo.fsf@gitster.g","threadId":"65195","inReplyTo":"5f100fe0-d601-4ee3-adb9-a2458203d10d@gmail.com","subject":"Re: [PATCH 0/5] Advice on checkout dirty files","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2026-03-10T13:36:11Z","receivedAt":"2026-03-10T13:36:14Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Phillip Wood <phillip.wood123@gmail.com> writes:\n\n> If the intent is for the user to carry over the changes to the new \n> branch then recommending \"git checkout -m\" might be more convenient \n> rather than having to stash, checkout and unstash as three separate steps.\n\nI personally would not recommend pushing \"-m\" to new people without\nexplaining its ramifications, though.\n\nIf \"git stash pop\" fails while a commit different from the original\nis checked out, the working tree will get conflicts for you to\nresolve, and that is the same as \"git checkout -m\".  But the\nconflict may turn out to be too complex that you might not be able\nto cleanly resolve.\n\nWith a \"git stash pop\" that gets interrupted by a conflict, the\nstash entry is not removed from the stash, so there is a clean\nrecourse to \"git reset --hard\" away the conflict and attempting to\nunstash (either to the same commit or to a different base).\n\nWith \"git checkout -m\", on the other hand, there is no such\nrecourse.  The conflicted working tree with the unmerged index is\nall you get, and you get only a single chance to resolve it\ncorrectly.\n\nSo...\n\n"},{"id":"538438","messageId":"CAOAgETMe_yGyuaV4Eo9WDNYBa+eG-SEYDTCDoV45itNh_TE_GA@mail.gmail.com","threadId":"65195","inReplyTo":"abAZw-Z1mKf4tAuH@pks.im","subject":"Re: [PATCH v2] advice: add stashBeforeCheckout advice for dirty branch switches","fromName":"Arsh Srivastava","fromEmail":"arshsrivastava00@gmail.com","sentAt":"2026-03-10T13:36:39Z","receivedAt":"2026-03-10T13:36:52Z","isPatch":true,"sender":{"key":"arshsrivastava00@gmail.com","avatar":"https://gravatar.com/avatar/31a57f3c18a3d49c0601d1863b1cea06242a5d6808b9bcc8fa8a801195d04cc7?d=mp&s=160"},"body":"Thank you so much for looking into my PR and i believe advice.h is\nused in the add.c file. And advice really helps young developers\nunderstand what's wrong in their files because navigating git and\ntrying to find solutions is very difficult, causing them to go to ai\nmodels making them copy pasting machines.\n\n\nOn Tue, 10 Mar 2026 at 18:46, Patrick Steinhardt <ps@pks.im> wrote:\n>\n> On Tue, Mar 10, 2026 at 10:59:24AM +0000, Arsh Srivastava via GitGitGadget wrote:\n> > diff --git a/advice.c b/advice.c\n> > index 0018501b7b..e1264f525c 100644\n> > --- a/advice.c\n> > +++ b/advice.c\n> > @@ -81,6 +81,7 @@ static struct {\n> >       [ADVICE_SET_UPSTREAM_FAILURE]                   = { \"setUpstreamFailure\" },\n> >       [ADVICE_SKIPPED_CHERRY_PICKS]                   = { \"skippedCherryPicks\" },\n> >       [ADVICE_SPARSE_INDEX_EXPANDED]                  = { \"sparseIndexExpanded\" },\n> > +     [ADVICE_STASH_BEFORE_CHECKOUT] = { \"stashBeforeCheckout\" },\n> >       [ADVICE_STATUS_AHEAD_BEHIND_WARNING]            = { \"statusAheadBehindWarning\" },\n> >       [ADVICE_STATUS_HINTS]                           = { \"statusHints\" },\n> >       [ADVICE_STATUS_U_OPTION]                        = { \"statusUoption\" },\n> > @@ -312,3 +313,29 @@ void advise_on_moving_dirty_path(struct string_list *pathspec_list)\n> >                           \"* Use \\\"git add --sparse <paths>\\\" to update the index\\n\"\n> >                           \"* Use \\\"git sparse-checkout reapply\\\" to apply the sparsity rules\"));\n> >  }\n> > +\n> > +void advise_on_checkout_dirty_files(struct string_list *file_list)\n>\n> Huh. So this patch wires up a new function and advice, but we don't ever\n> seem to use it. Am I missing something?\n>\n> Patrick\n"},{"id":"538439","messageId":"CAOAgETNoQuju_RWbe=jo8JF7J2+V_pVoyr6FeKw8LwYKi_HipA@mail.gmail.com","threadId":"65195","inReplyTo":"xmqqzf4fx0vo.fsf@gitster.g","subject":"Re: [PATCH 0/5] Advice on checkout dirty files","fromName":"Arsh Srivastava","fromEmail":"arshsrivastava00@gmail.com","sentAt":"2026-03-10T13:40:20Z","receivedAt":"2026-03-10T13:40:32Z","isPatch":true,"sender":{"key":"arshsrivastava00@gmail.com","avatar":"https://gravatar.com/avatar/31a57f3c18a3d49c0601d1863b1cea06242a5d6808b9bcc8fa8a801195d04cc7?d=mp&s=160"},"body":"As per the recommendation of Phillip Wood <phillip.wood123@gmail.com>\nI have changed my files and added git checkout -m after understanding\nits significance :)\n\nOn Tue, 10 Mar 2026 at 19:06, Junio C Hamano <gitster@pobox.com> wrote:\n>\n> Phillip Wood <phillip.wood123@gmail.com> writes:\n>\n> > If the intent is for the user to carry over the changes to the new\n> > branch then recommending \"git checkout -m\" might be more convenient\n> > rather than having to stash, checkout and unstash as three separate steps.\n>\n> I personally would not recommend pushing \"-m\" to new people without\n> explaining its ramifications, though.\n>\n> If \"git stash pop\" fails while a commit different from the original\n> is checked out, the working tree will get conflicts for you to\n> resolve, and that is the same as \"git checkout -m\".  But the\n> conflict may turn out to be too complex that you might not be able\n> to cleanly resolve.\n>\n> With a \"git stash pop\" that gets interrupted by a conflict, the\n> stash entry is not removed from the stash, so there is a clean\n> recourse to \"git reset --hard\" away the conflict and attempting to\n> unstash (either to the same commit or to a different base).\n>\n> With \"git checkout -m\", on the other hand, there is no such\n> recourse.  The conflicted working tree with the unmerged index is\n> all you get, and you get only a single chance to resolve it\n> correctly.\n>\n> So...\n>\n"},{"id":"538440","messageId":"CAOAgETOQ8eEKYc9qwShKOgO+50RzOMQdqTv0G3fOUznmw5Xzzg@mail.gmail.com","threadId":"65195","inReplyTo":"eb5639dbc3571fde15f2d93cf2d137b8df775d2f.1773149337.git.gitgitgadget@gmail.com","subject":"Re: [PATCH v3 1/2] advice: add stashBeforeCheckout advice for dirty branch switches","fromName":"Arsh Srivastava","fromEmail":"arshsrivastava00@gmail.com","sentAt":"2026-03-10T13:43:05Z","receivedAt":"2026-03-10T13:43:18Z","isPatch":true,"sender":{"key":"arshsrivastava00@gmail.com","avatar":"https://gravatar.com/avatar/31a57f3c18a3d49c0601d1863b1cea06242a5d6808b9bcc8fa8a801195d04cc7?d=mp&s=160"},"body":"Thank you so much for looking into my PR and i believe\n> advice.h is used in the add.c file.\n> And advice really helps young developers\n   understand what's wrong in their files because navigating git and\n   trying to find solutions is very difficult,\n> causing them to go to ai models making them copy pasting machines.\n\nOn Tue, 10 Mar 2026 at 18:59, Arsh Srivastava via GitGitGadget\n<gitgitgadget@gmail.com> wrote:\n>\n> From: Arsh Srivastava <arshsrivastava00@gmail.com>\n>\n> Add a new advice type ADVICE_STASH_BEFORE_CHECKOUT to guide users\n> when they attempt to switch branches with local modifications that\n> would be overwritten by the operation.\n>\n> This includes:\n> > New ADVICE_STASH_BEFORE_CHECKOUT enum value in advice.h\n> > Corresponding \"stashBeforeCheckout\" entry in advice_setting[]\n> > New advise_on_checkout_dirty_files() function that lists the\n>   affected files and suggests using git stash push/pop\n> > Documentation entry in Documentation/config/advice.txt\n>\n> The advice follows existing patterns established by\n> advise_on_updating_sparse_paths() and can be silenced with:\n>\n>   git config set advice.stashBeforeCheckout false\n>\n> Signed-off-by: Arsh Srivastava <arshsrivastava00@gmail.com>\n> ---\n>  Documentation/config/advice.adoc |  5 +++++\n>  advice.c                         | 27 +++++++++++++++++++++++++++\n>  advice.h                         |  2 ++\n>  3 files changed, 34 insertions(+)\n>\n> diff --git a/Documentation/config/advice.adoc b/Documentation/config/advice.adoc\n> index 257db58918..8752e05636 100644\n> --- a/Documentation/config/advice.adoc\n> +++ b/Documentation/config/advice.adoc\n> @@ -126,6 +126,11 @@ all advice messages.\n>                 Shown when a sparse index is expanded to a full index, which is likely\n>                 due to an unexpected set of files existing outside of the\n>                 sparse-checkout.\n> +       stashBeforeCheckout::\n> +               Shown when the user attempts to switch branches but has\n> +               local modifications that would be overwritten by the\n> +               operation, to suggest using linkgit:git-stash[1] to\n> +               save changes before switching.\n>         statusAheadBehind::\n>                 Shown when linkgit:git-status[1] computes the ahead/behind\n>                 counts for a local ref compared to its remote tracking ref,\n> diff --git a/advice.c b/advice.c\n> index 0018501b7b..e1264f525c 100644\n> --- a/advice.c\n> +++ b/advice.c\n> @@ -81,6 +81,7 @@ static struct {\n>         [ADVICE_SET_UPSTREAM_FAILURE]                   = { \"setUpstreamFailure\" },\n>         [ADVICE_SKIPPED_CHERRY_PICKS]                   = { \"skippedCherryPicks\" },\n>         [ADVICE_SPARSE_INDEX_EXPANDED]                  = { \"sparseIndexExpanded\" },\n> +       [ADVICE_STASH_BEFORE_CHECKOUT] = { \"stashBeforeCheckout\" },\n>         [ADVICE_STATUS_AHEAD_BEHIND_WARNING]            = { \"statusAheadBehindWarning\" },\n>         [ADVICE_STATUS_HINTS]                           = { \"statusHints\" },\n>         [ADVICE_STATUS_U_OPTION]                        = { \"statusUoption\" },\n> @@ -312,3 +313,29 @@ void advise_on_moving_dirty_path(struct string_list *pathspec_list)\n>                             \"* Use \\\"git add --sparse <paths>\\\" to update the index\\n\"\n>                             \"* Use \\\"git sparse-checkout reapply\\\" to apply the sparsity rules\"));\n>  }\n> +\n> +void advise_on_checkout_dirty_files(struct string_list *file_list)\n> +{\n> +    struct string_list_item *item;\n> +\n> +    if (!file_list->nr)\n> +       return;\n> +\n> +    fprintf(stderr, _(\"The following files have local modifications that would\\n\"\n> +                     \"be overwritten by switching branches:\\n\"));\n> +    for_each_string_list_item(item, file_list)\n> +       fprintf(stderr, \"\\t%s\\n\", item->string);\n> +\n> +    advise_if_enabled(ADVICE_STASH_BEFORE_CHECKOUT,\n> +                     _(\"You can save your local changes before switching by running:\\n\"\n> +                       \"\\n\"\n> +                       \"\\tgit stash push\\n\"\n> +                       \"\\n\"\n> +                       \"Then restore them after switching with:\\n\"\n> +                       \"\\n\"\n> +                       \"\\tgit stash pop\\n\"\n> +                       \"\\n\"\n> +                       \"Or to discard your local changes, use:\\n\"\n> +                       \"\\n\"\n> +                       \"\\tgit checkout -- <file>\"));\n> +}\n> diff --git a/advice.h b/advice.h\n> index 8def280688..c035b5d8e3 100644\n> --- a/advice.h\n> +++ b/advice.h\n> @@ -48,6 +48,7 @@ enum advice_type {\n>         ADVICE_SET_UPSTREAM_FAILURE,\n>         ADVICE_SKIPPED_CHERRY_PICKS,\n>         ADVICE_SPARSE_INDEX_EXPANDED,\n> +       ADVICE_STASH_BEFORE_CHECKOUT,\n>         ADVICE_STATUS_AHEAD_BEHIND_WARNING,\n>         ADVICE_STATUS_HINTS,\n>         ADVICE_STATUS_U_OPTION,\n> @@ -83,5 +84,6 @@ void NORETURN die_ff_impossible(void);\n>  void advise_on_updating_sparse_paths(struct string_list *pathspec_list);\n>  void detach_advice(const char *new_name);\n>  void advise_on_moving_dirty_path(struct string_list *pathspec_list);\n> +void advise_on_checkout_dirty_files(struct string_list *file_list);\n>\n>  #endif /* ADVICE_H */\n> --\n> gitgitgadget\n>\n"},{"id":"538446","messageId":"abApu_JDG4im9vwT@pks.im","threadId":"65195","inReplyTo":"CAOAgETMe_yGyuaV4Eo9WDNYBa+eG-SEYDTCDoV45itNh_TE_GA@mail.gmail.com","subject":"Re: [PATCH v2] advice: add stashBeforeCheckout advice for dirty branch switches","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2026-03-10T14:24:59Z","receivedAt":"2026-03-10T14:25:06Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"On Tue, Mar 10, 2026 at 07:06:39PM +0530, Arsh Srivastava wrote:\n> On Tue, 10 Mar 2026 at 18:46, Patrick Steinhardt <ps@pks.im> wrote:\n> > On Tue, Mar 10, 2026 at 10:59:24AM +0000, Arsh Srivastava via GitGitGadget wrote:\n> > > diff --git a/advice.c b/advice.c\n> > > index 0018501b7b..e1264f525c 100644\n> > > --- a/advice.c\n> > > +++ b/advice.c\n> > > @@ -81,6 +81,7 @@ static struct {\n> > >       [ADVICE_SET_UPSTREAM_FAILURE]                   = { \"setUpstreamFailure\" },\n> > >       [ADVICE_SKIPPED_CHERRY_PICKS]                   = { \"skippedCherryPicks\" },\n> > >       [ADVICE_SPARSE_INDEX_EXPANDED]                  = { \"sparseIndexExpanded\" },\n> > > +     [ADVICE_STASH_BEFORE_CHECKOUT] = { \"stashBeforeCheckout\" },\n> > >       [ADVICE_STATUS_AHEAD_BEHIND_WARNING]            = { \"statusAheadBehindWarning\" },\n> > >       [ADVICE_STATUS_HINTS]                           = { \"statusHints\" },\n> > >       [ADVICE_STATUS_U_OPTION]                        = { \"statusUoption\" },\n> > > @@ -312,3 +313,29 @@ void advise_on_moving_dirty_path(struct string_list *pathspec_list)\n> > >                           \"* Use \\\"git add --sparse <paths>\\\" to update the index\\n\"\n> > >                           \"* Use \\\"git sparse-checkout reapply\\\" to apply the sparsity rules\"));\n> > >  }\n> > > +\n> > > +void advise_on_checkout_dirty_files(struct string_list *file_list)\n> >\n> > Huh. So this patch wires up a new function and advice, but we don't ever\n> > seem to use it. Am I missing something?\n> \n> Thank you so much for looking into my PR and i believe advice.h is\n> used in the add.c file. And advice really helps young developers\n> understand what's wrong in their files because navigating git and\n> trying to find solutions is very difficult, causing them to go to ai\n> models making them copy pasting machines.\n\n(Please note that we prefer bottom posting on this mailing list, where\nyour answer goes below the quoted context.)\n\nIt is used in \"add.c\", but not magically so. The function that you have\nintroduced is the only site that uses the new advice, but the function\nis never called as far as I can see. So ultimately, the proposed change\ndoes not have any effect on the user-observable behaviour.\n\nPatrick\n"},{"id":"538447","messageId":"CAOLa=ZRfaSR2CisUrW0gLf_45KQj1wQZ70F4PZ5XcwWZ--+HhQ@mail.gmail.com","threadId":"65195","inReplyTo":"pull.2233.v2.git.git.1773140364525.gitgitgadget@gmail.com","subject":"Re: [PATCH v2] advice: add stashBeforeCheckout advice for dirty branch switches","fromName":"Karthik Nayak","fromEmail":"karthik.188@gmail.com","sentAt":"2026-03-10T14:31:43Z","receivedAt":"2026-03-10T14:31:44Z","isPatch":true,"sender":{"key":"karthik.188@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1786334?v=4"},"body":"\"Arsh Srivastava via GitGitGadget\" <gitgitgadget@gmail.com> writes:\n\n> From: Arsh Srivastava <arshsrivastava00@gmail.com>\n>\n> Add a new advice type ADVICE_STASH_BEFORE_CHECKOUT to guide users\n> when they attempt to switch branches with local modifications that\n> would be overwritten by the operation.\n>\n> This includes:\n>> New ADVICE_STASH_BEFORE_CHECKOUT enum value in advice.h\n>> Corresponding \"stashBeforeCheckout\" entry in advice_setting[]\n>> New advise_on_checkout_dirty_files() function that lists the\n>   affected files and suggests using git stash push/pop\n>> Documentation entry in Documentation/config/advice.txt\n>\n\nNit: Did you mean to add bullet point here? '>' is generally used to\nquote text. Perhaps use '-' or '*'.\n\n[snip]\n\n>\n>  Documentation/config/advice.adoc |  5 +++++\n>  advice.c                         | 27 +++++++++++++++++++++++++++\n>  advice.h                         |  2 ++\n>  3 files changed, 34 insertions(+)\n>\n\nHmm. Shouldn't there be changes which actually call the newly introduced\nfunction? Also shouldn't there be tests added?\n\n> diff --git a/Documentation/config/advice.adoc b/Documentation/config/advice.adoc\n> index 257db58918..8752e05636 100644\n> --- a/Documentation/config/advice.adoc\n> +++ b/Documentation/config/advice.adoc\n> @@ -126,6 +126,11 @@ all advice messages.\n>  \t\tShown when a sparse index is expanded to a full index, which is likely\n>  \t\tdue to an unexpected set of files existing outside of the\n>  \t\tsparse-checkout.\n> +\tstashBeforeCheckout::\n> +\t\tShown when the user attempts to switch branches but has\n> +\t\tlocal modifications that would be overwritten by the\n> +\t\toperation, to suggest using linkgit:git-stash[1] to\n> +\t\tsave changes before switching.\n\nDoesn't 'ADVICE_COMMIT_BEFORE_MERGE' already do this?\n\nIn one of my repos:\n\n❯ git status\nOn branch master\nYour branch is up to date with 'origin/master'.\n\nnothing to commit, working tree clean\n\n❯ echo \"aldjf\" >> LICENSE\n\n❯ git status\nOn branch master\nYour branch is up to date with 'origin/master'.\n\nChanges not staged for commit:\n  (use \"git add <file>...\" to update what will be committed)\n  (use \"git restore <file>...\" to discard changes in working directory)\n\tmodified:   LICENSE\n\nno changes added to commit (use \"git add\" and/or \"git commit -a\")\n\n❯ git checkout  0-1-stable\nerror: Your local changes to the following files would be overwritten\nby checkout:\n\tLICENSE\nPlease commit your changes or stash them before you switch branches.\nAborting\n\nSo won't this simply be duplicating the same message?\n\n>  \tstatusAheadBehind::\n>  \t\tShown when linkgit:git-status[1] computes the ahead/behind\n>  \t\tcounts for a local ref compared to its remote tracking ref,\n> diff --git a/advice.c b/advice.c\n> index 0018501b7b..e1264f525c 100644\n> --- a/advice.c\n> +++ b/advice.c\n> @@ -81,6 +81,7 @@ static struct {\n>  \t[ADVICE_SET_UPSTREAM_FAILURE]\t\t\t= { \"setUpstreamFailure\" },\n>  \t[ADVICE_SKIPPED_CHERRY_PICKS]\t\t\t= { \"skippedCherryPicks\" },\n>  \t[ADVICE_SPARSE_INDEX_EXPANDED]\t\t\t= { \"sparseIndexExpanded\" },\n> +\t[ADVICE_STASH_BEFORE_CHECKOUT] = { \"stashBeforeCheckout\" },\n>  \t[ADVICE_STATUS_AHEAD_BEHIND_WARNING]\t\t= { \"statusAheadBehindWarning\" },\n>  \t[ADVICE_STATUS_HINTS]\t\t\t\t= { \"statusHints\" },\n>  \t[ADVICE_STATUS_U_OPTION]\t\t\t= { \"statusUoption\" },\n> @@ -312,3 +313,29 @@ void advise_on_moving_dirty_path(struct string_list *pathspec_list)\n>  \t\t\t    \"* Use \\\"git add --sparse <paths>\\\" to update the index\\n\"\n>  \t\t\t    \"* Use \\\"git sparse-checkout reapply\\\" to apply the sparsity rules\"));\n>  }\n> +\n> +void advise_on_checkout_dirty_files(struct string_list *file_list)\n> +{\n> +    struct string_list_item *item;\n> +\n> +    if (!file_list->nr)\n> +\treturn;\n> +\n> +    fprintf(stderr, _(\"The following files have local modifications that would\\n\"\n> +\t\t      \"be overwritten by switching branches:\\n\"));\n> +    for_each_string_list_item(item, file_list)\n> +\tfprintf(stderr, \"\\t%s\\n\", item->string);\n> +\n> +    advise_if_enabled(ADVICE_STASH_BEFORE_CHECKOUT,\n> +\t\t      _(\"You can save your local changes before switching by running:\\n\"\n> +\t\t\t\"\\n\"\n> +\t\t\t\"\\tgit stash push\\n\"\n> +\t\t\t\"\\n\"\n> +\t\t\t\"Then restore them after switching with:\\n\"\n> +\t\t\t\"\\n\"\n> +\t\t\t\"\\tgit stash pop\\n\"\n> +\t\t\t\"\\n\"\n> +\t\t\t\"Or to discard your local changes, use:\\n\"\n> +\t\t\t\"\\n\"\n> +\t\t\t\"\\tgit checkout -- <file>\"));\n> +}\n\nThis doesn't seem to be formatted with tabs.\n"},{"id":"538452","messageId":"CAOAgETMmLKcz2CWqfKCJeoTCfACMXz7M0d2g_zO5M53tnGqQuA@mail.gmail.com","threadId":"65195","inReplyTo":"CAOLa=ZRfaSR2CisUrW0gLf_45KQj1wQZ70F4PZ5XcwWZ--+HhQ@mail.gmail.com","subject":"Re: [PATCH v2] advice: add stashBeforeCheckout advice for dirty branch switches","fromName":"Arsh Srivastava","fromEmail":"arshsrivastava00@gmail.com","sentAt":"2026-03-10T14:37:16Z","receivedAt":"2026-03-10T14:37:29Z","isPatch":true,"sender":{"key":"arshsrivastava00@gmail.com","avatar":"https://gravatar.com/avatar/31a57f3c18a3d49c0601d1863b1cea06242a5d6808b9bcc8fa8a801195d04cc7?d=mp&s=160"},"body":"Subject: Re: [GSOC] advice: add stashBeforeCheckout advice for dirty\nbranch switches\n\nKarthik Nayak <karthik.188@gmail.com> writes:\n\n> Doesn't 'ADVICE_COMMIT_BEFORE_MERGE' already do this?\n> So won't this simply be duplicating the same message?\n\nThank you for the detailed review. You are correct, the existing message\nin unpack-trees.c already handles this case and my patch duplicates it.\nI also acknowledge the other issues raised:\n\n- The newly introduced function was never called anywhere in the codebase\n- No tests were added\n- The bullet points in the commit message used '>' instead of '-' or '*'\n- The advice message was not formatted with tabs\n\nRather than duplicating the existing behaviour, I think the better\napproach would be to enhance the existing message in unpack-trees.c to\nalso mention 'git checkout -m' as an option for users who want to carry\ntheir local changes over to the new branch, since the current message\nonly says \"commit or stash\" without mentioning that option.\n\nI will rework the patch in that direction and send a v4.\n\nSigned-off-by: Arsh Srivastava <arshsrivastava00@gmail.com>\n\nOn Tue, 10 Mar 2026 at 20:01, Karthik Nayak <karthik.188@gmail.com> wrote:\n>\n> \"Arsh Srivastava via GitGitGadget\" <gitgitgadget@gmail.com> writes:\n>\n> > From: Arsh Srivastava <arshsrivastava00@gmail.com>\n> >\n> > Add a new advice type ADVICE_STASH_BEFORE_CHECKOUT to guide users\n> > when they attempt to switch branches with local modifications that\n> > would be overwritten by the operation.\n> >\n> > This includes:\n> >> New ADVICE_STASH_BEFORE_CHECKOUT enum value in advice.h\n> >> Corresponding \"stashBeforeCheckout\" entry in advice_setting[]\n> >> New advise_on_checkout_dirty_files() function that lists the\n> >   affected files and suggests using git stash push/pop\n> >> Documentation entry in Documentation/config/advice.txt\n> >\n>\n> Nit: Did you mean to add bullet point here? '>' is generally used to\n> quote text. Perhaps use '-' or '*'.\n>\n> [snip]\n>\n> >\n> >  Documentation/config/advice.adoc |  5 +++++\n> >  advice.c                         | 27 +++++++++++++++++++++++++++\n> >  advice.h                         |  2 ++\n> >  3 files changed, 34 insertions(+)\n> >\n>\n> Hmm. Shouldn't there be changes which actually call the newly introduced\n> function? Also shouldn't there be tests added?\n>\n> > diff --git a/Documentation/config/advice.adoc b/Documentation/config/advice.adoc\n> > index 257db58918..8752e05636 100644\n> > --- a/Documentation/config/advice.adoc\n> > +++ b/Documentation/config/advice.adoc\n> > @@ -126,6 +126,11 @@ all advice messages.\n> >               Shown when a sparse index is expanded to a full index, which is likely\n> >               due to an unexpected set of files existing outside of the\n> >               sparse-checkout.\n> > +     stashBeforeCheckout::\n> > +             Shown when the user attempts to switch branches but has\n> > +             local modifications that would be overwritten by the\n> > +             operation, to suggest using linkgit:git-stash[1] to\n> > +             save changes before switching.\n>\n> Doesn't 'ADVICE_COMMIT_BEFORE_MERGE' already do this?\n>\n> In one of my repos:\n>\n> ❯ git status\n> On branch master\n> Your branch is up to date with 'origin/master'.\n>\n> nothing to commit, working tree clean\n>\n> ❯ echo \"aldjf\" >> LICENSE\n>\n> ❯ git status\n> On branch master\n> Your branch is up to date with 'origin/master'.\n>\n> Changes not staged for commit:\n>   (use \"git add <file>...\" to update what will be committed)\n>   (use \"git restore <file>...\" to discard changes in working directory)\n>         modified:   LICENSE\n>\n> no changes added to commit (use \"git add\" and/or \"git commit -a\")\n>\n> ❯ git checkout  0-1-stable\n> error: Your local changes to the following files would be overwritten\n> by checkout:\n>         LICENSE\n> Please commit your changes or stash them before you switch branches.\n> Aborting\n>\n> So won't this simply be duplicating the same message?\n>\n> >       statusAheadBehind::\n> >               Shown when linkgit:git-status[1] computes the ahead/behind\n> >               counts for a local ref compared to its remote tracking ref,\n> > diff --git a/advice.c b/advice.c\n> > index 0018501b7b..e1264f525c 100644\n> > --- a/advice.c\n> > +++ b/advice.c\n> > @@ -81,6 +81,7 @@ static struct {\n> >       [ADVICE_SET_UPSTREAM_FAILURE]                   = { \"setUpstreamFailure\" },\n> >       [ADVICE_SKIPPED_CHERRY_PICKS]                   = { \"skippedCherryPicks\" },\n> >       [ADVICE_SPARSE_INDEX_EXPANDED]                  = { \"sparseIndexExpanded\" },\n> > +     [ADVICE_STASH_BEFORE_CHECKOUT] = { \"stashBeforeCheckout\" },\n> >       [ADVICE_STATUS_AHEAD_BEHIND_WARNING]            = { \"statusAheadBehindWarning\" },\n> >       [ADVICE_STATUS_HINTS]                           = { \"statusHints\" },\n> >       [ADVICE_STATUS_U_OPTION]                        = { \"statusUoption\" },\n> > @@ -312,3 +313,29 @@ void advise_on_moving_dirty_path(struct string_list *pathspec_list)\n> >                           \"* Use \\\"git add --sparse <paths>\\\" to update the index\\n\"\n> >                           \"* Use \\\"git sparse-checkout reapply\\\" to apply the sparsity rules\"));\n> >  }\n> > +\n> > +void advise_on_checkout_dirty_files(struct string_list *file_list)\n> > +{\n> > +    struct string_list_item *item;\n> > +\n> > +    if (!file_list->nr)\n> > +     return;\n> > +\n> > +    fprintf(stderr, _(\"The following files have local modifications that would\\n\"\n> > +                   \"be overwritten by switching branches:\\n\"));\n> > +    for_each_string_list_item(item, file_list)\n> > +     fprintf(stderr, \"\\t%s\\n\", item->string);\n> > +\n> > +    advise_if_enabled(ADVICE_STASH_BEFORE_CHECKOUT,\n> > +                   _(\"You can save your local changes before switching by running:\\n\"\n> > +                     \"\\n\"\n> > +                     \"\\tgit stash push\\n\"\n> > +                     \"\\n\"\n> > +                     \"Then restore them after switching with:\\n\"\n> > +                     \"\\n\"\n> > +                     \"\\tgit stash pop\\n\"\n> > +                     \"\\n\"\n> > +                     \"Or to discard your local changes, use:\\n\"\n> > +                     \"\\n\"\n> > +                     \"\\tgit checkout -- <file>\"));\n> > +}\n>\n> This doesn't seem to be formatted with tabs.\n"},{"id":"538454","messageId":"CAOAgETOcivRUskCi4PCLnXzn1qGs9jx39JzgBA0jE=CirSkZJQ@mail.gmail.com","threadId":"65195","inReplyTo":"CAOAgETMmLKcz2CWqfKCJeoTCfACMXz7M0d2g_zO5M53tnGqQuA@mail.gmail.com","subject":"Re: [PATCH v2] advice: add stashBeforeCheckout advice for dirty branch switches","fromName":"Arsh Srivastava","fromEmail":"arshsrivastava00@gmail.com","sentAt":"2026-03-10T14:40:57Z","receivedAt":"2026-03-10T14:41:12Z","isPatch":true,"sender":{"key":"arshsrivastava00@gmail.com","avatar":"https://gravatar.com/avatar/31a57f3c18a3d49c0601d1863b1cea06242a5d6808b9bcc8fa8a801195d04cc7?d=mp&s=160"},"body":"Subject: Re: [GSOC] advice: add stashBeforeCheckout advice for dirty\nbranch switches\n\nPatrick Steinhardt <ps@pks.im> writes:\n\n> It is used in \"add.c\", but not magically so. The function that you have\n> introduced is the only site that uses the new advice, but the function\n> is never called as far as I can see. So ultimately, the proposed change\n> does not have any effect on the user-observable behaviour.\n\nThank you for the correction and for the bottom-posting reminder.\n\nYou are right. The function advise_on_checkout_dirty_files() is defined\nbut never called anywhere, so the patch has no user-observable effect.\nI also looked into the existing behaviour more carefully and found that\nunpack-trees.c already handles this case and prints a message telling\nthe user to commit or stash their changes before switching branches.\n\nSo the patch as written is both incomplete and duplicates existing\nbehaviour. I will rework it in v3 to instead enhance the existing\nmessage in unpack-trees.c to also mention 'git checkout -m' for users\nwho want to carry their local changes over to the new branch.\n\nSigned-off-by: Arsh Srivastava <arshsrivastava00@gmail.com>\n\nOn Tue, 10 Mar 2026 at 20:07, Arsh Srivastava\n<arshsrivastava00@gmail.com> wrote:\n>\n> Subject: Re: [GSOC] advice: add stashBeforeCheckout advice for dirty\n> branch switches\n>\n> Karthik Nayak <karthik.188@gmail.com> writes:\n>\n> > Doesn't 'ADVICE_COMMIT_BEFORE_MERGE' already do this?\n> > So won't this simply be duplicating the same message?\n>\n> Thank you for the detailed review. You are correct, the existing message\n> in unpack-trees.c already handles this case and my patch duplicates it.\n> I also acknowledge the other issues raised:\n>\n> - The newly introduced function was never called anywhere in the codebase\n> - No tests were added\n> - The bullet points in the commit message used '>' instead of '-' or '*'\n> - The advice message was not formatted with tabs\n>\n> Rather than duplicating the existing behaviour, I think the better\n> approach would be to enhance the existing message in unpack-trees.c to\n> also mention 'git checkout -m' as an option for users who want to carry\n> their local changes over to the new branch, since the current message\n> only says \"commit or stash\" without mentioning that option.\n>\n> I will rework the patch in that direction and send a v4.\n>\n> Signed-off-by: Arsh Srivastava <arshsrivastava00@gmail.com>\n>\n> On Tue, 10 Mar 2026 at 20:01, Karthik Nayak <karthik.188@gmail.com> wrote:\n> >\n> > \"Arsh Srivastava via GitGitGadget\" <gitgitgadget@gmail.com> writes:\n> >\n> > > From: Arsh Srivastava <arshsrivastava00@gmail.com>\n> > >\n> > > Add a new advice type ADVICE_STASH_BEFORE_CHECKOUT to guide users\n> > > when they attempt to switch branches with local modifications that\n> > > would be overwritten by the operation.\n> > >\n> > > This includes:\n> > >> New ADVICE_STASH_BEFORE_CHECKOUT enum value in advice.h\n> > >> Corresponding \"stashBeforeCheckout\" entry in advice_setting[]\n> > >> New advise_on_checkout_dirty_files() function that lists the\n> > >   affected files and suggests using git stash push/pop\n> > >> Documentation entry in Documentation/config/advice.txt\n> > >\n> >\n> > Nit: Did you mean to add bullet point here? '>' is generally used to\n> > quote text. Perhaps use '-' or '*'.\n> >\n> > [snip]\n> >\n> > >\n> > >  Documentation/config/advice.adoc |  5 +++++\n> > >  advice.c                         | 27 +++++++++++++++++++++++++++\n> > >  advice.h                         |  2 ++\n> > >  3 files changed, 34 insertions(+)\n> > >\n> >\n> > Hmm. Shouldn't there be changes which actually call the newly introduced\n> > function? Also shouldn't there be tests added?\n> >\n> > > diff --git a/Documentation/config/advice.adoc b/Documentation/config/advice.adoc\n> > > index 257db58918..8752e05636 100644\n> > > --- a/Documentation/config/advice.adoc\n> > > +++ b/Documentation/config/advice.adoc\n> > > @@ -126,6 +126,11 @@ all advice messages.\n> > >               Shown when a sparse index is expanded to a full index, which is likely\n> > >               due to an unexpected set of files existing outside of the\n> > >               sparse-checkout.\n> > > +     stashBeforeCheckout::\n> > > +             Shown when the user attempts to switch branches but has\n> > > +             local modifications that would be overwritten by the\n> > > +             operation, to suggest using linkgit:git-stash[1] to\n> > > +             save changes before switching.\n> >\n> > Doesn't 'ADVICE_COMMIT_BEFORE_MERGE' already do this?\n> >\n> > In one of my repos:\n> >\n> > ❯ git status\n> > On branch master\n> > Your branch is up to date with 'origin/master'.\n> >\n> > nothing to commit, working tree clean\n> >\n> > ❯ echo \"aldjf\" >> LICENSE\n> >\n> > ❯ git status\n> > On branch master\n> > Your branch is up to date with 'origin/master'.\n> >\n> > Changes not staged for commit:\n> >   (use \"git add <file>...\" to update what will be committed)\n> >   (use \"git restore <file>...\" to discard changes in working directory)\n> >         modified:   LICENSE\n> >\n> > no changes added to commit (use \"git add\" and/or \"git commit -a\")\n> >\n> > ❯ git checkout  0-1-stable\n> > error: Your local changes to the following files would be overwritten\n> > by checkout:\n> >         LICENSE\n> > Please commit your changes or stash them before you switch branches.\n> > Aborting\n> >\n> > So won't this simply be duplicating the same message?\n> >\n> > >       statusAheadBehind::\n> > >               Shown when linkgit:git-status[1] computes the ahead/behind\n> > >               counts for a local ref compared to its remote tracking ref,\n> > > diff --git a/advice.c b/advice.c\n> > > index 0018501b7b..e1264f525c 100644\n> > > --- a/advice.c\n> > > +++ b/advice.c\n> > > @@ -81,6 +81,7 @@ static struct {\n> > >       [ADVICE_SET_UPSTREAM_FAILURE]                   = { \"setUpstreamFailure\" },\n> > >       [ADVICE_SKIPPED_CHERRY_PICKS]                   = { \"skippedCherryPicks\" },\n> > >       [ADVICE_SPARSE_INDEX_EXPANDED]                  = { \"sparseIndexExpanded\" },\n> > > +     [ADVICE_STASH_BEFORE_CHECKOUT] = { \"stashBeforeCheckout\" },\n> > >       [ADVICE_STATUS_AHEAD_BEHIND_WARNING]            = { \"statusAheadBehindWarning\" },\n> > >       [ADVICE_STATUS_HINTS]                           = { \"statusHints\" },\n> > >       [ADVICE_STATUS_U_OPTION]                        = { \"statusUoption\" },\n> > > @@ -312,3 +313,29 @@ void advise_on_moving_dirty_path(struct string_list *pathspec_list)\n> > >                           \"* Use \\\"git add --sparse <paths>\\\" to update the index\\n\"\n> > >                           \"* Use \\\"git sparse-checkout reapply\\\" to apply the sparsity rules\"));\n> > >  }\n> > > +\n> > > +void advise_on_checkout_dirty_files(struct string_list *file_list)\n> > > +{\n> > > +    struct string_list_item *item;\n> > > +\n> > > +    if (!file_list->nr)\n> > > +     return;\n> > > +\n> > > +    fprintf(stderr, _(\"The following files have local modifications that would\\n\"\n> > > +                   \"be overwritten by switching branches:\\n\"));\n> > > +    for_each_string_list_item(item, file_list)\n> > > +     fprintf(stderr, \"\\t%s\\n\", item->string);\n> > > +\n> > > +    advise_if_enabled(ADVICE_STASH_BEFORE_CHECKOUT,\n> > > +                   _(\"You can save your local changes before switching by running:\\n\"\n> > > +                     \"\\n\"\n> > > +                     \"\\tgit stash push\\n\"\n> > > +                     \"\\n\"\n> > > +                     \"Then restore them after switching with:\\n\"\n> > > +                     \"\\n\"\n> > > +                     \"\\tgit stash pop\\n\"\n> > > +                     \"\\n\"\n> > > +                     \"Or to discard your local changes, use:\\n\"\n> > > +                     \"\\n\"\n> > > +                     \"\\tgit checkout -- <file>\"));\n> > > +}\n> >\n> > This doesn't seem to be formatted with tabs.\n"},{"id":"538455","messageId":"CAOAgETMYM+W1fRG=sJj+WXwYT5FrxjbL9OMU1w4gs3MWuFTqTg@mail.gmail.com","threadId":"65195","inReplyTo":"CAOAgETMmLKcz2CWqfKCJeoTCfACMXz7M0d2g_zO5M53tnGqQuA@mail.gmail.com","subject":"Re: [PATCH v2] advice: add stashBeforeCheckout advice for dirty branch switches","fromName":"Arsh Srivastava","fromEmail":"arshsrivastava00@gmail.com","sentAt":"2026-03-10T14:41:15Z","receivedAt":"2026-03-10T14:41:28Z","isPatch":true,"sender":{"key":"arshsrivastava00@gmail.com","avatar":"https://gravatar.com/avatar/31a57f3c18a3d49c0601d1863b1cea06242a5d6808b9bcc8fa8a801195d04cc7?d=mp&s=160"},"body":"Subject: Re: [GSOC] advice: add stashBeforeCheckout advice for dirty\nbranch switches\n\nPatrick Steinhardt <ps@pks.im> writes:\n\n> It is used in \"add.c\", but not magically so. The function that you have\n> introduced is the only site that uses the new advice, but the function\n> is never called as far as I can see. So ultimately, the proposed change\n> does not have any effect on the user-observable behaviour.\n\nThank you for the correction and for the bottom-posting reminder.\n\nYou are right. The function advise_on_checkout_dirty_files() is defined\nbut never called anywhere, so the patch has no user-observable effect.\nI also looked into the existing behaviour more carefully and found that\nunpack-trees.c already handles this case and prints a message telling\nthe user to commit or stash their changes before switching branches.\n\nSo the patch as written is both incomplete and duplicates existing\nbehaviour. I will rework it in v4 to instead enhance the existing\nmessage in unpack-trees.c to also mention 'git checkout -m' for users\nwho want to carry their local changes over to the new branch.\n\nSigned-off-by: Arsh Srivastava <arshsrivastava00@gmail.com>\n\nOn Tue, 10 Mar 2026 at 20:07, Arsh Srivastava\n<arshsrivastava00@gmail.com> wrote:\n>\n> Subject: Re: [GSOC] advice: add stashBeforeCheckout advice for dirty\n> branch switches\n>\n> Karthik Nayak <karthik.188@gmail.com> writes:\n>\n> > Doesn't 'ADVICE_COMMIT_BEFORE_MERGE' already do this?\n> > So won't this simply be duplicating the same message?\n>\n> Thank you for the detailed review. You are correct, the existing message\n> in unpack-trees.c already handles this case and my patch duplicates it.\n> I also acknowledge the other issues raised:\n>\n> - The newly introduced function was never called anywhere in the codebase\n> - No tests were added\n> - The bullet points in the commit message used '>' instead of '-' or '*'\n> - The advice message was not formatted with tabs\n>\n> Rather than duplicating the existing behaviour, I think the better\n> approach would be to enhance the existing message in unpack-trees.c to\n> also mention 'git checkout -m' as an option for users who want to carry\n> their local changes over to the new branch, since the current message\n> only says \"commit or stash\" without mentioning that option.\n>\n> I will rework the patch in that direction and send a v4.\n>\n> Signed-off-by: Arsh Srivastava <arshsrivastava00@gmail.com>\n>\n> On Tue, 10 Mar 2026 at 20:01, Karthik Nayak <karthik.188@gmail.com> wrote:\n> >\n> > \"Arsh Srivastava via GitGitGadget\" <gitgitgadget@gmail.com> writes:\n> >\n> > > From: Arsh Srivastava <arshsrivastava00@gmail.com>\n> > >\n> > > Add a new advice type ADVICE_STASH_BEFORE_CHECKOUT to guide users\n> > > when they attempt to switch branches with local modifications that\n> > > would be overwritten by the operation.\n> > >\n> > > This includes:\n> > >> New ADVICE_STASH_BEFORE_CHECKOUT enum value in advice.h\n> > >> Corresponding \"stashBeforeCheckout\" entry in advice_setting[]\n> > >> New advise_on_checkout_dirty_files() function that lists the\n> > >   affected files and suggests using git stash push/pop\n> > >> Documentation entry in Documentation/config/advice.txt\n> > >\n> >\n> > Nit: Did you mean to add bullet point here? '>' is generally used to\n> > quote text. Perhaps use '-' or '*'.\n> >\n> > [snip]\n> >\n> > >\n> > >  Documentation/config/advice.adoc |  5 +++++\n> > >  advice.c                         | 27 +++++++++++++++++++++++++++\n> > >  advice.h                         |  2 ++\n> > >  3 files changed, 34 insertions(+)\n> > >\n> >\n> > Hmm. Shouldn't there be changes which actually call the newly introduced\n> > function? Also shouldn't there be tests added?\n> >\n> > > diff --git a/Documentation/config/advice.adoc b/Documentation/config/advice.adoc\n> > > index 257db58918..8752e05636 100644\n> > > --- a/Documentation/config/advice.adoc\n> > > +++ b/Documentation/config/advice.adoc\n> > > @@ -126,6 +126,11 @@ all advice messages.\n> > >               Shown when a sparse index is expanded to a full index, which is likely\n> > >               due to an unexpected set of files existing outside of the\n> > >               sparse-checkout.\n> > > +     stashBeforeCheckout::\n> > > +             Shown when the user attempts to switch branches but has\n> > > +             local modifications that would be overwritten by the\n> > > +             operation, to suggest using linkgit:git-stash[1] to\n> > > +             save changes before switching.\n> >\n> > Doesn't 'ADVICE_COMMIT_BEFORE_MERGE' already do this?\n> >\n> > In one of my repos:\n> >\n> > ❯ git status\n> > On branch master\n> > Your branch is up to date with 'origin/master'.\n> >\n> > nothing to commit, working tree clean\n> >\n> > ❯ echo \"aldjf\" >> LICENSE\n> >\n> > ❯ git status\n> > On branch master\n> > Your branch is up to date with 'origin/master'.\n> >\n> > Changes not staged for commit:\n> >   (use \"git add <file>...\" to update what will be committed)\n> >   (use \"git restore <file>...\" to discard changes in working directory)\n> >         modified:   LICENSE\n> >\n> > no changes added to commit (use \"git add\" and/or \"git commit -a\")\n> >\n> > ❯ git checkout  0-1-stable\n> > error: Your local changes to the following files would be overwritten\n> > by checkout:\n> >         LICENSE\n> > Please commit your changes or stash them before you switch branches.\n> > Aborting\n> >\n> > So won't this simply be duplicating the same message?\n> >\n> > >       statusAheadBehind::\n> > >               Shown when linkgit:git-status[1] computes the ahead/behind\n> > >               counts for a local ref compared to its remote tracking ref,\n> > > diff --git a/advice.c b/advice.c\n> > > index 0018501b7b..e1264f525c 100644\n> > > --- a/advice.c\n> > > +++ b/advice.c\n> > > @@ -81,6 +81,7 @@ static struct {\n> > >       [ADVICE_SET_UPSTREAM_FAILURE]                   = { \"setUpstreamFailure\" },\n> > >       [ADVICE_SKIPPED_CHERRY_PICKS]                   = { \"skippedCherryPicks\" },\n> > >       [ADVICE_SPARSE_INDEX_EXPANDED]                  = { \"sparseIndexExpanded\" },\n> > > +     [ADVICE_STASH_BEFORE_CHECKOUT] = { \"stashBeforeCheckout\" },\n> > >       [ADVICE_STATUS_AHEAD_BEHIND_WARNING]            = { \"statusAheadBehindWarning\" },\n> > >       [ADVICE_STATUS_HINTS]                           = { \"statusHints\" },\n> > >       [ADVICE_STATUS_U_OPTION]                        = { \"statusUoption\" },\n> > > @@ -312,3 +313,29 @@ void advise_on_moving_dirty_path(struct string_list *pathspec_list)\n> > >                           \"* Use \\\"git add --sparse <paths>\\\" to update the index\\n\"\n> > >                           \"* Use \\\"git sparse-checkout reapply\\\" to apply the sparsity rules\"));\n> > >  }\n> > > +\n> > > +void advise_on_checkout_dirty_files(struct string_list *file_list)\n> > > +{\n> > > +    struct string_list_item *item;\n> > > +\n> > > +    if (!file_list->nr)\n> > > +     return;\n> > > +\n> > > +    fprintf(stderr, _(\"The following files have local modifications that would\\n\"\n> > > +                   \"be overwritten by switching branches:\\n\"));\n> > > +    for_each_string_list_item(item, file_list)\n> > > +     fprintf(stderr, \"\\t%s\\n\", item->string);\n> > > +\n> > > +    advise_if_enabled(ADVICE_STASH_BEFORE_CHECKOUT,\n> > > +                   _(\"You can save your local changes before switching by running:\\n\"\n> > > +                     \"\\n\"\n> > > +                     \"\\tgit stash push\\n\"\n> > > +                     \"\\n\"\n> > > +                     \"Then restore them after switching with:\\n\"\n> > > +                     \"\\n\"\n> > > +                     \"\\tgit stash pop\\n\"\n> > > +                     \"\\n\"\n> > > +                     \"Or to discard your local changes, use:\\n\"\n> > > +                     \"\\n\"\n> > > +                     \"\\tgit checkout -- <file>\"));\n> > > +}\n> >\n> > This doesn't seem to be formatted with tabs.\n"},{"id":"538467","messageId":"xmqqv7f3wv51.fsf@gitster.g","threadId":"65195","inReplyTo":"CAOAgETNoQuju_RWbe=jo8JF7J2+V_pVoyr6FeKw8LwYKi_HipA@mail.gmail.com","subject":"Re: [PATCH 0/5] Advice on checkout dirty files","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2026-03-10T15:40:10Z","receivedAt":"2026-03-10T15:40:12Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Arsh Srivastava <arshsrivastava00@gmail.com> writes:\n\n> As per the recommendation of Phillip Wood <phillip.wood123@gmail.com>\n> I have changed my files and added git checkout -m after understanding\n> its significance :)\n\nIt is a given that you as the author of the patch understand it.\nWhat I meant was that the users who get the recommendation need to\nbe told about the potential issues.\n"},{"id":"538470","messageId":"CAOAgETNkKrJHpPjfbW2nfZ8DUJ84-Z-zBx-WefYJb2sfD+EdWg@mail.gmail.com","threadId":"65195","inReplyTo":"xmqqv7f3wv51.fsf@gitster.g","subject":"Re: [PATCH 0/5] Advice on checkout dirty files","fromName":"Arsh Srivastava","fromEmail":"arshsrivastava00@gmail.com","sentAt":"2026-03-10T16:05:49Z","receivedAt":"2026-03-10T16:06:03Z","isPatch":true,"sender":{"key":"arshsrivastava00@gmail.com","avatar":"https://gravatar.com/avatar/31a57f3c18a3d49c0601d1863b1cea06242a5d6808b9bcc8fa8a801195d04cc7?d=mp&s=160"},"body":"Junio C Hamano <gitster@pobox.com> writes:\n\n> It is understood as author that I understand.\n> It is the users who need to understand.\n\nAs informed by Karthik Nayak <karthik.188@gmail.com> and Patrick\nSteinhardt <ps@pks.im>.\nMy PR seemed to have redundancy for which I will create a v4 for my PR\nremoving it and giving it proper description for users to understand.\n\nSigned-off-by: Arsh Srivastava <arshsrivastava00@gmail.com>\n\nOn Tue, 10 Mar 2026 at 21:10, Junio C Hamano <gitster@pobox.com> wrote:\n>\n> Arsh Srivastava <arshsrivastava00@gmail.com> writes:\n>\n> > As per the recommendation of Phillip Wood <phillip.wood123@gmail.com>\n> > I have changed my files and added git checkout -m after understanding\n> > its significance :)\n>\n> It is a given that you as the author of the patch understand it.\n> What I meant was that the users who get the recommendation need to\n> be told about the potential issues.\n"},{"id":"538471","messageId":"CAOAgETMw2LdTpW3XjE3nDF61T9Fixa0r0tT+fWpc6DEXsREAmQ@mail.gmail.com","threadId":"65195","inReplyTo":"xmqqv7f3wv51.fsf@gitster.g","subject":"Re: [PATCH 0/5] Advice on checkout dirty files","fromName":"Arsh Srivastava","fromEmail":"arshsrivastava00@gmail.com","sentAt":"2026-03-10T16:08:03Z","receivedAt":"2026-03-10T16:08:16Z","isPatch":true,"sender":{"key":"arshsrivastava00@gmail.com","avatar":"https://gravatar.com/avatar/31a57f3c18a3d49c0601d1863b1cea06242a5d6808b9bcc8fa8a801195d04cc7?d=mp&s=160"},"body":"Junio C Hamano <gitster@pobox.com> writes:\n\n> It is understood as author that I understand.\n> It is the users who need to understand.\n> Potential risks for the user.\n\nAs informed by Karthik Nayak <karthik.188@gmail.com> and Patrick\nSteinhardt <ps@pks.im>.\nMy PR seemed to have redundancy for which I will create a v4 for my PR\nremoving it and giving it proper description for users to understand\nthe possible risks of using -m.\n\nSigned-off-by: Arsh Srivastava <arshsrivastava00@gmail.com>\n\n\nOn Tue, 10 Mar 2026 at 21:10, Junio C Hamano <gitster@pobox.com> wrote:\n>\n> Arsh Srivastava <arshsrivastava00@gmail.com> writes:\n>\n> > As per the recommendation of Phillip Wood <phillip.wood123@gmail.com>\n> > I have changed my files and added git checkout -m after understanding\n> > its significance :)\n>\n> It is a given that you as the author of the patch understand it.\n> What I meant was that the users who get the recommendation need to\n> be told about the potential issues.\n"},{"id":"538474","messageId":"xmqqeclrwrz4.fsf@gitster.g","threadId":"65195","inReplyTo":"CAOAgETMmLKcz2CWqfKCJeoTCfACMXz7M0d2g_zO5M53tnGqQuA@mail.gmail.com","subject":"Re: [PATCH v2] advice: add stashBeforeCheckout advice for dirty branch switches","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2026-03-10T16:48:31Z","receivedAt":"2026-03-10T16:48:33Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Arsh Srivastava <arshsrivastava00@gmail.com> writes:\n\n> Subject: Re: [GSOC] advice: add stashBeforeCheckout advice for dirty\n> branch switches\n>\n> Karthik Nayak <karthik.188@gmail.com> writes:\n>\n>> Doesn't 'ADVICE_COMMIT_BEFORE_MERGE' already do this?\n>> So won't this simply be duplicating the same message?\n>\n> Thank you for the detailed review. You are correct, the existing message\n> ...\n> I will rework the patch in that direction and send a v4.\n>\n> Signed-off-by: Arsh Srivastava <arshsrivastava00@gmail.com>\n\nJust a comment by a bystander, but it confuses me quite a lot to see\nin-body \"Subject:\" and \"Sign-off\" in a message that is *not* a patch\nat all.  What are you signing off with this signature?\n"},{"id":"538476","messageId":"CAOLa=ZQu1hyiwMpBxJ=0PhNCf6LQqBt3F3=kycDv9cZST_JTNw@mail.gmail.com","threadId":"65195","inReplyTo":"xmqqeclrwrz4.fsf@gitster.g","subject":"Re: [PATCH v2] advice: add stashBeforeCheckout advice for dirty branch switches","fromName":"Karthik Nayak","fromEmail":"karthik.188@gmail.com","sentAt":"2026-03-10T17:09:25Z","receivedAt":"2026-03-10T17:09:28Z","isPatch":true,"sender":{"key":"karthik.188@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1786334?v=4"},"body":"Junio C Hamano <gitster@pobox.com> writes:\n\n> Arsh Srivastava <arshsrivastava00@gmail.com> writes:\n>\n>> Subject: Re: [GSOC] advice: add stashBeforeCheckout advice for dirty\n>> branch switches\n>>\n>> Karthik Nayak <karthik.188@gmail.com> writes:\n>>\n>>> Doesn't 'ADVICE_COMMIT_BEFORE_MERGE' already do this?\n>>> So won't this simply be duplicating the same message?\n>>\n>> Thank you for the detailed review. You are correct, the existing message\n>> ...\n>> I will rework the patch in that direction and send a v4.\n>>\n>> Signed-off-by: Arsh Srivastava <arshsrivastava00@gmail.com>\n>\n> Just a comment by a bystander, but it confuses me quite a lot to see\n> in-body \"Subject:\" and \"Sign-off\" in a message that is *not* a patch\n> at all.  What are you signing off with this signature?\n\nTangentially, I know that b4 adds a \"Sign-off\" to the cover message.\n"},{"id":"538479","messageId":"CAOLa=ZRRFWyvX7fSar8R1WYOQOz+mz_c_S9ZM7CDe9v7bbQeQQ@mail.gmail.com","threadId":"65195","inReplyTo":"CAOAgETOcivRUskCi4PCLnXzn1qGs9jx39JzgBA0jE=CirSkZJQ@mail.gmail.com","subject":"Re: [PATCH v2] advice: add stashBeforeCheckout advice for dirty branch switches","fromName":"Karthik Nayak","fromEmail":"karthik.188@gmail.com","sentAt":"2026-03-10T17:15:31Z","receivedAt":"2026-03-10T17:15:35Z","isPatch":true,"sender":{"key":"karthik.188@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1786334?v=4"},"body":"Arsh Srivastava <arshsrivastava00@gmail.com> writes:\n\n> Subject: Re: [GSOC] advice: add stashBeforeCheckout advice for dirty\n> branch switches\n>\n> Patrick Steinhardt <ps@pks.im> writes:\n>\n>> It is used in \"add.c\", but not magically so. The function that you have\n>> introduced is the only site that uses the new advice, but the function\n>> is never called as far as I can see. So ultimately, the proposed change\n>> does not have any effect on the user-observable behaviour.\n>\n> Thank you for the correction and for the bottom-posting reminder.\n>\n> You are right. The function advise_on_checkout_dirty_files() is defined\n> but never called anywhere, so the patch has no user-observable effect.\n> I also looked into the existing behaviour more carefully and found that\n> unpack-trees.c already handles this case and prints a message telling\n> the user to commit or stash their changes before switching branches.\n>\n> So the patch as written is both incomplete and duplicates existing\n> behaviour. I will rework it in v3 to instead enhance the existing\n> message in unpack-trees.c to also mention 'git checkout -m' for users\n> who want to carry their local changes over to the new branch.\n>\n\nI must say that the patch itself and the responses seem like they're\ngenerated with LLMs. Our guidelines for AI usage within the Git project\nare laid out in 'Documentation/SubmittingPatches'.\n\nFor GSoC specifically, we have laid out our expectations here [1].\nPlease go through them.\n\n[1]: https://git.github.io/General-Application-Information/\n\n[snip]\n"},{"id":"538498","messageId":"CAOAgETMjppTDG9jkV=zR+CVsEXwpVZ1peu3SbPZY9fNaKKmEMg@mail.gmail.com","threadId":"65195","inReplyTo":"xmqqeclrwrz4.fsf@gitster.g","subject":"Re: [PATCH v2] advice: add stashBeforeCheckout advice for dirty branch switches","fromName":"Arsh Srivastava","fromEmail":"arshsrivastava00@gmail.com","sentAt":"2026-03-10T17:56:13Z","receivedAt":"2026-03-10T17:56:26Z","isPatch":true,"sender":{"key":"arshsrivastava00@gmail.com","avatar":"https://gravatar.com/avatar/31a57f3c18a3d49c0601d1863b1cea06242a5d6808b9bcc8fa8a801195d04cc7?d=mp&s=160"},"body":"Junio C Hamano <gitster@pobox.com> writes\n\n>Sign-off and Subject in body confuses\n\nI thought writing sign-off was a necessity for my mail to be accepted\n\nOn Tue, 10 Mar 2026 at 22:18, Junio C Hamano <gitster@pobox.com> wrote:\n>\n> Arsh Srivastava <arshsrivastava00@gmail.com> writes:\n>\n> > Subject: Re: [GSOC] advice: add stashBeforeCheckout advice for dirty\n> > branch switches\n> >\n> > Karthik Nayak <karthik.188@gmail.com> writes:\n> >\n> >> Doesn't 'ADVICE_COMMIT_BEFORE_MERGE' already do this?\n> >> So won't this simply be duplicating the same message?\n> >\n> > Thank you for the detailed review. You are correct, the existing message\n> > ...\n> > I will rework the patch in that direction and send a v4.\n> >\n> > Signed-off-by: Arsh Srivastava <arshsrivastava00@gmail.com>\n>\n> Just a comment by a bystander, but it confuses me quite a lot to see\n> in-body \"Subject:\" and \"Sign-off\" in a message that is *not* a patch\n> at all.  What are you signing off with this signature?\n"},{"id":"538499","messageId":"CAOAgETPfXxjo-Ltw=4q7rG_AV4VpGzRCwLDBTvdxtbWbh22GYA@mail.gmail.com","threadId":"65195","inReplyTo":"CAOLa=ZRRFWyvX7fSar8R1WYOQOz+mz_c_S9ZM7CDe9v7bbQeQQ@mail.gmail.com","subject":"Re: [PATCH v2] advice: add stashBeforeCheckout advice for dirty branch switches","fromName":"Arsh Srivastava","fromEmail":"arshsrivastava00@gmail.com","sentAt":"2026-03-10T18:00:32Z","receivedAt":"2026-03-10T18:00:45Z","isPatch":true,"sender":{"key":"arshsrivastava00@gmail.com","avatar":"https://gravatar.com/avatar/31a57f3c18a3d49c0601d1863b1cea06242a5d6808b9bcc8fa8a801195d04cc7?d=mp&s=160"},"body":"Karthik Nayak <karthik.188@gmail.com> writes\n\n> Use of Ai in patches and messages\n> Suggest the documentation for the same\n\nAfter reading the document carefully again , I understood my mistakes\nand I promise to not repeat it again while submitting future PR and\ncommits.\nI am deeply sorry for the mistakes I made and promise to never repeat\nthem again including in submission of version 4 of my current PR\n\nOn Tue, 10 Mar 2026 at 22:45, Karthik Nayak <karthik.188@gmail.com> wrote:\n>\n> Arsh Srivastava <arshsrivastava00@gmail.com> writes:\n>\n> > Subject: Re: [GSOC] advice: add stashBeforeCheckout advice for dirty\n> > branch switches\n> >\n> > Patrick Steinhardt <ps@pks.im> writes:\n> >\n> >> It is used in \"add.c\", but not magically so. The function that you have\n> >> introduced is the only site that uses the new advice, but the function\n> >> is never called as far as I can see. So ultimately, the proposed change\n> >> does not have any effect on the user-observable behaviour.\n> >\n> > Thank you for the correction and for the bottom-posting reminder.\n> >\n> > You are right. The function advise_on_checkout_dirty_files() is defined\n> > but never called anywhere, so the patch has no user-observable effect.\n> > I also looked into the existing behaviour more carefully and found that\n> > unpack-trees.c already handles this case and prints a message telling\n> > the user to commit or stash their changes before switching branches.\n> >\n> > So the patch as written is both incomplete and duplicates existing\n> > behaviour. I will rework it in v3 to instead enhance the existing\n> > message in unpack-trees.c to also mention 'git checkout -m' for users\n> > who want to carry their local changes over to the new branch.\n> >\n>\n> I must say that the patch itself and the responses seem like they're\n> generated with LLMs. Our guidelines for AI usage within the Git project\n> are laid out in 'Documentation/SubmittingPatches'.\n>\n> For GSoC specifically, we have laid out our expectations here [1].\n> Please go through them.\n>\n> [1]: https://git.github.io/General-Application-Information/\n>\n> [snip]\n"},{"id":"538565","messageId":"pull.2233.v4.git.git.1773219028.gitgitgadget@gmail.com","threadId":"65195","inReplyTo":"pull.2233.v3.git.git.1773149337.gitgitgadget@gmail.com","subject":"[PATCH v4 0/5] Advice on checkout dirty files","fromName":"Arsh Srivastava via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2026-03-11T08:50:23Z","receivedAt":"2026-03-11T08:50:33Z","isPatch":true,"sender":{"key":"arshsrivastava00@gmail.com","avatar":"https://gravatar.com/avatar/31a57f3c18a3d49c0601d1863b1cea06242a5d6808b9bcc8fa8a801195d04cc7?d=mp&s=160"},"body":"This is my submission for microproject [GSOC]\n\nThis patch adds a new advice type ADVICE_STASH_BEFORE_CHECKOUT to help users\nwhen they attempt to switch branches with local modifications that would be\noverwritten by the operation.\n\nThe new advice follows the same patterns established by existing advice\nfunctions such as advise_on_updating_sparse_paths(). When triggered, it\nlists the affected files and suggests using git stash push/pop to save and\nrestore local changes.\n\nThe advice can be silenced with:\n\ngit config set advice.stashBeforeCheckout false\n\nChanges:\n\n> advice.h: add ADVICE_STASH_BEFORE_CHECKOUT enum value advice.c: add\n> \"stashBeforeCheckout\" to advice_setting[] and implement\n> advise_on_checkout_dirty_files() function\n> Documentation/config/advice.adoc: document the new advice key\n\nSigned-off-by: Arsh Srivastava arshsrivastava00@gmail.com\n\nArsh Srivastava (5):\n  advice: add stashBeforeCheckout advice for dirty branch switches\n  advice: add stashBeforeCheckout advice for dirty branch switches\n    [GSOC]\n  unpack-trees: suggesting 'git checkout -m <branch>' with its\n    repercussions\n  Updating tests and unpack-tress.c [GSOC]\n  File updation [GSOC]\n\n t/t6439-merge-co-error-msgs.sh | 6 ++++++\n t/t7406-submodule-update.sh    | 3 +++\n unpack-trees.c                 | 9 +++++++--\n 3 files changed, 16 insertions(+), 2 deletions(-)\n\n\nbase-commit: d181b9354cf85b44455ce3ca9e6af0b9559e0ae2\nPublished-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-2233%2FArsh123344423%2Fadvice_on_checkout_dirty_files-v4\nFetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-2233/Arsh123344423/advice_on_checkout_dirty_files-v4\nPull-Request: https://github.com/git/git/pull/2233\n\nRange-diff vs v3:\n\n 1:  eb5639dbc3 = 1:  eb5639dbc3 advice: add stashBeforeCheckout advice for dirty branch switches\n 2:  e88c851701 = 2:  e88c851701 advice: add stashBeforeCheckout advice for dirty branch switches [GSOC]\n -:  ---------- > 3:  4237b9667d unpack-trees: suggesting 'git checkout -m <branch>' with its repercussions\n -:  ---------- > 4:  b25ea22410 Updating tests and unpack-tress.c [GSOC]\n -:  ---------- > 5:  2ef7d5a3d6 File updation [GSOC]\n\n-- \ngitgitgadget\n"},{"id":"538566","messageId":"eb5639dbc3571fde15f2d93cf2d137b8df775d2f.1773219028.git.gitgitgadget@gmail.com","threadId":"65195","inReplyTo":"pull.2233.v4.git.git.1773219028.gitgitgadget@gmail.com","subject":"[PATCH v4 1/5] advice: add stashBeforeCheckout advice for dirty branch switches","fromName":"Arsh Srivastava via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2026-03-11T08:50:24Z","receivedAt":"2026-03-11T08:50:34Z","isPatch":true,"sender":{"key":"arshsrivastava00@gmail.com","avatar":"https://gravatar.com/avatar/31a57f3c18a3d49c0601d1863b1cea06242a5d6808b9bcc8fa8a801195d04cc7?d=mp&s=160"},"body":"From: Arsh Srivastava <arshsrivastava00@gmail.com>\n\nAdd a new advice type ADVICE_STASH_BEFORE_CHECKOUT to guide users\nwhen they attempt to switch branches with local modifications that\nwould be overwritten by the operation.\n\nThis includes:\n> New ADVICE_STASH_BEFORE_CHECKOUT enum value in advice.h\n> Corresponding \"stashBeforeCheckout\" entry in advice_setting[]\n> New advise_on_checkout_dirty_files() function that lists the\n  affected files and suggests using git stash push/pop\n> Documentation entry in Documentation/config/advice.txt\n\nThe advice follows existing patterns established by\nadvise_on_updating_sparse_paths() and can be silenced with:\n\n  git config set advice.stashBeforeCheckout false\n\nSigned-off-by: Arsh Srivastava <arshsrivastava00@gmail.com>\n---\n Documentation/config/advice.adoc |  5 +++++\n advice.c                         | 27 +++++++++++++++++++++++++++\n advice.h                         |  2 ++\n 3 files changed, 34 insertions(+)\n\ndiff --git a/Documentation/config/advice.adoc b/Documentation/config/advice.adoc\nindex 257db58918..8752e05636 100644\n--- a/Documentation/config/advice.adoc\n+++ b/Documentation/config/advice.adoc\n@@ -126,6 +126,11 @@ all advice messages.\n \t\tShown when a sparse index is expanded to a full index, which is likely\n \t\tdue to an unexpected set of files existing outside of the\n \t\tsparse-checkout.\n+\tstashBeforeCheckout::\n+\t\tShown when the user attempts to switch branches but has\n+\t\tlocal modifications that would be overwritten by the\n+\t\toperation, to suggest using linkgit:git-stash[1] to\n+\t\tsave changes before switching.\n \tstatusAheadBehind::\n \t\tShown when linkgit:git-status[1] computes the ahead/behind\n \t\tcounts for a local ref compared to its remote tracking ref,\ndiff --git a/advice.c b/advice.c\nindex 0018501b7b..e1264f525c 100644\n--- a/advice.c\n+++ b/advice.c\n@@ -81,6 +81,7 @@ static struct {\n \t[ADVICE_SET_UPSTREAM_FAILURE]\t\t\t= { \"setUpstreamFailure\" },\n \t[ADVICE_SKIPPED_CHERRY_PICKS]\t\t\t= { \"skippedCherryPicks\" },\n \t[ADVICE_SPARSE_INDEX_EXPANDED]\t\t\t= { \"sparseIndexExpanded\" },\n+\t[ADVICE_STASH_BEFORE_CHECKOUT] = { \"stashBeforeCheckout\" },\n \t[ADVICE_STATUS_AHEAD_BEHIND_WARNING]\t\t= { \"statusAheadBehindWarning\" },\n \t[ADVICE_STATUS_HINTS]\t\t\t\t= { \"statusHints\" },\n \t[ADVICE_STATUS_U_OPTION]\t\t\t= { \"statusUoption\" },\n@@ -312,3 +313,29 @@ void advise_on_moving_dirty_path(struct string_list *pathspec_list)\n \t\t\t    \"* Use \\\"git add --sparse <paths>\\\" to update the index\\n\"\n \t\t\t    \"* Use \\\"git sparse-checkout reapply\\\" to apply the sparsity rules\"));\n }\n+\n+void advise_on_checkout_dirty_files(struct string_list *file_list)\n+{\n+    struct string_list_item *item;\n+\n+    if (!file_list->nr)\n+\treturn;\n+\n+    fprintf(stderr, _(\"The following files have local modifications that would\\n\"\n+\t\t      \"be overwritten by switching branches:\\n\"));\n+    for_each_string_list_item(item, file_list)\n+\tfprintf(stderr, \"\\t%s\\n\", item->string);\n+\n+    advise_if_enabled(ADVICE_STASH_BEFORE_CHECKOUT,\n+\t\t      _(\"You can save your local changes before switching by running:\\n\"\n+\t\t\t\"\\n\"\n+\t\t\t\"\\tgit stash push\\n\"\n+\t\t\t\"\\n\"\n+\t\t\t\"Then restore them after switching with:\\n\"\n+\t\t\t\"\\n\"\n+\t\t\t\"\\tgit stash pop\\n\"\n+\t\t\t\"\\n\"\n+\t\t\t\"Or to discard your local changes, use:\\n\"\n+\t\t\t\"\\n\"\n+\t\t\t\"\\tgit checkout -- <file>\"));\n+}\ndiff --git a/advice.h b/advice.h\nindex 8def280688..c035b5d8e3 100644\n--- a/advice.h\n+++ b/advice.h\n@@ -48,6 +48,7 @@ enum advice_type {\n \tADVICE_SET_UPSTREAM_FAILURE,\n \tADVICE_SKIPPED_CHERRY_PICKS,\n \tADVICE_SPARSE_INDEX_EXPANDED,\n+\tADVICE_STASH_BEFORE_CHECKOUT,\n \tADVICE_STATUS_AHEAD_BEHIND_WARNING,\n \tADVICE_STATUS_HINTS,\n \tADVICE_STATUS_U_OPTION,\n@@ -83,5 +84,6 @@ void NORETURN die_ff_impossible(void);\n void advise_on_updating_sparse_paths(struct string_list *pathspec_list);\n void detach_advice(const char *new_name);\n void advise_on_moving_dirty_path(struct string_list *pathspec_list);\n+void advise_on_checkout_dirty_files(struct string_list *file_list);\n \n #endif /* ADVICE_H */\n-- \ngitgitgadget\n\n"},{"id":"538567","messageId":"e88c85170147a7c5d44640cba0c48aa686e23f17.1773219028.git.gitgitgadget@gmail.com","threadId":"65195","inReplyTo":"pull.2233.v4.git.git.1773219028.gitgitgadget@gmail.com","subject":"[PATCH v4 2/5] advice: add stashBeforeCheckout advice for dirty branch switches [GSOC]","fromName":"Arsh Srivastava via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2026-03-11T08:50:25Z","receivedAt":"2026-03-11T08:50:35Z","isPatch":true,"sender":{"key":"arshsrivastava00@gmail.com","avatar":"https://gravatar.com/avatar/31a57f3c18a3d49c0601d1863b1cea06242a5d6808b9bcc8fa8a801195d04cc7?d=mp&s=160"},"body":"From: Arsh Srivastava <arshsrivastava00@gmail.com>\n\nAdd a new advice type ADVICE_STASH_BEFORE_CHECKOUT to guide users\nwhen they attempt to switch branches with local modifications that\nwould be overwritten by the operation.\n\nThe advice suggests using \"git checkout -m\" to carry local changes\nover to the new branch in a single step.\n\nThe advice can be silenced with:\n\n  git config set advice.stashBeforeCheckout false\n\nChanges:\n- advice.h: add ADVICE_STASH_BEFORE_CHECKOUT enum value\n- advice.c: add \"stashBeforeCheckout\" to advice_setting[] and implement\n  advise_on_checkout_dirty_files() function\n- Documentation/config/advice.adoc: document the new advice key\n\nSigned-off-by: Arsh Srivastava <arshsrivastava00@gmail.com>\n---\n advice.c | 13 +++----------\n 1 file changed, 3 insertions(+), 10 deletions(-)\n\ndiff --git a/advice.c b/advice.c\nindex e1264f525c..ba290d3760 100644\n--- a/advice.c\n+++ b/advice.c\n@@ -327,15 +327,8 @@ void advise_on_checkout_dirty_files(struct string_list *file_list)\n \tfprintf(stderr, \"\\t%s\\n\", item->string);\n \n     advise_if_enabled(ADVICE_STASH_BEFORE_CHECKOUT,\n-\t\t      _(\"You can save your local changes before switching by running:\\n\"\n+\t\t      _(\"To carry your local changes over to the new branch, use:\\n\"\n \t\t\t\"\\n\"\n-\t\t\t\"\\tgit stash push\\n\"\n-\t\t\t\"\\n\"\n-\t\t\t\"Then restore them after switching with:\\n\"\n-\t\t\t\"\\n\"\n-\t\t\t\"\\tgit stash pop\\n\"\n-\t\t\t\"\\n\"\n-\t\t\t\"Or to discard your local changes, use:\\n\"\n-\t\t\t\"\\n\"\n-\t\t\t\"\\tgit checkout -- <file>\"));\n+\t\t\t\"\\tgit checkout -m <branch>\\n\"\n+\t\t\t));\n }\n-- \ngitgitgadget\n\n"},{"id":"538568","messageId":"4237b9667d40e2bf3ad71d953a06eec2aa70aa1b.1773219028.git.gitgitgadget@gmail.com","threadId":"65195","inReplyTo":"pull.2233.v4.git.git.1773219028.gitgitgadget@gmail.com","subject":"[PATCH v4 3/5] unpack-trees: suggesting 'git checkout -m <branch>' with its repercussions","fromName":"Arsh Srivastava via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2026-03-11T08:50:26Z","receivedAt":"2026-03-11T08:50:36Z","isPatch":true,"sender":{"key":"arshsrivastava00@gmail.com","avatar":"https://gravatar.com/avatar/31a57f3c18a3d49c0601d1863b1cea06242a5d6808b9bcc8fa8a801195d04cc7?d=mp&s=160"},"body":"From: Arsh Srivastava <arshsrivastava00@gmail.com>\n\nThis comment is an extention to the already existing stash comment.\n\nAfter the valuable insights given to me by git maintaniers.\nI removed the new function I introduced.\nAdded updated comment over the already existing function\n\"setup_unpack_trees_porcelain\" with \"git checkout -m <branch>\"\nand its repercussions\nI have also mentioned the repercussions of using \"-m\".\n\nSigned-off-by: Arsh Srivastava <arshsrivastava00@gmail.com>\n---\n Documentation/config/advice.adoc |  5 -----\n advice.c                         | 20 --------------------\n advice.h                         |  2 --\n unpack-trees.c                   | 13 +++++++++++--\n 4 files changed, 11 insertions(+), 29 deletions(-)\n\ndiff --git a/Documentation/config/advice.adoc b/Documentation/config/advice.adoc\nindex 8752e05636..257db58918 100644\n--- a/Documentation/config/advice.adoc\n+++ b/Documentation/config/advice.adoc\n@@ -126,11 +126,6 @@ all advice messages.\n \t\tShown when a sparse index is expanded to a full index, which is likely\n \t\tdue to an unexpected set of files existing outside of the\n \t\tsparse-checkout.\n-\tstashBeforeCheckout::\n-\t\tShown when the user attempts to switch branches but has\n-\t\tlocal modifications that would be overwritten by the\n-\t\toperation, to suggest using linkgit:git-stash[1] to\n-\t\tsave changes before switching.\n \tstatusAheadBehind::\n \t\tShown when linkgit:git-status[1] computes the ahead/behind\n \t\tcounts for a local ref compared to its remote tracking ref,\ndiff --git a/advice.c b/advice.c\nindex ba290d3760..0018501b7b 100644\n--- a/advice.c\n+++ b/advice.c\n@@ -81,7 +81,6 @@ static struct {\n \t[ADVICE_SET_UPSTREAM_FAILURE]\t\t\t= { \"setUpstreamFailure\" },\n \t[ADVICE_SKIPPED_CHERRY_PICKS]\t\t\t= { \"skippedCherryPicks\" },\n \t[ADVICE_SPARSE_INDEX_EXPANDED]\t\t\t= { \"sparseIndexExpanded\" },\n-\t[ADVICE_STASH_BEFORE_CHECKOUT] = { \"stashBeforeCheckout\" },\n \t[ADVICE_STATUS_AHEAD_BEHIND_WARNING]\t\t= { \"statusAheadBehindWarning\" },\n \t[ADVICE_STATUS_HINTS]\t\t\t\t= { \"statusHints\" },\n \t[ADVICE_STATUS_U_OPTION]\t\t\t= { \"statusUoption\" },\n@@ -313,22 +312,3 @@ void advise_on_moving_dirty_path(struct string_list *pathspec_list)\n \t\t\t    \"* Use \\\"git add --sparse <paths>\\\" to update the index\\n\"\n \t\t\t    \"* Use \\\"git sparse-checkout reapply\\\" to apply the sparsity rules\"));\n }\n-\n-void advise_on_checkout_dirty_files(struct string_list *file_list)\n-{\n-    struct string_list_item *item;\n-\n-    if (!file_list->nr)\n-\treturn;\n-\n-    fprintf(stderr, _(\"The following files have local modifications that would\\n\"\n-\t\t      \"be overwritten by switching branches:\\n\"));\n-    for_each_string_list_item(item, file_list)\n-\tfprintf(stderr, \"\\t%s\\n\", item->string);\n-\n-    advise_if_enabled(ADVICE_STASH_BEFORE_CHECKOUT,\n-\t\t      _(\"To carry your local changes over to the new branch, use:\\n\"\n-\t\t\t\"\\n\"\n-\t\t\t\"\\tgit checkout -m <branch>\\n\"\n-\t\t\t));\n-}\ndiff --git a/advice.h b/advice.h\nindex c035b5d8e3..8def280688 100644\n--- a/advice.h\n+++ b/advice.h\n@@ -48,7 +48,6 @@ enum advice_type {\n \tADVICE_SET_UPSTREAM_FAILURE,\n \tADVICE_SKIPPED_CHERRY_PICKS,\n \tADVICE_SPARSE_INDEX_EXPANDED,\n-\tADVICE_STASH_BEFORE_CHECKOUT,\n \tADVICE_STATUS_AHEAD_BEHIND_WARNING,\n \tADVICE_STATUS_HINTS,\n \tADVICE_STATUS_U_OPTION,\n@@ -84,6 +83,5 @@ void NORETURN die_ff_impossible(void);\n void advise_on_updating_sparse_paths(struct string_list *pathspec_list);\n void detach_advice(const char *new_name);\n void advise_on_moving_dirty_path(struct string_list *pathspec_list);\n-void advise_on_checkout_dirty_files(struct string_list *file_list);\n \n #endif /* ADVICE_H */\ndiff --git a/unpack-trees.c b/unpack-trees.c\nindex 998a1e6dc7..9449ee8203 100644\n--- a/unpack-trees.c\n+++ b/unpack-trees.c\n@@ -128,8 +128,17 @@ void setup_unpack_trees_porcelain(struct unpack_trees_options *opts,\n \tif (!strcmp(cmd, \"checkout\"))\n \t\tmsg = advice_enabled(ADVICE_COMMIT_BEFORE_MERGE)\n \t\t      ? _(\"Your local changes to the following files would be overwritten by checkout:\\n%%s\"\n-\t\t\t  \"Please commit your changes or stash them before you switch branches.\")\n-\t\t      : _(\"Your local changes to the following files would be overwritten by checkout:\\n%%s\");\n+\t\t\t  \"Please commit your changes or stash them before you switch branches.\\n\"\n+\t\t\t  \"Try using 'git checkout -m <branch>' for a quick fix. \\n\"\n+\t\t\t  \"Please Note :- that using -m (merge) will not save your changes, rather would directly merge them.\\n\"\n+\t\t\t  \"Meaning if you are not able to resolve conflicts and does --hard reset your local changes would be gone.\"\n+\t\t\t  )\n+\t\t      : _(\"Your local changes to the following files would be overwritten by checkout:\\n%%s\"\n+\t\t\t\t\"Please commit your changes or stash them before you switch branches.\\n\"\n+\t\t\t  \"Try using 'git checkout -m <branch>' for a quick fix.\\n\"\n+\t\t\t  \"Please Note :- that using -m (merge) will not save your changes, rather would directly merge them.\\n\"\n+\t\t\t  \"Meaning if you are not able to resolve conflicts and does --hard reset your local changes would be gone.\"\n+\t\t\t  );\n \telse if (!strcmp(cmd, \"merge\"))\n \t\tmsg = advice_enabled(ADVICE_COMMIT_BEFORE_MERGE)\n \t\t      ? _(\"Your local changes to the following files would be overwritten by merge:\\n%%s\"\n-- \ngitgitgadget\n\n"},{"id":"538569","messageId":"b25ea22410a6f8a3e223ecfdf4941a72041844d0.1773219028.git.gitgitgadget@gmail.com","threadId":"65195","inReplyTo":"pull.2233.v4.git.git.1773219028.gitgitgadget@gmail.com","subject":"[PATCH v4 4/5] Updating tests and unpack-tress.c [GSOC]","fromName":"Arsh Srivastava via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2026-03-11T08:50:27Z","receivedAt":"2026-03-11T08:50:38Z","isPatch":true,"sender":{"key":"arshsrivastava00@gmail.com","avatar":"https://gravatar.com/avatar/31a57f3c18a3d49c0601d1863b1cea06242a5d6808b9bcc8fa8a801195d04cc7?d=mp&s=160"},"body":"From: Arsh Srivastava <arshsrivastava00@gmail.com>\n\nWhile submitting my previous commit found that\nprevious testcases weren't working properly\nwith my updates\n\nSo fixed the test updates and advice conflict issue.\n\nSigned-off-by: Arsh Srivastava <arshsrivastava00@gmail.com>\n---\n t/t6439-merge-co-error-msgs.sh | 4 ++++\n t/t7406-submodule-update.sh    | 2 ++\n unpack-trees.c                 | 6 +-----\n 3 files changed, 7 insertions(+), 5 deletions(-)\n\ndiff --git a/t/t6439-merge-co-error-msgs.sh b/t/t6439-merge-co-error-msgs.sh\nindex 643c9368e0..6ebc1d2565 100755\n--- a/t/t6439-merge-co-error-msgs.sh\n+++ b/t/t6439-merge-co-error-msgs.sh\n@@ -77,6 +77,8 @@ error: Your local changes to the following files would be overwritten by checkou\n \trep/one\n \trep/two\n Please commit your changes or stash them before you switch branches.\n+Try using 'git checkout -m <branch>' for a quick fix.\n+Please Note :- that using -m (merge) will not save your changes, rather would directly merge them. Meaning if you are not able to resolve conflicts and does --hard reset your local changes would be gone.\n Aborting\n EOF\n \n@@ -99,6 +101,8 @@ error: Your local changes to the following files would be overwritten by checkou\n \trep/one\n \trep/two\n Please commit your changes or stash them before you switch branches.\n+Try using 'git checkout -m <branch>' for a quick fix.\n+Please Note :- that using -m (merge) will not save your changes, rather would directly merge them. Meaning if you are not able to resolve conflicts and does --hard reset your local changes would be gone.\n Aborting\n EOF\n \ndiff --git a/t/t7406-submodule-update.sh b/t/t7406-submodule-update.sh\nindex 3adab12091..a359429bf5 100755\n--- a/t/t7406-submodule-update.sh\n+++ b/t/t7406-submodule-update.sh\n@@ -212,6 +212,8 @@ test_expect_success 'submodule update should fail due to local changes' '\n \t> error: Your local changes to the following files would be overwritten by checkout:\n \t> \tfile\n \t> Please commit your changes or stash them before you switch branches.\n+\t> Try using '\\''git checkout -m <branch>'\\'' for a quick fix.\n+\t> Please Note :- that using -m (merge) will not save your changes, rather would directly merge them. Meaning if you are not able to resolve conflicts and does --hard reset your local changes would be gone.\n \t> Aborting\n \t> fatal: Unable to checkout OID in submodule path '\\''submodule'\\''\n \tEOF\ndiff --git a/unpack-trees.c b/unpack-trees.c\nindex 9449ee8203..cb4cdee9b9 100644\n--- a/unpack-trees.c\n+++ b/unpack-trees.c\n@@ -134,11 +134,7 @@ void setup_unpack_trees_porcelain(struct unpack_trees_options *opts,\n \t\t\t  \"Meaning if you are not able to resolve conflicts and does --hard reset your local changes would be gone.\"\n \t\t\t  )\n \t\t      : _(\"Your local changes to the following files would be overwritten by checkout:\\n%%s\"\n-\t\t\t\t\"Please commit your changes or stash them before you switch branches.\\n\"\n-\t\t\t  \"Try using 'git checkout -m <branch>' for a quick fix.\\n\"\n-\t\t\t  \"Please Note :- that using -m (merge) will not save your changes, rather would directly merge them.\\n\"\n-\t\t\t  \"Meaning if you are not able to resolve conflicts and does --hard reset your local changes would be gone.\"\n-\t\t\t  );\n+\t\t\t\t\"Please commit your changes or stash them before you switch branches.\");\n \telse if (!strcmp(cmd, \"merge\"))\n \t\tmsg = advice_enabled(ADVICE_COMMIT_BEFORE_MERGE)\n \t\t      ? _(\"Your local changes to the following files would be overwritten by merge:\\n%%s\"\n-- \ngitgitgadget\n\n"},{"id":"538570","messageId":"2ef7d5a3d6c2249f153dfc3a2a3dbacfea8253e5.1773219028.git.gitgitgadget@gmail.com","threadId":"65195","inReplyTo":"pull.2233.v4.git.git.1773219028.gitgitgadget@gmail.com","subject":"[PATCH v4 5/5] File updation [GSOC]","fromName":"Arsh Srivastava via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2026-03-11T08:50:28Z","receivedAt":"2026-03-11T08:50:41Z","isPatch":true,"sender":{"key":"arshsrivastava00@gmail.com","avatar":"https://gravatar.com/avatar/31a57f3c18a3d49c0601d1863b1cea06242a5d6808b9bcc8fa8a801195d04cc7?d=mp&s=160"},"body":"From: Arsh Srivastava <arshsrivastava00@gmail.com>\n\nI have ran tests locally for this file\nand tried to fix all the CI issues\nLets Hope it works\n\nSigned-off-by: Arsh Srivastava <arshsrivastava00@gmail.com>\n---\n t/t6439-merge-co-error-msgs.sh | 6 ++++--\n t/t7406-submodule-update.sh    | 3 ++-\n unpack-trees.c                 | 2 +-\n 3 files changed, 7 insertions(+), 4 deletions(-)\n\ndiff --git a/t/t6439-merge-co-error-msgs.sh b/t/t6439-merge-co-error-msgs.sh\nindex 6ebc1d2565..cf996e0e51 100755\n--- a/t/t6439-merge-co-error-msgs.sh\n+++ b/t/t6439-merge-co-error-msgs.sh\n@@ -78,7 +78,8 @@ error: Your local changes to the following files would be overwritten by checkou\n \trep/two\n Please commit your changes or stash them before you switch branches.\n Try using 'git checkout -m <branch>' for a quick fix.\n-Please Note :- that using -m (merge) will not save your changes, rather would directly merge them. Meaning if you are not able to resolve conflicts and does --hard reset your local changes would be gone.\n+Please Note :- that using -m (merge) will not save your changes, rather would directly merge them.\n+Meaning if you are not able to resolve conflicts and does --hard reset your local changes would be gone.\n Aborting\n EOF\n \n@@ -102,7 +103,8 @@ error: Your local changes to the following files would be overwritten by checkou\n \trep/two\n Please commit your changes or stash them before you switch branches.\n Try using 'git checkout -m <branch>' for a quick fix.\n-Please Note :- that using -m (merge) will not save your changes, rather would directly merge them. Meaning if you are not able to resolve conflicts and does --hard reset your local changes would be gone.\n+Please Note :- that using -m (merge) will not save your changes, rather would directly merge them.\n+Meaning if you are not able to resolve conflicts and does --hard reset your local changes would be gone.\n Aborting\n EOF\n \ndiff --git a/t/t7406-submodule-update.sh b/t/t7406-submodule-update.sh\nindex a359429bf5..2e4cc9b3fe 100755\n--- a/t/t7406-submodule-update.sh\n+++ b/t/t7406-submodule-update.sh\n@@ -213,7 +213,8 @@ test_expect_success 'submodule update should fail due to local changes' '\n \t> \tfile\n \t> Please commit your changes or stash them before you switch branches.\n \t> Try using '\\''git checkout -m <branch>'\\'' for a quick fix.\n-\t> Please Note :- that using -m (merge) will not save your changes, rather would directly merge them. Meaning if you are not able to resolve conflicts and does --hard reset your local changes would be gone.\n+\t> Please Note :- that using -m (merge) will not save your changes, rather would directly merge them.\n+\t> Meaning if you are not able to resolve conflicts and does --hard reset your local changes would be gone.\n \t> Aborting\n \t> fatal: Unable to checkout OID in submodule path '\\''submodule'\\''\n \tEOF\ndiff --git a/unpack-trees.c b/unpack-trees.c\nindex cb4cdee9b9..9835a82455 100644\n--- a/unpack-trees.c\n+++ b/unpack-trees.c\n@@ -129,7 +129,7 @@ void setup_unpack_trees_porcelain(struct unpack_trees_options *opts,\n \t\tmsg = advice_enabled(ADVICE_COMMIT_BEFORE_MERGE)\n \t\t      ? _(\"Your local changes to the following files would be overwritten by checkout:\\n%%s\"\n \t\t\t  \"Please commit your changes or stash them before you switch branches.\\n\"\n-\t\t\t  \"Try using 'git checkout -m <branch>' for a quick fix. \\n\"\n+\t\t\t  \"Try using 'git checkout -m <branch>' for a quick fix.\\n\"\n \t\t\t  \"Please Note :- that using -m (merge) will not save your changes, rather would directly merge them.\\n\"\n \t\t\t  \"Meaning if you are not able to resolve conflicts and does --hard reset your local changes would be gone.\"\n \t\t\t  )\n-- \ngitgitgadget\n"},{"id":"538621","messageId":"xmqqikb2qq20.fsf@gitster.g","threadId":"65195","inReplyTo":"pull.2233.v4.git.git.1773219028.gitgitgadget@gmail.com","subject":"Re: [PATCH v4 0/5] Advice on checkout dirty files","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2026-03-11T16:38:47Z","receivedAt":"2026-03-11T16:38:50Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"Arsh Srivastava via GitGitGadget\" <gitgitgadget@gmail.com> writes:\n\n> This is my submission for microproject [GSOC]\n>\n> This patch adds a new advice type ADVICE_STASH_BEFORE_CHECKOUT to help users\n> when they attempt to switch branches with local modifications that would be\n> overwritten by the operation.\n>\n> The new advice follows the same patterns established by existing advice\n> functions such as advise_on_updating_sparse_paths(). When triggered, it\n> lists the affected files and suggests using git stash push/pop to save and\n> restore local changes.\n>\n> The advice can be silenced with:\n>\n> git config set advice.stashBeforeCheckout false\n>\n> Changes:\n>\n>> advice.h: add ADVICE_STASH_BEFORE_CHECKOUT enum value advice.c: add\n>> \"stashBeforeCheckout\" to advice_setting[] and implement\n>> advise_on_checkout_dirty_files() function\n>> Documentation/config/advice.adoc: document the new advice key\n>\n> Signed-off-by: Arsh Srivastava arshsrivastava00@gmail.com\n\nEven though no developer is perfect, when you are presenting your\nupdated work, armed with wisdom borrowed from your reviewers'\ncomments on your earlier attempts, you are expected to take the\nopportunity to pretend to have written a series of patches that are\nperfect logical progression towards the final shape of the code\nwithout detours, change of plans, and fixing earlier mistakes made\nin the series.\n\nPlease do not throw a drunken-man's-walk series at us.  For example,\nI see that [PATCH 3/5] literally removes what was added by earlier\npatches.  This is not a place for you to show how you made wrong\nturns before arriving at the final shape of the code.\n\nThe final series accepted by the project will have to stay in our\nhistory for later developers to see in \"git log\" output to learn\nfrom, and a series being clean logical progression is a must for\nthat to happen.\n\nAlso, what is \"updation\"?  Is it a standard English word, or some\ndialect of an LLM origin?\n\n> Arsh Srivastava (5):\n>   advice: add stashBeforeCheckout advice for dirty branch switches\n>   advice: add stashBeforeCheckout advice for dirty branch switches\n>     [GSOC]\n>   unpack-trees: suggesting 'git checkout -m <branch>' with its\n>     repercussions\n>   Updating tests and unpack-tress.c [GSOC]\n>   File updation [GSOC]\n>\n>  t/t6439-merge-co-error-msgs.sh | 6 ++++++\n>  t/t7406-submodule-update.sh    | 3 +++\n>  unpack-trees.c                 | 9 +++++++--\n>  3 files changed, 16 insertions(+), 2 deletions(-)\n>\n>\n> base-commit: d181b9354cf85b44455ce3ca9e6af0b9559e0ae2\n> Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-2233%2FArsh123344423%2Fadvice_on_checkout_dirty_files-v4\n> Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-2233/Arsh123344423/advice_on_checkout_dirty_files-v4\n> Pull-Request: https://github.com/git/git/pull/2233\n>\n> Range-diff vs v3:\n>\n>  1:  eb5639dbc3 = 1:  eb5639dbc3 advice: add stashBeforeCheckout advice for dirty branch switches\n>  2:  e88c851701 = 2:  e88c851701 advice: add stashBeforeCheckout advice for dirty branch switches [GSOC]\n>  -:  ---------- > 3:  4237b9667d unpack-trees: suggesting 'git checkout -m <branch>' with its repercussions\n>  -:  ---------- > 4:  b25ea22410 Updating tests and unpack-tress.c [GSOC]\n>  -:  ---------- > 5:  2ef7d5a3d6 File updation [GSOC]\n"},{"id":"538623","messageId":"CAOAgETOZL5339mypnb9z4JXZj=7TsOfdNy=x_uwBLFKcxH13cQ@mail.gmail.com","threadId":"65195","inReplyTo":"xmqqikb2qq20.fsf@gitster.g","subject":"Re: [PATCH v4 0/5] Advice on checkout dirty files","fromName":"Arsh Srivastava","fromEmail":"arshsrivastava00@gmail.com","sentAt":"2026-03-11T17:06:04Z","receivedAt":"2026-03-11T17:06:17Z","isPatch":true,"sender":{"key":"arshsrivastava00@gmail.com","avatar":"https://gravatar.com/avatar/31a57f3c18a3d49c0601d1863b1cea06242a5d6808b9bcc8fa8a801195d04cc7?d=mp&s=160"},"body":"Junio C Hamano <gitster@pobox.com> writes :-\n> provide perfect logic not drunken-man's-walk series.\n> not a place for you to show how you made wrong turns before arriving at the final shape of the code.\n> history for later developers to see in \"git log\" output to learn from\n> what is \"updation\"\n\nThank you so much for your feedback.\nAgain terribly sorry I will rebase my commit so that it has perfect progression.\nAnd updation is a noun first published in Oxford English Dictionary in 2018.\n\nOn Wed, 11 Mar 2026 at 22:08, Junio C Hamano <gitster@pobox.com> wrote:\n>\n> \"Arsh Srivastava via GitGitGadget\" <gitgitgadget@gmail.com> writes:\n>\n> > This is my submission for microproject [GSOC]\n> >\n> > This patch adds a new advice type ADVICE_STASH_BEFORE_CHECKOUT to help users\n> > when they attempt to switch branches with local modifications that would be\n> > overwritten by the operation.\n> >\n> > The new advice follows the same patterns established by existing advice\n> > functions such as advise_on_updating_sparse_paths(). When triggered, it\n> > lists the affected files and suggests using git stash push/pop to save and\n> > restore local changes.\n> >\n> > The advice can be silenced with:\n> >\n> > git config set advice.stashBeforeCheckout false\n> >\n> > Changes:\n> >\n> >> advice.h: add ADVICE_STASH_BEFORE_CHECKOUT enum value advice.c: add\n> >> \"stashBeforeCheckout\" to advice_setting[] and implement\n> >> advise_on_checkout_dirty_files() function\n> >> Documentation/config/advice.adoc: document the new advice key\n> >\n> > Signed-off-by: Arsh Srivastava arshsrivastava00@gmail.com\n>\n> Even though no developer is perfect, when you are presenting your\n> updated work, armed with wisdom borrowed from your reviewers'\n> comments on your earlier attempts, you are expected to take the\n> opportunity to pretend to have written a series of patches that are\n> perfect logical progression towards the final shape of the code\n> without detours, change of plans, and fixing earlier mistakes made\n> in the series.\n>\n> Please do not throw a drunken-man's-walk series at us.  For example,\n> I see that [PATCH 3/5] literally removes what was added by earlier\n> patches.  This is not a place for you to show how you made wrong\n> turns before arriving at the final shape of the code.\n>\n> The final series accepted by the project will have to stay in our\n> history for later developers to see in \"git log\" output to learn\n> from, and a series being clean logical progression is a must for\n> that to happen.\n>\n> Also, what is \"updation\"?  Is it a standard English word, or some\n> dialect of an LLM origin?\n>\n> > Arsh Srivastava (5):\n> >   advice: add stashBeforeCheckout advice for dirty branch switches\n> >   advice: add stashBeforeCheckout advice for dirty branch switches\n> >     [GSOC]\n> >   unpack-trees: suggesting 'git checkout -m <branch>' with its\n> >     repercussions\n> >   Updating tests and unpack-tress.c [GSOC]\n> >   File updation [GSOC]\n> >\n> >  t/t6439-merge-co-error-msgs.sh | 6 ++++++\n> >  t/t7406-submodule-update.sh    | 3 +++\n> >  unpack-trees.c                 | 9 +++++++--\n> >  3 files changed, 16 insertions(+), 2 deletions(-)\n> >\n> >\n> > base-commit: d181b9354cf85b44455ce3ca9e6af0b9559e0ae2\n> > Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-2233%2FArsh123344423%2Fadvice_on_checkout_dirty_files-v4\n> > Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-2233/Arsh123344423/advice_on_checkout_dirty_files-v4\n> > Pull-Request: https://github.com/git/git/pull/2233\n> >\n> > Range-diff vs v3:\n> >\n> >  1:  eb5639dbc3 = 1:  eb5639dbc3 advice: add stashBeforeCheckout advice for dirty branch switches\n> >  2:  e88c851701 = 2:  e88c851701 advice: add stashBeforeCheckout advice for dirty branch switches [GSOC]\n> >  -:  ---------- > 3:  4237b9667d unpack-trees: suggesting 'git checkout -m <branch>' with its repercussions\n> >  -:  ---------- > 4:  b25ea22410 Updating tests and unpack-tress.c [GSOC]\n> >  -:  ---------- > 5:  2ef7d5a3d6 File updation [GSOC]\n"},{"id":"538640","messageId":"pull.2233.v5.git.git.1773251369.gitgitgadget@gmail.com","threadId":"65195","inReplyTo":"pull.2233.v4.git.git.1773219028.gitgitgadget@gmail.com","subject":"[PATCH v5 0/3] Advice on checkout dirty files","fromName":"Arsh Srivastava via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2026-03-11T17:49:26Z","receivedAt":"2026-03-11T17:49:32Z","isPatch":true,"sender":{"key":"arshsrivastava00@gmail.com","avatar":"https://gravatar.com/avatar/31a57f3c18a3d49c0601d1863b1cea06242a5d6808b9bcc8fa8a801195d04cc7?d=mp&s=160"},"body":"This is my submission for microproject [GSOC]\n\nThis patch adds a new advice type ADVICE_STASH_BEFORE_CHECKOUT to help users\nwhen they attempt to switch branches with local modifications that would be\noverwritten by the operation.\n\nThe new advice follows the same patterns established by existing advice\nfunctions such as advise_on_updating_sparse_paths(). When triggered, it\nlists the affected files and suggests using git stash push/pop to save and\nrestore local changes.\n\nThe advice can be silenced with:\n\ngit config set advice.stashBeforeCheckout false\n\nChanges:\n\n> advice.h: add ADVICE_STASH_BEFORE_CHECKOUT enum value advice.c: add\n> \"stashBeforeCheckout\" to advice_setting[] and implement\n> advise_on_checkout_dirty_files() function\n> Documentation/config/advice.adoc: document the new advice key\n\nSigned-off-by: Arsh Srivastava arshsrivastava00@gmail.com\n\nArsh Srivastava (3):\n  advice: add stashBeforeCheckout advice for dirty branch switches\n  advice: add stashBeforeCheckout advice for dirty branch switches\n    [GSOC]\n  unpack-trees: suggesting 'git checkout -m <branch>' with its\n    repercussions\n\n t/t6439-merge-co-error-msgs.sh | 6 ++++++\n t/t7406-submodule-update.sh    | 3 +++\n unpack-trees.c                 | 9 +++++++--\n 3 files changed, 16 insertions(+), 2 deletions(-)\n\n\nbase-commit: d181b9354cf85b44455ce3ca9e6af0b9559e0ae2\nPublished-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-2233%2FArsh123344423%2Fadvice_on_checkout_dirty_files-v5\nFetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-2233/Arsh123344423/advice_on_checkout_dirty_files-v5\nPull-Request: https://github.com/git/git/pull/2233\n\nRange-diff vs v4:\n\n 1:  eb5639dbc3 = 1:  eb5639dbc3 advice: add stashBeforeCheckout advice for dirty branch switches\n 2:  e88c851701 = 2:  e88c851701 advice: add stashBeforeCheckout advice for dirty branch switches [GSOC]\n 3:  4237b9667d ! 3:  1cc22f437e unpack-trees: suggesting 'git checkout -m <branch>' with its repercussions\n     @@ advice.h: void NORETURN die_ff_impossible(void);\n       \n       #endif /* ADVICE_H */\n      \n     + ## t/t6439-merge-co-error-msgs.sh ##\n     +@@ t/t6439-merge-co-error-msgs.sh: error: Your local changes to the following files would be overwritten by checkou\n     + \trep/one\n     + \trep/two\n     + Please commit your changes or stash them before you switch branches.\n     ++Try using 'git checkout -m <branch>' for a quick fix.\n     ++Please Note :- that using -m (merge) will not save your changes, rather would directly merge them.\n     ++Meaning if you are not able to resolve conflicts and does --hard reset your local changes would be gone.\n     + Aborting\n     + EOF\n     + \n     +@@ t/t6439-merge-co-error-msgs.sh: error: Your local changes to the following files would be overwritten by checkou\n     + \trep/one\n     + \trep/two\n     + Please commit your changes or stash them before you switch branches.\n     ++Try using 'git checkout -m <branch>' for a quick fix.\n     ++Please Note :- that using -m (merge) will not save your changes, rather would directly merge them.\n     ++Meaning if you are not able to resolve conflicts and does --hard reset your local changes would be gone.\n     + Aborting\n     + EOF\n     + \n     +\n     + ## t/t7406-submodule-update.sh ##\n     +@@ t/t7406-submodule-update.sh: test_expect_success 'submodule update should fail due to local changes' '\n     + \t> error: Your local changes to the following files would be overwritten by checkout:\n     + \t> \tfile\n     + \t> Please commit your changes or stash them before you switch branches.\n     ++\t> Try using '\\''git checkout -m <branch>'\\'' for a quick fix.\n     ++\t> Please Note :- that using -m (merge) will not save your changes, rather would directly merge them.\n     ++\t> Meaning if you are not able to resolve conflicts and does --hard reset your local changes would be gone.\n     + \t> Aborting\n     + \t> fatal: Unable to checkout OID in submodule path '\\''submodule'\\''\n     + \tEOF\n     +\n       ## unpack-trees.c ##\n      @@ unpack-trees.c: void setup_unpack_trees_porcelain(struct unpack_trees_options *opts,\n       \tif (!strcmp(cmd, \"checkout\"))\n     @@ unpack-trees.c: void setup_unpack_trees_porcelain(struct unpack_trees_options *o\n      -\t\t\t  \"Please commit your changes or stash them before you switch branches.\")\n      -\t\t      : _(\"Your local changes to the following files would be overwritten by checkout:\\n%%s\");\n      +\t\t\t  \"Please commit your changes or stash them before you switch branches.\\n\"\n     -+\t\t\t  \"Try using 'git checkout -m <branch>' for a quick fix. \\n\"\n     ++\t\t\t  \"Try using 'git checkout -m <branch>' for a quick fix.\\n\"\n      +\t\t\t  \"Please Note :- that using -m (merge) will not save your changes, rather would directly merge them.\\n\"\n      +\t\t\t  \"Meaning if you are not able to resolve conflicts and does --hard reset your local changes would be gone.\"\n      +\t\t\t  )\n      +\t\t      : _(\"Your local changes to the following files would be overwritten by checkout:\\n%%s\"\n     -+\t\t\t\t\"Please commit your changes or stash them before you switch branches.\\n\"\n     -+\t\t\t  \"Try using 'git checkout -m <branch>' for a quick fix.\\n\"\n     -+\t\t\t  \"Please Note :- that using -m (merge) will not save your changes, rather would directly merge them.\\n\"\n     -+\t\t\t  \"Meaning if you are not able to resolve conflicts and does --hard reset your local changes would be gone.\"\n     -+\t\t\t  );\n     ++\t\t\t\t\"Please commit your changes or stash them before you switch branches.\");\n       \telse if (!strcmp(cmd, \"merge\"))\n       \t\tmsg = advice_enabled(ADVICE_COMMIT_BEFORE_MERGE)\n       \t\t      ? _(\"Your local changes to the following files would be overwritten by merge:\\n%%s\"\n 4:  b25ea22410 < -:  ---------- Updating tests and unpack-tress.c [GSOC]\n 5:  2ef7d5a3d6 < -:  ---------- File updation [GSOC]\n\n-- \ngitgitgadget\n"},{"id":"538641","messageId":"eb5639dbc3571fde15f2d93cf2d137b8df775d2f.1773251369.git.gitgitgadget@gmail.com","threadId":"65195","inReplyTo":"pull.2233.v5.git.git.1773251369.gitgitgadget@gmail.com","subject":"[PATCH v5 1/3] advice: add stashBeforeCheckout advice for dirty branch switches","fromName":"Arsh Srivastava via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2026-03-11T17:49:27Z","receivedAt":"2026-03-11T17:49:33Z","isPatch":true,"sender":{"key":"arshsrivastava00@gmail.com","avatar":"https://gravatar.com/avatar/31a57f3c18a3d49c0601d1863b1cea06242a5d6808b9bcc8fa8a801195d04cc7?d=mp&s=160"},"body":"From: Arsh Srivastava <arshsrivastava00@gmail.com>\n\nAdd a new advice type ADVICE_STASH_BEFORE_CHECKOUT to guide users\nwhen they attempt to switch branches with local modifications that\nwould be overwritten by the operation.\n\nThis includes:\n> New ADVICE_STASH_BEFORE_CHECKOUT enum value in advice.h\n> Corresponding \"stashBeforeCheckout\" entry in advice_setting[]\n> New advise_on_checkout_dirty_files() function that lists the\n  affected files and suggests using git stash push/pop\n> Documentation entry in Documentation/config/advice.txt\n\nThe advice follows existing patterns established by\nadvise_on_updating_sparse_paths() and can be silenced with:\n\n  git config set advice.stashBeforeCheckout false\n\nSigned-off-by: Arsh Srivastava <arshsrivastava00@gmail.com>\n---\n Documentation/config/advice.adoc |  5 +++++\n advice.c                         | 27 +++++++++++++++++++++++++++\n advice.h                         |  2 ++\n 3 files changed, 34 insertions(+)\n\ndiff --git a/Documentation/config/advice.adoc b/Documentation/config/advice.adoc\nindex 257db58918..8752e05636 100644\n--- a/Documentation/config/advice.adoc\n+++ b/Documentation/config/advice.adoc\n@@ -126,6 +126,11 @@ all advice messages.\n \t\tShown when a sparse index is expanded to a full index, which is likely\n \t\tdue to an unexpected set of files existing outside of the\n \t\tsparse-checkout.\n+\tstashBeforeCheckout::\n+\t\tShown when the user attempts to switch branches but has\n+\t\tlocal modifications that would be overwritten by the\n+\t\toperation, to suggest using linkgit:git-stash[1] to\n+\t\tsave changes before switching.\n \tstatusAheadBehind::\n \t\tShown when linkgit:git-status[1] computes the ahead/behind\n \t\tcounts for a local ref compared to its remote tracking ref,\ndiff --git a/advice.c b/advice.c\nindex 0018501b7b..e1264f525c 100644\n--- a/advice.c\n+++ b/advice.c\n@@ -81,6 +81,7 @@ static struct {\n \t[ADVICE_SET_UPSTREAM_FAILURE]\t\t\t= { \"setUpstreamFailure\" },\n \t[ADVICE_SKIPPED_CHERRY_PICKS]\t\t\t= { \"skippedCherryPicks\" },\n \t[ADVICE_SPARSE_INDEX_EXPANDED]\t\t\t= { \"sparseIndexExpanded\" },\n+\t[ADVICE_STASH_BEFORE_CHECKOUT] = { \"stashBeforeCheckout\" },\n \t[ADVICE_STATUS_AHEAD_BEHIND_WARNING]\t\t= { \"statusAheadBehindWarning\" },\n \t[ADVICE_STATUS_HINTS]\t\t\t\t= { \"statusHints\" },\n \t[ADVICE_STATUS_U_OPTION]\t\t\t= { \"statusUoption\" },\n@@ -312,3 +313,29 @@ void advise_on_moving_dirty_path(struct string_list *pathspec_list)\n \t\t\t    \"* Use \\\"git add --sparse <paths>\\\" to update the index\\n\"\n \t\t\t    \"* Use \\\"git sparse-checkout reapply\\\" to apply the sparsity rules\"));\n }\n+\n+void advise_on_checkout_dirty_files(struct string_list *file_list)\n+{\n+    struct string_list_item *item;\n+\n+    if (!file_list->nr)\n+\treturn;\n+\n+    fprintf(stderr, _(\"The following files have local modifications that would\\n\"\n+\t\t      \"be overwritten by switching branches:\\n\"));\n+    for_each_string_list_item(item, file_list)\n+\tfprintf(stderr, \"\\t%s\\n\", item->string);\n+\n+    advise_if_enabled(ADVICE_STASH_BEFORE_CHECKOUT,\n+\t\t      _(\"You can save your local changes before switching by running:\\n\"\n+\t\t\t\"\\n\"\n+\t\t\t\"\\tgit stash push\\n\"\n+\t\t\t\"\\n\"\n+\t\t\t\"Then restore them after switching with:\\n\"\n+\t\t\t\"\\n\"\n+\t\t\t\"\\tgit stash pop\\n\"\n+\t\t\t\"\\n\"\n+\t\t\t\"Or to discard your local changes, use:\\n\"\n+\t\t\t\"\\n\"\n+\t\t\t\"\\tgit checkout -- <file>\"));\n+}\ndiff --git a/advice.h b/advice.h\nindex 8def280688..c035b5d8e3 100644\n--- a/advice.h\n+++ b/advice.h\n@@ -48,6 +48,7 @@ enum advice_type {\n \tADVICE_SET_UPSTREAM_FAILURE,\n \tADVICE_SKIPPED_CHERRY_PICKS,\n \tADVICE_SPARSE_INDEX_EXPANDED,\n+\tADVICE_STASH_BEFORE_CHECKOUT,\n \tADVICE_STATUS_AHEAD_BEHIND_WARNING,\n \tADVICE_STATUS_HINTS,\n \tADVICE_STATUS_U_OPTION,\n@@ -83,5 +84,6 @@ void NORETURN die_ff_impossible(void);\n void advise_on_updating_sparse_paths(struct string_list *pathspec_list);\n void detach_advice(const char *new_name);\n void advise_on_moving_dirty_path(struct string_list *pathspec_list);\n+void advise_on_checkout_dirty_files(struct string_list *file_list);\n \n #endif /* ADVICE_H */\n-- \ngitgitgadget\n\n"},{"id":"538642","messageId":"e88c85170147a7c5d44640cba0c48aa686e23f17.1773251369.git.gitgitgadget@gmail.com","threadId":"65195","inReplyTo":"pull.2233.v5.git.git.1773251369.gitgitgadget@gmail.com","subject":"[PATCH v5 2/3] advice: add stashBeforeCheckout advice for dirty branch switches [GSOC]","fromName":"Arsh Srivastava via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2026-03-11T17:49:28Z","receivedAt":"2026-03-11T17:49:35Z","isPatch":true,"sender":{"key":"arshsrivastava00@gmail.com","avatar":"https://gravatar.com/avatar/31a57f3c18a3d49c0601d1863b1cea06242a5d6808b9bcc8fa8a801195d04cc7?d=mp&s=160"},"body":"From: Arsh Srivastava <arshsrivastava00@gmail.com>\n\nAdd a new advice type ADVICE_STASH_BEFORE_CHECKOUT to guide users\nwhen they attempt to switch branches with local modifications that\nwould be overwritten by the operation.\n\nThe advice suggests using \"git checkout -m\" to carry local changes\nover to the new branch in a single step.\n\nThe advice can be silenced with:\n\n  git config set advice.stashBeforeCheckout false\n\nChanges:\n- advice.h: add ADVICE_STASH_BEFORE_CHECKOUT enum value\n- advice.c: add \"stashBeforeCheckout\" to advice_setting[] and implement\n  advise_on_checkout_dirty_files() function\n- Documentation/config/advice.adoc: document the new advice key\n\nSigned-off-by: Arsh Srivastava <arshsrivastava00@gmail.com>\n---\n advice.c | 13 +++----------\n 1 file changed, 3 insertions(+), 10 deletions(-)\n\ndiff --git a/advice.c b/advice.c\nindex e1264f525c..ba290d3760 100644\n--- a/advice.c\n+++ b/advice.c\n@@ -327,15 +327,8 @@ void advise_on_checkout_dirty_files(struct string_list *file_list)\n \tfprintf(stderr, \"\\t%s\\n\", item->string);\n \n     advise_if_enabled(ADVICE_STASH_BEFORE_CHECKOUT,\n-\t\t      _(\"You can save your local changes before switching by running:\\n\"\n+\t\t      _(\"To carry your local changes over to the new branch, use:\\n\"\n \t\t\t\"\\n\"\n-\t\t\t\"\\tgit stash push\\n\"\n-\t\t\t\"\\n\"\n-\t\t\t\"Then restore them after switching with:\\n\"\n-\t\t\t\"\\n\"\n-\t\t\t\"\\tgit stash pop\\n\"\n-\t\t\t\"\\n\"\n-\t\t\t\"Or to discard your local changes, use:\\n\"\n-\t\t\t\"\\n\"\n-\t\t\t\"\\tgit checkout -- <file>\"));\n+\t\t\t\"\\tgit checkout -m <branch>\\n\"\n+\t\t\t));\n }\n-- \ngitgitgadget\n\n"},{"id":"538643","messageId":"1cc22f437e92fe522ca23891cf3686c6b4e815c2.1773251369.git.gitgitgadget@gmail.com","threadId":"65195","inReplyTo":"pull.2233.v5.git.git.1773251369.gitgitgadget@gmail.com","subject":"[PATCH v5 3/3] unpack-trees: suggesting 'git checkout -m <branch>' with its repercussions","fromName":"Arsh Srivastava via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2026-03-11T17:49:29Z","receivedAt":"2026-03-11T17:49:36Z","isPatch":true,"sender":{"key":"arshsrivastava00@gmail.com","avatar":"https://gravatar.com/avatar/31a57f3c18a3d49c0601d1863b1cea06242a5d6808b9bcc8fa8a801195d04cc7?d=mp&s=160"},"body":"From: Arsh Srivastava <arshsrivastava00@gmail.com>\n\nThis comment is an extention to the already existing stash comment.\n\nAfter the valuable insights given to me by git maintaniers.\nI removed the new function I introduced.\nAdded updated comment over the already existing function\n\"setup_unpack_trees_porcelain\" with \"git checkout -m <branch>\"\nand its repercussions\nI have also mentioned the repercussions of using \"-m\".\n\nSigned-off-by: Arsh Srivastava <arshsrivastava00@gmail.com>\n---\n Documentation/config/advice.adoc |  5 -----\n advice.c                         | 20 --------------------\n advice.h                         |  2 --\n t/t6439-merge-co-error-msgs.sh   |  6 ++++++\n t/t7406-submodule-update.sh      |  3 +++\n unpack-trees.c                   |  9 +++++++--\n 6 files changed, 16 insertions(+), 29 deletions(-)\n\ndiff --git a/Documentation/config/advice.adoc b/Documentation/config/advice.adoc\nindex 8752e05636..257db58918 100644\n--- a/Documentation/config/advice.adoc\n+++ b/Documentation/config/advice.adoc\n@@ -126,11 +126,6 @@ all advice messages.\n \t\tShown when a sparse index is expanded to a full index, which is likely\n \t\tdue to an unexpected set of files existing outside of the\n \t\tsparse-checkout.\n-\tstashBeforeCheckout::\n-\t\tShown when the user attempts to switch branches but has\n-\t\tlocal modifications that would be overwritten by the\n-\t\toperation, to suggest using linkgit:git-stash[1] to\n-\t\tsave changes before switching.\n \tstatusAheadBehind::\n \t\tShown when linkgit:git-status[1] computes the ahead/behind\n \t\tcounts for a local ref compared to its remote tracking ref,\ndiff --git a/advice.c b/advice.c\nindex ba290d3760..0018501b7b 100644\n--- a/advice.c\n+++ b/advice.c\n@@ -81,7 +81,6 @@ static struct {\n \t[ADVICE_SET_UPSTREAM_FAILURE]\t\t\t= { \"setUpstreamFailure\" },\n \t[ADVICE_SKIPPED_CHERRY_PICKS]\t\t\t= { \"skippedCherryPicks\" },\n \t[ADVICE_SPARSE_INDEX_EXPANDED]\t\t\t= { \"sparseIndexExpanded\" },\n-\t[ADVICE_STASH_BEFORE_CHECKOUT] = { \"stashBeforeCheckout\" },\n \t[ADVICE_STATUS_AHEAD_BEHIND_WARNING]\t\t= { \"statusAheadBehindWarning\" },\n \t[ADVICE_STATUS_HINTS]\t\t\t\t= { \"statusHints\" },\n \t[ADVICE_STATUS_U_OPTION]\t\t\t= { \"statusUoption\" },\n@@ -313,22 +312,3 @@ void advise_on_moving_dirty_path(struct string_list *pathspec_list)\n \t\t\t    \"* Use \\\"git add --sparse <paths>\\\" to update the index\\n\"\n \t\t\t    \"* Use \\\"git sparse-checkout reapply\\\" to apply the sparsity rules\"));\n }\n-\n-void advise_on_checkout_dirty_files(struct string_list *file_list)\n-{\n-    struct string_list_item *item;\n-\n-    if (!file_list->nr)\n-\treturn;\n-\n-    fprintf(stderr, _(\"The following files have local modifications that would\\n\"\n-\t\t      \"be overwritten by switching branches:\\n\"));\n-    for_each_string_list_item(item, file_list)\n-\tfprintf(stderr, \"\\t%s\\n\", item->string);\n-\n-    advise_if_enabled(ADVICE_STASH_BEFORE_CHECKOUT,\n-\t\t      _(\"To carry your local changes over to the new branch, use:\\n\"\n-\t\t\t\"\\n\"\n-\t\t\t\"\\tgit checkout -m <branch>\\n\"\n-\t\t\t));\n-}\ndiff --git a/advice.h b/advice.h\nindex c035b5d8e3..8def280688 100644\n--- a/advice.h\n+++ b/advice.h\n@@ -48,7 +48,6 @@ enum advice_type {\n \tADVICE_SET_UPSTREAM_FAILURE,\n \tADVICE_SKIPPED_CHERRY_PICKS,\n \tADVICE_SPARSE_INDEX_EXPANDED,\n-\tADVICE_STASH_BEFORE_CHECKOUT,\n \tADVICE_STATUS_AHEAD_BEHIND_WARNING,\n \tADVICE_STATUS_HINTS,\n \tADVICE_STATUS_U_OPTION,\n@@ -84,6 +83,5 @@ void NORETURN die_ff_impossible(void);\n void advise_on_updating_sparse_paths(struct string_list *pathspec_list);\n void detach_advice(const char *new_name);\n void advise_on_moving_dirty_path(struct string_list *pathspec_list);\n-void advise_on_checkout_dirty_files(struct string_list *file_list);\n \n #endif /* ADVICE_H */\ndiff --git a/t/t6439-merge-co-error-msgs.sh b/t/t6439-merge-co-error-msgs.sh\nindex 643c9368e0..cf996e0e51 100755\n--- a/t/t6439-merge-co-error-msgs.sh\n+++ b/t/t6439-merge-co-error-msgs.sh\n@@ -77,6 +77,9 @@ error: Your local changes to the following files would be overwritten by checkou\n \trep/one\n \trep/two\n Please commit your changes or stash them before you switch branches.\n+Try using 'git checkout -m <branch>' for a quick fix.\n+Please Note :- that using -m (merge) will not save your changes, rather would directly merge them.\n+Meaning if you are not able to resolve conflicts and does --hard reset your local changes would be gone.\n Aborting\n EOF\n \n@@ -99,6 +102,9 @@ error: Your local changes to the following files would be overwritten by checkou\n \trep/one\n \trep/two\n Please commit your changes or stash them before you switch branches.\n+Try using 'git checkout -m <branch>' for a quick fix.\n+Please Note :- that using -m (merge) will not save your changes, rather would directly merge them.\n+Meaning if you are not able to resolve conflicts and does --hard reset your local changes would be gone.\n Aborting\n EOF\n \ndiff --git a/t/t7406-submodule-update.sh b/t/t7406-submodule-update.sh\nindex 3adab12091..2e4cc9b3fe 100755\n--- a/t/t7406-submodule-update.sh\n+++ b/t/t7406-submodule-update.sh\n@@ -212,6 +212,9 @@ test_expect_success 'submodule update should fail due to local changes' '\n \t> error: Your local changes to the following files would be overwritten by checkout:\n \t> \tfile\n \t> Please commit your changes or stash them before you switch branches.\n+\t> Try using '\\''git checkout -m <branch>'\\'' for a quick fix.\n+\t> Please Note :- that using -m (merge) will not save your changes, rather would directly merge them.\n+\t> Meaning if you are not able to resolve conflicts and does --hard reset your local changes would be gone.\n \t> Aborting\n \t> fatal: Unable to checkout OID in submodule path '\\''submodule'\\''\n \tEOF\ndiff --git a/unpack-trees.c b/unpack-trees.c\nindex 998a1e6dc7..9835a82455 100644\n--- a/unpack-trees.c\n+++ b/unpack-trees.c\n@@ -128,8 +128,13 @@ void setup_unpack_trees_porcelain(struct unpack_trees_options *opts,\n \tif (!strcmp(cmd, \"checkout\"))\n \t\tmsg = advice_enabled(ADVICE_COMMIT_BEFORE_MERGE)\n \t\t      ? _(\"Your local changes to the following files would be overwritten by checkout:\\n%%s\"\n-\t\t\t  \"Please commit your changes or stash them before you switch branches.\")\n-\t\t      : _(\"Your local changes to the following files would be overwritten by checkout:\\n%%s\");\n+\t\t\t  \"Please commit your changes or stash them before you switch branches.\\n\"\n+\t\t\t  \"Try using 'git checkout -m <branch>' for a quick fix.\\n\"\n+\t\t\t  \"Please Note :- that using -m (merge) will not save your changes, rather would directly merge them.\\n\"\n+\t\t\t  \"Meaning if you are not able to resolve conflicts and does --hard reset your local changes would be gone.\"\n+\t\t\t  )\n+\t\t      : _(\"Your local changes to the following files would be overwritten by checkout:\\n%%s\"\n+\t\t\t\t\"Please commit your changes or stash them before you switch branches.\");\n \telse if (!strcmp(cmd, \"merge\"))\n \t\tmsg = advice_enabled(ADVICE_COMMIT_BEFORE_MERGE)\n \t\t      ? _(\"Your local changes to the following files would be overwritten by merge:\\n%%s\"\n-- \ngitgitgadget\n"},{"id":"538707","messageId":"xmqqjyvhkggf.fsf@gitster.g","threadId":"65195","inReplyTo":"pull.2233.v5.git.git.1773251369.gitgitgadget@gmail.com","subject":"Re: [PATCH v5 0/3] Advice on checkout dirty files","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2026-03-12T01:02:40Z","receivedAt":"2026-03-12T01:02:43Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"Arsh Srivastava via GitGitGadget\" <gitgitgadget@gmail.com> writes:\n\n> Changes:\n>\n>> advice.h: add ADVICE_STASH_BEFORE_CHECKOUT enum value advice.c: add\n>> \"stashBeforeCheckout\" to advice_setting[] and implement\n>> advise_on_checkout_dirty_files() function\n>> Documentation/config/advice.adoc: document the new advice key\n>\n> Signed-off-by: Arsh Srivastava arshsrivastava00@gmail.com\n>\n> Arsh Srivastava (3):\n>   advice: add stashBeforeCheckout advice for dirty branch switches\n>   advice: add stashBeforeCheckout advice for dirty branch switches\n>     [GSOC]\n>   unpack-trees: suggesting 'git checkout -m <branch>' with its\n>     repercussions\n\nI still see that [PATCH 3/3] literally removes what was added by\nearlier patches.  ADVICE_STASH_BEFORE_CHECKOUT is added to\nadvice.[ch] and stashBeforeCheckOut is added to\nDocumentation/config/adivce.adoc in [1/3], and then they are removed\nin [3/3].  If your final solution does not involve such an advice,\nthen do not even add it in an earlier patch, only to retract it and\nreplace it with something else in a later patch.  If the reason why\nthat \"something else\" replaces the advice is because it is a better\nsolution to the problem you initially started to solve than the\nadvice message added in [1/3], then just go straight to that\n\"something else\", without adding and removing the advice mechanism.\n\nThat is what \"perfect logical progression without detours, change of\nplans, and fixes earlier mistake\" is about.\n\nIn other words, please do not throw a drunken-man's-walk series at\nus.  Pretend to be a perfect developer.\n\nThe final series accepted by the project will have to stay in our\nhistory for later developers to see in \"git log\" output to learn\nfrom, and a series being clean logical progression is a must for\nthat to happen.\n\n"},{"id":"538713","messageId":"CAOAgETMrx5b0qc2Tsy+f=Bk3HKFaayeXXFvc_1=HwoxixH+WMQ@mail.gmail.com","threadId":"65195","inReplyTo":"xmqqjyvhkggf.fsf@gitster.g","subject":"Re: [PATCH v5 0/3] Advice on checkout dirty files","fromName":"Arsh Srivastava","fromEmail":"arshsrivastava00@gmail.com","sentAt":"2026-03-12T03:32:45Z","receivedAt":"2026-03-12T03:32:58Z","isPatch":true,"sender":{"key":"arshsrivastava00@gmail.com","avatar":"https://gravatar.com/avatar/31a57f3c18a3d49c0601d1863b1cea06242a5d6808b9bcc8fa8a801195d04cc7?d=mp&s=160"},"body":"Junio C Hamano <gitster@pobox.com> writes :\n\n> He still see 3 patches for a work that can be done by one.\n> That is what \"perfect logical progression without detours, change of\n> plans, and fixes earlier mistake\" is about.\n> please do not throw a drunken-man's-walk series at\n> us.  Pretend to be a perfect developer\n\nI understand now sorry for the inconvenience.\nYour mail also specified the same thing but I was not able to truly\ngrasp the essence of that mail.\nThank you for explaining it again to me, I now have clear\nunderstanding of what is expected from me.\nI will create one single commit :) .\nI also saw that git via git gadget forwards all my commits making it\nmessy and not ideal.\nI will make a clean single commit that will look perfect and wouldn't\nmake such a messy commit history.\n\nOn Thu, 12 Mar 2026 at 06:32, Junio C Hamano <gitster@pobox.com> wrote:\n>\n> \"Arsh Srivastava via GitGitGadget\" <gitgitgadget@gmail.com> writes:\n>\n> > Changes:\n> >\n> >> advice.h: add ADVICE_STASH_BEFORE_CHECKOUT enum value advice.c: add\n> >> \"stashBeforeCheckout\" to advice_setting[] and implement\n> >> advise_on_checkout_dirty_files() function\n> >> Documentation/config/advice.adoc: document the new advice key\n> >\n> > Signed-off-by: Arsh Srivastava arshsrivastava00@gmail.com\n> >\n> > Arsh Srivastava (3):\n> >   advice: add stashBeforeCheckout advice for dirty branch switches\n> >   advice: add stashBeforeCheckout advice for dirty branch switches\n> >     [GSOC]\n> >   unpack-trees: suggesting 'git checkout -m <branch>' with its\n> >     repercussions\n>\n> I still see that [PATCH 3/3] literally removes what was added by\n> earlier patches.  ADVICE_STASH_BEFORE_CHECKOUT is added to\n> advice.[ch] and stashBeforeCheckOut is added to\n> Documentation/config/adivce.adoc in [1/3], and then they are removed\n> in [3/3].  If your final solution does not involve such an advice,\n> then do not even add it in an earlier patch, only to retract it and\n> replace it with something else in a later patch.  If the reason why\n> that \"something else\" replaces the advice is because it is a better\n> solution to the problem you initially started to solve than the\n> advice message added in [1/3], then just go straight to that\n> \"something else\", without adding and removing the advice mechanism.\n>\n> That is what \"perfect logical progression without detours, change of\n> plans, and fixes earlier mistake\" is about.\n>\n> In other words, please do not throw a drunken-man's-walk series at\n> us.  Pretend to be a perfect developer.\n>\n> The final series accepted by the project will have to stay in our\n> history for later developers to see in \"git log\" output to learn\n> from, and a series being clean logical progression is a must for\n> that to happen.\n>\n"},{"id":"538714","messageId":"pull.2233.v6.git.git.1773288013936.gitgitgadget@gmail.com","threadId":"65195","inReplyTo":"pull.2233.v5.git.git.1773251369.gitgitgadget@gmail.com","subject":"[PATCH v6] unpack-trees: suggesting 'git checkout -m' with its repercussions","fromName":"Arsh Srivastava via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2026-03-12T04:00:13Z","receivedAt":"2026-03-12T04:00:17Z","isPatch":true,"sender":{"key":"arshsrivastava00@gmail.com","avatar":"https://gravatar.com/avatar/31a57f3c18a3d49c0601d1863b1cea06242a5d6808b9bcc8fa8a801195d04cc7?d=mp&s=160"},"body":"From: Arsh Srivastava <arshsrivastava00@gmail.com>\n\nThis comment is an extention to the already existing stash comment.\nAdded updated comment over the already existing function\n\"setup_unpack_trees_porcelain\" with \"git checkout -m\"\nand its repercussions\nI have also mentioned the repercussions of using \"-m\".\n\nSigned-off-by: Arsh Srivastava arshsrivastava00@gmail.com\n---\n    Advice on checkout dirty files\n    \n    This is my submission for microproject [GSOC]\n    \n    This patch extends the current message to help users better understand\n    risks and alternatives to stashing their changes.\n    \n    The alternative consists of\n    \n    > git checkout -m and its repercussions.\n    \n    This extended message is tied to the existing advice.commitBeforeMerge\n    configuration and can be silenced with:\n    \n    > git config set advice.commitBeforeMerge false\n    \n    Changes:\n    \n    > unpack-trees.c: expanded the already existing message.\n    > t/t6439-merge-co-error-msgs.sh: update expected output for merge and\n    > checkout tests. t/t7406-submodule-update.sh: update expected output\n    > for submodule checkout tests.\n    \n    Signed-off-by: Arsh Srivastava arshsrivastava00@gmail.com\n\nPublished-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-2233%2FArsh123344423%2Fadvice_on_checkout_dirty_files-v6\nFetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-2233/Arsh123344423/advice_on_checkout_dirty_files-v6\nPull-Request: https://github.com/git/git/pull/2233\n\nRange-diff vs v5:\n\n 1:  eb5639dbc3 < -:  ---------- advice: add stashBeforeCheckout advice for dirty branch switches\n 2:  e88c851701 < -:  ---------- advice: add stashBeforeCheckout advice for dirty branch switches [GSOC]\n 3:  1cc22f437e ! 1:  e0ba5fad82 unpack-trees: suggesting 'git checkout -m <branch>' with its repercussions\n     @@ Metadata\n      Author: Arsh Srivastava <arshsrivastava00@gmail.com>\n      \n       ## Commit message ##\n     -    unpack-trees: suggesting 'git checkout -m <branch>' with its repercussions\n     +    unpack-trees: suggesting 'git checkout -m' with its repercussions\n      \n          This comment is an extention to the already existing stash comment.\n     -\n     -    After the valuable insights given to me by git maintaniers.\n     -    I removed the new function I introduced.\n          Added updated comment over the already existing function\n     -    \"setup_unpack_trees_porcelain\" with \"git checkout -m <branch>\"\n     +    \"setup_unpack_trees_porcelain\" with \"git checkout -m\"\n          and its repercussions\n          I have also mentioned the repercussions of using \"-m\".\n      \n     -    Signed-off-by: Arsh Srivastava <arshsrivastava00@gmail.com>\n     -\n     - ## Documentation/config/advice.adoc ##\n     -@@ Documentation/config/advice.adoc: all advice messages.\n     - \t\tShown when a sparse index is expanded to a full index, which is likely\n     - \t\tdue to an unexpected set of files existing outside of the\n     - \t\tsparse-checkout.\n     --\tstashBeforeCheckout::\n     --\t\tShown when the user attempts to switch branches but has\n     --\t\tlocal modifications that would be overwritten by the\n     --\t\toperation, to suggest using linkgit:git-stash[1] to\n     --\t\tsave changes before switching.\n     - \tstatusAheadBehind::\n     - \t\tShown when linkgit:git-status[1] computes the ahead/behind\n     - \t\tcounts for a local ref compared to its remote tracking ref,\n     -\n     - ## advice.c ##\n     -@@ advice.c: static struct {\n     - \t[ADVICE_SET_UPSTREAM_FAILURE]\t\t\t= { \"setUpstreamFailure\" },\n     - \t[ADVICE_SKIPPED_CHERRY_PICKS]\t\t\t= { \"skippedCherryPicks\" },\n     - \t[ADVICE_SPARSE_INDEX_EXPANDED]\t\t\t= { \"sparseIndexExpanded\" },\n     --\t[ADVICE_STASH_BEFORE_CHECKOUT] = { \"stashBeforeCheckout\" },\n     - \t[ADVICE_STATUS_AHEAD_BEHIND_WARNING]\t\t= { \"statusAheadBehindWarning\" },\n     - \t[ADVICE_STATUS_HINTS]\t\t\t\t= { \"statusHints\" },\n     - \t[ADVICE_STATUS_U_OPTION]\t\t\t= { \"statusUoption\" },\n     -@@ advice.c: void advise_on_moving_dirty_path(struct string_list *pathspec_list)\n     - \t\t\t    \"* Use \\\"git add --sparse <paths>\\\" to update the index\\n\"\n     - \t\t\t    \"* Use \\\"git sparse-checkout reapply\\\" to apply the sparsity rules\"));\n     - }\n     --\n     --void advise_on_checkout_dirty_files(struct string_list *file_list)\n     --{\n     --    struct string_list_item *item;\n     --\n     --    if (!file_list->nr)\n     --\treturn;\n     --\n     --    fprintf(stderr, _(\"The following files have local modifications that would\\n\"\n     --\t\t      \"be overwritten by switching branches:\\n\"));\n     --    for_each_string_list_item(item, file_list)\n     --\tfprintf(stderr, \"\\t%s\\n\", item->string);\n     --\n     --    advise_if_enabled(ADVICE_STASH_BEFORE_CHECKOUT,\n     --\t\t      _(\"To carry your local changes over to the new branch, use:\\n\"\n     --\t\t\t\"\\n\"\n     --\t\t\t\"\\tgit checkout -m <branch>\\n\"\n     --\t\t\t));\n     --}\n     -\n     - ## advice.h ##\n     -@@ advice.h: enum advice_type {\n     - \tADVICE_SET_UPSTREAM_FAILURE,\n     - \tADVICE_SKIPPED_CHERRY_PICKS,\n     - \tADVICE_SPARSE_INDEX_EXPANDED,\n     --\tADVICE_STASH_BEFORE_CHECKOUT,\n     - \tADVICE_STATUS_AHEAD_BEHIND_WARNING,\n     - \tADVICE_STATUS_HINTS,\n     - \tADVICE_STATUS_U_OPTION,\n     -@@ advice.h: void NORETURN die_ff_impossible(void);\n     - void advise_on_updating_sparse_paths(struct string_list *pathspec_list);\n     - void detach_advice(const char *new_name);\n     - void advise_on_moving_dirty_path(struct string_list *pathspec_list);\n     --void advise_on_checkout_dirty_files(struct string_list *file_list);\n     - \n     - #endif /* ADVICE_H */\n     +    Signed-off-by: Arsh Srivastava arshsrivastava00@gmail.com\n      \n       ## t/t6439-merge-co-error-msgs.sh ##\n      @@ t/t6439-merge-co-error-msgs.sh: error: Your local changes to the following files would be overwritten by checkou\n\n\n t/t6439-merge-co-error-msgs.sh | 6 ++++++\n t/t7406-submodule-update.sh    | 3 +++\n unpack-trees.c                 | 9 +++++++--\n 3 files changed, 16 insertions(+), 2 deletions(-)\n\ndiff --git a/t/t6439-merge-co-error-msgs.sh b/t/t6439-merge-co-error-msgs.sh\nindex 643c9368e0..cf996e0e51 100755\n--- a/t/t6439-merge-co-error-msgs.sh\n+++ b/t/t6439-merge-co-error-msgs.sh\n@@ -77,6 +77,9 @@ error: Your local changes to the following files would be overwritten by checkou\n \trep/one\n \trep/two\n Please commit your changes or stash them before you switch branches.\n+Try using 'git checkout -m <branch>' for a quick fix.\n+Please Note :- that using -m (merge) will not save your changes, rather would directly merge them.\n+Meaning if you are not able to resolve conflicts and does --hard reset your local changes would be gone.\n Aborting\n EOF\n \n@@ -99,6 +102,9 @@ error: Your local changes to the following files would be overwritten by checkou\n \trep/one\n \trep/two\n Please commit your changes or stash them before you switch branches.\n+Try using 'git checkout -m <branch>' for a quick fix.\n+Please Note :- that using -m (merge) will not save your changes, rather would directly merge them.\n+Meaning if you are not able to resolve conflicts and does --hard reset your local changes would be gone.\n Aborting\n EOF\n \ndiff --git a/t/t7406-submodule-update.sh b/t/t7406-submodule-update.sh\nindex 3adab12091..2e4cc9b3fe 100755\n--- a/t/t7406-submodule-update.sh\n+++ b/t/t7406-submodule-update.sh\n@@ -212,6 +212,9 @@ test_expect_success 'submodule update should fail due to local changes' '\n \t> error: Your local changes to the following files would be overwritten by checkout:\n \t> \tfile\n \t> Please commit your changes or stash them before you switch branches.\n+\t> Try using '\\''git checkout -m <branch>'\\'' for a quick fix.\n+\t> Please Note :- that using -m (merge) will not save your changes, rather would directly merge them.\n+\t> Meaning if you are not able to resolve conflicts and does --hard reset your local changes would be gone.\n \t> Aborting\n \t> fatal: Unable to checkout OID in submodule path '\\''submodule'\\''\n \tEOF\ndiff --git a/unpack-trees.c b/unpack-trees.c\nindex 998a1e6dc7..9835a82455 100644\n--- a/unpack-trees.c\n+++ b/unpack-trees.c\n@@ -128,8 +128,13 @@ void setup_unpack_trees_porcelain(struct unpack_trees_options *opts,\n \tif (!strcmp(cmd, \"checkout\"))\n \t\tmsg = advice_enabled(ADVICE_COMMIT_BEFORE_MERGE)\n \t\t      ? _(\"Your local changes to the following files would be overwritten by checkout:\\n%%s\"\n-\t\t\t  \"Please commit your changes or stash them before you switch branches.\")\n-\t\t      : _(\"Your local changes to the following files would be overwritten by checkout:\\n%%s\");\n+\t\t\t  \"Please commit your changes or stash them before you switch branches.\\n\"\n+\t\t\t  \"Try using 'git checkout -m <branch>' for a quick fix.\\n\"\n+\t\t\t  \"Please Note :- that using -m (merge) will not save your changes, rather would directly merge them.\\n\"\n+\t\t\t  \"Meaning if you are not able to resolve conflicts and does --hard reset your local changes would be gone.\"\n+\t\t\t  )\n+\t\t      : _(\"Your local changes to the following files would be overwritten by checkout:\\n%%s\"\n+\t\t\t\t\"Please commit your changes or stash them before you switch branches.\");\n \telse if (!strcmp(cmd, \"merge\"))\n \t\tmsg = advice_enabled(ADVICE_COMMIT_BEFORE_MERGE)\n \t\t      ? _(\"Your local changes to the following files would be overwritten by merge:\\n%%s\"\n\nbase-commit: d181b9354cf85b44455ce3ca9e6af0b9559e0ae2\n-- \ngitgitgadget\n"},{"id":"538757","messageId":"xmqqms0dghgk.fsf@gitster.g","threadId":"65195","inReplyTo":"pull.2233.v6.git.git.1773288013936.gitgitgadget@gmail.com","subject":"Re: [PATCH v6] unpack-trees: suggesting 'git checkout -m' with its repercussions","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2026-03-12T16:06:51Z","receivedAt":"2026-03-12T16:06:54Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"Arsh Srivastava via GitGitGadget\" <gitgitgadget@gmail.com> writes:\n\n> From: Arsh Srivastava <arshsrivastava00@gmail.com>\n>\n> This comment is an extention to the already existing stash comment.\n> Added updated comment over the already existing function\n> \"setup_unpack_trees_porcelain\" with \"git checkout -m\"\n> and its repercussions\n> I have also mentioned the repercussions of using \"-m\".\n>\n> Signed-off-by: Arsh Srivastava arshsrivastava00@gmail.com\n\nThe commit message should focus on the \"why\" and \"what\" from a user\nperspective, following the project's standard format (problem\ndescription, then solution).\n\nConsider a more standard phrasing:\n\n    unpack-trees: suggest 'git checkout -m' when checkout fails\n\n    When a branch switch fails due to local changes, we suggest\n    stashing or committing. However, 'git checkout -m' is a valid\n    alternative for users who wish to carry their changes over via a\n    merge.\n\n    Update the advice message to suggest this option, while\n    including a warning about the potential for data loss if a hard\n    reset is performed after a conflicted merge.\n\nAlso, note that \"extention\" is a typo; it should be \"extension\".\n\nHaving said that, I am not sure if we want to suggest \"checkout -m\"\nin this situation after all.\n\nThe added message is quite long:\n\n> Try using 'git checkout -m <branch>' for a quick fix.\n> Please Note :- that using -m (merge) will not save your changes,\n> rather would directly merge them.\n> Meaning if you are not able to resolve conflicts and does --hard\n> reset your local changes would be gone.\n\nWhen advice requires a multi-line warning about potential data loss,\nit's often a sign that the operation being suggested isn't suitable\nfor general advice. The goal of these messages should be to provide\na clear, safe next step, not a list of advanced alternatives with\ncaveats. After all, the users who need such an \"it failed, now what\nshould I do to recover?\" message the most are relatively\ninexperienced users and we do not want the advice to be\noverwhelming.\n\nThe primary concern is that 'git checkout -m' is a high-stakes\noperation compared to 'git stash'.\n\n- When a user uses 'git stash', their changes are recorded in a\n  stash entry. If 'git stash pop' later results in conflicts they\n  cannot resolve, the user can always 'git reset --hard' to get back\n  to a clean state, knowing their original changes are still safe in\n  the stash entry, which they can re-attempt to use later.\n\n- In contrast, 'git checkout -m' performs the merge directly in\n  the working tree.  If conflicts arise, the original local changes\n  are immediately replaced by conflict markers. Unlike stash, there\n  is no \"undo\" record. If the user realizes they are in over their\n  head, they cannot simply \"abort\" to get their original changes\n  back. They have only one chance to resolve it correctly, and they\n  have to do so right there.\n\nSuggesting this \"one-shot\" approach to a user who is already in a\nstate of friction (and likely less experienced) might be providing\nthem with a \"foot-gun\" rather than a helpful tip. Generally, advice\nthat nudges users toward the safest \"golden paths\" like stashing or\ncommitting is preferred.\n\nFor a microproject, you've successfully demonstrated that you can\nmodify the advice system and update the test suite. However, for the\nhealth of the project's usability, it might be better to drop the\n'checkout -m' suggestion and instead focus on making the existing\n'stash' and 'commit' advice as clear and helpful as possible.\n\nThanks.\n\n"},{"id":"538785","messageId":"CAOAgETN-UVtee5OjjcLE45sRxajCkgF3nipBqXpec4JjN8+vfw@mail.gmail.com","threadId":"65195","inReplyTo":"xmqqms0dghgk.fsf@gitster.g","subject":"Re: [PATCH v6] unpack-trees: suggesting 'git checkout -m' with its repercussions","fromName":"Arsh Srivastava","fromEmail":"arshsrivastava00@gmail.com","sentAt":"2026-03-12T18:13:15Z","receivedAt":"2026-03-12T18:13:29Z","isPatch":true,"sender":{"key":"arshsrivastava00@gmail.com","avatar":"https://gravatar.com/avatar/31a57f3c18a3d49c0601d1863b1cea06242a5d6808b9bcc8fa8a801195d04cc7?d=mp&s=160"},"body":"Junio C Hamano <gitster@pobox.com> writes :\n> The commit message should focus on the \"why\" and \"what\" from a user perspective, following the project's standard format (problem description, then solution).\n> Also showed an example for the same.\n> Also, note that \"extention\" is a typo; it should be \"extension\".\n> Having said that, I am not sure if we want to suggest \"checkout -m\" in this situation after all.\n> Pointed out the difference between \"stash\" and \"checkout -m\".\n> When advice requires a multi-line warning about potential data loss.\n> The goal of these messages should be to provide a clear, safe next step, not a list of advanced alternatives with caveats.\n>  After all, the users who need such an \"it failed, now what should I do to recover?\" message the most are relatively inexperienced users and we do not want the advice to be overwhelming.\n> Suggesting this \"one-shot\" approach to a user who is already in a state of friction (and likely less experienced) might be providing them with a \"foot-gun\" rather than a helpful tip. Generally, advice that nudges users toward the safest \"golden paths\" like stashing or committing is preferred.\n> For a microproject, you've successfully demonstrated that you can modify the advice system and update the test suite.\n> it might be better to drop the 'checkout -m' suggestion and instead focus on making the existing 'stash' and 'commit' advice as clear and helpful as possible.\n\nThank you so much for the valuable feedback.\n\nI will redefine my advice and will make it more precise and will\nchange it to git stash which is truly more beneficial for the new\nusers.\nAlso will update my commit so that it is properly structured with\nformat first \"why\" then \"what\".\nI will create a v7 with all these changes.\nI am really obliged.\n\nThanks again for the guidance.\n\nOn Thu, 12 Mar 2026 at 21:36, Junio C Hamano <gitster@pobox.com> wrote:\n>\n> \"Arsh Srivastava via GitGitGadget\" <gitgitgadget@gmail.com> writes:\n>\n> > From: Arsh Srivastava <arshsrivastava00@gmail.com>\n> >\n> > This comment is an extention to the already existing stash comment.\n> > Added updated comment over the already existing function\n> > \"setup_unpack_trees_porcelain\" with \"git checkout -m\"\n> > and its repercussions\n> > I have also mentioned the repercussions of using \"-m\".\n> >\n> > Signed-off-by: Arsh Srivastava arshsrivastava00@gmail.com\n>\n> The commit message should focus on the \"why\" and \"what\" from a user\n> perspective, following the project's standard format (problem\n> description, then solution).\n>\n> Consider a more standard phrasing:\n>\n>     unpack-trees: suggest 'git checkout -m' when checkout fails\n>\n>     When a branch switch fails due to local changes, we suggest\n>     stashing or committing. However, 'git checkout -m' is a valid\n>     alternative for users who wish to carry their changes over via a\n>     merge.\n>\n>     Update the advice message to suggest this option, while\n>     including a warning about the potential for data loss if a hard\n>     reset is performed after a conflicted merge.\n>\n> Also, note that \"extention\" is a typo; it should be \"extension\".\n>\n> Having said that, I am not sure if we want to suggest \"checkout -m\"\n> in this situation after all.\n>\n> The added message is quite long:\n>\n> > Try using 'git checkout -m <branch>' for a quick fix.\n> > Please Note :- that using -m (merge) will not save your changes,\n> > rather would directly merge them.\n> > Meaning if you are not able to resolve conflicts and does --hard\n> > reset your local changes would be gone.\n>\n> When advice requires a multi-line warning about potential data loss,\n> it's often a sign that the operation being suggested isn't suitable\n> for general advice. The goal of these messages should be to provide\n> a clear, safe next step, not a list of advanced alternatives with\n> caveats. After all, the users who need such an \"it failed, now what\n> should I do to recover?\" message the most are relatively\n> inexperienced users and we do not want the advice to be\n> overwhelming.\n>\n> The primary concern is that 'git checkout -m' is a high-stakes\n> operation compared to 'git stash'.\n>\n> - When a user uses 'git stash', their changes are recorded in a\n>   stash entry. If 'git stash pop' later results in conflicts they\n>   cannot resolve, the user can always 'git reset --hard' to get back\n>   to a clean state, knowing their original changes are still safe in\n>   the stash entry, which they can re-attempt to use later.\n>\n> - In contrast, 'git checkout -m' performs the merge directly in\n>   the working tree.  If conflicts arise, the original local changes\n>   are immediately replaced by conflict markers. Unlike stash, there\n>   is no \"undo\" record. If the user realizes they are in over their\n>   head, they cannot simply \"abort\" to get their original changes\n>   back. They have only one chance to resolve it correctly, and they\n>   have to do so right there.\n>\n> Suggesting this \"one-shot\" approach to a user who is already in a\n> state of friction (and likely less experienced) might be providing\n> them with a \"foot-gun\" rather than a helpful tip. Generally, advice\n> that nudges users toward the safest \"golden paths\" like stashing or\n> committing is preferred.\n>\n> For a microproject, you've successfully demonstrated that you can\n> modify the advice system and update the test suite. However, for the\n> health of the project's usability, it might be better to drop the\n> 'checkout -m' suggestion and instead focus on making the existing\n> 'stash' and 'commit' advice as clear and helpful as possible.\n>\n> Thanks.\n>\n"},{"id":"538788","messageId":"xmqqwlzgev16.fsf@gitster.g","threadId":"65195","inReplyTo":"CAOAgETN-UVtee5OjjcLE45sRxajCkgF3nipBqXpec4JjN8+vfw@mail.gmail.com","subject":"Re: [PATCH v6] unpack-trees: suggesting 'git checkout -m' with its repercussions","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2026-03-12T18:56:37Z","receivedAt":"2026-03-12T18:56:39Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Arsh Srivastava <arshsrivastava00@gmail.com> writes:\n\n> Junio C Hamano <gitster@pobox.com> writes :\n>> The commit message should focus on the \"why\" and \"what\" from a user perspective, following the project's standard format (problem description, then solution).\n>> Also showed an example for the same.\n>> Also, note that \"extention\" is a typo; it should be \"extension\".\n>> Having said that, I am not sure if we want to suggest \"checkout -m\" in this situation after all.\n>> Pointed out the difference between \"stash\" and \"checkout -m\".\n>> When advice requires a multi-line warning about potential data loss.\n>> The goal of these messages should be to provide a clear, safe next step, not a list of advanced alternatives with caveats.\n>>  After all, the users who need such an \"it failed, now what should I do to recover?\" message the most are relatively inexperienced users and we do not want the advice to be overwhelming.\n>> Suggesting this \"one-shot\" approach to a user who is already in a state of friction (and likely less experienced) might be providing them with a \"foot-gun\" rather than a helpful tip. Generally, advice that nudges users toward the safest \"golden paths\" like stashing or committing is preferred.\n>> For a microproject, you've successfully demonstrated that you can modify the advice system and update the test suite.\n>> it might be better to drop the 'checkout -m' suggestion and instead focus on making the existing 'stash' and 'commit' advice as clear and helpful as possible.\n\nI wonder where this came from, as it is quite unusual to have a\nrephrased summary of what you respond to.  Is this LLM-generated\nsummary that was copied-and-pasted without much human brain effort?\n\nWhat is more usual is to quote the message you are responding to,\ntrim the parts you are not going to comment on and not necessary for\nbystanders to read in order to understand your response, and then\nsprinkle your comments in between the parts of the quoted message,\ninstead of saying only your thing before the message you are\nresponding to without trimming (which is highly frowned upon, and\npeople often tell you not to \"top-post\").\n\n"},{"id":"538789","messageId":"CAOAgETOd7-vPpBK+8rhE-i_vpqw48gDBdc3QPm3xWOR4w3c7jw@mail.gmail.com","threadId":"65195","inReplyTo":"xmqqwlzgev16.fsf@gitster.g","subject":"Re: [PATCH v6] unpack-trees: suggesting 'git checkout -m' with its repercussions","fromName":"Arsh Srivastava","fromEmail":"arshsrivastava00@gmail.com","sentAt":"2026-03-12T19:03:51Z","receivedAt":"2026-03-12T19:04:06Z","isPatch":true,"sender":{"key":"arshsrivastava00@gmail.com","avatar":"https://gravatar.com/avatar/31a57f3c18a3d49c0601d1863b1cea06242a5d6808b9bcc8fa8a801195d04cc7?d=mp&s=160"},"body":"Junio C Hamano <gitster@pobox.com> write:\n> I wonder where this came from, as it is quite unusual to have a rephrased summary of what you respond to.\n> Is this LLM-generated summary that was copied-and-pasted without much human brain effort?\n> What is more usual is to quote the message you are responding to.\n\nActually as suspicious as it looks the mail was written by me only and\nI thought that each line was as important as other and\nI wanted to reply to each point you mentioned\nSorry for shortening your response\nnext time I will make sure that I will make quotations direct.\n\nOn Fri, 13 Mar 2026 at 00:26, Junio C Hamano <gitster@pobox.com> wrote:\n>\n> Arsh Srivastava <arshsrivastava00@gmail.com> writes:\n>\n> > Junio C Hamano <gitster@pobox.com> writes :\n> >> The commit message should focus on the \"why\" and \"what\" from a user perspective, following the project's standard format (problem description, then solution).\n> >> Also showed an example for the same.\n> >> Also, note that \"extention\" is a typo; it should be \"extension\".\n> >> Having said that, I am not sure if we want to suggest \"checkout -m\" in this situation after all.\n> >> Pointed out the difference between \"stash\" and \"checkout -m\".\n> >> When advice requires a multi-line warning about potential data loss.\n> >> The goal of these messages should be to provide a clear, safe next step, not a list of advanced alternatives with caveats.\n> >>  After all, the users who need such an \"it failed, now what should I do to recover?\" message the most are relatively inexperienced users and we do not want the advice to be overwhelming.\n> >> Suggesting this \"one-shot\" approach to a user who is already in a state of friction (and likely less experienced) might be providing them with a \"foot-gun\" rather than a helpful tip. Generally, advice that nudges users toward the safest \"golden paths\" like stashing or committing is preferred.\n> >> For a microproject, you've successfully demonstrated that you can modify the advice system and update the test suite.\n> >> it might be better to drop the 'checkout -m' suggestion and instead focus on making the existing 'stash' and 'commit' advice as clear and helpful as possible.\n>\n> I wonder where this came from, as it is quite unusual to have a\n> rephrased summary of what you respond to.  Is this LLM-generated\n> summary that was copied-and-pasted without much human brain effort?\n>\n> What is more usual is to quote the message you are responding to,\n> trim the parts you are not going to comment on and not necessary for\n> bystanders to read in order to understand your response, and then\n> sprinkle your comments in between the parts of the quoted message,\n> instead of saying only your thing before the message you are\n> responding to without trimming (which is highly frowned upon, and\n> people often tell you not to \"top-post\").\n>\n"},{"id":"538791","messageId":"xmqqsea4eujd.fsf@gitster.g","threadId":"65195","inReplyTo":"CAOAgETOd7-vPpBK+8rhE-i_vpqw48gDBdc3QPm3xWOR4w3c7jw@mail.gmail.com","subject":"Re: [PATCH v6] unpack-trees: suggesting 'git checkout -m' with its repercussions","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2026-03-12T19:07:18Z","receivedAt":"2026-03-12T19:07:21Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Arsh Srivastava <arshsrivastava00@gmail.com> writes:\n\n> Junio C Hamano <gitster@pobox.com> write:\n>> I wonder where this came from, as it is quite unusual to have a rephrased summary of what you respond to.\n>> Is this LLM-generated summary that was copied-and-pasted without much human brain effort?\n>> What is more usual is to quote the message you are responding to.\n>\n> Actually as suspicious as it looks the mail was written by me only and\n> I thought that each line was as important as other and\n> I wanted to reply to each point you mentioned\n> Sorry for shortening your response\n> next time I will make sure that I will make quotations direct.\n\nThat wasn't what I meant, and you are still top-posting X-<.\n"},{"id":"538794","messageId":"CAOAgETMXbFVH=SLk5xHZ6uvO1BFpfP93WNRUn18uDzDzsbHfEw@mail.gmail.com","threadId":"65195","inReplyTo":"xmqqsea4eujd.fsf@gitster.g","subject":"Re: [PATCH v6] unpack-trees: suggesting 'git checkout -m' with its repercussions","fromName":"Arsh Srivastava","fromEmail":"arshsrivastava00@gmail.com","sentAt":"2026-03-12T19:12:49Z","receivedAt":"2026-03-12T19:13:03Z","isPatch":true,"sender":{"key":"arshsrivastava00@gmail.com","avatar":"https://gravatar.com/avatar/31a57f3c18a3d49c0601d1863b1cea06242a5d6808b9bcc8fa8a801195d04cc7?d=mp&s=160"},"body":"Junio C Hamano <gitster@pobox.com> write:\n> That wasn't what I meant, and you are still top-posting X-<.\n\nOh.. I understand now I mistakenly again used top-posting mail (-<\nwhich is frustrating\nI will use the recommended method only from now on. : )\n\nOn Fri, 13 Mar 2026 at 00:37, Junio C Hamano <gitster@pobox.com> wrote:\n>\n> Arsh Srivastava <arshsrivastava00@gmail.com> writes:\n>\n> > Junio C Hamano <gitster@pobox.com> write:\n> >> I wonder where this came from, as it is quite unusual to have a rephrased summary of what you respond to.\n> >> Is this LLM-generated summary that was copied-and-pasted without much human brain effort?\n> >> What is more usual is to quote the message you are responding to.\n> >\n> > Actually as suspicious as it looks the mail was written by me only and\n> > I thought that each line was as important as other and\n> > I wanted to reply to each point you mentioned\n> > Sorry for shortening your response\n> > next time I will make sure that I will make quotations direct.\n>\n> That wasn't what I meant, and you are still top-posting X-<.\n"},{"id":"538806","messageId":"pull.2233.v7.git.git.1773345901659.gitgitgadget@gmail.com","threadId":"65195","inReplyTo":"pull.2233.v6.git.git.1773288013936.gitgitgadget@gmail.com","subject":"[PATCH v7] unpack-trees: suggest using 'git stash' when checkout fails","fromName":"Arsh Srivastava via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2026-03-12T20:05:01Z","receivedAt":"2026-03-12T20:05:04Z","isPatch":true,"sender":{"key":"arshsrivastava00@gmail.com","avatar":"https://gravatar.com/avatar/31a57f3c18a3d49c0601d1863b1cea06242a5d6808b9bcc8fa8a801195d04cc7?d=mp&s=160"},"body":"From: Arsh Srivastava <arshsrivastava00@gmail.com>\n\nWhen a branch switch fails due to local changes and\nnew users who are not familiar with the error message often\nget confused about how to move ahead and resolve the issue as\nthe previous error message only suggests to commit or stash the changes\nbut doesn't explain how to do that or what the next steps are.\n\nThis patch enhances the error message with more specific\ninstructions in a concise manner to help users understand\nhow to resolve the issue and move their local changes\nsafely to the other branch using stash.\n\nSigned-off-by: Arsh Srivastava <arshsrivastava00@gmail.com>\n---\n    Advice on checkout dirty files\n    \n    This is my submission for microproject [GSOC]\n    \n    This patch extends the current message to help users better understand\n    risks and alternatives to stashing their changes.\n    \n    The alternative consists of\n    \n    > git checkout -m and its repercussions.\n    \n    This extended message is tied to the existing advice.commitBeforeMerge\n    configuration and can be silenced with:\n    \n    > git config set advice.commitBeforeMerge false\n    \n    Changes:\n    \n    > unpack-trees.c: expanded the already existing message.\n    > t/t6439-merge-co-error-msgs.sh: update expected output for merge and\n    > checkout tests. t/t7406-submodule-update.sh: update expected output\n    > for submodule checkout tests.\n    \n    Signed-off-by: Arsh Srivastava arshsrivastava00@gmail.com\n\nPublished-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-2233%2FArsh123344423%2Fadvice_on_checkout_dirty_files-v7\nFetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-2233/Arsh123344423/advice_on_checkout_dirty_files-v7\nPull-Request: https://github.com/git/git/pull/2233\n\nRange-diff vs v6:\n\n 1:  e0ba5fad82 ! 1:  72cb550621 unpack-trees: suggesting 'git checkout -m' with its repercussions\n     @@ Metadata\n      Author: Arsh Srivastava <arshsrivastava00@gmail.com>\n      \n       ## Commit message ##\n     -    unpack-trees: suggesting 'git checkout -m' with its repercussions\n     +    unpack-trees: suggest using 'git stash' when checkout fails\n      \n     -    This comment is an extention to the already existing stash comment.\n     -    Added updated comment over the already existing function\n     -    \"setup_unpack_trees_porcelain\" with \"git checkout -m\"\n     -    and its repercussions\n     -    I have also mentioned the repercussions of using \"-m\".\n     +    When a branch switch fails due to local changes and\n     +    new users who are not familiar with the error message often\n     +    get confused about how to move ahead and resolve the issue as\n     +    the previous error message only suggests to commit or stash the changes\n     +    but doesn't explain how to do that or what the next steps are.\n      \n     -    Signed-off-by: Arsh Srivastava arshsrivastava00@gmail.com\n     +    This patch enhances the error message with more specific\n     +    instructions in a concise manner to help users understand\n     +    how to resolve the issue and move their local changes\n     +    safely to the other branch using stash.\n     +\n     +    Signed-off-by: Arsh Srivastava <arshsrivastava00@gmail.com>\n      \n       ## t/t6439-merge-co-error-msgs.sh ##\n     -@@ t/t6439-merge-co-error-msgs.sh: error: Your local changes to the following files would be overwritten by checkou\n     +@@ t/t6439-merge-co-error-msgs.sh: cat >expect <<\\EOF\n     + error: Your local changes to the following files would be overwritten by checkout:\n       \trep/one\n       \trep/two\n     - Please commit your changes or stash them before you switch branches.\n     -+Try using 'git checkout -m <branch>' for a quick fix.\n     -+Please Note :- that using -m (merge) will not save your changes, rather would directly merge them.\n     -+Meaning if you are not able to resolve conflicts and does --hard reset your local changes would be gone.\n     +-Please commit your changes or stash them before you switch branches.\n     ++To move you local changes safely to the other branch,\n     ++Please try 'git stash' followed by 'git checkout <branch>' followed by 'git stash pop' for safe merge.\n       Aborting\n       EOF\n       \n     -@@ t/t6439-merge-co-error-msgs.sh: error: Your local changes to the following files would be overwritten by checkou\n     +@@ t/t6439-merge-co-error-msgs.sh: cat >expect <<\\EOF\n     + error: Your local changes to the following files would be overwritten by checkout:\n       \trep/one\n       \trep/two\n     - Please commit your changes or stash them before you switch branches.\n     -+Try using 'git checkout -m <branch>' for a quick fix.\n     -+Please Note :- that using -m (merge) will not save your changes, rather would directly merge them.\n     -+Meaning if you are not able to resolve conflicts and does --hard reset your local changes would be gone.\n     +-Please commit your changes or stash them before you switch branches.\n     ++To move you local changes safely to the other branch,\n     ++Please try 'git stash' followed by 'git checkout <branch>' followed by 'git stash pop' for safe merge.\n       Aborting\n       EOF\n       \n      \n       ## t/t7406-submodule-update.sh ##\n      @@ t/t7406-submodule-update.sh: test_expect_success 'submodule update should fail due to local changes' '\n     + \tsed \"s/^> //\" >expect <<-\\EOF &&\n       \t> error: Your local changes to the following files would be overwritten by checkout:\n       \t> \tfile\n     - \t> Please commit your changes or stash them before you switch branches.\n     -+\t> Try using '\\''git checkout -m <branch>'\\'' for a quick fix.\n     -+\t> Please Note :- that using -m (merge) will not save your changes, rather would directly merge them.\n     -+\t> Meaning if you are not able to resolve conflicts and does --hard reset your local changes would be gone.\n     +-\t> Please commit your changes or stash them before you switch branches.\n     ++\t> To move you local changes safely to the other branch,\n     ++\t> Please try '\\''git stash'\\'' followed by '\\''git checkout <branch>'\\'' followed by '\\''git stash pop'\\'' for safe merge.\n       \t> Aborting\n       \t> fatal: Unable to checkout OID in submodule path '\\''submodule'\\''\n       \tEOF\n     @@ unpack-trees.c: void setup_unpack_trees_porcelain(struct unpack_trees_options *o\n       \t\t      ? _(\"Your local changes to the following files would be overwritten by checkout:\\n%%s\"\n      -\t\t\t  \"Please commit your changes or stash them before you switch branches.\")\n      -\t\t      : _(\"Your local changes to the following files would be overwritten by checkout:\\n%%s\");\n     -+\t\t\t  \"Please commit your changes or stash them before you switch branches.\\n\"\n     -+\t\t\t  \"Try using 'git checkout -m <branch>' for a quick fix.\\n\"\n     -+\t\t\t  \"Please Note :- that using -m (merge) will not save your changes, rather would directly merge them.\\n\"\n     -+\t\t\t  \"Meaning if you are not able to resolve conflicts and does --hard reset your local changes would be gone.\"\n     ++\t\t\t  \"To move you local changes safely to the other branch,\\n\"\n     ++\t\t\t  \"Please try 'git stash' followed by 'git checkout <branch>' followed by 'git stash pop' for safe merge.\"\n      +\t\t\t  )\n      +\t\t      : _(\"Your local changes to the following files would be overwritten by checkout:\\n%%s\"\n      +\t\t\t\t\"Please commit your changes or stash them before you switch branches.\");\n\n\n t/t6439-merge-co-error-msgs.sh | 6 ++++--\n t/t7406-submodule-update.sh    | 3 ++-\n unpack-trees.c                 | 7 +++++--\n 3 files changed, 11 insertions(+), 5 deletions(-)\n\ndiff --git a/t/t6439-merge-co-error-msgs.sh b/t/t6439-merge-co-error-msgs.sh\nindex 643c9368e0..6ccc1e0416 100755\n--- a/t/t6439-merge-co-error-msgs.sh\n+++ b/t/t6439-merge-co-error-msgs.sh\n@@ -76,7 +76,8 @@ cat >expect <<\\EOF\n error: Your local changes to the following files would be overwritten by checkout:\n \trep/one\n \trep/two\n-Please commit your changes or stash them before you switch branches.\n+To move you local changes safely to the other branch,\n+Please try 'git stash' followed by 'git checkout <branch>' followed by 'git stash pop' for safe merge.\n Aborting\n EOF\n \n@@ -98,7 +99,8 @@ cat >expect <<\\EOF\n error: Your local changes to the following files would be overwritten by checkout:\n \trep/one\n \trep/two\n-Please commit your changes or stash them before you switch branches.\n+To move you local changes safely to the other branch,\n+Please try 'git stash' followed by 'git checkout <branch>' followed by 'git stash pop' for safe merge.\n Aborting\n EOF\n \ndiff --git a/t/t7406-submodule-update.sh b/t/t7406-submodule-update.sh\nindex 3adab12091..1ba15918a5 100755\n--- a/t/t7406-submodule-update.sh\n+++ b/t/t7406-submodule-update.sh\n@@ -211,7 +211,8 @@ test_expect_success 'submodule update should fail due to local changes' '\n \tsed \"s/^> //\" >expect <<-\\EOF &&\n \t> error: Your local changes to the following files would be overwritten by checkout:\n \t> \tfile\n-\t> Please commit your changes or stash them before you switch branches.\n+\t> To move you local changes safely to the other branch,\n+\t> Please try '\\''git stash'\\'' followed by '\\''git checkout <branch>'\\'' followed by '\\''git stash pop'\\'' for safe merge.\n \t> Aborting\n \t> fatal: Unable to checkout OID in submodule path '\\''submodule'\\''\n \tEOF\ndiff --git a/unpack-trees.c b/unpack-trees.c\nindex 998a1e6dc7..e817477926 100644\n--- a/unpack-trees.c\n+++ b/unpack-trees.c\n@@ -128,8 +128,11 @@ void setup_unpack_trees_porcelain(struct unpack_trees_options *opts,\n \tif (!strcmp(cmd, \"checkout\"))\n \t\tmsg = advice_enabled(ADVICE_COMMIT_BEFORE_MERGE)\n \t\t      ? _(\"Your local changes to the following files would be overwritten by checkout:\\n%%s\"\n-\t\t\t  \"Please commit your changes or stash them before you switch branches.\")\n-\t\t      : _(\"Your local changes to the following files would be overwritten by checkout:\\n%%s\");\n+\t\t\t  \"To move you local changes safely to the other branch,\\n\"\n+\t\t\t  \"Please try 'git stash' followed by 'git checkout <branch>' followed by 'git stash pop' for safe merge.\"\n+\t\t\t  )\n+\t\t      : _(\"Your local changes to the following files would be overwritten by checkout:\\n%%s\"\n+\t\t\t\t\"Please commit your changes or stash them before you switch branches.\");\n \telse if (!strcmp(cmd, \"merge\"))\n \t\tmsg = advice_enabled(ADVICE_COMMIT_BEFORE_MERGE)\n \t\t      ? _(\"Your local changes to the following files would be overwritten by merge:\\n%%s\"\n\nbase-commit: d181b9354cf85b44455ce3ca9e6af0b9559e0ae2\n-- \ngitgitgadget\n"},{"id":"538822","messageId":"xmqqldfwacyw.fsf@gitster.g","threadId":"65195","inReplyTo":"pull.2233.v7.git.git.1773345901659.gitgitgadget@gmail.com","subject":"Re: [PATCH v7] unpack-trees: suggest using 'git stash' when checkout fails","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2026-03-12T22:40:23Z","receivedAt":"2026-03-12T22:40:26Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"Arsh Srivastava via GitGitGadget\" <gitgitgadget@gmail.com> writes:\n\n> When a branch switch fails due to local changes and\n> new users who are not familiar with the error message often\n> get confused about how to move ahead and resolve the issue as\n> the previous error message only suggests to commit or stash the changes\n> but doesn't explain how to do that or what the next steps are.\n\nThe first paragraph is a bit of a run-on and has a misplaced \"and\";\nI cannot quite read and understand this overly long single sentence.\n\nPerhaps the early part can become a bit easier to read with\npunctuations, and cutting the sentence into two, e.g.,\n\n  When a branch switch fails due to local changes, new users who\n  are unfamiliar with the error message often get confused about how\n  to move ahead and resolve the issue.\n\nAlso it is misleading to say \"previous\" error message.  We talk\nabout the current code in the present tense, to highlight what the\nproblem in the current code is.  The _current_ message stops at\nhinting the commands to be used without giving wordy instructions\nthat are best left to manuals.  You may view it as a weakness (which\nmay motivate this patch to be written).  But I personally am not so\nsure that adding words to the existing message would necessarily\nmake it more clear.\n\n> This patch enhances the error message with more specific\n> instructions in a concise manner to help users understand\n> how to resolve the issue and move their local changes\n> safely to the other branch using stash.\n\nAs Documentation/SubmittingPatches says, let's instruct the code to\n\"be like so\" in imperative mood.  E.g., \"Enhance the error\nmessage...\" instead of \"This patch enhances...\".\n\nBy the way, the updated message seems much less concise than the\noriginal.\n\n>  \tmsg = advice_enabled(ADVICE_COMMIT_BEFORE_MERGE)\n>  \t      ? _(\"Your local changes to the following files would be overwritten by checkout:\\n%%s\"\n> -\t\t  \"Please commit your changes or stash them before you switch branches.\")\n> -\t      : _(\"Your local changes to the following files would be overwritten by checkout:\\n%%s\");\n> +\t\t  \"To move you local changes safely to the other branch,\\n\"\n> +\t\t  \"Please try 'git stash' followed by 'git checkout <branch>' followed by 'git stash pop' for safe merge.\"\n> +\t\t  )\n> +\t      : _(\"Your local changes to the following files would be overwritten by checkout:\\n%%s\"\n> +\t\t  \"Please commit your changes or stash them before you switch branches.\");\n\nThese were already overly long, but the updated one is way too long\nto be read on end-user's terminal.  The source lines are overly\nlong, too.\n\nThe original was this:\n\n \tmsg = advice_enabled(ADVICE_COMMIT_BEFORE_MERGE)\n \t      ? _(\"Your local changes to the following files would be overwritten by checkout:\\n%%s\"\n\t\t  \"Please commit your changes or stash them before you switch branches.\")\n\t      : _(\"Your local changes to the following files would be overwritten by checkout:\\n%%s\");\n\nNote that when advice is *NOT* enabled, we only gave\n\n_(\"Your local changes to the following files would be overwritten by checkout:\\n%%s\");\n\nwithout any \"advise\" in the output.  That is what !advice_enabled() means.\n\nThe updated code does this:\n\n\tmsg = advice_enabled(ADVICE_COMMIT_BEFORE_MERGE)\n\t      ? _(\"Your local changes to the following files would be overwritten by checkout:\\n%%s\"\n\t\t  \"To move you local changes safely to the other branch,\\n\"\n\t\t  \"Please try 'git stash' followed by 'git checkout <branch>' followed by 'git stash pop' for safe merge.\"\n\t\t  )\n\t      : _(\"Your local changes to the following files would be overwritten by checkout:\\n%%s\"\n\t\t  \"Please commit your changes or stash them before you switch branches.\");\n\nto those users who decline the advice, we now show \"Please\ncommit...\".  That is not what !advice_enabled() should trigger, is\nit?\n\nAlso \"To move you\" -> \"To move your\".\n\nAlso the advice lost the other possiblity of first committing the\nwork in progress on the original branch before switching, yet the\nnew advice message is quite wordy.\n\nAlso, using \"for safe merge\" when the user is performing a\n\"checkout\" might be slightly confusing, even if 'stash pop' involves\na merge under the hood.\n\nA more concise version might say:\n\n  Try 'git stash && git checkout <branch> && git stash pop' to carry\n  your changes to the new branch, or commit your work before switching.\n\nBut as I already said, I think the current text may already strike\nthe right balance between being clear and being concise.\n\nThanks.\n\n"},{"id":"538836","messageId":"CAOAgETMCb++MnOC9YEN+y0TE9NeVC+-=Zez7UOVY3kt8vv7dRQ@mail.gmail.com","threadId":"65195","inReplyTo":"xmqqldfwacyw.fsf@gitster.g","subject":"Re: [PATCH v7] unpack-trees: suggest using 'git stash' when checkout fails","fromName":"Arsh Srivastava","fromEmail":"arshsrivastava00@gmail.com","sentAt":"2026-03-13T03:13:14Z","receivedAt":"2026-03-13T03:13:28Z","isPatch":true,"sender":{"key":"arshsrivastava00@gmail.com","avatar":"https://gravatar.com/avatar/31a57f3c18a3d49c0601d1863b1cea06242a5d6808b9bcc8fa8a801195d04cc7?d=mp&s=160"},"body":"Junio C Hamano <gitster@pobox.com> writes :\n\n> The first paragraph is a bit of a run-on and has a misplaced \"and\";\n> I cannot quite read and understand this overly long single sentence.\n> Perhaps the early part can become a bit easier to read with\npunctuations, and cutting the sentence into two, e.g.,\n\nIn my future commits I will remember to make it as easy to read as possible.\nWith less punctuations and shorter sentences which will in turn make it more\nconcise.\n\n> Also it is misleading to say \"previous\" error message.  We talk\n> about the current code in the present tense, to highlight what the\n> problem in the current code is.\n\nUnderstood I will in future not use previous because it is the\n_current_ code.\n\n> You may view it as a weakness (which\n> may motivate this patch to be written).  But I personally am not so\n> sure that adding words to the existing message would necessarily\n> make it more clear.\n\nI understand, git wants people to not explore the available\nchange options and help them make logical decisions rather\nthan pushing them with some unneeded commands.\n\n> As Documentation/SubmittingPatches says, let's instruct the code to\n> \"be like so\" in imperative mood.  E.g., \"Enhance the error\n> message...\" instead of \"This patch enhances...\".\n\nUnderstood that makes sense because nevertheless\nit is given that I am writing the changes for this patch only.\n\n> These were already overly long, but the updated one is way too long\n> to be read on end-user's terminal.  The source lines are overly\n> long, too.\n\nThat makes total sense.\n\n> to those users who decline the advice, we now show \"Please\n> commit...\".  That is not what !advice_enabled() should trigger, is\n> it?\n\nThank you so much for your guidance the advice should not\ntrigger to those who have opted not to see.\nMy code might have misjudged this paradigm.\n\n> Also \"To move you\" -> \"To move your\".\n\nI thought I had fixed this typo. Seems like I didn't.\nI will remember to be more cautious next time.\n\n> Also the advice lost the other possiblity of first committing the\n> work in progress on the original branch before switching, yet the\n> new advice message is quite wordy.\n\nAbsolutely correct this commit does narrow the users vision\nfor exploring.\n\n> Also, using \"for safe merge\" when the user is performing a\n> \"checkout\" might be slightly confusing, even if 'stash pop' involves\n> a merge under the hood.\n\nI don't want to sound like a programmed robot but I absolutely\nagree with the recommendations.\n\n> But as I already said, I think the current text may already strike\n> the right balance between being clear and being concise.\n\nThank you so much for your valuable guidance.\nIf it's possible I want some guidance over the questions written below,\nAs it is well stated by you that the current\ntext is clear enough.\nShould I still work on this PR from a purely GSoC\nperspective. Or should I start making my proposal or\nstill work on this PR until my micro project is merged?\nBecause I have already shown I can navigate git project which\nwas the goal of micro projects in the first place.\n\nOn Fri, 13 Mar 2026 at 04:10, Junio C Hamano <gitster@pobox.com> wrote:\n>\n> \"Arsh Srivastava via GitGitGadget\" <gitgitgadget@gmail.com> writes:\n>\n> > When a branch switch fails due to local changes and\n> > new users who are not familiar with the error message often\n> > get confused about how to move ahead and resolve the issue as\n> > the previous error message only suggests to commit or stash the changes\n> > but doesn't explain how to do that or what the next steps are.\n>\n> The first paragraph is a bit of a run-on and has a misplaced \"and\";\n> I cannot quite read and understand this overly long single sentence.\n>\n> Perhaps the early part can become a bit easier to read with\n> punctuations, and cutting the sentence into two, e.g.,\n>\n>   When a branch switch fails due to local changes, new users who\n>   are unfamiliar with the error message often get confused about how\n>   to move ahead and resolve the issue.\n>\n> Also it is misleading to say \"previous\" error message.  We talk\n> about the current code in the present tense, to highlight what the\n> problem in the current code is.  The _current_ message stops at\n> hinting the commands to be used without giving wordy instructions\n> that are best left to manuals.  You may view it as a weakness (which\n> may motivate this patch to be written).  But I personally am not so\n> sure that adding words to the existing message would necessarily\n> make it more clear.\n>\n> > This patch enhances the error message with more specific\n> > instructions in a concise manner to help users understand\n> > how to resolve the issue and move their local changes\n> > safely to the other branch using stash.\n>\n> As Documentation/SubmittingPatches says, let's instruct the code to\n> \"be like so\" in imperative mood.  E.g., \"Enhance the error\n> message...\" instead of \"This patch enhances...\".\n>\n> By the way, the updated message seems much less concise than the\n> original.\n>\n> >       msg = advice_enabled(ADVICE_COMMIT_BEFORE_MERGE)\n> >             ? _(\"Your local changes to the following files would be overwritten by checkout:\\n%%s\"\n> > -               \"Please commit your changes or stash them before you switch branches.\")\n> > -           : _(\"Your local changes to the following files would be overwritten by checkout:\\n%%s\");\n> > +               \"To move you local changes safely to the other branch,\\n\"\n> > +               \"Please try 'git stash' followed by 'git checkout <branch>' followed by 'git stash pop' for safe merge.\"\n> > +               )\n> > +           : _(\"Your local changes to the following files would be overwritten by checkout:\\n%%s\"\n> > +               \"Please commit your changes or stash them before you switch branches.\");\n>\n> These were already overly long, but the updated one is way too long\n> to be read on end-user's terminal.  The source lines are overly\n> long, too.\n>\n> The original was this:\n>\n>         msg = advice_enabled(ADVICE_COMMIT_BEFORE_MERGE)\n>               ? _(\"Your local changes to the following files would be overwritten by checkout:\\n%%s\"\n>                   \"Please commit your changes or stash them before you switch branches.\")\n>               : _(\"Your local changes to the following files would be overwritten by checkout:\\n%%s\");\n>\n> Note that when advice is *NOT* enabled, we only gave\n>\n> _(\"Your local changes to the following files would be overwritten by checkout:\\n%%s\");\n>\n> without any \"advise\" in the output.  That is what !advice_enabled() means.\n>\n> The updated code does this:\n>\n>         msg = advice_enabled(ADVICE_COMMIT_BEFORE_MERGE)\n>               ? _(\"Your local changes to the following files would be overwritten by checkout:\\n%%s\"\n>                   \"To move you local changes safely to the other branch,\\n\"\n>                   \"Please try 'git stash' followed by 'git checkout <branch>' followed by 'git stash pop' for safe merge.\"\n>                   )\n>               : _(\"Your local changes to the following files would be overwritten by checkout:\\n%%s\"\n>                   \"Please commit your changes or stash them before you switch branches.\");\n>\n> to those users who decline the advice, we now show \"Please\n> commit...\".  That is not what !advice_enabled() should trigger, is\n> it?\n>\n> Also \"To move you\" -> \"To move your\".\n>\n> Also the advice lost the other possiblity of first committing the\n> work in progress on the original branch before switching, yet the\n> new advice message is quite wordy.\n>\n> Also, using \"for safe merge\" when the user is performing a\n> \"checkout\" might be slightly confusing, even if 'stash pop' involves\n> a merge under the hood.\n>\n> A more concise version might say:\n>\n>   Try 'git stash && git checkout <branch> && git stash pop' to carry\n>   your changes to the new branch, or commit your work before switching.\n>\n> But as I already said, I think the current text may already strike\n> the right balance between being clear and being concise.\n>\n> Thanks.\n>\n"},{"id":"538874","messageId":"CAOLa=ZTJ1u+cyVZyOGQbdOniK+U3CGrYSJRaeecYsT9+D8gWFQ@mail.gmail.com","threadId":"65195","inReplyTo":"CAOAgETMCb++MnOC9YEN+y0TE9NeVC+-=Zez7UOVY3kt8vv7dRQ@mail.gmail.com","subject":"Re: [PATCH v7] unpack-trees: suggest using 'git stash' when checkout fails","fromName":"Karthik Nayak","fromEmail":"karthik.188@gmail.com","sentAt":"2026-03-13T10:43:11Z","receivedAt":"2026-03-13T10:43:13Z","isPatch":true,"sender":{"key":"karthik.188@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1786334?v=4"},"body":"Arsh Srivastava <arshsrivastava00@gmail.com> writes:\n\n> Junio C Hamano <gitster@pobox.com> writes :\n>\n>> The first paragraph is a bit of a run-on and has a misplaced \"and\";\n>> I cannot quite read and understand this overly long single sentence.\n>> Perhaps the early part can become a bit easier to read with\n> punctuations, and cutting the sentence into two, e.g.,\n>\n> In my future commits I will remember to make it as easy to read as possible.\n> With less punctuations and shorter sentences which will in turn make it more\n> concise.\n>\n>> Also it is misleading to say \"previous\" error message.  We talk\n>> about the current code in the present tense, to highlight what the\n>> problem in the current code is.\n>\n> Understood I will in future not use previous because it is the\n> _current_ code.\n>\n>> You may view it as a weakness (which\n>> may motivate this patch to be written).  But I personally am not so\n>> sure that adding words to the existing message would necessarily\n>> make it more clear.\n>\n> I understand, git wants people to not explore the available\n> change options and help them make logical decisions rather\n> than pushing them with some unneeded commands.\n>\n>> As Documentation/SubmittingPatches says, let's instruct the code to\n>> \"be like so\" in imperative mood.  E.g., \"Enhance the error\n>> message...\" instead of \"This patch enhances...\".\n>\n> Understood that makes sense because nevertheless\n> it is given that I am writing the changes for this patch only.\n>\n>> These were already overly long, but the updated one is way too long\n>> to be read on end-user's terminal.  The source lines are overly\n>> long, too.\n>\n> That makes total sense.\n>\n>> to those users who decline the advice, we now show \"Please\n>> commit...\".  That is not what !advice_enabled() should trigger, is\n>> it?\n>\n> Thank you so much for your guidance the advice should not\n> trigger to those who have opted not to see.\n> My code might have misjudged this paradigm.\n>\n>> Also \"To move you\" -> \"To move your\".\n>\n> I thought I had fixed this typo. Seems like I didn't.\n> I will remember to be more cautious next time.\n>\n>> Also the advice lost the other possiblity of first committing the\n>> work in progress on the original branch before switching, yet the\n>> new advice message is quite wordy.\n>\n> Absolutely correct this commit does narrow the users vision\n> for exploring.\n>\n>> Also, using \"for safe merge\" when the user is performing a\n>> \"checkout\" might be slightly confusing, even if 'stash pop' involves\n>> a merge under the hood.\n>\n> I don't want to sound like a programmed robot but I absolutely\n> agree with the recommendations.\n>\n>> But as I already said, I think the current text may already strike\n>> the right balance between being clear and being concise.\n>\n> Thank you so much for your valuable guidance.\n> If it's possible I want some guidance over the questions written below,\n> As it is well stated by you that the current\n> text is clear enough.\n> Should I still work on this PR from a purely GSoC\n> perspective. Or should I start making my proposal or\n> still work on this PR until my micro project is merged?\n> Because I have already shown I can navigate git project which\n> was the goal of micro projects in the first place.\n>\n\nFrom the micro-project information [1] for GSoC we have:\n\n  The coding part of the microproject should be very small (say, 10-30\n  minutes). We don’t require that your patch be accepted into the\n  “master” branch by the time of your formal application; we mostly want\n  to see that you have a basic level of competence and especially the\n  ability to interact with the other Git developers.\n\nAs such and seeing Junio's previous response, I would say that no\nfurther work is required here.\n\n[1]: https://git.github.io/General-Microproject-Information/\n\n[snip]\n"},{"id":"538875","messageId":"CAOAgETMBnbhSYmHkc0sSTCCsZesxO0G8timU0yF22-PkMi_CsA@mail.gmail.com","threadId":"65195","inReplyTo":"CAOAgETMCb++MnOC9YEN+y0TE9NeVC+-=Zez7UOVY3kt8vv7dRQ@mail.gmail.com","subject":"Re: [PATCH v7] unpack-trees: suggest using 'git stash' when checkout fails","fromName":"Arsh Srivastava","fromEmail":"arshsrivastava00@gmail.com","sentAt":"2026-03-13T10:49:47Z","receivedAt":"2026-03-13T10:50:01Z","isPatch":true,"sender":{"key":"arshsrivastava00@gmail.com","avatar":"https://gravatar.com/avatar/31a57f3c18a3d49c0601d1863b1cea06242a5d6808b9bcc8fa8a801195d04cc7?d=mp&s=160"},"body":"Arsh Srivastava <arshsrivastava00@gmail.com> writes:\n\n> I understand, git wants people to not explore the available\n> change options and help them make logical decisions rather\n> than pushing them with some unneeded commands.\n\nActually the above text should be :-\nI understand, git wants people to explore the available\nchange options and help them make logical decisions rather\nthan pushing them with some unneeded commands.\n\nOn Fri, 13 Mar 2026 at 08:43, Arsh Srivastava\n<arshsrivastava00@gmail.com> wrote:\n>\n> Junio C Hamano <gitster@pobox.com> writes :\n>\n> > The first paragraph is a bit of a run-on and has a misplaced \"and\";\n> > I cannot quite read and understand this overly long single sentence.\n> > Perhaps the early part can become a bit easier to read with\n> punctuations, and cutting the sentence into two, e.g.,\n>\n> In my future commits I will remember to make it as easy to read as possible.\n> With less punctuations and shorter sentences which will in turn make it more\n> concise.\n>\n> > Also it is misleading to say \"previous\" error message.  We talk\n> > about the current code in the present tense, to highlight what the\n> > problem in the current code is.\n>\n> Understood I will in future not use previous because it is the\n> _current_ code.\n>\n> > You may view it as a weakness (which\n> > may motivate this patch to be written).  But I personally am not so\n> > sure that adding words to the existing message would necessarily\n> > make it more clear.\n>\n> I understand, git wants people to not explore the available\n> change options and help them make logical decisions rather\n> than pushing them with some unneeded commands.\n>\n> > As Documentation/SubmittingPatches says, let's instruct the code to\n> > \"be like so\" in imperative mood.  E.g., \"Enhance the error\n> > message...\" instead of \"This patch enhances...\".\n>\n> Understood that makes sense because nevertheless\n> it is given that I am writing the changes for this patch only.\n>\n> > These were already overly long, but the updated one is way too long\n> > to be read on end-user's terminal.  The source lines are overly\n> > long, too.\n>\n> That makes total sense.\n>\n> > to those users who decline the advice, we now show \"Please\n> > commit...\".  That is not what !advice_enabled() should trigger, is\n> > it?\n>\n> Thank you so much for your guidance the advice should not\n> trigger to those who have opted not to see.\n> My code might have misjudged this paradigm.\n>\n> > Also \"To move you\" -> \"To move your\".\n>\n> I thought I had fixed this typo. Seems like I didn't.\n> I will remember to be more cautious next time.\n>\n> > Also the advice lost the other possiblity of first committing the\n> > work in progress on the original branch before switching, yet the\n> > new advice message is quite wordy.\n>\n> Absolutely correct this commit does narrow the users vision\n> for exploring.\n>\n> > Also, using \"for safe merge\" when the user is performing a\n> > \"checkout\" might be slightly confusing, even if 'stash pop' involves\n> > a merge under the hood.\n>\n> I don't want to sound like a programmed robot but I absolutely\n> agree with the recommendations.\n>\n> > But as I already said, I think the current text may already strike\n> > the right balance between being clear and being concise.\n>\n> Thank you so much for your valuable guidance.\n> If it's possible I want some guidance over the questions written below,\n> As it is well stated by you that the current\n> text is clear enough.\n> Should I still work on this PR from a purely GSoC\n> perspective. Or should I start making my proposal or\n> still work on this PR until my micro project is merged?\n> Because I have already shown I can navigate git project which\n> was the goal of micro projects in the first place.\n>\n> On Fri, 13 Mar 2026 at 04:10, Junio C Hamano <gitster@pobox.com> wrote:\n> >\n> > \"Arsh Srivastava via GitGitGadget\" <gitgitgadget@gmail.com> writes:\n> >\n> > > When a branch switch fails due to local changes and\n> > > new users who are not familiar with the error message often\n> > > get confused about how to move ahead and resolve the issue as\n> > > the previous error message only suggests to commit or stash the changes\n> > > but doesn't explain how to do that or what the next steps are.\n> >\n> > The first paragraph is a bit of a run-on and has a misplaced \"and\";\n> > I cannot quite read and understand this overly long single sentence.\n> >\n> > Perhaps the early part can become a bit easier to read with\n> > punctuations, and cutting the sentence into two, e.g.,\n> >\n> >   When a branch switch fails due to local changes, new users who\n> >   are unfamiliar with the error message often get confused about how\n> >   to move ahead and resolve the issue.\n> >\n> > Also it is misleading to say \"previous\" error message.  We talk\n> > about the current code in the present tense, to highlight what the\n> > problem in the current code is.  The _current_ message stops at\n> > hinting the commands to be used without giving wordy instructions\n> > that are best left to manuals.  You may view it as a weakness (which\n> > may motivate this patch to be written).  But I personally am not so\n> > sure that adding words to the existing message would necessarily\n> > make it more clear.\n> >\n> > > This patch enhances the error message with more specific\n> > > instructions in a concise manner to help users understand\n> > > how to resolve the issue and move their local changes\n> > > safely to the other branch using stash.\n> >\n> > As Documentation/SubmittingPatches says, let's instruct the code to\n> > \"be like so\" in imperative mood.  E.g., \"Enhance the error\n> > message...\" instead of \"This patch enhances...\".\n> >\n> > By the way, the updated message seems much less concise than the\n> > original.\n> >\n> > >       msg = advice_enabled(ADVICE_COMMIT_BEFORE_MERGE)\n> > >             ? _(\"Your local changes to the following files would be overwritten by checkout:\\n%%s\"\n> > > -               \"Please commit your changes or stash them before you switch branches.\")\n> > > -           : _(\"Your local changes to the following files would be overwritten by checkout:\\n%%s\");\n> > > +               \"To move you local changes safely to the other branch,\\n\"\n> > > +               \"Please try 'git stash' followed by 'git checkout <branch>' followed by 'git stash pop' for safe merge.\"\n> > > +               )\n> > > +           : _(\"Your local changes to the following files would be overwritten by checkout:\\n%%s\"\n> > > +               \"Please commit your changes or stash them before you switch branches.\");\n> >\n> > These were already overly long, but the updated one is way too long\n> > to be read on end-user's terminal.  The source lines are overly\n> > long, too.\n> >\n> > The original was this:\n> >\n> >         msg = advice_enabled(ADVICE_COMMIT_BEFORE_MERGE)\n> >               ? _(\"Your local changes to the following files would be overwritten by checkout:\\n%%s\"\n> >                   \"Please commit your changes or stash them before you switch branches.\")\n> >               : _(\"Your local changes to the following files would be overwritten by checkout:\\n%%s\");\n> >\n> > Note that when advice is *NOT* enabled, we only gave\n> >\n> > _(\"Your local changes to the following files would be overwritten by checkout:\\n%%s\");\n> >\n> > without any \"advise\" in the output.  That is what !advice_enabled() means.\n> >\n> > The updated code does this:\n> >\n> >         msg = advice_enabled(ADVICE_COMMIT_BEFORE_MERGE)\n> >               ? _(\"Your local changes to the following files would be overwritten by checkout:\\n%%s\"\n> >                   \"To move you local changes safely to the other branch,\\n\"\n> >                   \"Please try 'git stash' followed by 'git checkout <branch>' followed by 'git stash pop' for safe merge.\"\n> >                   )\n> >               : _(\"Your local changes to the following files would be overwritten by checkout:\\n%%s\"\n> >                   \"Please commit your changes or stash them before you switch branches.\");\n> >\n> > to those users who decline the advice, we now show \"Please\n> > commit...\".  That is not what !advice_enabled() should trigger, is\n> > it?\n> >\n> > Also \"To move you\" -> \"To move your\".\n> >\n> > Also the advice lost the other possiblity of first committing the\n> > work in progress on the original branch before switching, yet the\n> > new advice message is quite wordy.\n> >\n> > Also, using \"for safe merge\" when the user is performing a\n> > \"checkout\" might be slightly confusing, even if 'stash pop' involves\n> > a merge under the hood.\n> >\n> > A more concise version might say:\n> >\n> >   Try 'git stash && git checkout <branch> && git stash pop' to carry\n> >   your changes to the new branch, or commit your work before switching.\n> >\n> > But as I already said, I think the current text may already strike\n> > the right balance between being clear and being concise.\n> >\n> > Thanks.\n> >\n"},{"id":"538876","messageId":"CAOAgETNZ4HJrhDnc70k1RzCaGaajHDK-esqN+kwLj4xkRbaddQ@mail.gmail.com","threadId":"65195","inReplyTo":"CAOLa=ZTJ1u+cyVZyOGQbdOniK+U3CGrYSJRaeecYsT9+D8gWFQ@mail.gmail.com","subject":"Re: [PATCH v7] unpack-trees: suggest using 'git stash' when checkout fails","fromName":"Arsh Srivastava","fromEmail":"arshsrivastava00@gmail.com","sentAt":"2026-03-13T11:02:50Z","receivedAt":"2026-03-13T11:03:05Z","isPatch":true,"sender":{"key":"arshsrivastava00@gmail.com","avatar":"https://gravatar.com/avatar/31a57f3c18a3d49c0601d1863b1cea06242a5d6808b9bcc8fa8a801195d04cc7?d=mp&s=160"},"body":"Karthik Nayak <karthik.188@gmail.com> writes :\n\n>  We don’t require that your patch be accepted into the\n>  “master” branch by the time of your formal application\n\nUnderstandable\n\n> we mostly want to see that you have a basic level of\n> competence and especially the\n> ability to interact with the other Git developers.\n\nTruly this is something that is very important in any\norganization.\n\n> As such and seeing Junio's previous response, I would say that no\n> further work is required here.\n\nThank you so much for your valuable guidance, I will now\ndraft a formal proposal for GSoC and I look forward to working\nwith you in the future too. :)\n\nOn Fri, 13 Mar 2026 at 16:13, Karthik Nayak <karthik.188@gmail.com> wrote:\n>\n> Arsh Srivastava <arshsrivastava00@gmail.com> writes:\n>\n> > Junio C Hamano <gitster@pobox.com> writes :\n> >\n> >> The first paragraph is a bit of a run-on and has a misplaced \"and\";\n> >> I cannot quite read and understand this overly long single sentence.\n> >> Perhaps the early part can become a bit easier to read with\n> > punctuations, and cutting the sentence into two, e.g.,\n> >\n> > In my future commits I will remember to make it as easy to read as possible.\n> > With less punctuations and shorter sentences which will in turn make it more\n> > concise.\n> >\n> >> Also it is misleading to say \"previous\" error message.  We talk\n> >> about the current code in the present tense, to highlight what the\n> >> problem in the current code is.\n> >\n> > Understood I will in future not use previous because it is the\n> > _current_ code.\n> >\n> >> You may view it as a weakness (which\n> >> may motivate this patch to be written).  But I personally am not so\n> >> sure that adding words to the existing message would necessarily\n> >> make it more clear.\n> >\n> > I understand, git wants people to not explore the available\n> > change options and help them make logical decisions rather\n> > than pushing them with some unneeded commands.\n> >\n> >> As Documentation/SubmittingPatches says, let's instruct the code to\n> >> \"be like so\" in imperative mood.  E.g., \"Enhance the error\n> >> message...\" instead of \"This patch enhances...\".\n> >\n> > Understood that makes sense because nevertheless\n> > it is given that I am writing the changes for this patch only.\n> >\n> >> These were already overly long, but the updated one is way too long\n> >> to be read on end-user's terminal.  The source lines are overly\n> >> long, too.\n> >\n> > That makes total sense.\n> >\n> >> to those users who decline the advice, we now show \"Please\n> >> commit...\".  That is not what !advice_enabled() should trigger, is\n> >> it?\n> >\n> > Thank you so much for your guidance the advice should not\n> > trigger to those who have opted not to see.\n> > My code might have misjudged this paradigm.\n> >\n> >> Also \"To move you\" -> \"To move your\".\n> >\n> > I thought I had fixed this typo. Seems like I didn't.\n> > I will remember to be more cautious next time.\n> >\n> >> Also the advice lost the other possiblity of first committing the\n> >> work in progress on the original branch before switching, yet the\n> >> new advice message is quite wordy.\n> >\n> > Absolutely correct this commit does narrow the users vision\n> > for exploring.\n> >\n> >> Also, using \"for safe merge\" when the user is performing a\n> >> \"checkout\" might be slightly confusing, even if 'stash pop' involves\n> >> a merge under the hood.\n> >\n> > I don't want to sound like a programmed robot but I absolutely\n> > agree with the recommendations.\n> >\n> >> But as I already said, I think the current text may already strike\n> >> the right balance between being clear and being concise.\n> >\n> > Thank you so much for your valuable guidance.\n> > If it's possible I want some guidance over the questions written below,\n> > As it is well stated by you that the current\n> > text is clear enough.\n> > Should I still work on this PR from a purely GSoC\n> > perspective. Or should I start making my proposal or\n> > still work on this PR until my micro project is merged?\n> > Because I have already shown I can navigate git project which\n> > was the goal of micro projects in the first place.\n> >\n>\n> From the micro-project information [1] for GSoC we have:\n>\n>   The coding part of the microproject should be very small (say, 10-30\n>   minutes). We don’t require that your patch be accepted into the\n>   “master” branch by the time of your formal application; we mostly want\n>   to see that you have a basic level of competence and especially the\n>   ability to interact with the other Git developers.\n>\n> As such and seeing Junio's previous response, I would say that no\n> further work is required here.\n>\n> [1]: https://git.github.io/General-Microproject-Information/\n>\n> [snip]\n"},{"id":"538877","messageId":"CAOAgETM=TL1V2U-t3uLehfoQ2dJ=biwR9dw=33J_uHCqh9+mpg@mail.gmail.com","threadId":"65195","inReplyTo":"CAOAgETMCb++MnOC9YEN+y0TE9NeVC+-=Zez7UOVY3kt8vv7dRQ@mail.gmail.com","subject":"Re: [PATCH v7] unpack-trees: suggest using 'git stash' when checkout fails","fromName":"Arsh Srivastava","fromEmail":"arshsrivastava00@gmail.com","sentAt":"2026-03-13T11:04:05Z","receivedAt":"2026-03-13T11:04:20Z","isPatch":true,"sender":{"key":"arshsrivastava00@gmail.com","avatar":"https://gravatar.com/avatar/31a57f3c18a3d49c0601d1863b1cea06242a5d6808b9bcc8fa8a801195d04cc7?d=mp&s=160"},"body":"Arsh Srivastava <arshsrivastava00@gmail.com> writes:\n\n> I understand, git wants people to not explore the available\n\nThis was a typo the real text is :\n\nI understand, git wants people to explore the available\n\nOn Fri, 13 Mar 2026 at 08:43, Arsh Srivastava\n<arshsrivastava00@gmail.com> wrote:\n>\n> Junio C Hamano <gitster@pobox.com> writes :\n>\n> > The first paragraph is a bit of a run-on and has a misplaced \"and\";\n> > I cannot quite read and understand this overly long single sentence.\n> > Perhaps the early part can become a bit easier to read with\n> punctuations, and cutting the sentence into two, e.g.,\n>\n> In my future commits I will remember to make it as easy to read as possible.\n> With less punctuations and shorter sentences which will in turn make it more\n> concise.\n>\n> > Also it is misleading to say \"previous\" error message.  We talk\n> > about the current code in the present tense, to highlight what the\n> > problem in the current code is.\n>\n> Understood I will in future not use previous because it is the\n> _current_ code.\n>\n> > You may view it as a weakness (which\n> > may motivate this patch to be written).  But I personally am not so\n> > sure that adding words to the existing message would necessarily\n> > make it more clear.\n>\n> I understand, git wants people to not explore the available\n> change options and help them make logical decisions rather\n> than pushing them with some unneeded commands.\n>\n> > As Documentation/SubmittingPatches says, let's instruct the code to\n> > \"be like so\" in imperative mood.  E.g., \"Enhance the error\n> > message...\" instead of \"This patch enhances...\".\n>\n> Understood that makes sense because nevertheless\n> it is given that I am writing the changes for this patch only.\n>\n> > These were already overly long, but the updated one is way too long\n> > to be read on end-user's terminal.  The source lines are overly\n> > long, too.\n>\n> That makes total sense.\n>\n> > to those users who decline the advice, we now show \"Please\n> > commit...\".  That is not what !advice_enabled() should trigger, is\n> > it?\n>\n> Thank you so much for your guidance the advice should not\n> trigger to those who have opted not to see.\n> My code might have misjudged this paradigm.\n>\n> > Also \"To move you\" -> \"To move your\".\n>\n> I thought I had fixed this typo. Seems like I didn't.\n> I will remember to be more cautious next time.\n>\n> > Also the advice lost the other possiblity of first committing the\n> > work in progress on the original branch before switching, yet the\n> > new advice message is quite wordy.\n>\n> Absolutely correct this commit does narrow the users vision\n> for exploring.\n>\n> > Also, using \"for safe merge\" when the user is performing a\n> > \"checkout\" might be slightly confusing, even if 'stash pop' involves\n> > a merge under the hood.\n>\n> I don't want to sound like a programmed robot but I absolutely\n> agree with the recommendations.\n>\n> > But as I already said, I think the current text may already strike\n> > the right balance between being clear and being concise.\n>\n> Thank you so much for your valuable guidance.\n> If it's possible I want some guidance over the questions written below,\n> As it is well stated by you that the current\n> text is clear enough.\n> Should I still work on this PR from a purely GSoC\n> perspective. Or should I start making my proposal or\n> still work on this PR until my micro project is merged?\n> Because I have already shown I can navigate git project which\n> was the goal of micro projects in the first place.\n>\n> On Fri, 13 Mar 2026 at 04:10, Junio C Hamano <gitster@pobox.com> wrote:\n> >\n> > \"Arsh Srivastava via GitGitGadget\" <gitgitgadget@gmail.com> writes:\n> >\n> > > When a branch switch fails due to local changes and\n> > > new users who are not familiar with the error message often\n> > > get confused about how to move ahead and resolve the issue as\n> > > the previous error message only suggests to commit or stash the changes\n> > > but doesn't explain how to do that or what the next steps are.\n> >\n> > The first paragraph is a bit of a run-on and has a misplaced \"and\";\n> > I cannot quite read and understand this overly long single sentence.\n> >\n> > Perhaps the early part can become a bit easier to read with\n> > punctuations, and cutting the sentence into two, e.g.,\n> >\n> >   When a branch switch fails due to local changes, new users who\n> >   are unfamiliar with the error message often get confused about how\n> >   to move ahead and resolve the issue.\n> >\n> > Also it is misleading to say \"previous\" error message.  We talk\n> > about the current code in the present tense, to highlight what the\n> > problem in the current code is.  The _current_ message stops at\n> > hinting the commands to be used without giving wordy instructions\n> > that are best left to manuals.  You may view it as a weakness (which\n> > may motivate this patch to be written).  But I personally am not so\n> > sure that adding words to the existing message would necessarily\n> > make it more clear.\n> >\n> > > This patch enhances the error message with more specific\n> > > instructions in a concise manner to help users understand\n> > > how to resolve the issue and move their local changes\n> > > safely to the other branch using stash.\n> >\n> > As Documentation/SubmittingPatches says, let's instruct the code to\n> > \"be like so\" in imperative mood.  E.g., \"Enhance the error\n> > message...\" instead of \"This patch enhances...\".\n> >\n> > By the way, the updated message seems much less concise than the\n> > original.\n> >\n> > >       msg = advice_enabled(ADVICE_COMMIT_BEFORE_MERGE)\n> > >             ? _(\"Your local changes to the following files would be overwritten by checkout:\\n%%s\"\n> > > -               \"Please commit your changes or stash them before you switch branches.\")\n> > > -           : _(\"Your local changes to the following files would be overwritten by checkout:\\n%%s\");\n> > > +               \"To move you local changes safely to the other branch,\\n\"\n> > > +               \"Please try 'git stash' followed by 'git checkout <branch>' followed by 'git stash pop' for safe merge.\"\n> > > +               )\n> > > +           : _(\"Your local changes to the following files would be overwritten by checkout:\\n%%s\"\n> > > +               \"Please commit your changes or stash them before you switch branches.\");\n> >\n> > These were already overly long, but the updated one is way too long\n> > to be read on end-user's terminal.  The source lines are overly\n> > long, too.\n> >\n> > The original was this:\n> >\n> >         msg = advice_enabled(ADVICE_COMMIT_BEFORE_MERGE)\n> >               ? _(\"Your local changes to the following files would be overwritten by checkout:\\n%%s\"\n> >                   \"Please commit your changes or stash them before you switch branches.\")\n> >               : _(\"Your local changes to the following files would be overwritten by checkout:\\n%%s\");\n> >\n> > Note that when advice is *NOT* enabled, we only gave\n> >\n> > _(\"Your local changes to the following files would be overwritten by checkout:\\n%%s\");\n> >\n> > without any \"advise\" in the output.  That is what !advice_enabled() means.\n> >\n> > The updated code does this:\n> >\n> >         msg = advice_enabled(ADVICE_COMMIT_BEFORE_MERGE)\n> >               ? _(\"Your local changes to the following files would be overwritten by checkout:\\n%%s\"\n> >                   \"To move you local changes safely to the other branch,\\n\"\n> >                   \"Please try 'git stash' followed by 'git checkout <branch>' followed by 'git stash pop' for safe merge.\"\n> >                   )\n> >               : _(\"Your local changes to the following files would be overwritten by checkout:\\n%%s\"\n> >                   \"Please commit your changes or stash them before you switch branches.\");\n> >\n> > to those users who decline the advice, we now show \"Please\n> > commit...\".  That is not what !advice_enabled() should trigger, is\n> > it?\n> >\n> > Also \"To move you\" -> \"To move your\".\n> >\n> > Also the advice lost the other possiblity of first committing the\n> > work in progress on the original branch before switching, yet the\n> > new advice message is quite wordy.\n> >\n> > Also, using \"for safe merge\" when the user is performing a\n> > \"checkout\" might be slightly confusing, even if 'stash pop' involves\n> > a merge under the hood.\n> >\n> > A more concise version might say:\n> >\n> >   Try 'git stash && git checkout <branch> && git stash pop' to carry\n> >   your changes to the new branch, or commit your work before switching.\n> >\n> > But as I already said, I think the current text may already strike\n> > the right balance between being clear and being concise.\n> >\n> > Thanks.\n> >\n"},{"id":"538938","messageId":"xmqqbjgr2xn0.fsf@gitster.g","threadId":"65195","inReplyTo":"CAOLa=ZTJ1u+cyVZyOGQbdOniK+U3CGrYSJRaeecYsT9+D8gWFQ@mail.gmail.com","subject":"Re: [PATCH v7] unpack-trees: suggest using 'git stash' when checkout fails","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2026-03-13T22:05:39Z","receivedAt":"2026-03-13T22:05:42Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Karthik Nayak <karthik.188@gmail.com> writes:\n\n> From the micro-project information [1] for GSoC we have:\n>\n>   The coding part of the microproject should be very small (say, 10-30\n>   minutes). We don’t require that your patch be accepted into the\n>   “master” branch by the time of your formal application; we mostly want\n>   to see that you have a basic level of competence and especially the\n>   ability to interact with the other Git developers.\n>\n> As such and seeing Junio's previous response, I would say that no\n> further work is required here.\n>\n> [1]: https://git.github.io/General-Microproject-Information/\n\nThanks ;-).\n"},{"id":"538951","messageId":"20260314-towering-tourmaline-seahorse-caf5f7@lemur","threadId":"65195","inReplyTo":"CAOLa=ZQu1hyiwMpBxJ=0PhNCf6LQqBt3F3=kycDv9cZST_JTNw@mail.gmail.com","subject":"Re: [PATCH v2] advice: add stashBeforeCheckout advice for dirty branch switches","fromName":"Konstantin Ryabitsev","fromEmail":"mricon@kernel.org","sentAt":"2026-03-14T04:27:18Z","receivedAt":"2026-03-14T04:27:19Z","isPatch":true,"sender":{"key":"mricon@kernel.org","avatar":"https://gravatar.com/avatar/d74ca8eb882d19f551bebba2b75663fd9032ab8590103b23ec87236dcd7f349b?d=mp&s=160"},"body":"On Tue, Mar 10, 2026 at 10:09:25AM -0700, Karthik Nayak wrote:\n> >> I will rework the patch in that direction and send a v4.\n> >>\n> >> Signed-off-by: Arsh Srivastava <arshsrivastava00@gmail.com>\n> >\n> > Just a comment by a bystander, but it confuses me quite a lot to see\n> > in-body \"Subject:\" and \"Sign-off\" in a message that is *not* a patch\n> > at all.  What are you signing off with this signature?\n> \n> Tangentially, I know that b4 adds a \"Sign-off\" to the cover message.\n\nThis is a feature, because some subsystems use the cover message as the source\nfor the merge commit, so the cover message *is* a commit despite not being a\npatch. :)\n\nRegards,\n-- \nKR\n"}]}