{"thread":{"id":"10588","subject":"[PATCH] status&commit: Teach them to show commits of modified submodules.","startedAt":"2007-11-02T11:53:47Z","lastAt":"2007-11-07T15:20:00Z","messageCount":11,"participants":["Ping Yin","Junio C Hamano","Yin Ping"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"57974","messageId":"1194004427-26934-1-git-send-email-pkufranky@gmail.com","threadId":"10588","inReplyTo":null,"subject":"[PATCH] status&commit: Teach them to show commits of modified submodules.","fromName":"Ping Yin","fromEmail":"pkufranky@gmail.com","sentAt":"2007-11-02T11:53:47Z","receivedAt":"2007-11-02T11:53:47Z","isPatch":true,"sender":{"key":"pkufranky@gmail.com","avatar":"https://avatars.githubusercontent.com/u/5346?v=4"},"body":"git status/commit just treats submodules as ordinary files when reporting status\nchanges. However, one may also wonder how the submodules change.\n\nThis commit teaches git status/commit to also show commits of\nmodified submodules since HEAD (or HEAD^ if --amend option is on).\n\nFor example, when commiting, submodule sm1 and sm2 are both changed. sm1 has commit C in HEAD and\ncommit E in index. The history of sm1 is\n\t--A-->B-->C (in HEAD:354cd45)\n\t  \\\n\t   -->D->E (in index:3f751e5)\n\ngit status will give the following output (just output commits of submodules\nbefore normal output) to show how to change from commit C (in HEAD) to commit\nE (in index): backward ('<<<') to commit A, and then forward ('>>>') to commit\nE.\n\n\t#\n\t# submodule modifiled: sm1 sm2\n\t#\n\t# * sm1 354cd45...3f751e5:\n\t#   <<<\n\t#   \tone line message for C\n\t#   \tone line message for B\n\t#   >>>\n\t#   \tone line message for D\n\t#   \tone line message for E\n\t#\n\t# * sm2 5c8bfb5...ac46d84:\n\t#   <<<\n\t#   \tmsg\n\t#\n\t# On branch master\n\t# Changes to be committed:\n\t#   (use \"git reset HEAD <file>...\" to unstage)\n\t#\n\t#\tmodified:   sm1\n\t#\tmodified:   sm2\n---\n git-commit.sh |   40 ++++++++++++++++++++++++++++++++++++++++\n 1 files changed, 40 insertions(+), 0 deletions(-)\n\ndiff --git a/git-commit.sh b/git-commit.sh\nindex fcb8443..d362caa 100755\n--- a/git-commit.sh\n+++ b/git-commit.sh\n@@ -33,6 +33,40 @@ save_index () {\n \tcp -p \"$THIS_INDEX\" \"$NEXT_INDEX\"\n }\n \n+# Show log of modified submodule (index modification since HEAD or $1)\n+show_module_log () {\n+\tmodules=`git diff --cached --name-only $1 |\n+\twhile read name\n+\tdo\n+\t\tgit ls-files --stage $name\n+\tdone |\n+\tgrep '^160000 ' | awk '{print $4}'`\n+\ttest -z \"$modules\" && return\n+\n+\tmodules=$(echo $modules)\n+\techo -e \"#\\n# submodule modifiled: $modules\\n#\"\n+\tfor name in $modules\n+\tdo\n+\t\trange=`git diff --cached -- $name | sed -n '2 p' | awk '{print $2}'`\n+\t\tindexone=${range#*..}\n+\t\theadone=${range%..*}\n+\t\t(\n+\t\t\techo \"* $name $headone...$indexone:\"\n+\t\t\tcd $name >&/dev/null || { echo \"  Warning: fail to chdir to $name\" && exit; }\n+\t\t\tleft=\"`git log --pretty=oneline $indexone..$headone 2>&1 | sed 's/^\\w\\+ /  \\t/'`\"\n+\t\t\tright=\"`git log --pretty=oneline --reverse  $headone..$indexone 2>&1 | sed 's/^\\w\\+ /  \\t/'`\"\n+\t\t\tif echo \"$left$right\" | grep 'unknown revision' >&/dev/null\n+\t\t\tthen\n+\t\t\t\techo \"  Warning: $name is not a repository or dosn't contains commit $headone/$indexone\"\n+\t\t\telse\n+\t\t\t\ttest -n \"$left\" && echo -e \"  <<<\\n$left\"\n+\t\t\t\ttest -n \"$right\" && echo -e \"  >>>\\n$right\"\n+\t\t\tfi\n+\t\t\techo\n+\t\t) | sed 's/^/# /'\n+\tdone\n+}\n+\n run_status () {\n \t# If TMP_INDEX is defined, that means we are doing\n \t# \"--only\" partial commit, and that index file is used\n@@ -55,6 +89,12 @@ run_status () {\n \telse\n \t\tcolor=--nocolor\n \tfi\n+\tif test -z \"$amend\"\n+\tthen\n+\t\tshow_module_log\n+\telse\n+\t\tshow_module_log \"HEAD^\"\n+\tfi\n \tgit runstatus ${color} \\\n \t\t${verbose:+--verbose} \\\n \t\t${amend:+--amend} \\\n-- \n1.5.3.4\n"},{"id":"58034","messageId":"7vd4us1jds.fsf@gitster.siamese.dyndns.org","threadId":"10588","inReplyTo":"1194004427-26934-1-git-send-email-pkufranky@gmail.com","subject":"Re: [PATCH] status&commit: Teach them to show commits of modified submodules.","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2007-11-02T20:29:19Z","receivedAt":"2007-11-02T20:29:19Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"How does this work when you are a toplevel developer and do not\nhave the submodule cloned and checked out?\n\nOur code should treat having the submodule directory and not\nhaving it when there is a mode 160000 entry in the index equally\nlikely.  Cloning and checking-out is _not_ the norm (nor the\nexception).\n"},{"id":"58057","messageId":"46dff0320711021650q4e56d025q63a961176c682a14@mail.gmail.com","threadId":"10588","inReplyTo":"7vd4us1jds.fsf@gitster.siamese.dyndns.org","subject":"Re: [PATCH] status&commit: Teach them to show commits of modified submodules.","fromName":"Yin Ping","fromEmail":"pkufranky@gmail.com","sentAt":"2007-11-02T23:50:51Z","receivedAt":"2007-11-02T23:50:51Z","isPatch":true,"sender":{"key":"pkufranky@gmail.com","avatar":"https://avatars.githubusercontent.com/u/5346?v=4"},"body":"On 11/3/07, Junio C Hamano <gitster@pobox.com> wrote:\n> How does this work when you are a toplevel developer and do not\n> have the submodule cloned and checked out?\n>\n> Our code should treat having the submodule directory and not\n> having it when there is a mode 160000 entry in the index equally\n> likely.  Cloning and checking-out is _not_ the norm (nor the\n> exception).\n>\nWhen submodule is not cheched out, it is never modified. In this case\nmodules variable will be empty ( since git diff --cached is used) and\nthe corrosponding module directory will not be checked. So the output\nwill be the same as the original output.\n\n\n\n-- \nfranky\n"},{"id":"58059","messageId":"7vfxzoyz7f.fsf@gitster.siamese.dyndns.org","threadId":"10588","inReplyTo":"46dff0320711021650q4e56d025q63a961176c682a14@mail.gmail.com","subject":"Re: [PATCH] status&commit: Teach them to show commits of modified submodules.","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2007-11-03T00:01:08Z","receivedAt":"2007-11-03T00:01:08Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"Yin Ping\" <pkufranky@gmail.com> writes:\n\n> On 11/3/07, Junio C Hamano <gitster@pobox.com> wrote:\n>> How does this work when you are a toplevel developer and do not\n>> have the submodule cloned and checked out?\n>>\n>> Our code should treat having the submodule directory and not\n>> having it when there is a mode 160000 entry in the index equally\n>> likely.  Cloning and checking-out is _not_ the norm (nor the\n>> exception).\n>>\n> When submodule is not cheched out, it is never modified.\n\nHow so?  Can't you update the index alone?\n"},{"id":"58232","messageId":"46dff0320711040122o271b3da4wb16b0317224d3ac3@mail.gmail.com","threadId":"10588","inReplyTo":"7vfxzoyz7f.fsf@gitster.siamese.dyndns.org","subject":"Re: [PATCH] status&commit: Teach them to show commits of modified submodules.","fromName":"Yin Ping","fromEmail":"pkufranky@gmail.com","sentAt":"2007-11-04T09:22:13Z","receivedAt":"2007-11-04T09:22:13Z","isPatch":true,"sender":{"key":"pkufranky@gmail.com","avatar":"https://avatars.githubusercontent.com/u/5346?v=4"},"body":"On 11/3/07, Junio C Hamano <gitster@pobox.com> wrote:\n> \"Yin Ping\" <pkufranky@gmail.com> writes:\n>\n> > On 11/3/07, Junio C Hamano <gitster@pobox.com> wrote:\n> >> How does this work when you are a toplevel developer and do not\n> >> have the submodule cloned and checked out?\n> >>\n> >> Our code should treat having the submodule directory and not\n> >> having it when there is a mode 160000 entry in the index equally\n> >> likely.  Cloning and checking-out is _not_ the norm (nor the\n> >> exception).\n> >>\n> > When submodule is not cheched out, it is never modified.\n>\n> How so?  Can't you update the index alone?\n>\nSorry i have been away and come back just now.\n\nI think it's a rare case that the submodule entry in the index is\ndifferent from HEAD when the submodule is not checked out.\n\nThis may only happen when git-reset --soft is called. However, it may\nbe a wrong  operation to commit the changed submodule index entry\nwhile the submodule is never checked out.\n\nThere is another similar case, 'git pull' update the submodule entry\nin both HEAD and index, but the submodule checked out is not updated.\nIn this case, 'git-log since..until'  in the submodule directory will\nfail since 'until' commit is not checked out yet. I think it may be\nalso a user mistake.\n\nIn both case, i think the user should be notified about the\ninconsistence. My patch handle this by two warning messages as follows\n(where $name is module name)\n\n+                       cd $name >&/dev/null || { echo \"  Warning:\nfail to chdir to $name\" && exit; }\n\n\n+                       if echo \"$left$right\" | grep 'unknown\nrevision' >&/dev/null\n+                       then\n+                               echo \"  Warning: $name is not a\nrepository or dosn't contains commit $headone/$indexone\"\n+                       else\n\n\n\n-- \nfranky\n"},{"id":"58233","messageId":"46dff0320711040125v111c75davb49e9822537f4b19@mail.gmail.com","threadId":"10588","inReplyTo":"7vfxzoyz7f.fsf@gitster.siamese.dyndns.org","subject":"Re: [PATCH] status&commit: Teach them to show commits of modified submodules.","fromName":"Yin Ping","fromEmail":"pkufranky@gmail.com","sentAt":"2007-11-04T09:25:15Z","receivedAt":"2007-11-04T09:25:15Z","isPatch":true,"sender":{"key":"pkufranky@gmail.com","avatar":"https://avatars.githubusercontent.com/u/5346?v=4"},"body":"sorry, this is the reformated message of last one\nOn 11/3/07, Junio C Hamano <gitster@pobox.com> wrote:\n> \"Yin Ping\" <pkufranky@gmail.com> writes:\n>\n> > On 11/3/07, Junio C Hamano <gitster@pobox.com> wrote:\n> >> How does this work when you are a toplevel developer and do not\n> >> have the submodule cloned and checked out?\n> >>\n> >> Our code should treat having the submodule directory and not\n> >> having it when there is a mode 160000 entry in the index equally\n> >> likely.  Cloning and checking-out is _not_ the norm (nor the\n> >> exception).\n> >>\n> > When submodule is not cheched out, it is never modified.\n>\n> How so?  Can't you update the index alone?\n>\n\nSorry i have been away and come back just now.\n\nI think it's a rare case that the submodule entry in the index is\ndifferent from HEAD when the submodule is not checked out.\n\nThis may only happen when git-reset --soft is called. However, it may\nbe a wrong  operation to commit the changed submodule index entry\nwhile the submodule is never checked out.\n\nThere is another similar case, 'git pull' update the submodule entry\nin both HEAD and index, but the submodule checked out is not updated.\nIn this case, 'git-log since..until'  in the submodule directory will\nfail since 'until' commit is not checked out yet. I think it may be\nalso a user mistake.\n\nIn both case, i think the user should be notified about the\ninconsistence. My patch handle this by two warning messages as follows\n(where $name is module name)\n\n+                       cd $name >&/dev/null || { echo \"  Warning:\nfail to chdir to $name\" && exit; }\n\n\n+                       if echo \"$left$right\" | grep 'unknown\nrevision' >&/dev/null\n+                       then\n+                               echo \"  Warning: $name is not a\nrepository or doesn't contains commit $headone/$indexone\"\n+                       else\n\n-- \nfranky\n"},{"id":"58238","messageId":"46dff0320711040156s7a780a8dp7c76f1cbf3fd6e60@mail.gmail.com","threadId":"10588","inReplyTo":"46dff0320711040125v111c75davb49e9822537f4b19@mail.gmail.com","subject":"Re: [PATCH] status&commit: Teach them to show commits of modified submodules.","fromName":"Yin Ping","fromEmail":"pkufranky@gmail.com","sentAt":"2007-11-04T09:56:03Z","receivedAt":"2007-11-04T09:56:03Z","isPatch":true,"sender":{"key":"pkufranky@gmail.com","avatar":"https://avatars.githubusercontent.com/u/5346?v=4"},"body":"On 11/4/07, Yin Ping <pkufranky@gmail.com> wrote:\n> sorry, this is the reformated message of last one\n\nOh, I'm beaten my the mail client (gmail client will automatically\nwrap line to width 80, which is not suitable for patch). Just ignore\nmy last messge and bear the wrapped patch line. Sorry for the\ninconvience again\n\n-- \nfranky\n"},{"id":"58250","messageId":"7vmytus0ff.fsf@gitster.siamese.dyndns.org","threadId":"10588","inReplyTo":"46dff0320711040145k1edb1fcaq1daa5469c1158e81@mail.gmail.com","subject":"Re: [PATCH] status&commit: Teach them to show commits of modified submodules.","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2007-11-04T11:41:08Z","receivedAt":"2007-11-04T11:41:08Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"Yin Ping\" <pkufranky@gmail.com> writes:\n\n> In both case, i think the user should be notified about the inconsistence.\n> My patch given in the first letter handles this by two warning messages as\n> follows (where $name is module name)\n>\n> +                       cd $name >&/dev/null || { echo \"  Warning: fail to\n> chdir to $name\" && exit; }\n\nMy point was that it is wrong to make this \"you do not have that\nsubmodule checked out\" a warning.\n\nThink about somebody who does _not_ care about that particular\nsubmodule.  He is working on one branch, and tries to merge\nanother branch that has some interesting changes outside the\nsubmodule, but that branch also has updates to the submodule.\n\nAs he is _not_ interested in the submodule, he does not have it\nchecked out.  He has not changed the commit bound in his index\nwith 160000 mode bits for that submodule since the common\nancestor, either (that's what \"he does not care about the\nsubmodule\" means).\n\nThe merge will take the submodule commit object name from the\nother branches change, just like the ordinary three-way merge\nrule would do (one side changed, the other did not do anything,\nso take the change).  Suppose some files in the project proper,\noutside the submodule, had conflicts.  He has an unmerged index,\nthat has the submodule already correctly merged.  But other\nparts of his index are unmerged.  git-status would guide him\nwhat are conflicting, and git-commit would show him what he\nwould be committing.\n\nIn that situation, all he needs to know, with respect to the\nsubmodule, is that the submodule has been updated since his HEAD\n(and that is given by the runstatus output).  He does not _care_\nabout what the individual commits in the submodule were.  It is\nnot an error that the information from the submodule cannot be\nshown to him.  He _chose_ to ignore the details of that\nsubmodule by not checking it out to begin with.\n\nSomething like this, to be totally quiet, would be more\nappropriate.\n\n\tfor name in $modules\n        do\n                (\n                \t... do the range, indexone, headone stuff\n                        cd \"$name\" 2>/dev/null || exit 0\n                \techo \"* $name $headone...$indexone:\"\n\t\t\t... whatever log you show\n\t\t) | sed ...\n\tdone\n\nBy the way, I do not know about the quoting issues with $modules\nvariable in the above illustration, as I am not (yet) discussing\nabout the implementation level of details.\n"},{"id":"58262","messageId":"46dff0320711040517r6da5d7aaid849ff06df1b5bb6@mail.gmail.com","threadId":"10588","inReplyTo":"7vmytus0ff.fsf@gitster.siamese.dyndns.org","subject":"Re: [PATCH] status&commit: Teach them to show commits of modified submodules.","fromName":"Yin Ping","fromEmail":"pkufranky@gmail.com","sentAt":"2007-11-04T13:17:58Z","receivedAt":"2007-11-04T13:17:58Z","isPatch":true,"sender":{"key":"pkufranky@gmail.com","avatar":"https://avatars.githubusercontent.com/u/5346?v=4"},"body":"On 11/4/07, Junio C Hamano <gitster@pobox.com> wrote:\n> \"Yin Ping\" <pkufranky@gmail.com> writes:\n>\n> > In both case, i think the user should be notified about the inconsistence.\n> > My patch given in the first letter handles this by two warning messages as\n> > follows (where $name is module name)\n> >\n> > +                       cd $name >&/dev/null || { echo \"  Warning: fail to\n> > chdir to $name\" && exit; }\n>\n> In that situation, all he needs to know, with respect to the\n> submodule, is that the submodule has been updated since his HEAD\n> (and that is given by the runstatus output).  He does not _care_\n> about what the individual commits in the submodule were.  It is\n> not an error that the information from the submodule cannot be\n> shown to him.  He _chose_ to ignore the details of that\n> submodule by not checking it out to begin with.\n>\n> Something like this, to be totally quiet, would be more\n> appropriate.\n>\n>        for name in $modules\n>        do\n>                (\n>                        ... do the range, indexone, headone stuff\n>                        cd \"$name\" 2>/dev/null || exit 0\n>                        echo \"* $name $headone...$indexone:\"\n>                        ... whatever log you show\n>                ) | sed ...\n>        done\n>\nYour point is in some cases people think the warning messages are\nannoying because they don't care the change details for submodules.\nHowever, in some cases these messages are helpful. And a third kind of\ncases is that people care about only part of all submodules.\n\nSo, maybe some an switch can be used to turn this on or off (default\noff)? For example\n# only sm1 and sm2 are cared\ngit commit --submodule=sm1,sm2\n\n# all submodules are cared\ngit commit --submodule='*'\n\n> By the way, I do not know about the quoting issues with $modules\n> variable in the above illustration, as I am not (yet) discussing\n> about the implementation level of details.\n>\n\n\n-- \nfranky\n"},{"id":"58478","messageId":"7vwsswjeom.fsf@gitster.siamese.dyndns.org","threadId":"10588","inReplyTo":"46dff0320711040517r6da5d7aaid849ff06df1b5bb6@mail.gmail.com","subject":"Re: [PATCH] status&commit: Teach them to show commits of modified submodules.","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2007-11-06T02:22:33Z","receivedAt":"2007-11-06T02:22:33Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"Yin Ping\" <pkufranky@gmail.com> writes:\n\n> However, in some cases these messages are helpful. And a third kind of\n> cases is that people care about only part of all submodules.\n>\n> So, maybe some an switch can be used to turn this on or off (default\n> off)?\n\nI personally think that is overengineering.  Isn't having/not\nhaving the submodule directory cloned a good enough indicator\nof which submodules are interested in by the user?\n"},{"id":"58685","messageId":"46dff0320711070720j2af83fabm28cdbf03b82d7862@mail.gmail.com","threadId":"10588","inReplyTo":"7vwsswjeom.fsf@gitster.siamese.dyndns.org","subject":"Re: [PATCH] status&commit: Teach them to show commits of modified submodules.","fromName":"Yin Ping","fromEmail":"pkufranky@gmail.com","sentAt":"2007-11-07T15:20:00Z","receivedAt":"2007-11-07T15:20:00Z","isPatch":true,"sender":{"key":"pkufranky@gmail.com","avatar":"https://avatars.githubusercontent.com/u/5346?v=4"},"body":"On 11/6/07, Junio C Hamano <gitster@pobox.com> wrote:\n> \"Yin Ping\" <pkufranky@gmail.com> writes:\n>\n> > However, in some cases these messages are helpful. And a third kind of\n> > cases is that people care about only part of all submodules.\n> >\n> > So, maybe some an switch can be used to turn this on or off (default\n> > off)?\n>\n> I personally think that is overengineering.  Isn't having/not\n> having the submodule directory cloned a good enough indicator\n> of which submodules are interested in by the user?\n>\nGood suggestion. I'll give my new patch later.\n\n-- \nfranky\n"}]}