git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[RFC] Converting git stash to a builtin

From
Joel Teichroeb <joel@teichroeb.net>
Date
Mar 11, 2017, 20:25 UTC
Message-ID
<CA+CzEk9-SDj9FTC_ucu9oBDOe59ce4Jz_OxZbYrDpmbUJHTpFg@mail.gmail.com>

I've been working on rewriting git stash as a c builtin and I have all but three tests passing. I'm having a bit of trouble fixing them, as well as a few other issues, so I'd really appreciate some help. Don't bother commenting on the small details yet as I still need to go though the code to make sure it matches the code style guidelines.

The commit is a bit big, so I'll just link to it on github.
https://github.com/klusark/git/commit/f74d65ae3e06d2c0ab000702ac5e756550e06454
Test Summary Report
-------------------
t7601-merge-pull-config.sh                       (Wstat: 256 Tests: 14
Failed: 2)
  Failed tests:  11-12
  Non-zero exit status: 1
t3903-stash.sh                                   (Wstat: 256 Tests: 74
Failed: 1)
  Failed test:  69
  Non-zero exit status: 1
It looks to be the same issue for both of these cases where
merge-recursive reports:
error: Your local changes to the following files would be overwritten by merge:
        file
        other-file

which doesn't make sense as those files didn't exist before the merge. Furthermore if I take the existing git stash implementation and have it stop before running the merge-recursive command and then run it on the commandline manually, I get the same issue. I've tried setting all the same environment variables that the existing git stash implementation does, but it doesn't help. It seems like there could be a bug in merge-recursive, but I'm not sure how to track it down.

git stash uses the GIT_INDEX_FILE environment variable in order to not trash the main index. I ended up doing things like this:

    discard_cache();
    ret = read_cache_from(index_path);
    write_index_as_tree(orig_tree.hash, &the_index, index_path, 0, NULL);
    discard_cache();
    ret = read_cache_from(index_path);

in order to have an empty cache. Could someone take a look at my uses of the index and point out better ways to do it?

My main goal right now is to cleanup the code and replace more of the commands with native code.

Thanks, Joel

Message 1 of 1 in “[RFC] Converting git stash to a builtin”
  1. Joel TeichroebMar 11, 2017

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.