Skip to content

Conversation

@vanpipy
Copy link
Collaborator

@vanpipy vanpipy commented Jul 29, 2022

fix #985

The implement 91b3e47 gives a great idea to show the way to reach the goal. I just renew the way to show it clearly.

bin/git-cp Outdated

# We keep the existing file on the side in a commit
git mv "${CURRENT_FILENAME}" "${INTERMEDIATE_FILENAME}"
git commit -a -nm "Keep $CURRENT_FILENAME"
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why do we need to use -a after git mv?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It is the test to avoid interruption because the original implementation was interrupted by conflict always. At first, it confused me and I thought something missing maybe, so the option -a was added. The option -a is useless for the current implementation and I forget to remove it. Fixed already.

@vanpipy vanpipy force-pushed the feature/fix-git-cp-did-not-keep-history branch from 0d721fa to 6e6f59b Compare August 1, 2022 01:15
Copy link
Collaborator

@spacewander spacewander left a comment

Choose a reason for hiding this comment

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

I tried the PR and found out it will create multiple commits for a cp operation? The previous version only created one.

@vanpipy
Copy link
Collaborator Author

vanpipy commented Aug 1, 2022

I tried the PR and found out it will create multiple commits for a cp operation? The previous version only created one.

Keeping only one commit will overwrite the history always and I did not find a better way to keep the history and only one commit. But i think keeping the history of the file is meaningful. That is the reason the PR comes out. If the history did not keep anymore, the document of the git-cp needs to sync the action.

Copy link
Collaborator

@spacewander spacewander left a comment

Choose a reason for hiding this comment

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

I run git cp AUTHORS AUTHORS.txt with the new git-cp, but the AUTHORS.txt doesn't have the same history as AUTHORS.

@vanpipy
Copy link
Collaborator Author

vanpipy commented Aug 2, 2022

I run git cp AUTHORS AUTHORS.txt with the new git-cp, but the AUTHORS.txt doesn't have the same history as AUTHORS.

I tried and had seen the history, but there is one difference - one more column original file is added to the history of the file copied.

diff

The git version I used is 2.25.1

@spacewander
Copy link
Collaborator

I run git cp AUTHORS AUTHORS.txt with the new git-cp, but the AUTHORS.txt doesn't have the same history as AUTHORS.

I tried and had seen the history, but there is one difference - one more column original file is added to the history of the file copied.

diff

The git version I used is 2.25.1

Ah, it is my mistake.

@spacewander spacewander merged commit 3b9ea70 into tj:master Aug 5, 2022
@vanpipy vanpipy deleted the feature/fix-git-cp-did-not-keep-history branch July 14, 2023 09:43
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.

git-cp does not preserve file history

2 participants