Skip to content
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

put alias error #37

Merged
merged 3 commits into from
Apr 23, 2018
Merged

put alias error #37

merged 3 commits into from
Apr 23, 2018

Conversation

berkin
Copy link

@berkin berkin commented Apr 22, 2018

the push command also run with the parameter and it gives error.

git put test 
[master b9f5249] test
 1 file changed, 1 insertion(+), 1 deletion(-)
fatal: 'test' does not appear to be a git repository
fatal: Could not read from remote repository.

gitalias.txt Outdated
@@ -505,7 +505,7 @@

# Do everything we can to synchronize all changes
get = !git pull --rebase && git submodule update --init --recursive
put = !git commit --all --message="$1" && git push
put = "!f() { git add -A && git commit -m \"$@\" && git push; }; f"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a big difference between git commit --all and git add -A && git commit. Is the change intentional?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Excellent point, thank you.

gitalias.txt Outdated
@@ -505,7 +505,7 @@

# Do everything we can to synchronize all changes
get = !git pull --rebase && git submodule update --init --recursive
put = !git commit --all --message="$1" && git push
put = "!f() { git add -A && git commit -m \"$@\" && git push; }; f"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also can I ask to fix minor style problem: two spaces before }?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks, i fixed.

@joelparkerhenderson
Copy link
Member

Good discovery. Thank you. Definitely a bug.

The intent of get and put is primarily "Do the typical thing for the typical case".

What are opinions on whether adding the "git add -A" is the typical thing for the typical case?

If so, this would alter the alias, beyond just fixing the bug.

Just doing a bug fix could be more akin to this:

git commit --all --message="$1"; shift; git push \"$@\"

@erikmd
Copy link

erikmd commented Apr 22, 2018

What are opinions on whether adding the "git add -A" is the typical thing for the typical case?

I think git add -A && git commit -m ... && git push is probably too rude, because it will silently add everything that is not tracked, then commit and push it... so I'd vote for keeping this PR as a bugfix and just run

git commit --all --message="$1"; shift; git push \"$@\"

@erikmd
Copy link

erikmd commented Apr 22, 2018

Another solution for accepting multiple arguments would be to turn them into several -m flags, i.e.:

git commit -m "Title" -m "First paragraph..." -m "Second paragraph..."

@berkin
Copy link
Author

berkin commented Apr 23, 2018

What are opinions on whether adding the "git add -A" is the typical thing for the typical case?

The comment above the aliases says it will synchronise all changes so adding untracked files makes sense to me. Maybe it is better to change it with git add ., it will commit changes under that folder only.

Copy link
Contributor

@phdru phdru left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm -0 about git add -A and +1 on the style change.

@joelparkerhenderson
Copy link
Member

Thanks all for comments!

Here's feedback I received from a peer about principles:

  • Fix each bug in its own commit.
  • Do the fix with similar syntax if possible to make it easier for readers to understand.
  • Do any implementation change (e.g. change to f()) in its own commit as a "Refactor ..."
  • Do any feature change (e.g. change to add --all) in its own commit as an "Add ..."

Here's the fix code that seems to work for me, that's the closest to the syntax:

 put = !git commit --all --message=\"$1\" && shift && git push

@berkin Do you want credit for this fix? If you do, can you adjust the PR to be just the fix? If you don't care, then let me know and I can do it. If you would like, you can do a subsequent PR to do the refactor of get and put to use functions.

Thanks!

@joelparkerhenderson joelparkerhenderson merged commit 65d0a6d into GitAlias:master Apr 23, 2018
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.

None yet

4 participants