{"thread":{"id":"45356","subject":"[RFC] Converting git stash to a builtin","startedAt":"2017-03-11T20:26:23Z","lastAt":"2017-03-11T20:26:23Z","messageCount":1,"participants":["Joel Teichroeb"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"313834","messageId":"CA+CzEk9-SDj9FTC_ucu9oBDOe59ce4Jz_OxZbYrDpmbUJHTpFg@mail.gmail.com","threadId":"45356","inReplyTo":null,"subject":"[RFC] Converting git stash to a builtin","fromName":"Joel Teichroeb","fromEmail":"joel@teichroeb.net","sentAt":"2017-03-11T20:25:57Z","receivedAt":"2017-03-11T20:26:23Z","isPatch":false,"sender":{"key":"joel@teichroeb.net","avatar":"https://avatars.githubusercontent.com/u/240865?v=4"},"body":"I've been working on rewriting git stash as a c builtin and I have all\nbut three tests passing. I'm having a bit of trouble fixing them, as\nwell as a few other issues, so I'd really appreciate some help. Don't\nbother commenting on the small details yet as I still need to go\nthough the code to make sure it matches the code style guidelines.\n\nThe commit is a bit big, so I'll just link to it on github.\n\nhttps://github.com/klusark/git/commit/f74d65ae3e06d2c0ab000702ac5e756550e06454\n\n\nTest Summary Report\n-------------------\nt7601-merge-pull-config.sh                       (Wstat: 256 Tests: 14\nFailed: 2)\n  Failed tests:  11-12\n  Non-zero exit status: 1\nt3903-stash.sh                                   (Wstat: 256 Tests: 74\nFailed: 1)\n  Failed test:  69\n  Non-zero exit status: 1\n\nIt looks to be the same issue for both of these cases where\nmerge-recursive reports:\nerror: Your local changes to the following files would be overwritten by merge:\n        file\n        other-file\n\nwhich doesn't make sense as those files didn't exist before the merge.\nFurthermore if I take the existing git stash implementation and have\nit stop before running the merge-recursive command and then run it on\nthe commandline manually, I get the same issue. I've tried setting all\nthe same environment variables that the existing git stash\nimplementation does, but it doesn't help. It seems like there could be\na bug in merge-recursive, but I'm not sure how to track it down.\n\n\ngit stash uses the GIT_INDEX_FILE environment variable in order to not\ntrash the main index. I ended up doing things like this:\n\n    discard_cache();\n    ret = read_cache_from(index_path);\n    write_index_as_tree(orig_tree.hash, &the_index, index_path, 0, NULL);\n    discard_cache();\n    ret = read_cache_from(index_path);\n\nin order to have an empty cache. Could someone take a look at my uses\nof the index and point out better ways to do it?\n\nMy main goal right now is to cleanup the code and replace more of the\ncommands with native code.\n\nThanks,\nJoel\n"}]}