Skip to content

Simplify git commands #487

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed

Conversation

hatkyinc2
Copy link
Contributor

Description

git -C to replace the confusing pair of --git-dir and --work-tree

Signed-off-by: Ofir Petrushka <hatkyinc@gmail.com>
@jcouball
Copy link
Member

jcouball commented Sep 7, 2020

I think having both --git-dir and --work-tree options is necessary to cover the case where the .git directory isn't located within the work tree or isn't named .git.

It seems like we should have tests for that but I guess we don't since the tests passed with this change.

@hatkyinc2
Copy link
Contributor Author

the .git being a file in place of a directory is exactly the reason I started down the rabbit hole, I believe it currently has bugs, for both submodules and worktrees, opening a Git and trying to checkout a new branch fails. Even if the submodules code is to be fixed it should be duplicated or moved to the initialize function.
I'm in too deep and I'm a bit lost for a few days already...

The two switches need to be amended differently for each case and I'm yet to fully get exactly how they work, couldn't find much documented to explain what they mean.
I also get into weird states where the change tree doesn't match the preped files or a .lock file missing issue...
So the -C is close to an actual change directory, which actually works in place of the two switches for all cases. git CLI just figures them alone and the rest of the stuff.. you may still override them even after a -C when they would be relative to that (assuming relative paths are used over full ones)

@hatkyinc2
Copy link
Contributor Author

I'm happy to add tests for these, due they currently fail for other stuff...
If you want to depend this change merge on added tests for submodule and worktree, that's fine.

@hatkyinc2 hatkyinc2 mentioned this pull request Sep 7, 2020
@hatkyinc2
Copy link
Contributor Author

hatkyinc2 commented Sep 7, 2020

So this is a submodule test it fails for both master and this PR (#487) 😭
#488 (against master)
hatkyinc2#1 (against this PR)

But my conclusions from it are:

Unless my test is just broken in a way I can't see at the moment 🙈

@hatkyinc2
Copy link
Contributor Author

This is a test for worktree new branch checkout, same error as with the submodule
#489

@hatkyinc2
Copy link
Contributor Author

hatkyinc2 commented Sep 7, 2020

I think at this point I need help.
Like I don't get it, if I do exactly as the test and the command listed on the terminal it works
But obviously this doesn't work.

It's probably something super silly, that's how it usually works 😞

@jcouball
Copy link
Member

jcouball commented Sep 9, 2020

@hatkyinc2 I was wondering if you could take a look at #490. In addition to fixing a bug (how the default for index is calculated) it also adds a test for when git-dir is in a non-standard place relative to work-tree. This test should fail with the change you are proposing in this PR.

@jcouball
Copy link
Member

Closing this for the reasons stated in the comments above. It comes down to the matter that sometimes the .git file/directory is not within the working copy.

@jcouball jcouball closed this Dec 23, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants