{"thread":{"id":"25235","subject":"What exactly does 'needs update' mean?","startedAt":"2010-09-25T05:18:59Z","lastAt":"2010-09-26T18:51:17Z","messageCount":12,"participants":["Joshua Jensen","Junio C Hamano","Ramkumar Ramachandra","Matthieu Moy"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"151608","messageId":"4C9D8643.1040001@workspacewhiz.com","threadId":"25235","inReplyTo":null,"subject":"What exactly does 'needs update' mean?","fromName":"Joshua Jensen","fromEmail":"jjensen@workspacewhiz.com","sentAt":"2010-09-25T05:18:59Z","receivedAt":"2010-09-25T05:18:59Z","isPatch":false,"sender":{"key":"jjensen@workspacewhiz.com","avatar":"https://avatars.githubusercontent.com/u/111687?v=4"},"body":"  I've come to accept the term 'needs update' when I've forgotten to \nstash or commit before certain Git operations.  However, I got cornered \ntoday and was asked to explain what it means.  I had to admit I don't know.\n\nWhat does \"you can't do this operation without having a clean working \ntree and these are the modified files currently preventing the operation \nfrom proceeding\" have to do with \"needs update\"?\n\nThanks.\n\nJosh\n"},{"id":"151612","messageId":"7vk4manyql.fsf@alter.siamese.dyndns.org","threadId":"25235","inReplyTo":"4C9D8643.1040001@workspacewhiz.com","subject":"Re: What exactly does 'needs update' mean?","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2010-09-25T06:06:26Z","receivedAt":"2010-09-25T06:06:26Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Joshua Jensen <jjensen@workspacewhiz.com> writes:\n\n>  I've come to accept the term 'needs update' when I've forgotten to\n> stash or commit before certain Git operations.  However, I got\n> cornered today and was asked to explain what it means.  I had to admit\n> I don't know.\n\nIt came from \"you need to run update-index on that path, as you have local\nmodification in the working tree\".\n"},{"id":"151645","messageId":"4C9E0427.9080901@workspacewhiz.com","threadId":"25235","inReplyTo":"7vk4manyql.fsf@alter.siamese.dyndns.org","subject":"Re: What exactly does 'needs update' mean?","fromName":"Joshua Jensen","fromEmail":"jjensen@workspacewhiz.com","sentAt":"2010-09-25T14:16:07Z","receivedAt":"2010-09-25T14:16:07Z","isPatch":false,"sender":{"key":"jjensen@workspacewhiz.com","avatar":"https://avatars.githubusercontent.com/u/111687?v=4"},"body":"  ----- Original Message -----\nFrom: Junio C Hamano\nDate: 9/25/2010 12:06 AM\n> Joshua Jensen<jjensen@workspacewhiz.com>  writes:\n>>   I've come to accept the term 'needs update' when I've forgotten to\n>> stash or commit before certain Git operations.  However, I got\n>> cornered today and was asked to explain what it means.  I had to admit\n>> I don't know.\n> It came from \"you need to run update-index on that path, as you have local\n> modification in the working tree\".\nOkay, your description makes sense to me, and I'll be able to explain \nwhat it means.\n\nI did a Google search before I posted here.  It turns out this phrase is \n*very* confusing to others.  Casual Joes don't use the plumbing commands \n(which I assume git update-index is).  Is there opposition to \nmodernizing this turn to make it more clear based on the porcelain \ncommands being run?\n\nThanks.\n\nJosh\n"},{"id":"151648","messageId":"4C9E07B1.50600@workspacewhiz.com","threadId":"25235","inReplyTo":"4C9E0427.9080901@workspacewhiz.com","subject":"Re: What exactly does 'needs update' mean?","fromName":"Joshua Jensen","fromEmail":"jjensen@workspacewhiz.com","sentAt":"2010-09-25T14:31:13Z","receivedAt":"2010-09-25T14:31:13Z","isPatch":false,"sender":{"key":"jjensen@workspacewhiz.com","avatar":"https://avatars.githubusercontent.com/u/111687?v=4"},"body":"  ----- Original Message -----\nFrom: Joshua Jensen\nDate: 9/25/2010 8:16 AM\n>  ----- Original Message -----\n> From: Junio C Hamano\n> Date: 9/25/2010 12:06 AM\n>> Joshua Jensen<jjensen@workspacewhiz.com>  writes:\n>>>   I've come to accept the term 'needs update' when I've forgotten to\n>>> stash or commit before certain Git operations.  However, I got\n>>> cornered today and was asked to explain what it means.  I had to admit\n>>> I don't know.\n>> It came from \"you need to run update-index on that path, as you have \n>> local\n>> modification in the working tree\".\n> Okay, your description makes sense to me, and I'll be able to explain \n> what it means.\n>\n> I did a Google search before I posted here.  It turns out this phrase \n> is *very* confusing to others.  Casual Joes don't use the plumbing \n> commands (which I assume git update-index is).  Is there opposition to \n> modernizing this turn to make it more clear based on the porcelain \n> commands being run?\n<sigh> Just waking up for the day.\n\nIs there opposition to modernizing this *term* to make it more clear \nbased on the porcelain commands being run?\n\n-Josh\n"},{"id":"151721","messageId":"1285514516-5112-1-git-send-email-artagnon@gmail.com","threadId":"25235","inReplyTo":"4C9E07B1.50600@workspacewhiz.com","subject":"[PATCH 0/2] Eliminate cryptic \"needs update\" error message","fromName":"Ramkumar Ramachandra","fromEmail":"artagnon@gmail.com","sentAt":"2010-09-26T15:21:54Z","receivedAt":"2010-09-26T15:21:54Z","isPatch":true,"sender":{"key":"r@artagnon.com","avatar":"https://avatars.githubusercontent.com/u/37226?v=4"},"body":"Hi Joshua,\n\nJoshua Jensen writes:\n> Is there opposition to modernizing this *term* to make it more clear\n> based on the porcelain commands being run?\n\nMost porcelain commands already contain checks to specifically prevent\nit from displaying this message. See:\n\ncache.h:506:#define REFRESH_IN_PORCELAIN        0x0020  /* user friendly output, not \"needs update\" */\ngit-add--interactive.perl:215:          ;# ignore 'needs update'\nread-cache.c:1109:      needs_update_fmt = (in_porcelain ? \"M\\t%s\\n\" : \"%s: needs update\\n\");\nbuiltin/add.c:190:      refresh_index(&the_index, verbose ? REFRESH_IN_PORCELAIN : REFRESH_QUIET,\nbuiltin/commit.c:284:   if (refresh_cache(refresh_flags | REFRESH_IN_PORCELAIN))\nbuiltin/reset.c:326:                            quiet ? REFRESH_QUIET : REFRESH_IN_PORCELAIN);\nbuiltin/reset.c:377:                            quiet ? REFRESH_QUIET : REFRESH_IN_PORCELAIN);\ncache.h:506:#define REFRESH_IN_PORCELAIN        0x0020  /* user friendly output, not \"needs update\" */\nread-cache.c:1104:      int in_porcelain = (flags & REFRESH_IN_PORCELAIN);\n\nThe real problem is with the shell scripts that invoke `git\nupdate-index --refresh` without `-q` and forget to redirect output to\n/dev/null. The Git infrastructure thinks update-index is a\nnon-porcelain: little does it know that update-index being run from a\nporcelain-level shell script.\n\nThank you for reporting this bug.\n\n-- Ram\n\nRamkumar Ramachandra (2):\n  sh-setup: Write a new require_clean_work_tree function\n  Porcelain scripts: Rewrite cryptic \"needs update\" error message\n\n git-pull.sh                |    5 +----\n git-rebase--interactive.sh |   16 ++++------------\n git-rebase.sh              |   14 +-------------\n git-sh-setup.sh            |   23 +++++++++++++++++++++++\n 4 files changed, 29 insertions(+), 29 deletions(-)\n\n-- \n1.7.2.2.409.gdbb11.dirty\n"},{"id":"151723","messageId":"1285514516-5112-2-git-send-email-artagnon@gmail.com","threadId":"25235","inReplyTo":"4C9E07B1.50600@workspacewhiz.com","subject":"[PATCH 1/2] sh-setup: Write a new require_clean_work_tree function","fromName":"Ramkumar Ramachandra","fromEmail":"artagnon@gmail.com","sentAt":"2010-09-26T15:21:55Z","receivedAt":"2010-09-26T15:21:55Z","isPatch":true,"sender":{"key":"r@artagnon.com","avatar":"https://avatars.githubusercontent.com/u/37226?v=4"},"body":"Write a new require_clean_work_tree function to error out when working\ntree contains unstaged changes or index contains uncommitted changes.\n\nSigned-off-by: Ramkumar Ramachandra <artagnon@gmail.com>\n---\n git-sh-setup.sh |   23 +++++++++++++++++++++++\n 1 files changed, 23 insertions(+), 0 deletions(-)\n\ndiff --git a/git-sh-setup.sh b/git-sh-setup.sh\nindex 6131670..3a337da 100644\n--- a/git-sh-setup.sh\n+++ b/git-sh-setup.sh\n@@ -145,6 +145,29 @@ require_work_tree () {\n \tdie \"fatal: $0 cannot be used without a working tree.\"\n }\n \n+require_clean_work_tree () {\n+\t# Update the index\n+\tgit update-index -q --ignore-submodules --refresh\n+\n+\t# Disallow unstaged changes in the working tree\n+\tif ! git diff-files --quiet --ignore-submodules --\n+\tthen\n+\t\techo >&2 \"cannot $1: you have unstaged changes.\"\n+\t\techo >&2 \"Please commit or stash them.\"\n+\t\tgit diff-files --name-status -r --ignore-submodules -- >&2\n+\t\texit 1\n+\tfi\n+\n+\t# Disallow uncommitted changes in the index\n+\tif ! git diff-index --cached --quiet --ignore-submodules HEAD --\n+\tthen\n+\t\techo >&2 \"cannot $1: your index contains uncommitted changes.\"\n+\t\techo >&2 \"Please commit or stash them.\"\n+\t\tgit diff-index --cached --name-status -r --ignore-submodules HEAD -- >&2\n+\t\texit 1\n+\tfi\n+}\n+\n get_author_ident_from_commit () {\n \tpick_author_script='\n \t/^author /{\n-- \n1.7.2.2.409.gdbb11.dirty\n"},{"id":"151722","messageId":"1285514516-5112-3-git-send-email-artagnon@gmail.com","threadId":"25235","inReplyTo":"4C9E07B1.50600@workspacewhiz.com","subject":"[PATCH 2/2] Porcelain scripts: Rewrite cryptic \"needs update\" error message","fromName":"Ramkumar Ramachandra","fromEmail":"artagnon@gmail.com","sentAt":"2010-09-26T15:21:56Z","receivedAt":"2010-09-26T15:21:56Z","isPatch":true,"sender":{"key":"r@artagnon.com","avatar":"https://avatars.githubusercontent.com/u/37226?v=4"},"body":"Although Git interally has the facility to differentiate between\nporcelain and plubmbing commands and appropriately print errors,\nseveral shell scripts invoke plubming commands triggering cryptic\nplumbing errors to be displayed on a porcelain interface. This patch\nreplaces the \"needs update\" message in git-pull and git-rebase, when\n`git update-index` is run, with a more friendly message.\n\nReported-by: Joshua Jensen <jjensen@workspacewhiz.com>\nSigned-off-by: Ramkumar Ramachandra <artagnon@gmail.com>\n---\n git-pull.sh                |    5 +----\n git-rebase--interactive.sh |   16 ++++------------\n git-rebase.sh              |   14 +-------------\n 3 files changed, 6 insertions(+), 29 deletions(-)\n\ndiff --git a/git-pull.sh b/git-pull.sh\nindex 8eb74d4..5da0f76 100755\n--- a/git-pull.sh\n+++ b/git-pull.sh\n@@ -201,10 +201,7 @@ test true = \"$rebase\" && {\n \t\t\tdie \"updating an unborn branch with changes added to the index\"\n \t\tfi\n \telse\n-\t\tgit update-index --ignore-submodules --refresh &&\n-\t\tgit diff-files --ignore-submodules --quiet &&\n-\t\tgit diff-index --ignore-submodules --cached --quiet HEAD -- ||\n-\t\tdie \"refusing to pull with rebase: your working tree is not up-to-date\"\n+\t\trequire_clean_work_tree \"pull with rebase\"\n \tfi\n \toldremoteref= &&\n \t. git-parse-remote &&\ndiff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh\nindex a27952d..8722baf 100755\n--- a/git-rebase--interactive.sh\n+++ b/git-rebase--interactive.sh\n@@ -153,14 +153,6 @@ run_pre_rebase_hook () {\n \tfi\n }\n \n-require_clean_work_tree () {\n-\t# test if working tree is dirty\n-\tgit rev-parse --verify HEAD > /dev/null &&\n-\tgit update-index --ignore-submodules --refresh &&\n-\tgit diff-files --quiet --ignore-submodules &&\n-\tgit diff-index --cached --quiet HEAD --ignore-submodules -- ||\n-\tdie \"Working tree is dirty\"\n-}\n \n ORIG_REFLOG_ACTION=\"$GIT_REFLOG_ACTION\"\n \n@@ -557,7 +549,7 @@ do_next () {\n \t\t\texit \"$status\"\n \t\tfi\n \t\t# Run in subshell because require_clean_work_tree can die.\n-\t\tif ! (require_clean_work_tree)\n+\t\tif ! (require_clean_work_tree \"rebase\")\n \t\tthen\n \t\t\twarn \"Commit or stash your changes, and then run\"\n \t\t\twarn\n@@ -740,7 +732,7 @@ do\n \t\t\tdie \"Cannot read HEAD\"\n \t\tgit update-index --ignore-submodules --refresh &&\n \t\t\tgit diff-files --quiet --ignore-submodules ||\n-\t\t\tdie \"Working tree is dirty\"\n+\t\t\tdie \"Working tree is dirty. Please commit or stash your changes to proceed.\"\n \n \t\t# do we have anything to commit?\n \t\tif git diff-index --cached --quiet --ignore-submodules HEAD --\n@@ -768,7 +760,7 @@ first and then run 'git rebase --continue' again.\"\n \n \t\trecord_in_rewritten \"$(cat \"$DOTEST\"/stopped-sha)\"\n \n-\t\trequire_clean_work_tree\n+\t\trequire_clean_work_tree \"rebase\"\n \t\tdo_rest\n \t\t;;\n \t--abort)\n@@ -866,7 +858,7 @@ first and then run 'git rebase --continue' again.\"\n \n \t\tcomment_for_reflog start\n \n-\t\trequire_clean_work_tree\n+\t\trequire_clean_work_tree \"rebase\"\n \n \t\tif test ! -z \"$1\"\n \t\tthen\ndiff --git a/git-rebase.sh b/git-rebase.sh\nindex 3335cee..c3ca8d5 100755\n--- a/git-rebase.sh\n+++ b/git-rebase.sh\n@@ -416,19 +416,7 @@ else\n \tfi\n fi\n \n-# The tree must be really really clean.\n-if ! git update-index --ignore-submodules --refresh > /dev/null; then\n-\techo >&2 \"cannot rebase: you have unstaged changes\"\n-\tgit diff-files --name-status -r --ignore-submodules -- >&2\n-\texit 1\n-fi\n-diff=$(git diff-index --cached --name-status -r --ignore-submodules HEAD --)\n-case \"$diff\" in\n-?*)\techo >&2 \"cannot rebase: your index contains uncommitted changes\"\n-\techo >&2 \"$diff\"\n-\texit 1\n-\t;;\n-esac\n+require_clean_work_tree \"rebase\"\n \n if test -z \"$rebase_root\"\n then\n-- \n1.7.2.2.409.gdbb11.dirty\n"},{"id":"151728","messageId":"vpqmxr4piyf.fsf@bauges.imag.fr","threadId":"25235","inReplyTo":"1285514516-5112-2-git-send-email-artagnon@gmail.com","subject":"Re: [PATCH 1/2] sh-setup: Write a new require_clean_work_tree function","fromName":"Matthieu Moy","fromEmail":"matthieu.moy@grenoble-inp.fr","sentAt":"2010-09-26T16:28:56Z","receivedAt":"2010-09-26T16:28:56Z","isPatch":true,"sender":{"key":"matthieu.moy@grenoble-inp.fr","avatar":"https://gravatar.com/avatar/72c8a2705971a25dfaff23cece15130d405685845d911aedd5667ace277f3fc5?d=mp&s=160"},"body":"Ramkumar Ramachandra <artagnon@gmail.com> writes:\n\n> +\tthen\n> +\t\techo >&2 \"cannot $1: you have unstaged changes.\"\n> +\t\techo >&2 \"Please commit or stash them.\"\n> +\t\tgit diff-files --name-status -r --ignore-submodules -- >&2\n\nI totally agree on the idea, and the implementation is OK. On the\nformat of the message, you can try to make it more consistent with\nother error messages, like:\n\n$ git merge branch\nerror: The following untracked working tree files would be overwritten by merge:\n        one\n\ttwo\nPlease move or remove them before you can merge.\n\nThat would give stg like:\n\necho >&2 \"error: The following files have unstaged changes:\"\ngit diff-files --name-status -r --ignore-submodules -- >&2\necho >&2 \"Please commit or stash them to proceed.\"\n\n(same for the second case)\n\nAlso, you probably want to give all the error before you \"exit 1\",\nhence stg like:\n\nerror=f\n...\nif\nthen\n\t...\n\terror=t\nfi\n\nif\nthen\n\t...\n\terror=t\nfi\n\nif [ \"$error\" = \"t\" ]; then\n\texit 1\nfi\n\n-- \nMatthieu Moy\nhttp://www-verimag.imag.fr/~moy/\n"},{"id":"151729","messageId":"vpqiq1spiuq.fsf@bauges.imag.fr","threadId":"25235","inReplyTo":"1285514516-5112-3-git-send-email-artagnon@gmail.com","subject":"Re: [PATCH 2/2] Porcelain scripts: Rewrite cryptic \"needs update\" error message","fromName":"Matthieu Moy","fromEmail":"matthieu.moy@grenoble-inp.fr","sentAt":"2010-09-26T16:31:09Z","receivedAt":"2010-09-26T16:31:09Z","isPatch":true,"sender":{"key":"matthieu.moy@grenoble-inp.fr","avatar":"https://gravatar.com/avatar/72c8a2705971a25dfaff23cece15130d405685845d911aedd5667ace277f3fc5?d=mp&s=160"},"body":"Ramkumar Ramachandra <artagnon@gmail.com> writes:\n\n>  \t\t# Run in subshell because require_clean_work_tree can die.\n> -\t\tif ! (require_clean_work_tree)\n> +\t\tif ! (require_clean_work_tree \"rebase\")\n>  \t\tthen\n>  \t\t\twarn \"Commit or stash your changes, and then run\"\n\nThat will make a duplicate \"commit or stash your changes\" message.\n\nOtherwise, the patch seems OK.\n\n-- \nMatthieu Moy\nhttp://www-verimag.imag.fr/~moy/\n"},{"id":"151733","messageId":"20100926173956.GA15143@kytes","threadId":"25235","inReplyTo":"vpqmxr4piyf.fsf@bauges.imag.fr","subject":"Re: [PATCH 1/2] sh-setup: Write a new require_clean_work_tree function","fromName":"Ramkumar Ramachandra","fromEmail":"artagnon@gmail.com","sentAt":"2010-09-26T17:39:59Z","receivedAt":"2010-09-26T17:39:59Z","isPatch":true,"sender":{"key":"r@artagnon.com","avatar":"https://avatars.githubusercontent.com/u/37226?v=4"},"body":"Hi Matthieu,\n\nMatthieu Moy writes:\n> I totally agree on the idea, and the implementation is OK. On the\n> format of the message, you can try to make it more consistent with\n> other error messages, like:\n\nThanks for the review.\n\n> $ git merge branch\n> error: The following untracked working tree files would be overwritten by merge:\n>         one\n> \ttwo\n> Please move or remove them before you can merge.\n> \n> That would give stg like:\n> \n> echo >&2 \"error: The following files have unstaged changes:\"\n> git diff-files --name-status -r --ignore-submodules -- >&2\n> echo >&2 \"Please commit or stash them to proceed.\"\n\nOk, sounds good.\n\n> Also, you probably want to give all the error before you \"exit 1\",\n> hence stg like:\n\nHm, is that a good idea? We want the output to be functional and\nindicative: it should tell the user what to do immediately. I'm afraid\nthat displaying both errors will make the output very verbose. We can\njust tell the user about the unstaged changes, and wait for them to\ncommit or stash it. Either way, both commit and stash will affect the\nindex by default :)\n\n-- Ram\n"},{"id":"151740","messageId":"vpqtylcgx75.fsf@bauges.imag.fr","threadId":"25235","inReplyTo":"20100926173956.GA15143@kytes","subject":"Re: [PATCH 1/2] sh-setup: Write a new require_clean_work_tree function","fromName":"Matthieu Moy","fromEmail":"matthieu.moy@grenoble-inp.fr","sentAt":"2010-09-26T18:46:06Z","receivedAt":"2010-09-26T18:46:06Z","isPatch":true,"sender":{"key":"matthieu.moy@grenoble-inp.fr","avatar":"https://gravatar.com/avatar/72c8a2705971a25dfaff23cece15130d405685845d911aedd5667ace277f3fc5?d=mp&s=160"},"body":"Ramkumar Ramachandra <artagnon@gmail.com> writes:\n\n>> Also, you probably want to give all the error before you \"exit 1\",\n>> hence stg like:\n>\n> Hm, is that a good idea? We want the output to be functional and\n> indicative: it should tell the user what to do immediately.\n\nYes, but I find this very painfull when you\n\n$ git do-something\nerror: you need X before you can do-something\n$ do X\n$ git do-something\nerror: Ah, you also need Y before you can do-something\n\n> I'm afraid that displaying both errors will make the output very\n> verbose. We can just tell the user about the unstaged changes, and\n> wait for them to commit or stash it. Either way, both commit and\n> stash will affect the index by default :)\n\nA plain commit will get rid of staged changes, not of unstaged ones.\n\nYour patch shows unstaged changes first. If the only problem was\nunstaged changes, then \"git stash --keep-index\" would be a good\nsolution. As a user, I prefer knowing both problems to find the right\nsolution (and avoid trying to solve only unstaged changes before\nnoticing I need to solve the other one too).\n\n-- \nMatthieu Moy\nhttp://www-verimag.imag.fr/~moy/\n"},{"id":"151741","messageId":"20100926185115.GA14596@kytes","threadId":"25235","inReplyTo":"vpqtylcgx75.fsf@bauges.imag.fr","subject":"Re: [PATCH 1/2] sh-setup: Write a new require_clean_work_tree function","fromName":"Ramkumar Ramachandra","fromEmail":"artagnon@gmail.com","sentAt":"2010-09-26T18:51:17Z","receivedAt":"2010-09-26T18:51:17Z","isPatch":true,"sender":{"key":"r@artagnon.com","avatar":"https://avatars.githubusercontent.com/u/37226?v=4"},"body":"Hi Matthieu,\n\nMatthieu Moy writes:\n> Yes, but I find this very painfull when you\n> \n> $ git do-something\n> error: you need X before you can do-something\n> $ do X\n> $ git do-something\n> error: Ah, you also need Y before you can do-something\n\nAh, yes. This would definitely be annoying.\n\n> A plain commit will get rid of staged changes, not of unstaged ones.\n> \n> Your patch shows unstaged changes first. If the only problem was\n> unstaged changes, then \"git stash --keep-index\" would be a good\n> solution. As a user, I prefer knowing both problems to find the right\n> solution (and avoid trying to solve only unstaged changes before\n> noticing I need to solve the other one too).\n\nGood point. I'll make the error messages a little more comprehensive\nand focused in the next iteration.\n\n-- Ram\n"}]}