{"thread":{"id":"42734","subject":"What's happening to the index","startedAt":"2016-06-28T14:30:53Z","lastAt":"2016-07-03T08:22:51Z","messageCount":5,"participants":["Andy Falanga (afalanga)","Matthieu Moy","David"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"290381","messageId":"57728A17.3010207@micron.com","threadId":"42734","inReplyTo":null,"subject":"What's happening to the index","fromName":"Andy Falanga (afalanga)","fromEmail":"afalanga@micron.com","sentAt":"2016-06-28T14:30:47Z","receivedAt":"2016-06-28T14:30:53Z","isPatch":false,"sender":{"key":"afalanga@micron.com","avatar":null},"body":"Hi,\n\nI'm using git version 1.8.3.1.  I have a process for building RPMs in my \nrepository.  The RPMs are versioned using a \"build number\". In order to \nmaintain uniqueness for this build number, I have stored this number to \na file which exists on only a unique branch.\n\nThe build process, for an actual release, is intended to be done by \nbranching on a tag.  During that process, a BASH script is called with \nchecks out \"rpm\", fetches the repo from remote, merges with origin/rpm, \nincrements the number and pushes back to origin.  It then returns the \nbranch to the original branch in which the script was called.  The make \nrecipe looks like this:\n\n\nrelease:\n     make clean\n     cd ../..  && ../tools/increlnum && cd -\n     if [[ $(TAG) = ......... ]]; then \\\n         git checkout -b rpm_build_$(TAG) $(TAG); \\\n     fi\n     make rpm RPM_BUILD_NUM=$(shell git show rpm:./rpm_build_num)\n\nAfter the line calling increlnum is executed, I often have issues with \nmake unable to spawn the next command because it can't read the current \ndirectory info.  Make stops with errors and I'm done.  I have the branch \nname displayed in my PS1 prompt.  I've noticed that, when make errors at \nthis point, the branch isn't displayed.  It's as if the index has become \nunstable (or something similar).  If I do: cd .. && cd -; all is well.\n\nWhat is the problem (I'd really like to understand) and what might I do \nto correct it?\n\nAndy"},{"id":"290383","messageId":"vpq60stuyv5.fsf@anie.imag.fr","threadId":"42734","inReplyTo":"57728A17.3010207@micron.com","subject":"Re: What's happening to the index","fromName":"Matthieu Moy","fromEmail":"matthieu.moy@grenoble-inp.fr","sentAt":"2016-06-28T15:17:18Z","receivedAt":"2016-06-28T15:17:38Z","isPatch":false,"sender":{"key":"matthieu.moy@grenoble-inp.fr","avatar":"https://gravatar.com/avatar/72c8a2705971a25dfaff23cece15130d405685845d911aedd5667ace277f3fc5?d=mp&s=160"},"body":"\"Andy Falanga (afalanga)\" <afalanga@micron.com> writes:\n\n> After the line calling increlnum is executed, I often have issues with \n> make unable to spawn the next command because it can't read the current \n> directory info.\n\nThis may happen if you delete the current directory, even if your\nre-create it afterwards. For example:\n\n/tmp/test$ rm -fr /tmp/test && mkdir /tmp/test\n/tmp/test$ touch foo\ntouch: cannot touch ‘foo’: No such file or directory\n/tmp/test$ cd /tmp/test\n/tmp/test$ touch foo   \n/tmp/test$ \n\nThis is unrelated from Git, but maybe you asked Git to delete a\ndirectory (by switching to a branch which doesn't contain a directory\nfor example).\n\n> If I do: cd .. && cd -; all is well.\n\nThis is a typical symptom of the issue above.\n\n-- \nMatthieu Moy\nhttp://www-verimag.imag.fr/~moy/\n"},{"id":"290443","messageId":"5772FF0E.6030503@micron.com","threadId":"42734","inReplyTo":"vpq60stuyv5.fsf@anie.imag.fr","subject":"Re: What's happening to the index","fromName":"Andy Falanga (afalanga)","fromEmail":"afalanga@micron.com","sentAt":"2016-06-28T22:49:51Z","receivedAt":"2016-06-28T22:50:03Z","isPatch":false,"sender":{"key":"afalanga@micron.com","avatar":null},"body":"On 06/28/2016 09:17 AM, Matthieu Moy wrote:\n> \"Andy Falanga (afalanga)\" <afalanga@micron.com> writes:\n>\n>> After the line calling increlnum is executed, I often have issues with\n>> make unable to spawn the next command because it can't read the current\n>> directory info.\n> This may happen if you delete the current directory, even if your\n> re-create it afterwards. For example:\n>\n> /tmp/test$ rm -fr /tmp/test && mkdir /tmp/test\n> /tmp/test$ touch foo\n> touch: cannot touch ‘foo’: No such file or directory\n> /tmp/test$ cd /tmp/test\n> /tmp/test$ touch foo\n> /tmp/test$\n>\n> This is unrelated from Git, but maybe you asked Git to delete a\n> directory (by switching to a branch which doesn't contain a directory\n> for example).\n>\n>> If I do: cd .. && cd -; all is well.\n> This is a typical symptom of the issue above.\n>\nThank you for the insight: very interesting.  After asking another \ncolleague how he solved this issue, I've re-written my increlnum script \nto, instead of working within my working tree, clone a temporary of this \none branch only.  Then, it increments the number and pushes back to the \norigin.  Once completed, the temporary clone is deleted.\n\nThe strange thing now is, after the script exits, I then call \"git \nfetch\" in the recipe.  I can see from the output of make that the remote \ndb is fetched.  However, when I call \"git show \norigin/rpm:path/to/rpm_build_num\" from the makefile I get the *previous* \nnumber.  Yet, as soon as the make process exits, I call \"git show \norigin/rpm:path/to/rpm_build_num\" and it shows the correct number!  What \ngives?  Is there some sort of strange file caching that happening when \nmake starts that, although the local db is updated, I don't get what I'm \nafter?\n\nAndy"},{"id":"290462","messageId":"vpqoa6kh23u.fsf@anie.imag.fr","threadId":"42734","inReplyTo":"5772FF0E.6030503@micron.com","subject":"Re: What's happening to the index","fromName":"Matthieu Moy","fromEmail":"matthieu.moy@grenoble-inp.fr","sentAt":"2016-06-29T07:43:17Z","receivedAt":"2016-06-29T07:43:29Z","isPatch":false,"sender":{"key":"matthieu.moy@grenoble-inp.fr","avatar":"https://gravatar.com/avatar/72c8a2705971a25dfaff23cece15130d405685845d911aedd5667ace277f3fc5?d=mp&s=160"},"body":"\"Andy Falanga (afalanga)\" <afalanga@micron.com> writes:\n\n> The strange thing now is, after the script exits, I then call \"git \n> fetch\" in the recipe.  I can see from the output of make that the remote \n> db is fetched.  However, when I call \"git show \n> origin/rpm:path/to/rpm_build_num\" from the makefile I get the *previous* \n> number.  Yet, as soon as the make process exits, I call \"git show \n> origin/rpm:path/to/rpm_build_num\" and it shows the correct number!\n\nMy bet would be that you are running the commands in two different\nrepositories. Try running\n\n  pwd && git show origin/rpm:path/to/rpm_build_num\n\nIn the Makefile and after make completes, and check that pwd returns the\nsame thing. Also, to avoid getting the issue you previously had, try\n\n  cd $(pwd) && pwd && git show origin/rpm:path/to/rpm_build_num\n\ntoo.\n\n> Is there some sort of strange file caching that happening\n> when make starts that, although the local db is updated, I don't get\n> what I'm after?\n\nGit can keep information either in RAM, hence not shared between git\ninvocations (so running git within or outside the Makefile wouldn't\nmatter), or on disk, but then inside or outside the Makefile doesn't\nmatter either.\n\n-- \nMatthieu Moy\nhttp://www-verimag.imag.fr/~moy/\n"},{"id":"290776","messageId":"CAMPXz=oMhTr0r8CCS-4B0KzfTCps-bHx9CKyrGCAy2nAbUc5HA@mail.gmail.com","threadId":"42734","inReplyTo":"5772FF0E.6030503@micron.com","subject":"Re: What's happening to the index","fromName":"David","fromEmail":"bouncingcats@gmail.com","sentAt":"2016-07-03T08:21:03Z","receivedAt":"2016-07-03T08:22:51Z","isPatch":false,"sender":{"key":"bouncingcats@gmail.com","avatar":null},"body":"On 29 June 2016 at 08:49, Andy Falanga (afalanga) <afalanga@micron.com> wrote:\n\n>  Is there some sort of strange file caching that happening when\n> make starts that, although the local db is updated, I don't get what I'm\n> after?\n\nI don't have time to look at your git issue, but I write this quick\nnote just in case it might help you to be aware that 'gnu make'\napparently does implement internal directory caching.\n\nThis is known to cause unexpected results in makefiles whose recipes\nchange the filesystem in ways that make does not notice.\n\nSee for example:\nhttp://lists.gnu.org/archive/html/help-make/2015-02/msg00012.html\n\nand related bug reports, for example:\nhttps://savannah.gnu.org/bugs/index.php?41273\n\nYou might want to create a simple runnable example and ask on the\nextremely helpful gnu-make mailing list:\nhttps://lists.gnu.org/mailman/listinfo/help-make\n"}]}